Skip to content

Commit 32e3969

Browse files
committed
widenDealias before extracting namedTupleElementTypes
1 parent 01b404f commit 32e3969

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
756756
return typedSelect(tree, pt, qual)
757757

758758
// Otherwise, try to expand a named tuple selection
759-
val namedTupleElems = qual.tpe.widen.namedTupleElementTypes
759+
val namedTupleElems = qual.tpe.widenDealias.namedTupleElementTypes
760760
val nameIdx = namedTupleElems.indexWhere(_._1 == selName)
761761
if nameIdx >= 0 && Feature.enabled(Feature.namedTuples) then
762762
return typed(
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import scala.language.experimental.namedTuples
2+
3+
object Test1:
4+
// original code from issue https://github.com/scala/scala3/issues/20439
5+
val bar = (a = 1, b = 2)
6+
7+
type ThatBar = bar.type
8+
val thatBar: ThatBar = bar
9+
val thatBar2: bar.type = bar
10+
11+
def test2 = thatBar.a // error
12+
def test3 = thatBar2.a // ok

0 commit comments

Comments
 (0)