summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala6
-rw-r--r--test/files/neg/t6558.check4
-rw-r--r--test/files/neg/t6558.scala9
3 files changed, 18 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 36edd46f25..193c2bc76e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -1260,7 +1260,11 @@ trait Namers extends MethodSynthesis {
case defn: MemberDef =>
val ainfos = defn.mods.annotations filterNot (_ eq null) map { ann =>
// need to be lazy, #1782. beforeTyper to allow inferView in annotation args, SI-5892.
- AnnotationInfo lazily beforeTyper(typer typedAnnotation ann)
+ AnnotationInfo lazily {
+ val context1 = typer.context.make(ann)
+ context1.setReportErrors()
+ beforeTyper(newTyper(context1) typedAnnotation ann)
+ }
}
if (ainfos.nonEmpty) {
annotated setAnnotations ainfos
diff --git a/test/files/neg/t6558.check b/test/files/neg/t6558.check
new file mode 100644
index 0000000000..bd118edec8
--- /dev/null
+++ b/test/files/neg/t6558.check
@@ -0,0 +1,4 @@
+t6558.scala:5: error: not found: type sth
+ @sth
+ ^
+one error found
diff --git a/test/files/neg/t6558.scala b/test/files/neg/t6558.scala
new file mode 100644
index 0000000000..92c788f21e
--- /dev/null
+++ b/test/files/neg/t6558.scala
@@ -0,0 +1,9 @@
+class AnnotNotFound {
+ def foo(a: Any) = ()
+
+ foo {
+ @sth
+ def foo = 0
+ foo
+ }
+}