File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
src/dotty/tools/dotc/core/classfile Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1127,7 +1127,11 @@ class ClassfileParser(
1127
1127
val outerName = entry.strippedOuter
1128
1128
val innerName = entry.originalName
1129
1129
val owner = classNameToSymbol(outerName)
1130
- val result = atPhase(typerPhase)(getMember(owner, innerName.toTypeName))
1130
+ val result = owner.denot.infoOrCompleter match
1131
+ case _ : StubInfo if hasAnnotation(entry.jflags) =>
1132
+ requiredClass(innerName.toTypeName)
1133
+ case _ =>
1134
+ atPhase(typerPhase)(getMember(owner, innerName.toTypeName))
1131
1135
assert(result ne NoSymbol ,
1132
1136
i """ failure to resolve inner class:
1133
1137
|externalName = ${entry.externalName},
Original file line number Diff line number Diff line change @@ -66,3 +66,26 @@ class AnnotationsTest:
66
66
s " A missing annotation while parsing a Java class should be silently ignored but: ${ctx.reporter.summary}" )
67
67
}
68
68
}
69
+
70
+ @ Test def surviveMissingInnerClassAnnot : Unit =
71
+ withJavaCompiled(
72
+ VirtualJavaSource (" Outer.java" ,
73
+ """ |package a.b;
74
+ |public @interface Outer { public @interface Value { @interface Immutable {} } }
75
+ |""" .stripMargin),
76
+ VirtualJavaSource (" Baz.java" ,
77
+ """ |package a.b;
78
+ |@Outer.Value.Immutable abstract class Baz {}""" .stripMargin)
79
+ ) { javaOutputDir =>
80
+ Files .delete(javaOutputDir.resolve(" a/b/Outer.class" ))
81
+ Files .delete(javaOutputDir.resolve(" a/b/Outer$Value.class" ))
82
+ Files .delete(javaOutputDir.resolve(" a/b/Outer$Value$Immutable.class" ))
83
+ inCompilerContext(javaOutputDir.toString + File .pathSeparator + TestConfiguration .basicClasspath) {
84
+ val cls = requiredClass(" a.b.Baz" )
85
+ val annots = cls.annotations.map(_.tree)
86
+ assert(annots == Nil ,
87
+ s " class Baz should have no visible annotations since Outer.Value.Immutable is not on the classpath, but found: $annots" )
88
+ assert(! ctx.reporter.hasErrors && ! ctx.reporter.hasWarnings,
89
+ s " A missing annotation while parsing a Java class should be silently ignored but: ${ctx.reporter.summary}" )
90
+ }
91
+ }
You can’t perform that action at this time.
0 commit comments