aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-06-20 02:25:55 +0200
committerMartin Odersky <odersky@gmail.com>2013-06-20 02:25:55 +0200
commitf4347b9ae8d7def0e092e154150098fdb9abc65e (patch)
treeedf76f76743c3ae49305b3666465eafe0b34d240 /src/dotty/tools/dotc/core/SymDenotations.scala
parente64db5defe1115427c39ffb19c3ee127d028b3cd (diff)
downloaddotty-f4347b9ae8d7def0e092e154150098fdb9abc65e.tar.gz
dotty-f4347b9ae8d7def0e092e154150098fdb9abc65e.tar.bz2
dotty-f4347b9ae8d7def0e092e154150098fdb9abc65e.zip
Added accessibility checks to typedIdent
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 95798d701..63c148e20 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -333,7 +333,7 @@ object SymDenotations {
* Everything is accessible if `pre` is `NoPrefix`.
* A symbol with type `NoType` is not accessible for any other prefix.
*/
- final def isAccessibleFrom(pre: Type, superAccess: Boolean = false)(implicit ctx: Context): Boolean = {
+ final def isAccessibleFrom(pre: Type, superAccess: Boolean = false, whyNot: StringBuffer = null)(implicit ctx: Context): Boolean = {
/** Are we inside definition of `boundary`? */
def accessWithin(boundary: Symbol) =
@@ -360,24 +360,24 @@ object SymDenotations {
/** Is protected access to target symbol permitted? */
def isProtectedAccessOK = {
def fail(str: => String): Boolean = {
- ctx.diagnose(str)
+ if (whyNot != null) whyNot append str
false
}
val cls = owner.enclosingSubClass
if (!cls.exists)
fail(
- s"""Access to protected $this not permitted because
- |enclosing ${ctx.owner.enclosingClass.showLocated} is not a subclass of
- |${owner.showLocated} where target is defined""".stripMargin)
+ s""" Access to protected $this not permitted because
+ | enclosing ${ctx.owner.enclosingClass.showLocated} is not a subclass of
+ | ${owner.showLocated} where target is defined""".stripMargin)
else if (
!( isType // allow accesses to types from arbitrary subclasses fixes #4737
|| pre.baseType(cls).exists
|| (owner is ModuleClass) // don't perform this check for static members
))
fail(
- s"""Access to protected ${symbol.show} not permitted because
- |prefix type ${pre.widen.show} does not conform to
- |${cls.showLocated} where the access takes place""".stripMargin)
+ s""" Access to protected ${symbol.show} not permitted because
+ | prefix type ${pre.widen.show} does not conform to
+ | ${cls.showLocated} where the access takes place""".stripMargin)
else true
}