Skip to content

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 15, 2020

Allow that the base type of a join may be a conjunction.

Allow that the base type of a join may be a conjunction.
tp1.derivedAppliedType(
mergeRefinedOrApplied(tycon1, tycon2),
ctx.typeComparer.lubArgs(args1, args2, tycon1.typeParams))
case AndType(tp21, tp22) =>
Copy link
Member

Choose a reason for hiding this comment

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

This handles having tp1 be an AppliedType and tp2 be an AndType, but it seems that we'd need similar special cases when tp1 is a RefinedType and tp2 is an AndType, etc. Instead maybe all calls to fail in this method could be replaced by a fallback that handles the recursion when tp2 is an AndType.

tp2 match {
case tp2 @ TypeRef(pre2, _) if tp1.name eq tp2.name =>
tp1.derivedSelect(pre1 | pre2)
case _ => fail
Copy link
Member

@smarter smarter Jan 15, 2020

Choose a reason for hiding this comment

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

The fallback is also necessary here, otherwise the following would crash:

class Outer { class Elem } class Test { val o1: Outer = ??? val o2: Outer = ??? val o3: Outer = ??? val x: o1.Elem | (o2.Elem & o3.Elem) def foo[T <: Outer#Elem](has: T): T = ??? foo(x) }
@smarter smarter merged commit 83ab6c7 into scala:master Jan 15, 2020
@smarter smarter deleted the fix-#7965 branch January 15, 2020 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants