Skip to content

Commit

Permalink
Merge pull request #9069 from lrytz/revert9023
Browse files Browse the repository at this point in the history
Revert "Fix cycle when annotation argument references the annottee"
  • Loading branch information
dwijnand committed Jun 22, 2020
2 parents bc040e4 + a41a919 commit a9d3775
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 76 deletions.
19 changes: 6 additions & 13 deletions src/compiler/scala/tools/nsc/typechecker/Namers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1890,19 +1890,12 @@ trait Namers extends MethodSynthesis {
def annotSig(annotations: List[Tree], annotee: Tree, pred: AnnotationInfo => Boolean): List[AnnotationInfo] =
annotations filterNot (_ eq null) map { ann =>
val ctx = typer.context
// enteringTyper to allow inferView in annotation args, scala/bug#5892
def createAnnotationInfo = enteringTyper {
val annotSig = newTyper(ctx.makeNonSilent(ann)).typedAnnotation(ann, Some(annotee))
if (pred(annotSig)) annotSig else UnmappableAnnotation // UnmappableAnnotation will be dropped in typedValDef and typedDefDef
}

ann match {
case Apply(_, Nil) =>
// zero-argument annotations can be computed eagerly, see also TreeInfo.isUncheckedStable
createAnnotationInfo
case _ =>
// need to be lazy, scala/bug#1782
AnnotationInfo lazily createAnnotationInfo
// need to be lazy, #1782. enteringTyper to allow inferView in annotation args, scala/bug#5892.
AnnotationInfo lazily {
enteringTyper {
val annotSig = newTyper(ctx.makeNonSilent(ann)).typedAnnotation(ann, Some(annotee))
if (pred(annotSig)) annotSig else UnmappableAnnotation // UnmappableAnnotation will be dropped in typedValDef and typedDefDef
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/reflect/scala/reflect/internal/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ abstract class TreeInfo {
private def symOk(sym: Symbol) = sym != null && !sym.isError && sym != NoSymbol
private def typeOk(tp: Type) = tp != null && ! tp.isError

private def isUncheckedStable(sym: Symbol) =
// zero-arg annotations (like @uncheckedStable) are created eagerly. avoid forcing all annotations (scala/bug#11870).
sym.isTerm && sym.annotations.exists(ann => ann.isInstanceOf[CompleteAnnotationInfo] && ann.symbol == uncheckedStableClass)
private def isUncheckedStable(sym: Symbol) = sym.isTerm && sym.hasAnnotation(uncheckedStableClass)

/** Assuming `sym` is a member of `tree`, is it a "stable member"?
*
Expand Down
60 changes: 0 additions & 60 deletions test/files/pos/t11870.scala

This file was deleted.

0 comments on commit a9d3775

Please sign in to comment.