Skip to content

Commit 6fd2734

Browse files
tryCompiletimeConstantFold in disjointnessBoundary
Fixes #20166
1 parent c1afc2c commit 6fd2734

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
@@ -2902,6 +2902,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
29022902
tp
29032903
case tp: ConstantType =>
29042904
tp
2905+
case tp: AppliedType if tp.tryCompiletimeConstantFold.exists =>
2906+
tp.tryCompiletimeConstantFold
29052907
case tp: HKTypeLambda =>
29062908
tp
29072909
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)