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

When simplifying match types, ensure fully defined before reducing #11980

Merged
merged 2 commits into from
Apr 9, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 3, 2021

Fixes #11977

Previously the match types were more often fully defined because inlining at Typer
caused more situations where type variables were instantiated. Now that inlining
is done later, we need to compensate. I believe it's a good idea anyway since it
means we can reduce more match types.

The weird widening from Int to Long in #11977 happened because the original match type was unreduced, so the original expression was judged as non-conforming. So Typer searched for an implicit conversion. But every conversion forced the matchtype to be fully defined and therefore reducible, so every implicit conversion to a wider numeric type succeeded. Then the smallest target was chosen: i.e. Int -> Long, or Long -> Float.

Fixes scala#11977

Previously the match types were more often fully defined because inlining at Typer
caused more situations where type variables were instantiated. Now that inlining
is done later, we need to compensate. I believe it's a good idea anyway since it
means we can reduce more match types.
@odersky odersky added this to the 3.0.0 milestone Apr 5, 2021
@odersky
Copy link
Contributor Author

odersky commented Apr 5, 2021

I put this under the 3.0 milestone since this we should discuss whether this fix requires a backport to the 3.0 RC branch (which means a new RC would be necessary). It certainly should be backported if we decide a new RC is necessary but I am not sure whether it is severe enough to require a new RC by itself.

The issue it fixes is certainly annoying and embarrassing. Basic tuple operations failed with weird types. I am a bit surprised this was not caught earlier since the problems exist since RC1.

On the other hand, it will affect new code only, and not be a problem for forward ported 2.13 code, since the failing operations are all 3.0 only. So, is that enough to go though another RC cycle for 3.0, or should we roll it into 3.0.1 which will come out 6 weeks after?

@odersky odersky merged commit 73bfead into scala:master Apr 9, 2021
@odersky odersky deleted the fix-11977 branch April 9, 2021 11:53
@Kordyjan Kordyjan modified the milestones: 3.0.0-RC3, 3.0.1 Aug 2, 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.

Type evaluation for 'Tuple.apply()' shows surprising behavior
3 participants