diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-08-07 12:22:10 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-08-08 09:09:24 +0200 |
commit | f76306b77fdc5b028d900141a40b8c98354641a9 (patch) | |
tree | aa9d013fc35a5bfcfda3ff96e8225ed042a6efbf /src/compiler | |
parent | 114367c0b2ce5f48186d4270c1724090fd77877b (diff) | |
download | scala-f76306b77fdc5b028d900141a40b8c98354641a9.tar.gz scala-f76306b77fdc5b028d900141a40b8c98354641a9.tar.bz2 scala-f76306b77fdc5b028d900141a40b8c98354641a9.zip |
SI-6040 error on unauthorized extension Dynamic
authorization is easy to get: `import language.dynamics`
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index d785988738..6e0d25b37b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1551,10 +1551,15 @@ trait Typers extends Modes with Adaptations with Tags { */ def validateParentClasses(parents: List[Tree], selfType: Type) { val pending = ListBuffer[AbsTypeError]() - def validateParentClass(parent: Tree, superclazz: Symbol) { + @inline def validateDynamicParent(parent: Symbol) = + if (parent == DynamicClass) checkFeature(parent.pos, DynamicsFeature) + + def validateParentClass(parent: Tree, superclazz: Symbol) = if (!parent.isErrorTyped) { val psym = parent.tpe.typeSymbol.initialize + checkStablePrefixClassType(parent) + if (psym != superclazz) { if (psym.isTrait) { val ps = psym.info.parents @@ -1564,6 +1569,7 @@ trait Typers extends Modes with Adaptations with Tags { pending += ParentNotATraitMixinError(parent, psym) } } + if (psym.isFinal) pending += ParentFinalInheritanceError(parent, psym) @@ -1586,12 +1592,17 @@ trait Typers extends Modes with Adaptations with Tags { pending += ParentSelfTypeConformanceError(parent, selfType) if (settings.explaintypes.value) explainTypes(selfType, parent.tpe.typeOfThis) } + if (parents exists (p => p != parent && p.tpe.typeSymbol == psym && !psym.isError)) pending += ParentInheritedTwiceError(parent, psym) + + validateDynamicParent(psym) } + + if (!parents.isEmpty && parents.forall(!_.isErrorTyped)) { + val superclazz = parents.head.tpe.typeSymbol + for (p <- parents) validateParentClass(p, superclazz) } - if (!parents.isEmpty && parents.forall(!_.isErrorTyped)) - for (p <- parents) validateParentClass(p, parents.head.tpe.typeSymbol) /* if (settings.Xshowcls.value != "" && |