-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #9107: Restore constraints after MT reduction #9108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
object Test { | ||
sealed trait Off | ||
case class Of[sup, sub <: sup]() extends Off | ||
|
||
def sup[O <: Off](o: O) = o match { | ||
case _: Of[sup, sub] => | ||
val a: sub = null.asInstanceOf | ||
// Even though we know that sub <: sup from Of's bounds, that knowledge | ||
// is lost in the body of pattern matching expressions... | ||
|
||
val b: sup = a // error | ||
// Found: (a : sub) | ||
// Required: sup | ||
// where: sub is a type in method sup with bounds <: Test.Of[?, ?]#sup | ||
|
||
() | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
trait M[F[_]] | ||
trait Inv[T] | ||
|
||
object Test { | ||
def ev[X] = implicitly[ | ||
(X match { case Inv[t] => Int }) =:= | ||
(X match { case Inv[t] => t }) | ||
] // error | ||
|
||
def ev2[X] = implicitly[ | ||
(M[[t] =>> runtime.MatchCase[Inv[t], Int]]) =:= | ||
(M[[t] =>> runtime.MatchCase[Inv[t], t]]) | ||
] // error | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
object Test { | ||
import scala.compiletime.ops.int._ | ||
|
||
trait x | ||
|
||
type Range[Min <: Int, Max <: Int] <: Tuple = Min match { | ||
case Max => EmptyTuple | ||
case _ => Min *: Range[Min + 1, Max] | ||
} | ||
|
||
type TupleMap[Tup <: Tuple, Bound, F[_ <: Bound]] <: Tuple = Tup match { | ||
case EmptyTuple => EmptyTuple | ||
case h *: t => F[h] *: TupleMap[t, Bound, F] | ||
} | ||
type TupleDedup[Tup <: Tuple, Mask] <: Tuple = Tup match { | ||
case EmptyTuple => EmptyTuple | ||
case h *: t => h match { | ||
case Mask => TupleDedup[t, Mask] | ||
case _ => h *: TupleDedup[t, h | Mask] | ||
} | ||
} | ||
|
||
type CoordToPos[r <: Int, c <: Int] = r * 9 + c | ||
type Cell[r <: Int, c <: Int, Board <: Tuple] = Tuple.Elem[Board, CoordToPos[r, c]] | ||
type Col[c <: Int, Board <: Tuple] = TupleMap[Range[0, 9], Int, [r <: Int] =>> Cell[r, c, Board]] | ||
|
||
type ColFromPos[Pos <: Int] = Pos % 9 | ||
|
||
type Sudoku1 = ( | ||
x, x, x, x, 1, x, 4, x, 6, | ||
8, x, 1, 6, 2, x, x, x, 9, | ||
x, 3, x, x, x, 9, x, 2, x, | ||
|
||
5, x, 9, 1, 3, x, x, 6, x, | ||
x, 6, x, 9, x, 2, x, 4, x, | ||
x, 2, x, x, 6, 7, 8, x, 5, | ||
|
||
x, 9, x, 5, x, x, x, 3, x, | ||
3, x, x, x, 4, 6, 9, x, 7, | ||
6, x, 7, x, 9, x, x, x, x, | ||
) | ||
|
||
//compiles fine | ||
summon[Col[ColFromPos[0], Sudoku1] =:= (x, 8, x, 5, x, x, x, 3, 6)] | ||
|
||
summon[TupleDedup[(x, 8, x, 5, x, x, x, 3, 6), Nothing] =:= (x, 8, 5, 3, 6)] | ||
//but this doesn't | ||
summon[TupleDedup[Col[ColFromPos[0], Sudoku1], Nothing] =:= (x, 8, 5, 3, 6)] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why does canConstrain behave that way? To me it seems pretty surprising that isFrozenConstraint does not in fact fully freeze the constraints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an exception made for parameters of cases that are tested in a match type. These need to be instantiatable even though the constraint as a whole is frozen.
Maybe resetting the constraint should be done in matchCase? That's where we set
caseLambda
and where we instantiate it at the end if it's a match. So it seems to be cleaner to reset the constraint there.