Skip to content

Transform annotations only if defined in current run #1241

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

Merged
merged 3 commits into from
Apr 29, 2016
Merged
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
6 changes: 5 additions & 1 deletion src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ object desugar {
*/
override def ensureCompletions(implicit ctx: Context) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above could be updated to note that we also need to have the class itself completed.

if (!(ctx.owner is Package))
if (ctx.owner is ModuleClass) ctx.owner.linkedClass.ensureCompleted()
if (ctx.owner.isClass) {
ctx.owner.ensureCompleted()
if (ctx.owner is ModuleClass)
ctx.owner.linkedClass.ensureCompleted()
}
else ensureCompletions(ctx.outer)

/** Return info of original symbol, where all references to siblings of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
val ex = new BadSignature(
sm"""error reading Scala signature of $classRoot from $source:
|error occurred at position $readIndex: $msg""")
if (ctx.debug || true) original.getOrElse(ex).printStackTrace() // temporarilly enable printing of original failure signature to debug failing builds
if (ctx.debug || true) original.getOrElse(ex).printStackTrace() // temporarily enable printing of original failure signature to debug failing builds
throw ex
}

Expand Down
15 changes: 11 additions & 4 deletions src/dotty/tools/dotc/transform/TreeTransform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,19 @@ object TreeTransforms {

ref match {
case ref: SymDenotation =>
val annotTrees = ref.annotations.map(_.tree)
val annotTrees1 = annotTrees.mapConserve(annotationTransformer.macroTransform)
val annots1 = if (annotTrees eq annotTrees1) ref.annotations else annotTrees1.map(new ConcreteAnnotation(_))
val annots1 =
if (!ref.symbol.isDefinedInCurrentRun) ref.annotations // leave annotations read from class files alone
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

else {
val annotTrees = ref.annotations.map(_.tree)
val annotTrees1 = annotTrees.mapConserve(annotationTransformer.macroTransform)
if (annotTrees eq annotTrees1) ref.annotations
else annotTrees1.map(new ConcreteAnnotation(_))
}
if ((info1 eq ref.info) && (annots1 eq ref.annotations)) ref
else ref.copySymDenotation(info = info1, annotations = annots1)
case _ => if (info1 eq ref.info) ref else ref.derivedSingleDenotation(ref.symbol, info1)
case _ =>
if (info1 eq ref.info) ref
else ref.derivedSingleDenotation(ref.symbol, info1)
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,9 @@ trait Applications extends Compatibility { self: Typer =>
/** Drop any implicit parameter section */
def stripImplicit(tp: Type): Type = tp match {
case mt: ImplicitMethodType if !mt.isDependent =>
mt.resultType // todo: make sure implicit method types are not dependent
mt.resultType
// todo: make sure implicit method types are not dependent?
// but check test case in /tests/pos/depmet_implicit_chaining_zw.scala
case pt: PolyType =>
pt.derivedPolyType(pt.paramNames, pt.paramBounds, stripImplicit(pt.resultType))
case _ =>
Expand Down