Skip to content

Commit

Permalink
Closes SI-6952: add correct error positions for Dynamic feature check.
Browse files Browse the repository at this point in the history
  • Loading branch information
namin committed Jan 16, 2013
1 parent 6f3ea77 commit 8a74b7b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/compiler/scala/tools/nsc/typechecker/Typers.scala
Expand Up @@ -1740,8 +1740,8 @@ trait Typers extends Modes with Adaptations with Tags {
*/ */
def validateParentClasses(parents: List[Tree], selfType: Type) { def validateParentClasses(parents: List[Tree], selfType: Type) {
val pending = ListBuffer[AbsTypeError]() val pending = ListBuffer[AbsTypeError]()
def validateDynamicParent(parent: Symbol) = def validateDynamicParent(parent: Symbol, parentPos: Position) =
if (parent == DynamicClass) checkFeature(parent.pos, DynamicsFeature) if (parent == DynamicClass) checkFeature(parentPos, DynamicsFeature)


def validateParentClass(parent: Tree, superclazz: Symbol) = def validateParentClass(parent: Tree, superclazz: Symbol) =
if (!parent.isErrorTyped) { if (!parent.isErrorTyped) {
Expand Down Expand Up @@ -1791,7 +1791,7 @@ trait Typers extends Modes with Adaptations with Tags {
if (parents exists (p => p != parent && p.tpe.typeSymbol == psym && !psym.isError)) if (parents exists (p => p != parent && p.tpe.typeSymbol == psym && !psym.isError))
pending += ParentInheritedTwiceError(parent, psym) pending += ParentInheritedTwiceError(parent, psym)


validateDynamicParent(psym) validateDynamicParent(psym, parent.pos)
} }


if (!parents.isEmpty && parents.forall(!_.isErrorTyped)) { if (!parents.isEmpty && parents.forall(!_.isErrorTyped)) {
Expand Down
4 changes: 3 additions & 1 deletion 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. by making the implicit value language.dynamics visible.
This can be achieved by adding the import clause 'import scala.language.dynamics' This can be achieved by adding the import clause 'import scala.language.dynamics'
or by setting the compiler option -language:dynamics. or by setting the compiler option -language:dynamics.
See the Scala docs for value scala.language.dynamics for a discussion See the Scala docs for value scala.language.dynamics for a discussion
why the feature needs to be explicitly enabled. why the feature needs to be explicitly enabled.
class X extends Dynamic
^
one error found one error found
13 changes: 13 additions & 0 deletions 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
4 changes: 4 additions & 0 deletions 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

0 comments on commit 8a74b7b

Please sign in to comment.