From bbc4f7a3234937e5f79e8310e6fff2f9b4af0f98 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 29 Jan 2013 09:44:37 +0100 Subject: New Context architecture based on cloning --- src/dotty/tools/dotc/core/SymDenotations.scala | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala') diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 0a1138e46..0748cf42d 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -232,16 +232,13 @@ object SymDenotations { /** Is protected access to target symbol permitted? */ def isProtectedAccessOK = { - def fail(diagnostics: () => String): Boolean = { - ctx match { - case ctx: DiagnosticsContext => ctx.diagnostics = diagnostics - case _ => - } + def fail(str: => String): Boolean = { + ctx.diagnose(str) false } val cls = owner.enclosingSubClass if (!cls.exists) - fail(() => + fail( s"""Access to protected $this not permitted because |enclosing ${ctx.enclClass.owner.showLocated} is not a subclass of |${owner.showLocated} where target is defined""".stripMargin) @@ -249,7 +246,7 @@ object SymDenotations { pre.widen.typeSymbol.isSubClassOrCompanion(cls) || cls.isModuleClass && pre.widen.typeSymbol.isSubClassOrCompanion(cls.linkedClass))) - fail(() => + 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) @@ -449,7 +446,7 @@ object SymDenotations { to } baseClassesVar = symbol :: addParentBaseClasses(parents, Nil) - superClassBitsVar = ctx.root.uniqueBits.findEntryOrUpdate(seen.toImmutable) + superClassBitsVar = ctx.uniqueBits.findEntryOrUpdate(seen.toImmutable) } def superClassBits(implicit ctx: Context): BitSet = { -- cgit v1.2.3