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

Don't re-balance AndTypes arising from supertypes #20400

Merged
merged 1 commit into from
May 26, 2024

Conversation

odersky
Copy link
Contributor

@odersky odersky commented May 13, 2024

#20284 started breaking since we now balance AndTypes to avoid performance drops. But (re-)balancing an AndType interferes with the logic that determines which symbol is referred by a super select. This is fixed by two changes:

  • Form types of super with AndType instead of &
  • Don't simplify types of super since that would rebalance the underlying AndTypes.

Fixes #20284

scala#20284 started breaking since we now balance AndTypes to avoid performance drops.
But (re-)balancing an AndType interferes with the logic that determines which
symbol is referred by a super select. This is fixed by two changes:

 - Form types of super with `AndType` instead of `&`
 - Don't simplify types of super since that would rebalance the underlying AndTypes.

Fixes scala#20284
Copy link
Contributor

@EugeneFlesselle EugeneFlesselle left a comment

Choose a reason for hiding this comment

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

That was not an obvious consequence of rebalancing the AndTypes at all !

I've noticed we also rebalance the parents of a ClassInfo for the classBound used in the AvoidMap, I'm not sure if it could also have some an unexpected effects ?

def classBound(info: ClassInfo)(using Context): Type = {
val cls = info.cls
val parentType = info.parents.reduceLeft(TypeComparer.andType(_, _))

@odersky
Copy link
Contributor Author

odersky commented May 26, 2024

AvoidMap should be OK.

@odersky odersky merged commit 952b928 into scala:main May 26, 2024
19 checks passed
@odersky odersky deleted the fix-20284 branch May 26, 2024 09:34
@Kordyjan Kordyjan added this to the 3.5.1 milestone Jul 3, 2024
WojciechMazur added a commit that referenced this pull request Jul 9, 2024
…21124)

Backports #20400 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.

Wrong linearization for super calls caused by unrelated trait mixins
3 participants