diff --git a/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala b/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala index b080a97b6e94..17fef3852a66 100644 --- a/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala +++ b/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala @@ -221,7 +221,7 @@ object PickleBuffer { FINAL_PKL -> Final, METHOD_PKL -> Method, INTERFACE_PKL -> NoInitsInterface, - MODULE_PKL -> Module, + MODULE_PKL -> (Module | Lazy, Module), IMPLICIT_PKL -> Implicit, SEALED_PKL -> Sealed, CASE_PKL -> Case, diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala index eb231bfe730e..0dda44e840dc 100644 --- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -117,8 +117,6 @@ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransf object ExplicitOuter { import ast.tpd._ - private val LocalInstantiationSite = Module | Private - /** Ensure that class `cls` has outer accessors */ def ensureOuterAccessors(cls: ClassSymbol)(implicit ctx: Context): Unit = { //todo: implementing #165 would simplify this logic @@ -176,7 +174,9 @@ object ExplicitOuter { /** Class is always instantiated in the compilation unit where it is defined */ private def hasLocalInstantiation(cls: ClassSymbol)(implicit ctx: Context): Boolean = - cls.owner.isTerm || cls.is(LocalInstantiationSite) + // scala2x modules always take an outer pointer(as of 2.11) + // dotty modules are always locally instantiated + cls.owner.isTerm || cls.is(Private) || cls.is(Module, butNot = Scala2x) /** The outer parameter accessor of cass `cls` */ private def outerParamAccessor(cls: ClassSymbol)(implicit ctx: Context): TermSymbol = diff --git a/src/dotty/tools/dotc/transform/Mixin.scala b/src/dotty/tools/dotc/transform/Mixin.scala index ae4e261775f1..32b268fc75f9 100644 --- a/src/dotty/tools/dotc/transform/Mixin.scala +++ b/src/dotty/tools/dotc/transform/Mixin.scala @@ -216,7 +216,9 @@ class Mixin extends MiniPhaseTransform with SymTransformer { thisTransform => val rhs = if (ctx.atPhase(thisTransform)(implicit ctx => getter.is(ParamAccessor))) nextArgument() else if (isScala2x) - if (getter.is(Lazy)) lazyGetterCall + if (getter.is(Lazy, butNot = Module)) lazyGetterCall + else if (getter.is(Module)) + New(getter.info.resultType, List(This(cls))) else Underscore(getter.info.resultType) else transformFollowing(superRef(initializer(getter)).appliedToNone) // transformFollowing call is needed to make memoize & lazy vals run diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index a3c64f526379..9e5842b6895a 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -33,8 +33,6 @@ import util.Stats.{track, record} import config.Printers._ import language.implicitConversions -trait TyperContextOps { ctx: Context => } - object Typer { /** The precedence of bindings which determines which of several bindings will be