diff options
Diffstat (limited to 'src/compiler')
4 files changed, 17 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Flags.scala b/src/compiler/scala/tools/nsc/symtab/Flags.scala index d747ecfef7..2c526f77a9 100644 --- a/src/compiler/scala/tools/nsc/symtab/Flags.scala +++ b/src/compiler/scala/tools/nsc/symtab/Flags.scala @@ -58,7 +58,8 @@ object Flags extends Enumeration { final val PARAMACCESSOR = 0x20000000 // for value definitions: is an access method // for a final val parameter // for parameters: is a val parameter - final val MODULEVAR = 0x40000000 // for term symbols: is the variable caching a module value + final val MODULEVAR = 0x40000000 // for variables: is the variable caching a module value + final val SYNTHETICMETH = 0x40000000 // for methods: synthetic method, but without SYNTHETIC flag final val MONOMORPHIC = 0x40000000 // for type symbols: does not have type parameters final val LAZY = 0x80000000L // symbol is a lazy val. can't have MUTABLE unless transformed by typer diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index 7a12dcee2f..8d6f1b0c40 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -11,6 +11,8 @@ import scala.tools.nsc.io.AbstractFile import scala.tools.nsc.util.{Position, NoPosition, BatchSourceFile} import Flags._ +//todo: get rid of MONOMORPHIC flag + trait Symbols { self: SymbolTable => import definitions._ diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index dcb1ff70d9..962f749591 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -54,7 +54,7 @@ trait SyntheticMethods { self: Analyzer => def hasOverridingImplementation(meth: Symbol): Boolean = if (inIDE) true else { val sym = clazz.info.nonPrivateMember(meth.name) sym.alternatives exists { sym => - sym != meth && !(sym hasFlag DEFERRED) && !(sym hasFlag SYNTHETIC) && + sym != meth && !(sym hasFlag DEFERRED) && !(sym hasFlag (SYNTHETIC | SYNTHETICMETH)) && (clazz.thisType.memberType(sym) matches clazz.thisType.memberType(meth)) } } @@ -63,10 +63,9 @@ trait SyntheticMethods { self: Analyzer => newSyntheticMethod(name, flags | OVERRIDE, tpe) def newSyntheticMethod(name: Name, flags: Int, tpe: Type) = { - var method = clazz.newMethod(clazz.pos, name) setFlag ({ - if (inIDE) flags | SYNTHETIC - else flags - }) setInfo tpe + var method = clazz.newMethod(clazz.pos, name) + .setFlag(flags | (if (inIDE) SYNTHETIC else SYNTHETICMETH)) + .setInfo(tpe) method = clazz.info.decls.enter(method).asInstanceOf[TermSymbol] method } @@ -78,18 +77,18 @@ trait SyntheticMethods { self: Analyzer => } */ def productPrefixMethod: Tree = { - val method = syntheticMethod(nme.productPrefix, FINAL, PolyType(List(), StringClass.tpe)) + val method = syntheticMethod(nme.productPrefix, 0, PolyType(List(), StringClass.tpe)) typer.typed(DefDef(method, vparamss => Literal(Constant(clazz.name.decode)))) } def productArityMethod(nargs:Int ): Tree = { - val method = syntheticMethod(nme.productArity, FINAL, PolyType(List(), IntClass.tpe)) + val method = syntheticMethod(nme.productArity, 0, PolyType(List(), IntClass.tpe)) typer.typed(DefDef(method, vparamss => Literal(Constant(nargs)))) } def productElementMethod(accs: List[Symbol]): Tree = { //val retTpe = lub(accs map (_.tpe.resultType)) - val method = syntheticMethod(nme.productElement, FINAL, MethodType(List(IntClass.tpe), AnyClass.tpe/*retTpe*/)) + val method = syntheticMethod(nme.productElement, 0, MethodType(List(IntClass.tpe), AnyClass.tpe/*retTpe*/)) typer.typed(DefDef(method, vparamss => Match(Ident(vparamss.head.head), { (for ((sym,i) <- accs.zipWithIndex) yield { CaseDef(Literal(Constant(i)),EmptyTree, Ident(sym)) @@ -106,7 +105,7 @@ trait SyntheticMethods { self: Analyzer => } def tagMethod: Tree = { - val method = syntheticMethod(nme.tag, FINAL, MethodType(List(), IntClass.tpe)) + val method = syntheticMethod(nme.tag, 0, MethodType(List(), IntClass.tpe)) typer.typed(DefDef(method, vparamss => Literal(Constant(clazz.tag)))) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 2cdbb3d57d..db35ab1681 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -972,9 +972,11 @@ trait Typers { self: Analyzer => } else { error(parent.pos, psym+" needs to be a trait be mixed in") } - } else if (psym hasFlag FINAL) { - error(parent.pos, "illegal inheritance from final class") - } else if (psym.isSealed && !phase.erasedTypes) { + } + if (psym hasFlag FINAL) { + error(parent.pos, "illegal inheritance from final "+psym) + } + if (psym.isSealed && !phase.erasedTypes) { if (context.unit.source.file != psym.sourceFile) error(parent.pos, "illegal inheritance from sealed "+psym) else |