Skip to content

Fix/mixins #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/dotty/tools/dotc/core/Phases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ object Phases {
private var myErasedTypes = false
private var myFlatClasses = false
private var myRefChecked = false
private var mySymbolicRefs = false

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

final def erasedTypes = myErasedTypes
final def flatClasses = myFlatClasses
final def refChecked = myRefChecked
final def erasedTypes = myErasedTypes // Phase is after erasure
final def flatClasses = myFlatClasses // Phase is after flatten
final def refChecked = myRefChecked // Phase is after RefChecks
final def symbolicRefs = mySymbolicRefs // Phase is after ResolveSuper, newly generated TermRefs should be symbolic

protected[Phases] def init(base: ContextBase, start: Int, end:Int): Unit = {
if (start >= FirstPhaseId)
assert(myPeriod == Periods.InvalidPeriod, s"phase $this has already been used once; cannot be reused")
myBase = base
myPeriod = Period(start, end)
myErasedTypes = prev.getClass == classOf[Erasure] || prev.erasedTypes
myFlatClasses = prev.getClass == classOf[Flatten] || prev.flatClasses
myRefChecked = prev.getClass == classOf[RefChecks] || prev.refChecked
myErasedTypes = prev.getClass == classOf[Erasure] || prev.erasedTypes
myFlatClasses = prev.getClass == classOf[Flatten] || prev.flatClasses
myRefChecked = prev.getClass == classOf[RefChecks] || prev.refChecked
mySymbolicRefs = prev.getClass == classOf[ResolveSuper] || prev.symbolicRefs
}

protected[Phases] def init(base: ContextBase, id: Int): Unit = init(base, id, id)
Expand Down
10 changes: 6 additions & 4 deletions src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,8 @@ object Types {

object TermRef {

private def symbolicRefs(implicit ctx: Context) = ctx.phase.symbolicRefs

/** Create term ref with given name, without specifying a signature.
* Its meaning is the (potentially multi-) denotation of the member(s)
* of prefix with given name.
Expand All @@ -1562,7 +1564,7 @@ object Types {
* signature, if denotation is not yet completed.
*/
def apply(prefix: Type, name: TermName, denot: Denotation)(implicit ctx: Context): TermRef = {
if ((prefix eq NoPrefix) || denot.symbol.isFresh || ctx.erasedTypes)
if ((prefix eq NoPrefix) || denot.symbol.isFresh || symbolicRefs)
apply(prefix, denot.symbol.asTerm)
else denot match {
case denot: SymDenotation if denot.isCompleted => withSig(prefix, name, denot.signature)
Expand All @@ -1584,7 +1586,7 @@ object Types {
* (2) The name in the term ref need not be the same as the name of the Symbol.
*/
def withSymAndName(prefix: Type, sym: TermSymbol, name: TermName)(implicit ctx: Context): TermRef =
if ((prefix eq NoPrefix) || sym.isFresh || ctx.erasedTypes)
if ((prefix eq NoPrefix) || sym.isFresh || symbolicRefs)
withFixedSym(prefix, name, sym)
else if (sym.defRunId != NoRunId && sym.isCompleted)
withSig(prefix, name, sym.signature) withSym (sym, sym.signature)
Expand All @@ -1595,7 +1597,7 @@ object Types {
* (which must be completed).
*/
def withSig(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRef =
if ((prefix eq NoPrefix) || sym.isFresh || ctx.erasedTypes) withFixedSym(prefix, sym.name, sym)
if ((prefix eq NoPrefix) || sym.isFresh || symbolicRefs) withFixedSym(prefix, sym.name, sym)
else withSig(prefix, sym.name, sym.signature).withSym(sym, sym.signature)

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

/** Create a term ref with given prefix, name, signature, and initial denotation */
def withSigAndDenot(prefix: Type, name: TermName, sig: Signature, denot: Denotation)(implicit ctx: Context): TermRef = {
if ((prefix eq NoPrefix) || denot.symbol.isFresh || ctx.erasedTypes)
if ((prefix eq NoPrefix) || denot.symbol.isFresh || symbolicRefs)
withFixedSym(prefix, denot.symbol.asTerm.name, denot.symbol.asTerm)
else
withSig(prefix, name, sig)
Expand Down
6 changes: 4 additions & 2 deletions src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ object RefChecks {
}

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

// o: public | protected | package-protected (aka java's default access)
// ^-may be overridden by member with access privileges-v
Expand Down
3 changes: 1 addition & 2 deletions test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ class tests extends CompilerTest {
@Test def dotc_config = compileDir(dotcDir + "tools/dotc/config", twice)
@Test def dotc_core = compileDir(dotcDir + "tools/dotc/core", twice)(allowDeepSubtypes)
@Test def dotc_core_pickling = compileDir(dotcDir + "tools/dotc/core/pickling", twice)(allowDeepSubtypes)
// @Test def dotc_transform = compileDir(dotcDir + "tools/dotc/transform", twice)(allowDeepSubtypes)
// @odersky causes race error in ResolveSuper
@Test def dotc_transform = compileDir(dotcDir + "tools/dotc/transform", twice)(allowDeepSubtypes)

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