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

Normalize MatchAlias in unrollTupleTypes #19565

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

EugeneFlesselle
Copy link
Contributor

@EugeneFlesselle EugeneFlesselle commented Jan 29, 2024

I'm not sure whether the normalisation of MatchAlias should be done in dealias.
I suppose it is safer to only add the change in unrollTupleTypes where it is necessary.

Fixes #19385

@EugeneFlesselle EugeneFlesselle changed the title [WIP] Normalize MatchAlias in unrollTupleTypes Normalize MatchAlias in unrollTupleTypes Jan 30, 2024
@EugeneFlesselle EugeneFlesselle marked this pull request as ready for review January 30, 2024 10:08
@EugeneFlesselle
Copy link
Contributor Author

Similar to #19199

@nicolasstucki nicolasstucki self-requested a review January 30, 2024 10:54
@nicolasstucki nicolasstucki self-assigned this Jan 30, 2024
@@ -443,6 +443,9 @@ object Inlines:
unrollTupleTypes(tail).map(head :: _)
case tpe: TermRef if tpe.symbol == defn.EmptyTupleModule =>
Some(Nil)
case tpRef: TypeRef => tpRef.info match
Copy link
Contributor

Choose a reason for hiding this comment

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

The fix works, but I am not sure if this is the correct way to handle MatchAliases.

@sjrd could you have a look at this one?

Copy link
Member

Choose a reason for hiding this comment

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

It looks reasonable, although usually we would rather expect

case tpe: AppliedType if tpe.isMatchAlias => ... tpe.tryNormalize ...

It is a bit suspicious that we directly encounter the tycon here, rather than the surrounding AppliedType. What are tpe and tpe.dealias when we get here on the problematic test case?

Copy link
Contributor Author

@EugeneFlesselle EugeneFlesselle Jan 30, 2024

Choose a reason for hiding this comment

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

Yes I noticed that for instance isMatchAlias is defined on AppliedTypes.
But in this case, we have tpe := TypeRef(NoPrefix, Alias) which remains the same after dealias since the info of Alias is not a TypeAlias but a MatchAlias. The case is not covered here:
https://github.com/lampepfl/dotty/blob/997103d818ead17d528d320b01edefb8792579ac/compiler/src/dotty/tools/dotc/core/Types.scala#L1438-L1445

@EugeneFlesselle EugeneFlesselle merged commit 1ec17f6 into scala:main Jan 30, 2024
19 checks passed
@EugeneFlesselle EugeneFlesselle deleted the issues/i19385 branch February 6, 2024 08:13
@Kordyjan Kordyjan added this to the 3.4.1 milestone Feb 14, 2024
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.

summonAll for type alias does not work
4 participants