Skip to content

Commit 9711dcc

Browse files
committed
Revert to only reducing singleton args in singleton ops
As discussed in #7628
1 parent 90696e9 commit 9711dcc

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,10 +1043,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
10431043
*/
10441044
def compareCompiletimeAppliedType(tp: AppliedType, other: Type, fromBelow: Boolean): Boolean = {
10451045
if (defn.isCompiletime_S(tp.tycon.typeSymbol)) compareS(tp, other, fromBelow)
1046-
else {
1047-
val reduced = tp.tryCompiletimeConstantFold.getOrElse(tp.superType)
1048-
if (fromBelow) recur(other, reduced) else recur(reduced, other)
1049-
}
1046+
else tp.tryCompiletimeConstantFold.exists(folded => if (fromBelow) recur(other, folded) else recur(folded, other))
10501047
}
10511048

10521049
/** Like tp1 <:< tp2, but returns false immediately if we know that

tests/neg/singleton-ops.scala

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@ object Test {
55
summon[1763 =:= 41 * 43]
66
summon[2 + 2 =:= 3] // error
77
summon[29 * 31 =:= 900] // error
8-
summon[Any <:< Int + 1] // error
9-
summon[Int + 1 <:< Any]
10-
11-
val a: Int + Int = 3
12-
val c: 1 + Int = 2
13-
val d: Int + 1 = 1
14-
summon[Int + 1 =:= Int]
15-
summon[1 + 1 =:= Int] // error
8+
summon[Int <:< Int + 1] // error
9+
summon[1 + Int <:< Int]
1610

1711
val t0: 2 + 3 = 5
1812
val t1: 2 + 2 = 5 // error

0 commit comments

Comments
 (0)