diff options
Diffstat (limited to 'src')
5 files changed, 36 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index b6a4dc5e7..12c1e65a6 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -46,7 +46,11 @@ object desugar { */ override def ensureCompletions(implicit ctx: Context) = 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 diff --git a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 83d427a8f..cceaed53d 100644 --- a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -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 } diff --git a/src/dotty/tools/dotc/transform/FirstTransform.scala b/src/dotty/tools/dotc/transform/FirstTransform.scala index 97dd9404f..ae72d5f6c 100644 --- a/src/dotty/tools/dotc/transform/FirstTransform.scala +++ b/src/dotty/tools/dotc/transform/FirstTransform.scala @@ -28,6 +28,7 @@ import StdNames._ * - ensures there are companion objects for all classes except module classes * - eliminates some kinds of trees: Imports, NamedArgs * - stubs out native methods + * - eliminate self tree in Template and self symbol in ClassInfo */ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer with AnnotationTransformer { thisTransformer => import ast.tpd._ @@ -44,7 +45,14 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi this } - def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = tp/*{ + /** eliminate self symbol in ClassInfo */ + def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = tp match { + case tp@ClassInfo(_, _, _, _, self: Symbol) => + tp.derivedClassInfo(selfInfo = self.info) + case _ => + tp + } + /* tp match { //create companions for value classes that are not from currently compiled source file case tp@ClassInfo(_, cls, _, decls, _) @@ -59,7 +67,8 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi case _ => tp } } -*/ + */ + override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = { tree match { case Select(qual, _) if tree.symbol.exists => @@ -132,6 +141,11 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi (modul, mcComp, classComp) } + /** elimiate self in Template */ + override def transformTemplate(impl: Template)(implicit ctx: Context, info: TransformerInfo): Tree = { + cpy.Template(impl)(self = EmptyValDef) + } + override def transformDefDef(ddef: DefDef)(implicit ctx: Context, info: TransformerInfo) = { if (ddef.symbol.hasAnnotation(defn.NativeAnnot)) { ddef.symbol.resetFlag(Deferred) diff --git a/src/dotty/tools/dotc/transform/TreeTransform.scala b/src/dotty/tools/dotc/transform/TreeTransform.scala index 67bd2f160..abada9ab4 100644 --- a/src/dotty/tools/dotc/transform/TreeTransform.scala +++ b/src/dotty/tools/dotc/transform/TreeTransform.scala @@ -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 + 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) } } } diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index d70546f9d..390ecaee9 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -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 _ => |