Skip to content

Commit

Permalink
tryCompiletimeConstantFold in disjointnessBoundary
Browse files Browse the repository at this point in the history
Fixes #20166
  • Loading branch information
EugeneFlesselle committed Apr 25, 2024
1 parent 00802ab commit eef62f7
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 @@ -2902,6 +2902,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 eef62f7

Please sign in to comment.