Skip to content

Commit 745c852

Browse files
committed
Merge pull request #242 from dotty-staging/fix/mixins
Fix/mixins
2 parents b18ce86 + a7d5809 commit 745c852

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

src/dotty/tools/dotc/core/Phases.scala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ object Phases {
220220
private var myErasedTypes = false
221221
private var myFlatClasses = false
222222
private var myRefChecked = false
223+
private var mySymbolicRefs = false
223224

224225
/** The sequence position of this phase in the given context where 0
225226
* is reserved for NoPhase and the first real phase is at position 1.
@@ -231,18 +232,20 @@ object Phases {
231232
def start = myPeriod.firstPhaseId
232233
def end = myPeriod.lastPhaseId
233234

234-
final def erasedTypes = myErasedTypes
235-
final def flatClasses = myFlatClasses
236-
final def refChecked = myRefChecked
235+
final def erasedTypes = myErasedTypes // Phase is after erasure
236+
final def flatClasses = myFlatClasses // Phase is after flatten
237+
final def refChecked = myRefChecked // Phase is after RefChecks
238+
final def symbolicRefs = mySymbolicRefs // Phase is after ResolveSuper, newly generated TermRefs should be symbolic
237239

238240
protected[Phases] def init(base: ContextBase, start: Int, end:Int): Unit = {
239241
if (start >= FirstPhaseId)
240242
assert(myPeriod == Periods.InvalidPeriod, s"phase $this has already been used once; cannot be reused")
241243
myBase = base
242244
myPeriod = Period(start, end)
243-
myErasedTypes = prev.getClass == classOf[Erasure] || prev.erasedTypes
244-
myFlatClasses = prev.getClass == classOf[Flatten] || prev.flatClasses
245-
myRefChecked = prev.getClass == classOf[RefChecks] || prev.refChecked
245+
myErasedTypes = prev.getClass == classOf[Erasure] || prev.erasedTypes
246+
myFlatClasses = prev.getClass == classOf[Flatten] || prev.flatClasses
247+
myRefChecked = prev.getClass == classOf[RefChecks] || prev.refChecked
248+
mySymbolicRefs = prev.getClass == classOf[ResolveSuper] || prev.symbolicRefs
246249
}
247250

248251
protected[Phases] def init(base: ContextBase, id: Int): Unit = init(base, id, id)

src/dotty/tools/dotc/core/Types.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,8 @@ object Types {
15421542

15431543
object TermRef {
15441544

1545+
private def symbolicRefs(implicit ctx: Context) = ctx.phase.symbolicRefs
1546+
15451547
/** Create term ref with given name, without specifying a signature.
15461548
* Its meaning is the (potentially multi-) denotation of the member(s)
15471549
* of prefix with given name.
@@ -1562,7 +1564,7 @@ object Types {
15621564
* signature, if denotation is not yet completed.
15631565
*/
15641566
def apply(prefix: Type, name: TermName, denot: Denotation)(implicit ctx: Context): TermRef = {
1565-
if ((prefix eq NoPrefix) || denot.symbol.isFresh || ctx.erasedTypes)
1567+
if ((prefix eq NoPrefix) || denot.symbol.isFresh || symbolicRefs)
15661568
apply(prefix, denot.symbol.asTerm)
15671569
else denot match {
15681570
case denot: SymDenotation if denot.isCompleted => withSig(prefix, name, denot.signature)
@@ -1584,7 +1586,7 @@ object Types {
15841586
* (2) The name in the term ref need not be the same as the name of the Symbol.
15851587
*/
15861588
def withSymAndName(prefix: Type, sym: TermSymbol, name: TermName)(implicit ctx: Context): TermRef =
1587-
if ((prefix eq NoPrefix) || sym.isFresh || ctx.erasedTypes)
1589+
if ((prefix eq NoPrefix) || sym.isFresh || symbolicRefs)
15881590
withFixedSym(prefix, name, sym)
15891591
else if (sym.defRunId != NoRunId && sym.isCompleted)
15901592
withSig(prefix, name, sym.signature) withSym (sym, sym.signature)
@@ -1595,7 +1597,7 @@ object Types {
15951597
* (which must be completed).
15961598
*/
15971599
def withSig(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRef =
1598-
if ((prefix eq NoPrefix) || sym.isFresh || ctx.erasedTypes) withFixedSym(prefix, sym.name, sym)
1600+
if ((prefix eq NoPrefix) || sym.isFresh || symbolicRefs) withFixedSym(prefix, sym.name, sym)
15991601
else withSig(prefix, sym.name, sym.signature).withSym(sym, sym.signature)
16001602

16011603
/** Create a term ref with given prefix, name and signature */
@@ -1604,7 +1606,7 @@ object Types {
16041606

16051607
/** Create a term ref with given prefix, name, signature, and initial denotation */
16061608
def withSigAndDenot(prefix: Type, name: TermName, sig: Signature, denot: Denotation)(implicit ctx: Context): TermRef = {
1607-
if ((prefix eq NoPrefix) || denot.symbol.isFresh || ctx.erasedTypes)
1609+
if ((prefix eq NoPrefix) || denot.symbol.isFresh || symbolicRefs)
16081610
withFixedSym(prefix, denot.symbol.asTerm.name, denot.symbol.asTerm)
16091611
else
16101612
withSig(prefix, name, sig)

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,10 @@ object RefChecks {
222222
}
223223

224224
/* Is the intersection between given two lists of overridden symbols empty? */
225-
def intersectionIsEmpty(syms1: Iterator[Symbol], syms2: Iterator[Symbol]) =
226-
!(syms1 exists (syms2 contains _))
225+
def intersectionIsEmpty(syms1: Iterator[Symbol], syms2: Iterator[Symbol]) = {
226+
val set2 = syms2.toSet
227+
!(syms1 exists (set2 contains _))
228+
}
227229

228230
// o: public | protected | package-protected (aka java's default access)
229231
// ^-may be overridden by member with access privileges-v

test/dotc/tests.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ class tests extends CompilerTest {
113113
@Test def dotc_config = compileDir(dotcDir + "tools/dotc/config", twice)
114114
@Test def dotc_core = compileDir(dotcDir + "tools/dotc/core", twice)(allowDeepSubtypes)
115115
@Test def dotc_core_pickling = compileDir(dotcDir + "tools/dotc/core/pickling", twice)(allowDeepSubtypes)
116-
// @Test def dotc_transform = compileDir(dotcDir + "tools/dotc/transform", twice)(allowDeepSubtypes)
117-
// @odersky causes race error in ResolveSuper
116+
@Test def dotc_transform = compileDir(dotcDir + "tools/dotc/transform", twice)(allowDeepSubtypes)
118117

119118
@Test def dotc_parsing = compileDir(dotcDir + "tools/dotc/parsing", twice)
120119
@Test def dotc_printing = compileDir(dotcDir + "tools/dotc/printing", twice)

0 commit comments

Comments
 (0)