From 5cc825c48d3b9bf806d41195e0954b9a2ff2fc3f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 17 Aug 2008 20:34:21 +0000 Subject: Fixed #1186, #1230 --- src/compiler/scala/tools/nsc/CompilationUnits.scala | 2 +- src/compiler/scala/tools/nsc/transform/Erasure.scala | 3 ++- src/compiler/scala/tools/nsc/typechecker/Namers.scala | 16 ++++++++-------- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala index 3bac2f7525..f536a16a62 100644 --- a/src/compiler/scala/tools/nsc/CompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala @@ -73,7 +73,7 @@ trait CompilationUnits { self: Global => } /** Is this about a .java source file? */ - def isJava = source.file.name.endsWith(".java") + lazy val isJava = source.file.name.endsWith(".java") override def toString() = source.toString() diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 4c65f76c97..817c9bb658 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -208,7 +208,8 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { case tp => List(tp) } def boundSig(bounds: List[Type]) = { - val classBound = bounds find (t => t.typeSymbol.isClass && !t.typeSymbol.isTrait) match { + def isClassBound(t: Type) = t.typeSymbol.isClass || t.typeSymbol.isAbstractType + val classBound = bounds find isClassBound match { case Some(t) => javaSig(t) case None => "" } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index f6e6d4ef22..54ddcdb25d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -330,12 +330,16 @@ trait Namers { self: Analyzer => finish case ValDef(mods, name, tp, rhs) => - if (name.endsWith(nme.OUTER, nme.OUTER.length)) { // SM + if ((!context.owner.isClass || + (mods.flags & (PRIVATE | LOCAL)) == (PRIVATE | LOCAL) || + name.endsWith(nme.OUTER, nme.OUTER.length) || + context.unit.isJava) && + (mods.flags & LAZY) == 0) { tree.symbol = enterInScope(owner.newValue(tree.pos, name) .setFlag(mods.flags)) finish - } else if (context.owner.isClass && (mods.flags & (PRIVATE | LOCAL)) != (PRIVATE | LOCAL) - || (mods.flags & LAZY) != 0) { + } else { + // add getter and possibly also setter val accflags: Long = ACCESSOR | (if ((mods.flags & MUTABLE) != 0) mods.flags & ~MUTABLE & ~PRESUPER else mods.flags & ~PRESUPER | STABLE) @@ -367,11 +371,7 @@ trait Namers { self: Analyzer => if ((mods.flags & LAZY) != 0) vsym.setLazyAccessor(getter) vsym - } else getter; - } else { - tree.symbol = enterInScope(owner.newValue(tree.pos, name) - .setFlag(mods.flags)) - finish + } else getter } case DefDef(mods, nme.CONSTRUCTOR, tparams, _, _, _) => var sym = owner.newConstructor(tree.pos).setFlag(mods.flags | owner.getFlag(ConstrFlags)) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 014676199f..79621e00fe 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1540,7 +1540,7 @@ trait Typers { self: Analyzer => stats1 } - def typedImport(imp : Import) : Import = imp; + def typedImport(imp : Import) : Import = imp def typedStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = { -- cgit v1.2.3