Skip to content

Commit 97cd4a8

Browse files
committed
Avoid in ConstantTypes
1 parent 847eccc commit 97cd4a8

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools
22
package dotc
33
package core
44

5-
import Contexts._, Types._, Symbols._, Names._, NameKinds.*, Flags._
5+
import Contexts._, Types._, Symbols._, Names._, NameKinds.*, Flags._, Constants.*
66
import SymDenotations._
77
import util.Spans._
88
import util.Stats
@@ -560,6 +560,9 @@ object TypeOps:
560560
widenUnions = tp.widenUnions)(using mapCtx)
561561
val lo1 = apply(lo)
562562
if (lo1 ne lo) lo1 else tp
563+
case tp @ ConstantType(Constant(tp1: Type)) =>
564+
val tp2 = apply(tp1)
565+
if tp2 eq tp1 then tp else ConstantType(Constant(tp2))
563566
case _ =>
564567
super.apply(tp)
565568
end apply

tests/neg/i16954.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- [E170] Type Error: tests/neg/i16954.scala:4:12 ----------------------------------------------------------------------
2+
4 | classOf[y] // error
3+
| ^
4+
| y is not a class type

tests/neg/i16954.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Test:
2+
def test =
3+
type y
4+
classOf[y] // error: y is not a class type
5+
// was: "assertion failed: leak: y in { [..] }" crash after that error

0 commit comments

Comments
 (0)