Skip to content

Commit 2ce159f

Browse files
committed
Merge pull request #664 from dotty-staging/more-tests
Enable tests that pass, move macro tests to disabled.
2 parents 78fae11 + 797bfd7 commit 2ce159f

File tree

1,105 files changed

+41
-46
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,105 files changed

+41
-46
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import SymDenotations._
1111
import Types._
1212
import Decorators._
1313
import DenotTransformers._
14+
import Annotations._
1415
import StdNames._
1516
import NameOps._
1617
import ast.Trees._
@@ -80,9 +81,14 @@ class AugmentScala2Traits extends MiniPhaseTransform with IdentityDenotTransform
8081
for (sym <- mixin.info.decls) {
8182
if (needsForwarder(sym) || sym.isConstructor || sym.isGetter && sym.is(Lazy))
8283
implClass.enter(implMethod(sym.asTerm))
83-
if (sym.isGetter && !sym.is(LazyOrDeferred) &&
84-
!sym.setter.exists && !sym.info.resultType.isInstanceOf[ConstantType])
85-
traitSetter(sym.asTerm).enteredAfter(thisTransform)
84+
if (sym.isGetter)
85+
if (sym.is(Lazy)) {
86+
if (!sym.hasAnnotation(defn.VolatileAnnot))
87+
sym.addAnnotation(Annotation(defn.VolatileAnnot, Nil))
88+
}
89+
else if (!sym.is(Deferred) && !sym.setter.exists &&
90+
!sym.info.resultType.isInstanceOf[ConstantType])
91+
traitSetter(sym.asTerm).enteredAfter(thisTransform)
8692
if (sym.is(PrivateAccessor, butNot = ExpandedName) &&
8793
(sym.isGetter || sym.isSetter)) // strangely, Scala 2 fields are also methods that have Accessor set.
8894
sym.ensureNotPrivate.installAfter(thisTransform)

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,18 @@ class Mixin extends MiniPhaseTransform with SymTransformer { thisTransform =>
163163
if (isCurrent(getter) || getter.is(ExpandedName))
164164
// transformFollowing call is needed to make memoize & lazy vals run
165165
transformFollowing(
166-
DefDef(implementation(getter.asTerm), if (isScala2x) default else initial))
166+
DefDef(implementation(getter.asTerm),
167+
if (isScala2x) {
168+
if (getter.is(Flags.Lazy)) { // lazy vals need to have a rhs that will be the lazy initializer
169+
val sym = mixin.implClass.info.nonPrivateDecl(getter.name).suchThat(_.info.paramTypess match {
170+
case List(List(t: TypeRef)) => t.isDirectRef(mixin)
171+
case _ => false
172+
}).symbol // lazy val can be overloaded
173+
ref(mixin.implClass).select(sym).appliedTo(This(ctx.owner.asClass))
174+
}
175+
else default
176+
} else initial)
177+
)
167178
else if (isScala2x) EmptyTree
168179
else initial
169180
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)