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 parents of tuple classes #13659

Merged
merged 3 commits into from Oct 6, 2021
Merged

Fix parents of tuple classes #13659

merged 3 commits into from Oct 6, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Oct 2, 2021

Fixes #13435

@@ -349,7 +349,11 @@ object TypeOps:
val doms = dominators(commonBaseClasses, Nil)
def baseTp(cls: ClassSymbol): Type =
tp.baseType(cls).mapReduceOr(identity)(mergeRefinedOrApplied)
doms.map(baseTp).reduceLeft(AndType.apply)
def meet(tp1: Type, tp2: Type) =
if !tp1.exists then tp2
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why this is needed, we do:

val commonBaseClasses = tp.mapReduceOr(_.baseClasses)(intersect)

(btw, how is this different from tp.baseClasses ?)
So I would expect tp.baseType on any of the common base classes to exist, but in fact the base classes of Tuple1[(Axis, Int)] | ((Axis, Int), (Axis, Int)) contains Product2, even though Tuple1 does not extend Product2, so I think there's a bug in how we compute base classes for unions, either here or in OrType#baseClasses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(btw, how is this different from tp.baseClasses ?)

Turns out it's different for Null. Since Null is also outside the inheritance hierarchy.

@smarter smarter assigned odersky and unassigned smarter Oct 4, 2021
We inserted the :* class not in the correct place, so the linearizations
of Tuple1..Tuple22 were messed up.
@smarter smarter changed the title Harden orDominator Fix parents of tuple classes Oct 6, 2021
@smarter smarter merged commit af2dfe0 into scala:master Oct 6, 2021
@smarter smarter deleted the fix-13435 branch October 6, 2021 11:13
@Kordyjan Kordyjan added this to the 3.1.1 milestone 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
3 participants