-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Approximate MatchTypes with lub of case bodies, if non-recursive #19761
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8f2b6cf
Approximate MatchTypes with lub of case bodies, if non-recursive
dwijnand c25edde
Lub MatchTypeTree case body types and store as the inferred bound
dwijnand 55ecbfc
Use isProvisional instead of has LazyRef
dwijnand 3419aae
Fix PlusTri in pos/13633
dwijnand 2423198
Handle NoType in disjointnessBoundary
dwijnand db1dcdc
Fix run-macros/type-show
dwijnand d687dee
Rework ParamRef#underlying handling in disjointnessBoundary
dwijnand 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 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 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 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 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,7 @@ | ||
import compiletime.ops.int.* | ||
|
||
type Drop[T <: Tuple, N <: Int] <: Tuple = N match | ||
case 0 => T | ||
case S[n1] => T match | ||
case EmptyTuple => EmptyTuple | ||
case x *: xs => Drop[xs, n1] |
This file contains 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,7 @@ | ||
import compiletime.ops.int.* | ||
|
||
type Elem[T <: Tuple, I <: Int] = T match | ||
case h *: tail => | ||
I match | ||
case 0 => h | ||
case S[j] => Elem[tail, j] |
This file contains 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,11 @@ | ||
import scala.util.NotGiven | ||
|
||
type HasName1 = [n] =>> [x] =>> x match { | ||
case n => true | ||
case _ => false | ||
} | ||
@main def Test = { | ||
summon[HasName1["foo"]["foo"] =:= true] | ||
summon[NotGiven[HasName1["foo"]["bar"] =:= true]] | ||
summon[Tuple.Filter[(1, "foo", 2, "bar"), HasName1["foo"]] =:= Tuple1["foo"]] // error | ||
} |
Oops, something went wrong.
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.
That seems to be a problem with
ParamRef#superTypeNormalized
rather than withdisjointnessBoundary
.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.
What should
superTypeNormalized
do?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.
It should return the declared type of the corresponding param, which is supposed to be its
underlying
. I don't see a scenario in whichsuperTypeNormalized
should ever returnNoType
, except possibly forAnyKind
itself.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.
Apparently, it can happen that it is not initialised:
https://github.com/lampepfl/dotty/blob/e994cf06eeee23e8a55a086907957e43140f2112/compiler/src/dotty/tools/dotc/core/Types.scala#L4690-L4695
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.
That sort of explains it, although it's still concerning that we're attempting to read it from
provablyDisjoint
when it hasn't been initialized yet. Looks like a time bomb waiting to explode later due to weird compilation order issues.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.
Yes, and this is not the only case, I ran into a similar issue where normalisation relies on the
underlying
type, which is not always set as expected. For aTypeRef
, it goes through the denotation info, of which the completion seemed a bit unpredictable to me (heavily influenced by small changes in where things happen to be reduced).Also (maybe) unrelated the normalization depends on the gadt ctx which doesn't seem to be reliably populated when using
NamedType
s.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.
I guess I should've opted for AnyKind rather than Any, as the more conservative approach.
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.
I would still be less uncomfortable if we specifically handled
ParamRef
to deal with itssuperTypeNormalized
returningNoType
; instead of having this "catch-all"NoType
. That would limit the blast radius of this workaround. We should also clearly comment that it is a workaround.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.
Sure thing.