aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/transform')
-rw-r--r--src/dotty/tools/dotc/transform/AttachOuter.scala65
-rw-r--r--src/dotty/tools/dotc/transform/ExplicitOuter.scala10
-rw-r--r--src/dotty/tools/dotc/transform/Mixin.scala2
3 files changed, 6 insertions, 71 deletions
diff --git a/src/dotty/tools/dotc/transform/AttachOuter.scala b/src/dotty/tools/dotc/transform/AttachOuter.scala
deleted file mode 100644
index 9d2b0574d..000000000
--- a/src/dotty/tools/dotc/transform/AttachOuter.scala
+++ /dev/null
@@ -1,65 +0,0 @@
-package dotty.tools.dotc
-package transform
-
-import TreeTransforms._
-import core.DenotTransformers._
-import core.Symbols._
-import core.Contexts._
-import core.Types._
-import core.Flags._
-import core.Decorators._
-import core.StdNames.nme
-import ast.Trees._
-import util.Attachment
-
-/** This phase decorates News and parent constructors of non-static inner classes
- * with an attachment indicating the outer reference as a tree. This is necessary because
- * outer prefixes are erased, and explicit outer runs only after erasure.
- */
-class AttachOuter extends MiniPhaseTransform {
- import ast.tpd._
-
- val Outer = new Attachment.Key[Tree]
-
- override def phaseName: String = "attachOuter"
-
- private def outerPrefix(tpe: Type)(implicit ctx: Context): Type = tpe match {
- case tpe: TypeRef =>
- tpe.symbol match {
- case cls: ClassSymbol =>
- if (cls.owner.isStaticOwner || cls.is(Interface)) NoPrefix
- else if (tpe.prefix eq NoPrefix) cls.owner.enclosingClass.thisType
- else tpe.prefix
- case _ =>
- outerPrefix(tpe.underlying)
- }
- case tpe: TypeProxy =>
- outerPrefix(tpe.underlying)
- }
-
- override def transformNew(tree: New)(implicit ctx: Context, info: TransformerInfo): Tree = {
- val pre = outerPrefix(tree.tpt.tpe)
- pre match {
- case pre: SingletonType =>
- tree.putAttachment(Outer, singleton(pre)) match {
- case Some(outer) => assert(outer.tpe =:= pre)
- case none =>
- }
- case NoPrefix =>
- }
- tree
- }
-
- override def transformTemplate(tree: Template)(implicit ctx: Context, info: TransformerInfo): Tree = {
- def transformParent(tree: Tree): Tree = tree match {
- case tree: TypeTree if outerPrefix(tree.tpe) != NoPrefix =>
- val constr = New(tree.tpe, Nil).withPos(tree.pos)
- val Select(nu: New, _) = methPart(constr)
- transformNew(nu)
- constr
- case _ =>
- tree
- }
- cpy.Template(tree)(parents = tree.parents mapconserve transformParent)
- }
-} \ No newline at end of file
diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala
index 28d742b5e..436d9bcf7 100644
--- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala
+++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala
@@ -144,11 +144,11 @@ object ExplicitOuter {
nme.OUTER.expandedName(cls)
/** Class needs an outer pointer, provided there is a reference to an outer this in it. */
- def needsOuterIfReferenced(cls: ClassSymbol)(implicit ctx: Context): Boolean = !(
- cls.isStatic ||
- cls.owner.enclosingClass.isStaticOwner ||
- cls.is(Interface)
- )
+ def needsOuterIfReferenced(cls: ClassSymbol)(implicit ctx: Context): Boolean =
+ !(cls.isStatic ||
+ cls.owner.enclosingClass.isStaticOwner ||
+ cls.is(PureInterface)
+ )
/** Class unconditionally needs an outer pointer. This is the case if
* the class needs an outer pointer if referenced and one of the following holds:
diff --git a/src/dotty/tools/dotc/transform/Mixin.scala b/src/dotty/tools/dotc/transform/Mixin.scala
index 1d342404a..3d68a2687 100644
--- a/src/dotty/tools/dotc/transform/Mixin.scala
+++ b/src/dotty/tools/dotc/transform/Mixin.scala
@@ -134,7 +134,7 @@ class Mixin extends MiniPhaseTransform with SymTransformer { thisTransform =>
case Some(call) =>
if (defn.PhantomClasses.contains(baseCls)) Nil else call :: Nil
case None =>
- if (baseCls.is(Interface) || defn.PhantomClasses.contains(baseCls)) Nil
+ if (baseCls.is(NoInitsTrait) || defn.PhantomClasses.contains(baseCls)) Nil
else {
//println(i"synth super call ${baseCls.primaryConstructor}: ${baseCls.primaryConstructor.info}")
superRef(baseCls.primaryConstructor).appliedToNone :: Nil