Skip to content
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

Fix exhaustivity due to separate TypeVar lambdas #18616

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Sep 29, 2023

By using newTypeVar, separate type lambdas are created. I think due to that, type parameter ordering doesn't
come into play. When the unapply usage is typed, the PolyType that is the method is added as a whole, with all
its type parameters, and its type vars are instantiated against that, allowing one type var to instantiate
against another parameter - so we must make the same thing happen in the SpaceEngine.

Due to that, when erasing, we need to erase pattern bound symbols underlying pattern bound symbols.

Then, rework ProtoType's constrained API. Firstly remove the single-use overload and replace it with a much
more used alternative. Secondly return TypeVars instead of TypeTrees, so we don't have to unwrap the useless
wrapper a bunch of times, and instead we wrap the few times we really do want to.

Refs #14224

Remove the single use overload, replace with a much more used
alternative

Also return TypeVars instead of TypeTrees, so we don't have to unwrap
the useless wrapper a bunch of times, and instead we wrap the few times
we really do want to.
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -779,7 +777,7 @@ object ProtoTypes {
pt => bounds :: Nil,
pt => represents.orElse(defn.AnyType))
constrained(poly, untpd.EmptyTree, alwaysAddTypeVars = true, nestingLevel)
._2.head.tpe.asInstanceOf[TypeVar]
._2.head

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see, the changes are only about APIs, which simplifies usage in several places, the logic is the same. /cc: @odersky

@dwijnand dwijnand merged commit 138eb55 into scala:main Oct 16, 2023
18 checks passed
@dwijnand dwijnand deleted the false-exh branch October 16, 2023 20:04
@Kordyjan Kordyjan added this to the 3.4.0 milestone Dec 20, 2023
WojciechMazur added a commit that referenced this pull request Jun 22, 2024
…20715)

Backports #18616 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants