Skip to content

Commit

Permalink
Avoid in ConstantTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Feb 22, 2023
1 parent 847eccc commit 7b234f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools
package dotc
package core

import Contexts._, Types._, Symbols._, Names._, NameKinds.*, Flags._
import Contexts._, Types._, Symbols._, Names._, NameKinds.*, Flags._, Constants.*
import SymDenotations._
import util.Spans._
import util.Stats
Expand Down Expand Up @@ -560,6 +560,9 @@ object TypeOps:
widenUnions = tp.widenUnions)(using mapCtx)
val lo1 = apply(lo)
if (lo1 ne lo) lo1 else tp
case tp @ ConstantType(Constant(tp1: Type)) =>
val tp2 = apply(tp1)
if tp2 eq tp1 then tp else ConstantType(Constant(tp2))
case _ =>
super.apply(tp)
end apply
Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i16954.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- [E170] Type Error: tests/neg/i16954.scala:4:12 ----------------------------------------------------------------------
4 | classOf[y] // error: y is not a class type
| ^
| y is not a class type
5 changes: 5 additions & 0 deletions tests/neg/i16954.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Test:
def test =
type y
classOf[y] // error: y is not a class type
// was: "assertion failed: leak: y in { [..] }" crash after that error

0 comments on commit 7b234f1

Please sign in to comment.