summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-12-29 12:23:12 -0800
committerPaul Phillips <paulp@improving.org>2012-01-04 22:51:07 -0800
commitbedb33fd7cb3439a129dff15e1ea1341c5c8fe7d (patch)
treeafe1df7be20f55076d835b66a48a8f4b14bba70b
parent14ca7ef432d57a6188f184b700ca37e42b9ba17d (diff)
downloadscala-bedb33fd7cb3439a129dff15e1ea1341c5c8fe7d.tar.gz
scala-bedb33fd7cb3439a129dff15e1ea1341c5c8fe7d.tar.bz2
scala-bedb33fd7cb3439a129dff15e1ea1341c5c8fe7d.zip
Don't infer protected members into lub refinements.
Following up to the previous, taking my own advice in SI-5352.
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index c1d3f85bc9..0b6d77db07 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -2993,6 +2993,9 @@ A type's typeSymbol should never be inspected directly.
/** A creator for intersection type where intersections of a single type are
* replaced by the type itself, and repeated parent classes are merged.
+ *
+ * !!! Repeated parent classes are not merged - is this a bug in the
+ * comment or in the code?
*/
def intersectionType(tps: List[Type], owner: Symbol): Type = tps match {
case List(tp) =>
@@ -5749,9 +5752,16 @@ A type's typeSymbol should never be inspected directly.
val lubType =
if (phase.erasedTypes || depth == 0) lubBase
else {
- val lubRefined = refinedType(lubParents, lubOwner)
+ val lubRefined = refinedType(lubParents, lubOwner)
val lubThisType = lubRefined.typeSymbol.thisType
- val narrowts = ts map (_.narrow)
+ val narrowts = ts map (_.narrow)
+ def excludeFromLub(sym: Symbol) = (
+ sym.isClass
+ || sym.isConstructor
+ || !sym.isPublic
+ || isGetClass(sym)
+ || narrowts.exists(t => !refines(t, sym))
+ )
def lubsym(proto: Symbol): Symbol = {
val prototp = lubThisType.memberInfo(proto)
val syms = narrowts map (t =>
@@ -5780,16 +5790,15 @@ A type's typeSymbol should never be inspected directly.
// efficiency.
alt != sym && !specializesSym(lubThisType, sym, tp, alt)))
}
- for (sym <- lubBase.nonPrivateMembers) {
- // add a refinement symbol for all non-class members of lubBase
- // which are refined by every type in ts.
- if (!sym.isClass && !sym.isConstructor && !isGetClass(sym) && (narrowts forall (t => refines(t, sym))))
- try {
- val lsym = lubsym(sym)
- if (lsym != NoSymbol) addMember(lubThisType, lubRefined, lubsym(sym))
- } catch {
- case ex: NoCommonType =>
- }
+ // add a refinement symbol for all non-class members of lubBase
+ // which are refined by every type in ts.
+ for (sym <- lubBase.nonPrivateMembers ; if !excludeFromLub(sym)) {
+ try {
+ val lsym = lubsym(sym)
+ if (lsym != NoSymbol) addMember(lubThisType, lubRefined, lsym)
+ } catch {
+ case ex: NoCommonType =>
+ }
}
if (lubRefined.decls.isEmpty) lubBase
else if (!verifyLubs) lubRefined