diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-19 11:06:11 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-19 11:06:11 -0700 |
commit | b6ba7ea9f0499335feba6838da80f4333e2d366f (patch) | |
tree | 3257a98b083193eb68404b2d502b00edd71e141e | |
parent | 5084b74048f7f21f38fdf45ebfa8e634b863bb01 (diff) | |
parent | a721df7e030b2ba69e7a51d4821bc3622e4c6774 (diff) | |
download | scala-b6ba7ea9f0499335feba6838da80f4333e2d366f.tar.gz scala-b6ba7ea9f0499335feba6838da80f4333e2d366f.tar.bz2 scala-b6ba7ea9f0499335feba6838da80f4333e2d366f.zip |
Merge pull request #2839 from densh/topic/si-7757
SI-7757 disallow constructor annotations on traits
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t7757a.check | 4 | ||||
-rw-r--r-- | test/files/neg/t7757a.scala | 1 | ||||
-rw-r--r-- | test/files/neg/t7757b.check | 4 | ||||
-rw-r--r-- | test/files/neg/t7757b.scala | 2 |
5 files changed, 12 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 8479df512e..94270e4cf3 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2693,7 +2693,7 @@ self => syntaxError("traits cannot have type parameters with context bounds `: ...' nor view bounds `<% ...'", skipIt = false) classContextBounds = List() } - val constrAnnots = constructorAnnotations() + val constrAnnots = if (!mods.isTrait) constructorAnnotations() else Nil val (constrMods, vparamss) = if (mods.isTrait) (Modifiers(Flags.TRAIT), List()) else (accessModifierOpt(), paramClauses(name, classContextBounds, ofCaseClass = mods.isCase)) diff --git a/test/files/neg/t7757a.check b/test/files/neg/t7757a.check new file mode 100644 index 0000000000..de24e23004 --- /dev/null +++ b/test/files/neg/t7757a.check @@ -0,0 +1,4 @@ +t7757a.scala:1: error: ';' expected but '@' found. +trait Foo @annot + ^ +one error found diff --git a/test/files/neg/t7757a.scala b/test/files/neg/t7757a.scala new file mode 100644 index 0000000000..24f6c16cb4 --- /dev/null +++ b/test/files/neg/t7757a.scala @@ -0,0 +1 @@ +trait Foo @annot
\ No newline at end of file diff --git a/test/files/neg/t7757b.check b/test/files/neg/t7757b.check new file mode 100644 index 0000000000..3e5a0f1fa6 --- /dev/null +++ b/test/files/neg/t7757b.check @@ -0,0 +1,4 @@ +t7757b.scala:2: error: expected start of definition +@annot2 + ^ +one error found diff --git a/test/files/neg/t7757b.scala b/test/files/neg/t7757b.scala new file mode 100644 index 0000000000..e9a537dba1 --- /dev/null +++ b/test/files/neg/t7757b.scala @@ -0,0 +1,2 @@ +trait Foo2 +@annot2
\ No newline at end of file |