Skip to content

Commit d9928d5

Browse files
hubertpretronym
authored andcommitted
Fixes SI-6558: typecheck lazy annotation info using non-silent context.
Make context for typing lazy annotations always non-silent. If lazy annotation info was created in local (silent) context, error could go unnoticed because later they would still use silent typer for typing the annotation.
1 parent f16f4ab commit d9928d5

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/compiler/scala/tools/nsc/typechecker/Namers.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,11 @@ trait Namers extends MethodSynthesis {
12601260
case defn: MemberDef =>
12611261
val ainfos = defn.mods.annotations filterNot (_ eq null) map { ann =>
12621262
// need to be lazy, #1782. beforeTyper to allow inferView in annotation args, SI-5892.
1263-
AnnotationInfo lazily beforeTyper(typer typedAnnotation ann)
1263+
AnnotationInfo lazily {
1264+
val context1 = typer.context.make(ann)
1265+
context1.setReportErrors()
1266+
beforeTyper(newTyper(context1) typedAnnotation ann)
1267+
}
12641268
}
12651269
if (ainfos.nonEmpty) {
12661270
annotated setAnnotations ainfos

test/files/neg/t6558.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
t6558.scala:5: error: not found: type sth
2+
@sth
3+
^
4+
one error found

test/files/neg/t6558.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class AnnotNotFound {
2+
def foo(a: Any) = ()
3+
4+
foo {
5+
@sth
6+
def foo = 0
7+
foo
8+
}
9+
}

0 commit comments

Comments
 (0)