-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #7965: Deal with AndTypes in joins #7992
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
Conversation
Allow that the base type of a join may be a conjunction.
@@ -212,6 +212,8 @@ trait TypeOps { this: Context => // TODO: Make standalone object. | |||
tp1.derivedAppliedType( | |||
mergeRefinedOrApplied(tycon1, tycon2), | |||
ctx.typeComparer.lubArgs(args1, args2, tycon1.typeParams)) | |||
case AndType(tp21, tp22) => |
There was a problem hiding this comment.
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.
} | ||
case tp1 @ AppliedType(tycon1, args1) => | ||
tp2 match { | ||
case AppliedType(tycon2, args2) => | ||
tp1.derivedAppliedType( | ||
mergeRefinedOrApplied(tycon1, tycon2), | ||
ctx.typeComparer.lubArgs(args1, args2, tycon1.typeParams)) | ||
case _ => fail | ||
case _ => fallback | ||
} | ||
case tp1 @ TypeRef(pre1, _) => | ||
tp2 match { | ||
case tp2 @ TypeRef(pre2, _) if tp1.name eq tp2.name => | ||
tp1.derivedSelect(pre1 | pre2) | ||
case _ => fail |
There was a problem hiding this comment.
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)
}
Allow that the base type of a join may be a conjunction.