From 8a74b7bd136f691d9d60c7dd10ddf96a45e32329 Mon Sep 17 00:00:00 2001 From: amin Date: Wed, 16 Jan 2013 09:59:12 +0100 Subject: Closes SI-6952: add correct error positions for Dynamic feature check. --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 6 +++--- test/files/neg/t6040.check | 4 +++- test/files/neg/t6952.check | 13 +++++++++++++ test/files/neg/t6952.scala | 4 ++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 test/files/neg/t6952.check create mode 100644 test/files/neg/t6952.scala diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index b4c5365516..2efc1df1e5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1740,8 +1740,8 @@ trait Typers extends Modes with Adaptations with Tags { */ def validateParentClasses(parents: List[Tree], selfType: Type) { val pending = ListBuffer[AbsTypeError]() - def validateDynamicParent(parent: Symbol) = - if (parent == DynamicClass) checkFeature(parent.pos, DynamicsFeature) + def validateDynamicParent(parent: Symbol, parentPos: Position) = + if (parent == DynamicClass) checkFeature(parentPos, DynamicsFeature) def validateParentClass(parent: Tree, superclazz: Symbol) = if (!parent.isErrorTyped) { @@ -1791,7 +1791,7 @@ trait Typers extends Modes with Adaptations with Tags { if (parents exists (p => p != parent && p.tpe.typeSymbol == psym && !psym.isError)) pending += ParentInheritedTwiceError(parent, psym) - validateDynamicParent(psym) + validateDynamicParent(psym, parent.pos) } if (!parents.isEmpty && parents.forall(!_.isErrorTyped)) { diff --git a/test/files/neg/t6040.check b/test/files/neg/t6040.check index f6757f97e3..f91df0c46d 100644 --- a/test/files/neg/t6040.check +++ b/test/files/neg/t6040.check @@ -1,7 +1,9 @@ -error: extension of type scala.Dynamic needs to be enabled +t6040.scala:1: 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 scala.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. +class X extends Dynamic + ^ one error found diff --git a/test/files/neg/t6952.check b/test/files/neg/t6952.check new file mode 100644 index 0000000000..f1e1881404 --- /dev/null +++ b/test/files/neg/t6952.check @@ -0,0 +1,13 @@ +t6952.scala:2: 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 scala.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. +trait B extends Dynamic + ^ +t6952.scala:3: error: extension of type scala.Dynamic needs to be enabled +by making the implicit value language.dynamics visible. +trait C extends A with Dynamic + ^ +two errors found diff --git a/test/files/neg/t6952.scala b/test/files/neg/t6952.scala new file mode 100644 index 0000000000..257ea3be68 --- /dev/null +++ b/test/files/neg/t6952.scala @@ -0,0 +1,4 @@ +trait A +trait B extends Dynamic +trait C extends A with Dynamic +trait D extends B -- cgit v1.2.3