diff options
author | Paul Phillips <paulp@improving.org> | 2010-12-31 08:52:36 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-12-31 08:52:36 +0000 |
commit | 4db73388f2d63eb9b57fecfbd0d76203d7a71c18 (patch) | |
tree | ed06122bff32818e6debbd30600de287744b45bf /src | |
parent | 1259651a7ded65809d63d6b2744d4d097cc90ead (diff) | |
download | scala-4db73388f2d63eb9b57fecfbd0d76203d7a71c18.tar.gz scala-4db73388f2d63eb9b57fecfbd0d76203d7a71c18.tar.bz2 scala-4db73388f2d63eb9b57fecfbd0d76203d7a71c18.zip |
Modified the self-type protected accessor test ...
Modified the self-type protected accessor test to avoid unnecessary
runtime failures. Closes #4119, review by dragos.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index c2110f104d..985652deaa 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -434,18 +434,18 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT && (sym.owner.enclosingPackageClass == packageAccessBoundry(sym)) ) val host = hostForAccessorOf(sym, clazz) - def isSelfType = (host.thisSym != host) && { - if (host.thisSym.tpe.typeSymbol.isJavaDefined) + def isSelfType = !(host.tpe <:< host.typeOfThis) && { + if (host.typeOfThis.typeSymbol.isJavaDefined) restrictionError(pos, unit, - "%s accesses protected %s from self type %s.".format(clazz, sym, host.thisSym.tpe) + "%s accesses protected %s from self type %s.".format(clazz, sym, host.typeOfThis) ) true } def isJavaProtected = host.isTrait && sym.isJavaDefined && { restrictionError(pos, unit, - "%s accesses protected %s inside a concrete trait method. " + - "Add an accessor in a class extending %s to work around this bug." . - format(clazz, sym, sym.enclClass) + """|%s accesses protected %s inside a concrete trait method. + |Add an accessor in a class extending %s as a workaround.""".stripMargin.format( + clazz, sym, sym.enclClass) ) true } |