Skip to content

Commit b303d74

Browse files
committed
Assume StubSymbols are not StaticAnnotations
1 parent d70893c commit b303d74

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ abstract class Pickler extends SubComponent {
251251

252252
putChildren(sym, children.toList sortBy (_.sealedSortName))
253253
}
254-
for (annot <- (sym.annotations filter (ann => ann.isStatic && !ann.isErroneous)).reverse)
254+
for (annot <- (sym.annotations filter (ann => {ann.failIfStub; ann.isStatic && !ann.isErroneous})).reverse)
255255
putAnnotation(sym, annot)
256256
}
257257
else if (sym != NoSymbol) {
@@ -304,6 +304,7 @@ abstract class Pickler extends SubComponent {
304304
putSymbols(tparams)
305305
case AnnotatedType(_, underlying) =>
306306
putType(underlying)
307+
tp.annotations.foreach(_.failIfStub) // staticAnnotations skips stubs but we want a hard error
307308
tp.staticAnnotations foreach putAnnotation
308309
case _ =>
309310
throw new FatalError("bad type: " + tp + "(" + tp.getClass + ")")

src/reflect/scala/reflect/internal/AnnotationInfos.scala

+9-1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable =>
296296
* metaAnnotations = List(getter).
297297
*/
298298
def symbol = atp.typeSymbol
299+
final def failIfStub: Unit = symbol.info
299300

300301
/** These are meta-annotations attached at the use site; they
301302
* only apply to this annotation usage. For instance, in
@@ -323,7 +324,14 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable =>
323324
/** Check whether the type or any of the arguments are erroneous */
324325
def isErroneous = atp.isErroneous || args.exists(_.isErroneous)
325326

326-
def isStatic = symbol isNonBottomSubClass StaticAnnotationClass
327+
def isStatic = {
328+
symbol match {
329+
case _: StubSymbol =>
330+
false // See scala/bug#11679
331+
case _ =>
332+
symbol isNonBottomSubClass StaticAnnotationClass
333+
}
334+
}
327335

328336
/** Check whether any of the arguments mention a symbol */
329337
def refsSymbol(sym: Symbol) = hasArgWhich(_.symbol == sym)

src/reflect/scala/reflect/internal/Types.scala

+6-3
Original file line numberDiff line numberDiff line change
@@ -3461,9 +3461,12 @@ trait Types
34613461
object AnnotatedType extends AnnotatedTypeExtractor
34623462

34633463
object StaticallyAnnotatedType {
3464-
def unapply(tp: Type): Option[(List[AnnotationInfo], Type)] = tp.staticAnnotations match {
3465-
case Nil => None
3466-
case annots => Some((annots, tp.withoutAnnotations))
3464+
def unapply(tp: Type): Option[(List[AnnotationInfo], Type)] = {
3465+
tp.annotations.foreach(_.failIfStub) // staticAnnotations skips stubs but we want a hard error
3466+
tp.staticAnnotations match {
3467+
case Nil => None
3468+
case annots => Some((annots, tp.withoutAnnotations))
3469+
}
34673470
}
34683471
}
34693472

0 commit comments

Comments
 (0)