Skip to content

Add extension/conversion to GADT selection healing #16638

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

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Jan 9, 2023

Add extension/conversion to GADT selection healing

The GADT member selection "healing" logic only accounted for members
that belong to the resulting GADT-approximated type, meaning extension
methods weren't considered.

I moved that logic to typedSelect, so that the resulting tree from
running the extension or conversion attempt can be returned. In
adaptToSubType it was adapting the qualifier only. For example, we try
to extend/convert a.$asInstanceOf[MyData].printIt and get back
MyData.printIt(a.$asInstanceOf[MyData]) which we can return
(instead of throwing it away and having typedSelect redo the work.)

That also puts the new use of tryExtensionOrConversion next to the
previous use, for the original qualifier type.

The GADT member selection "healing" logic only accounted for members
that belong to the resulting GADT-approximated type, meaning extension
methods weren't considered.

I moved that logic to typedSelect, so that the resulting tree from
running the extension or conversion attempt can be returned.  In
adaptToSubType it was adapting the qualifier only.  For example, we try
to extend/convert `a.$asInstanceOf[MyData].printIt` and get back
`MyData.printIt(a.$asInstanceOf[MyData])` which we can return
(instead of throwing it away and having typedSelect redo the work.)

That also puts the new use of `tryExtensionOrConversion` next to the
previous use, for the original qualifier type.
@dwijnand dwijnand changed the title Unguard GADT selection healing Add extension/conversion to GADT selection healing Jan 11, 2023
@dwijnand dwijnand marked this pull request as ready for review January 11, 2023 14:06
@dwijnand dwijnand requested a review from abgruszecki January 11, 2023 14:06
@dwijnand dwijnand requested review from smarter and removed request for abgruszecki January 14, 2023 10:36
Copy link
Contributor

@abgruszecki abgruszecki left a comment

Choose a reason for hiding this comment

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

LGTM!

@dwijnand dwijnand merged commit 4277d86 into scala:main Jan 16, 2023
@dwijnand dwijnand deleted the gadt-ext-method branch January 16, 2023 09:02
@dwijnand dwijnand removed the request for review from smarter January 18, 2023 14:04
@dwijnand dwijnand assigned abgruszecki and unassigned smarter Jan 18, 2023
@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 1, 2023
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.

Extension methods don't get resolved on type inferred by GADT matching
4 participants