Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6e9635b

Browse files
committed
fix
1 parent 40689d1 commit 6e9635b

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
401401
compareErasedValueType
402402
case ConstantType(v2) =>
403403
tp1 match {
404-
case ConstantType(v1) =>
405-
(v1.value, v2.value) match {
406-
// To distinguish 0.0 and -0.0, floating-point numbers use the equals method of their boxing type.
407-
case (d1: Double, d2: Double) => java.lang.Double.valueOf(d1).equals(java.lang.Double.valueOf(d2)) && recur(v1.tpe, v2.tpe)
408-
case (f1: Float, f2: Float) => java.lang.Float.valueOf(f1).equals(java.lang.Float.valueOf(f2)) && recur(v1.tpe, v2.tpe)
409-
case _ => v1.value == v2.value && recur(v1.tpe, v2.tpe)
410-
}
404+
case ConstantType(v1) => v1 == v2 && recur(v1.tpe, v2.tpe)
411405
case _ => secondTry
412406
}
413407
case tp2: AnyConstantType =>

tests/neg/i23261.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@main def main(): Unit =
2-
summon[0.0 =:= -0.0]
3-
val d: 0.0 = -0.0
4-
val d2: -0.0 = 0.0
5-
summon[0.0f =:= -0.0f]
6-
val f: 0.0f = -0.0f
7-
val f2: -0.0f = 0.0f
2+
summon[0.0 =:= -0.0] // error: Cannot prove that (0.0: Double) =:= (-0.0: Double).
3+
val d: 0.0 = -0.0 // error: Cannot prove that (0.0: Double) =:= (-0.0: Double).
4+
val d2: -0.0 = 0.0 // error: Cannot prove that (-0.0: Double) =:= (0.0: Double).
5+
summon[0.0f =:= -0.0f] // error: Cannot prove that (0.0f: Float) =:= (-0.0f: Float).
6+
val f: 0.0f = -0.0f // error: Cannot prove that (0.0f: Float) =:= (-0.0f: Float).
7+
val f2: -0.0f = 0.0f // error: Cannot prove that (-0.0f: Float) =:= (0.0f: Float).

0 commit comments

Comments
 (0)