Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assume StubSymbols are not StaticAnnotations #67

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ abstract class Pickler extends SubComponent {

putChildren(sym, children.toList sortBy (_.sealedSortName))
}
for (annot <- (sym.annotations filter (ann => ann.isStatic && !ann.isErroneous)).reverse)
for (annot <- (sym.annotations filter (ann => {ann.failIfStub; ann.isStatic && !ann.isErroneous})).reverse)
putAnnotation(sym, annot)
}
else if (sym != NoSymbol) {
Expand Down Expand Up @@ -304,6 +304,7 @@ abstract class Pickler extends SubComponent {
putSymbols(tparams)
case AnnotatedType(_, underlying) =>
putType(underlying)
tp.annotations.foreach(_.failIfStub) // staticAnnotations skips stubs but we want a hard error
tp.staticAnnotations foreach putAnnotation
case _ =>
throw new FatalError("bad type: " + tp + "(" + tp.getClass + ")")
Expand Down
10 changes: 9 additions & 1 deletion src/reflect/scala/reflect/internal/AnnotationInfos.scala
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable =>
* metaAnnotations = List(getter).
*/
def symbol = atp.typeSymbol
final def failIfStub: Unit = symbol.info

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

def isStatic = symbol isNonBottomSubClass StaticAnnotationClass
def isStatic = {
symbol match {
case _: StubSymbol =>
false // See scala/bug#11679
case _ =>
symbol isNonBottomSubClass StaticAnnotationClass
}
}

/** Check whether any of the arguments mention a symbol */
def refsSymbol(sym: Symbol) = hasArgWhich(_.symbol == sym)
Expand Down
9 changes: 6 additions & 3 deletions src/reflect/scala/reflect/internal/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3461,9 +3461,12 @@ trait Types
object AnnotatedType extends AnnotatedTypeExtractor

object StaticallyAnnotatedType {
def unapply(tp: Type): Option[(List[AnnotationInfo], Type)] = tp.staticAnnotations match {
case Nil => None
case annots => Some((annots, tp.withoutAnnotations))
def unapply(tp: Type): Option[(List[AnnotationInfo], Type)] = {
tp.annotations.foreach(_.failIfStub) // staticAnnotations skips stubs but we want a hard error
tp.staticAnnotations match {
case Nil => None
case annots => Some((annots, tp.withoutAnnotations))
}
}
}

Expand Down