summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2010-06-11 09:40:31 +0000
committerIulian Dragos <jaguarul@gmail.com>2010-06-11 09:40:31 +0000
commit4865d85015227bfa84eae1bac6ebe868e0f27d6d (patch)
treeaca33fd3694ad0c58b82741772fc13a7ee63e82e
parentf730e2caf8b62a3acf370e84a243e665fbbc71dd (diff)
downloadscala-4865d85015227bfa84eae1bac6ebe868e0f27d6d.tar.gz
scala-4865d85015227bfa84eae1bac6ebe868e0f27d6d.tar.bz2
scala-4865d85015227bfa84eae1bac6ebe868e0f27d6d.zip
Merged revisions 22219 via svnmerge from
https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk ........ r22219 | dragos | 2010-06-11 11:34:42 +0200 (Fri, 11 Jun 2010) | 1 line Partial fix for #2296: instead of VerifyError we issue a compile-time error (implementation restriction). To properly generate accessors in traits we need to move most (all?) logic related to protected accessors to phase mixin, use abstract accessors all the way up to mixin, and generate the code in the mixin class. In other words, exactly what is done for super accessors right now. Review by extempore. ........
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
index fabf2ed063..0c3ac481ed 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
@@ -411,10 +411,15 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
unit.error(pos, "Implementation restriction: " + msg)
}
+ def accessibleThroughSubclassing: Boolean =
+ (validCurrentOwner
+ && currentOwner.enclClass.thisSym.isSubClass(sym.owner)
+ && !currentOwner.enclClass.isTrait)
+
val res = /* settings.debug.value && */
((sym hasFlag PROTECTED)
&& !sym.owner.isPackageClass
- && (!validCurrentOwner || !(currentOwner.enclClass.thisSym isSubClass sym.owner))
+ && !accessibleThroughSubclassing
&& (enclPackage(sym.owner) != enclPackage(currentOwner))
&& (enclPackage(sym.owner) == enclPackage(sym.accessBoundary(sym.owner))))
@@ -424,9 +429,12 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
if (host.isPackageClass) false
else if (host.thisSym != host) {
if (host.thisSym.tpe.typeSymbol.hasFlag(JAVA))
- errorRestriction(currentOwner.enclClass + " accesses protected " + sym
- + " from self type " + host.thisSym.tpe)
+ errorRestriction("%s accesses protected %s from self type %s.".format(currentOwner.enclClass, sym, host.thisSym.tpe))
false
+ } else if (host.isTrait && sym.hasFlag(JAVA)) {
+ errorRestriction(("%s accesses protected %s inside a concrete trait method. " +
+ "Add an accessor in a class extending %s to work around this bug.").format(currentOwner.enclClass, sym, sym.enclClass))
+ false
} else res
} else res
}