Skip to content

Commit 2bbd0e4

Browse files
committed
Fix #8843: Normalize type when constant folding
1 parent 37bc11d commit 2bbd0e4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
510510
*/
511511
def constToLiteral(tree: Tree)(implicit ctx: Context): Tree = {
512512
val tree1 = ConstFold(tree)
513-
tree1.tpe.widenTermRefExpr.dealias match {
513+
tree1.tpe.widenTermRefExpr.dealias.normalized match {
514514
case ConstantType(value) =>
515515
if (isIdempotentExpr(tree1)) Literal(value).withSpan(tree.span)
516516
else tree1 match {

tests/pos/i8843.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class C:
2+
type X <: Tuple
3+
4+
inline def f(c: C): Unit = {
5+
inline val size = compiletime.constValue[Tuple.Size[c.X]]
6+
val n = size
7+
val m: Int = n
8+
???
9+
}
10+
11+
def test: Unit = f(??? : C { type X = Tuple1[Any] })

0 commit comments

Comments
 (0)