Skip to content

Commit f9858a4

Browse files
committed
Merge pull request #1241 from dotty-staging/fix-#1222
Transform annotations only if defined in current run
2 parents 96fcdd9 + 1c7c738 commit f9858a4

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ object desugar {
4646
*/
4747
override def ensureCompletions(implicit ctx: Context) =
4848
if (!(ctx.owner is Package))
49-
if (ctx.owner is ModuleClass) ctx.owner.linkedClass.ensureCompleted()
49+
if (ctx.owner.isClass) {
50+
ctx.owner.ensureCompleted()
51+
if (ctx.owner is ModuleClass)
52+
ctx.owner.linkedClass.ensureCompleted()
53+
}
5054
else ensureCompletions(ctx.outer)
5155

5256
/** Return info of original symbol, where all references to siblings of the

src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
179179
val ex = new BadSignature(
180180
sm"""error reading Scala signature of $classRoot from $source:
181181
|error occurred at position $readIndex: $msg""")
182-
if (ctx.debug || true) original.getOrElse(ex).printStackTrace() // temporarilly enable printing of original failure signature to debug failing builds
182+
if (ctx.debug || true) original.getOrElse(ex).printStackTrace() // temporarily enable printing of original failure signature to debug failing builds
183183
throw ex
184184
}
185185

src/dotty/tools/dotc/transform/TreeTransform.scala

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,19 @@ object TreeTransforms {
185185

186186
ref match {
187187
case ref: SymDenotation =>
188-
val annotTrees = ref.annotations.map(_.tree)
189-
val annotTrees1 = annotTrees.mapConserve(annotationTransformer.macroTransform)
190-
val annots1 = if (annotTrees eq annotTrees1) ref.annotations else annotTrees1.map(new ConcreteAnnotation(_))
188+
val annots1 =
189+
if (!ref.symbol.isDefinedInCurrentRun) ref.annotations // leave annotations read from class files alone
190+
else {
191+
val annotTrees = ref.annotations.map(_.tree)
192+
val annotTrees1 = annotTrees.mapConserve(annotationTransformer.macroTransform)
193+
if (annotTrees eq annotTrees1) ref.annotations
194+
else annotTrees1.map(new ConcreteAnnotation(_))
195+
}
191196
if ((info1 eq ref.info) && (annots1 eq ref.annotations)) ref
192197
else ref.copySymDenotation(info = info1, annotations = annots1)
193-
case _ => if (info1 eq ref.info) ref else ref.derivedSingleDenotation(ref.symbol, info1)
198+
case _ =>
199+
if (info1 eq ref.info) ref
200+
else ref.derivedSingleDenotation(ref.symbol, info1)
194201
}
195202
}
196203
}

src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,9 @@ trait Applications extends Compatibility { self: Typer =>
925925
/** Drop any implicit parameter section */
926926
def stripImplicit(tp: Type): Type = tp match {
927927
case mt: ImplicitMethodType if !mt.isDependent =>
928-
mt.resultType // todo: make sure implicit method types are not dependent
928+
mt.resultType
929+
// todo: make sure implicit method types are not dependent?
930+
// but check test case in /tests/pos/depmet_implicit_chaining_zw.scala
929931
case pt: PolyType =>
930932
pt.derivedPolyType(pt.paramNames, pt.paramBounds, stripImplicit(pt.resultType))
931933
case _ =>

0 commit comments

Comments
 (0)