File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1015,7 +1015,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
1015
1015
false
1016
1016
}
1017
1017
1018
- /** Compare `tp` of form `S[arg]` with `other`, via ">:>` if fromBelow is true, "<:<" otherwise.
1018
+ /** Compare `tp` of form `S[arg]` with `other`, via ">:>" if fromBelow is true, "<:<" otherwise.
1019
1019
* If `arg` is a Nat constant `n`, proceed with comparing `n + 1` and `other`.
1020
1020
* Otherwise, if `other` is a Nat constant `n`, proceed with comparing `arg` and `n - 1`.
1021
1021
*/
@@ -1037,11 +1037,15 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
1037
1037
case _ => false
1038
1038
}
1039
1039
1040
+ /** Compare `tp` of form `tycon[...args]`, where `tycon` is a scala.compiletime type,
1041
+ * with `other` via ">:>" if fromBelow is true, "<:<" otherwise.
1042
+ * Delegates to compareS if `tycon` is scala.compiletime.S. Otherwise, constant folds if possible.
1043
+ */
1040
1044
def compareCompiletimeAppliedType (tp : AppliedType , other : Type , fromBelow : Boolean ): Boolean = {
1041
1045
if (defn.isCompiletime_S(tp.tycon.typeSymbol)) compareS(tp, other, fromBelow)
1042
1046
else {
1043
1047
val reduced = tp.tryCompiletimeConstantFold.getOrElse(tp.superType)
1044
- recur(reduced, other)
1048
+ if (fromBelow) recur(other, reduced) else recur(reduced, other)
1045
1049
}
1046
1050
}
1047
1051
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ object Test {
5
5
summon[1763 =:= 41 * 43 ]
6
6
summon[2 + 2 =:= 3 ] // error
7
7
summon[29 * 31 =:= 900 ] // error
8
+ summon[Any <:< Int + 1 ] // error
9
+ summon[Int + 1 <:< Any ]
8
10
9
11
val a : Int + Int = 3
10
12
val c : 1 + Int = 2
You can’t perform that action at this time.
0 commit comments