Skip to content

Commit

Permalink
tryCompiletimeConstantFold in disjointnessBoundary (#20168)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sjrd authored May 29, 2024
2 parents 6e86ada + 6fd2734 commit 110600b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2905,6 +2905,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
tp
case tp: ConstantType =>
tp
case tp: AppliedType if tp.tryCompiletimeConstantFold.exists =>
tp.tryCompiletimeConstantFold
case tp: HKTypeLambda =>
tp
case tp: ParamRef =>
Expand Down
24 changes: 24 additions & 0 deletions tests/pos/i20166.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import scala.compiletime.ops.int.*

// NOTE ops.int.S is documented as equivalent to MyS

type MyS[X] = X match
case 0 => 1
case 1 => 2
case 2 => 3

type M[I <: Int] = 4 match
case 1 - 1 => "0"
case MyS[I] => "2"
case S[I] => "2" // Not provablyDisjoint before changes
case 2 + I => "3"
case I + 3 => "4"

val _: M[1] = "4"


type M2[I <: Int, P] = I match
case P => "b"
case _ => "c"

val _: M2[5, 2 + 3] = "b"

0 comments on commit 110600b

Please sign in to comment.