diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 17 | ||||
-rw-r--r-- | test/files/neg/t6040.check | 7 | ||||
-rw-r--r-- | test/files/neg/t6040.scala | 1 | ||||
-rw-r--r-- | test/files/pos/t6040.scala | 3 | ||||
-rw-r--r-- | test/files/run/applydynamic_sip.flags | 1 | ||||
-rw-r--r-- | test/files/run/t4536.flags | 1 | ||||
-rw-r--r-- | test/files/run/t5040.flags | 1 |
7 files changed, 28 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 063f615e17..a6d7424837 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 != "" && diff --git a/test/files/neg/t6040.check b/test/files/neg/t6040.check new file mode 100644 index 0000000000..f44a81c471 --- /dev/null +++ b/test/files/neg/t6040.check @@ -0,0 +1,7 @@ +error: extension of type scala.Dynamic needs to be enabled +by making the implicit value language.dynamics visible. +This can be achieved by adding the import clause 'import language.dynamics' +or by setting the compiler option -language:dynamics. +See the Scala docs for value scala.language.dynamics for a discussion +why the feature needs to be explicitly enabled. +one error found diff --git a/test/files/neg/t6040.scala b/test/files/neg/t6040.scala new file mode 100644 index 0000000000..b8f7dab7a4 --- /dev/null +++ b/test/files/neg/t6040.scala @@ -0,0 +1 @@ +class X extends Dynamic
\ No newline at end of file diff --git a/test/files/pos/t6040.scala b/test/files/pos/t6040.scala new file mode 100644 index 0000000000..9c00ecd8e1 --- /dev/null +++ b/test/files/pos/t6040.scala @@ -0,0 +1,3 @@ +import language.dynamics + +class X extends Dynamic
\ No newline at end of file diff --git a/test/files/run/applydynamic_sip.flags b/test/files/run/applydynamic_sip.flags new file mode 100644 index 0000000000..1141f97507 --- /dev/null +++ b/test/files/run/applydynamic_sip.flags @@ -0,0 +1 @@ +-language:dynamics diff --git a/test/files/run/t4536.flags b/test/files/run/t4536.flags new file mode 100644 index 0000000000..1141f97507 --- /dev/null +++ b/test/files/run/t4536.flags @@ -0,0 +1 @@ +-language:dynamics diff --git a/test/files/run/t5040.flags b/test/files/run/t5040.flags new file mode 100644 index 0000000000..1141f97507 --- /dev/null +++ b/test/files/run/t5040.flags @@ -0,0 +1 @@ +-language:dynamics |