Skip to content

Commit 20a4652

Browse files
committed
Properly map type constants in TreeTypeMap
1 parent 4f9d7c8 commit 20a4652

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package ast
44

55
import core._
66
import Types._, Contexts._
7-
import Symbols._, Annotations._, Trees._, Symbols._
7+
import Symbols._, Annotations._, Trees._, Symbols._, Constants.Constant
88
import Decorators._
99
import dotty.tools.dotc.transform.SymUtils._
1010
import core.tasty.TreePickler.Hole
@@ -124,6 +124,8 @@ class TreeTypeMap(
124124
cpy.Labeled(labeled)(bind1, expr1)
125125
case Hole(isTermHole, n, args) =>
126126
Hole(isTermHole, n, args.mapConserve(transform)).withSpan(tree.span).withType(mapType(tree.tpe))
127+
case lit @ Literal(Constant(tpe: Type)) =>
128+
cpy.Literal(lit)(Constant(mapType(tpe)))
127129
case tree1 =>
128130
super.transform(tree1)
129131
}

tests/pos/i10542.scala

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package test1:
1+
package test_10542:
22

33
trait Foo {
44
inline def foo[A](t: => A): Unit = ()
@@ -12,8 +12,8 @@ package test1:
1212
case object S1 extends T1
1313
}
1414
}
15-
/*
16-
package test2:
15+
16+
package test_10540:
1717

1818
trait Foo {
1919
inline def foo[A](t: => A): Unit = ()
@@ -26,4 +26,13 @@ package test2:
2626
trait T1
2727
val array = Array(new T1 {})
2828
}
29-
}*/
29+
}
30+
31+
package test_9655:
32+
33+
inline def foo[T](inline body: T): T = body
34+
35+
def test = foo {
36+
sealed trait Status
37+
object Active extends Status
38+
}

0 commit comments

Comments
 (0)