File tree 2 files changed +7
-13
lines changed
compiler/src/dotty/tools/dotc/core 2 files changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -401,13 +401,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
401
401
compareErasedValueType
402
402
case ConstantType (v2) =>
403
403
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)
411
405
case _ => secondTry
412
406
}
413
407
case tp2 : AnyConstantType =>
Original file line number Diff line number Diff line change 1
1
@ 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).
You can’t perform that action at this time.
0 commit comments