Skip to content

Commit e740119

Browse files
committed
Check not only value equality of constants in Literalize postcondition but also type eqality
1 parent 209d3b0 commit e740119

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/dotty/tools/dotc/transform/Literalize.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class Literalize extends MiniPhaseTransform { thisTransform =>
8080
case Literal(c @ Constant(treeValue)) =>
8181
tree.tpe match {
8282
case ConstantType(typeValue) =>
83-
assert(treeValue == typeValue.value, i"Type of Literal $tree is inconsistent with underlying constant")
83+
assert(treeValue == typeValue.value && treeValue.getClass == typeValue.getClass,
84+
i"Type of Literal $tree is inconsistent with underlying constant")
8485
case tpe =>
8586
c.tpe =:= tpe
8687
}

0 commit comments

Comments
 (0)