Skip to content

Commit 9fcc0a2

Browse files
authored
Merge pull request #1772 from rethab/master
Fix #1702: handle ConstantType in TypeComparer
2 parents 9ceed92 + 4835d04 commit 9fcc0a2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
260260
secondTry(tp1, tp2)
261261
}
262262
compareErasedValueType
263+
case ConstantType(v2) =>
264+
tp1 match {
265+
case ConstantType(v1) => v1.value == v2.value
266+
case _ => secondTry(tp1, tp2)
267+
}
263268
case ErrorType =>
264269
true
265270
case _ =>

tests/repl/def.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ scala> def baz() = 2
66
def baz(): Int
77
scala> def qux(): Int = 2
88
def qux(): Int
9+
scala> def id(x: 4): 4 = x
10+
def id(x: 4.type): Int(4)
11+
scala> id(4)
12+
val res0: Int = 4
913
scala> :quit

0 commit comments

Comments
 (0)