Skip to content

Commit 2b5b064

Browse files
committed
Merge pull request #811 from dotty-staging/fix-objects-mixin
Fix #810: initialization of inner objects of traits.
2 parents cbb565a + db35474 commit 2b5b064

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ object PickleBuffer {
221221
FINAL_PKL -> Final,
222222
METHOD_PKL -> Method,
223223
INTERFACE_PKL -> NoInitsInterface,
224-
MODULE_PKL -> Module,
224+
MODULE_PKL -> (Module | Lazy, Module),
225225
IMPLICIT_PKL -> Implicit,
226226
SEALED_PKL -> Sealed,
227227
CASE_PKL -> Case,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransf
117117
object ExplicitOuter {
118118
import ast.tpd._
119119

120-
private val LocalInstantiationSite = Module | Private
121-
122120
/** Ensure that class `cls` has outer accessors */
123121
def ensureOuterAccessors(cls: ClassSymbol)(implicit ctx: Context): Unit = {
124122
//todo: implementing #165 would simplify this logic
@@ -176,7 +174,9 @@ object ExplicitOuter {
176174

177175
/** Class is always instantiated in the compilation unit where it is defined */
178176
private def hasLocalInstantiation(cls: ClassSymbol)(implicit ctx: Context): Boolean =
179-
cls.owner.isTerm || cls.is(LocalInstantiationSite)
177+
// scala2x modules always take an outer pointer(as of 2.11)
178+
// dotty modules are always locally instantiated
179+
cls.owner.isTerm || cls.is(Private) || cls.is(Module, butNot = Scala2x)
180180

181181
/** The outer parameter accessor of cass `cls` */
182182
private def outerParamAccessor(cls: ClassSymbol)(implicit ctx: Context): TermSymbol =

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ class Mixin extends MiniPhaseTransform with SymTransformer { thisTransform =>
216216
val rhs =
217217
if (ctx.atPhase(thisTransform)(implicit ctx => getter.is(ParamAccessor))) nextArgument()
218218
else if (isScala2x)
219-
if (getter.is(Lazy)) lazyGetterCall
219+
if (getter.is(Lazy, butNot = Module)) lazyGetterCall
220+
else if (getter.is(Module))
221+
New(getter.info.resultType, List(This(cls)))
220222
else Underscore(getter.info.resultType)
221223
else transformFollowing(superRef(initializer(getter)).appliedToNone)
222224
// transformFollowing call is needed to make memoize & lazy vals run

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ import util.Stats.{track, record}
3434
import config.Printers._
3535
import language.implicitConversions
3636

37-
trait TyperContextOps { ctx: Context => }
38-
3937
object Typer {
4038

4139
/** The precedence of bindings which determines which of several bindings will be

0 commit comments

Comments
 (0)