Skip to content

Commit 110600b

Browse files
authored
tryCompiletimeConstantFold in disjointnessBoundary (#20168)
Fixes #20166 Alternatively placing the tryCompiletimeConstantFold in `AppliedType#superType` also seems to fix the issue and not break anything. But I'm not very sure about the spec here either way.
2 parents 6e86ada + 6fd2734 commit 110600b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -2905,6 +2905,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
29052905
tp
29062906
case tp: ConstantType =>
29072907
tp
2908+
case tp: AppliedType if tp.tryCompiletimeConstantFold.exists =>
2909+
tp.tryCompiletimeConstantFold
29082910
case tp: HKTypeLambda =>
29092911
tp
29102912
case tp: ParamRef =>

tests/pos/i20166.scala

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import scala.compiletime.ops.int.*
2+
3+
// NOTE ops.int.S is documented as equivalent to MyS
4+
5+
type MyS[X] = X match
6+
case 0 => 1
7+
case 1 => 2
8+
case 2 => 3
9+
10+
type M[I <: Int] = 4 match
11+
case 1 - 1 => "0"
12+
case MyS[I] => "2"
13+
case S[I] => "2" // Not provablyDisjoint before changes
14+
case 2 + I => "3"
15+
case I + 3 => "4"
16+
17+
val _: M[1] = "4"
18+
19+
20+
type M2[I <: Int, P] = I match
21+
case P => "b"
22+
case _ => "c"
23+
24+
val _: M2[5, 2 + 3] = "b"

0 commit comments

Comments
 (0)