Skip to content

[Do not merge] Fix bootstrap 4 #1273

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

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f36c21e
Avoid merging denotations of different symbols in same class
odersky May 1, 2016
cc0f629
Don't copy Any constructor to Object in Erasure
odersky May 1, 2016
d0f05ad
ResolveOverloaded should handle alternatives that are the same TermRef
odersky May 1, 2016
2dd6a7a
Test case
odersky May 1, 2016
968f1ab
Fix test case
odersky May 2, 2016
48b7160
Issue MergeError exception for double def situations
odersky May 2, 2016
f722de7
A test case for overloading/overriding interactions
odersky May 2, 2016
fe5f4f3
Revert: ResolveOverloaded should handle alternatives that are the sam…
odersky May 2, 2016
9aa800f
Refined handling of atSignature
odersky May 2, 2016
3a97b3f
Another test case involving super accessors
odersky May 3, 2016
b26b725
Handle MergeErrors in RefChecks
odersky May 3, 2016
c9ac3d7
Remove stray test
odersky May 16, 2016
c29e975
Fix dotc bootstrap failure
odersky May 19, 2016
f1d95c2
Fix test
odersky May 19, 2016
c87c030
Better doc comment
odersky May 19, 2016
77642b9
Two more tests
odersky May 19, 2016
f4e7f84
Use source module ref as assumed self type when reading Tasty
odersky May 19, 2016
ad73126
Disable stub checking
odersky May 19, 2016
87489f5
Further improve doc comment
odersky May 20, 2016
1e3b0e1
Decouple annotation transformers from info transformers
odersky May 20, 2016
40696ba
Instrument Denotations#current to find CyclicReference
odersky May 20, 2016
2443760
Don't force a symbol's denotation for isTerm/isType
odersky May 20, 2016
09eddd0
Make sure local data is unpickled at right phase
odersky May 20, 2016
daf736c
Replace aliases to Unit by Unit
odersky May 20, 2016
4755570
Fix withPhaseNoLater
odersky May 20, 2016
e0c2e4d
Remove fingerprinting
odersky May 20, 2016
ddf16fd
Drop Frozen
odersky May 20, 2016
65513e0
Make sure delayed Tasty unpicklings are done at the latest at Pickler…
odersky May 21, 2016
fc2389f
Let createSymbol return a symbol
odersky May 21, 2016
85b488d
Maintain ownerTree data structure when unpickling Tasty
odersky May 21, 2016
630efff
Adopt new scheme for handling forward references in Tasty
odersky May 22, 2016
1094e63
Refine owner trees for templates
odersky May 23, 2016
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
12 changes: 11 additions & 1 deletion src/dotty/annotation/internal/Child.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,15 @@ package dotty.annotation.internal

import scala.annotation.Annotation

/** An annotation to indicate a child class or object of the annotated class. */
/** An annotation to indicate a child class or object of the annotated class.
* E.g. if we have
*
* sealed class A
* case class B() extends A
* case class C() extends A
*
* Then the class symbol `A` would carry the annotations
* `@Child[Bref] @Child[Cref]` where `Bref`, `Cref` are TypeRefs
* referring to the class symbols of `B` and `C`
*/
class Child[T] extends Annotation
1 change: 0 additions & 1 deletion src/dotty/tools/dotc/config/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ object Config {

final val cacheMembersNamed = true
final val cacheAsSeenFrom = true
final val useFingerPrints = true // note: it currently seems to be slightly faster not to use them! my junit test: 548s without, 560s with.
final val cacheMemberNames = true
final val cacheImplicitScopes = true

Expand Down
14 changes: 12 additions & 2 deletions src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ object Contexts {
withPhase(phase.id)

final def withPhaseNoLater(phase: Phase) =
if (ctx.phase.id > phase.id) withPhase(phase) else ctx
if (phase.exists && ctx.phase.id > phase.id) withPhase(phase) else ctx

/** If -Ydebug is on, the top of the stack trace where this context
* was created, otherwise `null`.
Expand Down Expand Up @@ -584,7 +584,7 @@ object Contexts {
private[core] var lastSuperId = -1

/** Allocate and return next free superclass id */
private[core] def nextSuperId: Int = {
private[core] def nextSuperId(): Int = {
lastSuperId += 1
if (lastSuperId >= classOfId.length) {
val tmp = new Array[ClassSymbol](classOfId.length * 2)
Expand All @@ -594,6 +594,16 @@ object Contexts {
lastSuperId
}

/** The last member-names generation number */
private[this] var myMNGen = 0

/** The next successive member-names generation number */
private[core] def nextMemberNamesGeneration(): Int = {
myMNGen += 1
myMNGen
}


// Types state
/** A table for hash consing unique types */
private[core] val uniques = new util.HashSet[Type](Config.initialUniquesCapacity) {
Expand Down
73 changes: 55 additions & 18 deletions src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ object Denotations {
/** The signature of the denotation. */
def signature(implicit ctx: Context): Signature

/** Resolve overloaded denotation to pick the one with the given signature
/** Resolve overloaded denotation to pick the ones with the given signature
* when seen from prefix `site`.
* @param relaxed When true, consider only parameter signatures for a match.
*/
def atSignature(sig: Signature, site: Type = NoPrefix, relaxed: Boolean = false)(implicit ctx: Context): SingleDenotation
def atSignature(sig: Signature, site: Type = NoPrefix, relaxed: Boolean = false)(implicit ctx: Context): Denotation

/** The variant of this denotation that's current in the given context, or
* `NotDefinedHereDenotation` if this denotation does not exist at current phase, but
Expand Down Expand Up @@ -157,7 +157,10 @@ object Denotations {
* or NoDenotation if no satisfying alternative exists.
* @throws TypeError if there is at more than one alternative that satisfies `p`.
*/
def suchThat(p: Symbol => Boolean): SingleDenotation
def suchThat(p: Symbol => Boolean)(implicit ctx: Context): SingleDenotation

/** If this is a SingleDenotation, return it, otherwise throw a TypeError */
def checkUnique(implicit ctx: Context): SingleDenotation = suchThat(alwaysTrue)

/** Does this denotation have an alternative that satisfies the predicate `p`? */
def hasAltWith(p: SingleDenotation => Boolean): Boolean
Expand Down Expand Up @@ -227,13 +230,17 @@ object Denotations {
/** The alternative of this denotation that has a type matching `targetType` when seen
* as a member of type `site`, `NoDenotation` if none exists.
*/
def matchingDenotation(site: Type, targetType: Type)(implicit ctx: Context): SingleDenotation =
if (isOverloaded)
atSignature(targetType.signature, site, relaxed = true).matchingDenotation(site, targetType)
else if (exists && !site.memberInfo(symbol).matchesLoosely(targetType))
NoDenotation
else
asSingleDenotation
def matchingDenotation(site: Type, targetType: Type)(implicit ctx: Context): SingleDenotation = {
def qualifies(sym: Symbol) = site.memberInfo(sym).matchesLoosely(targetType)
if (isOverloaded) {
atSignature(targetType.signature, site, relaxed = true) match {
case sd: SingleDenotation => sd.matchingDenotation(site, targetType)
case md => md.suchThat(qualifies(_))
}
}
else if (exists && !qualifies(symbol)) NoDenotation
else asSingleDenotation
}

/** Form a denotation by conjoining with denotation `that`.
*
Expand Down Expand Up @@ -282,8 +289,10 @@ object Denotations {
val info2 = denot2.info
val sym1 = denot1.symbol
val sym2 = denot2.symbol
val sym2Accessible = sym2.isAccessibleFrom(pre)

if (isDoubleDef(sym1, sym2)) doubleDefError(denot1, denot2, pre)

val sym2Accessible = sym2.isAccessibleFrom(pre)
/** Does `sym1` come before `sym2` in the linearization of `pre`? */
def precedes(sym1: Symbol, sym2: Symbol) = {
def precedesIn(bcs: List[ClassSymbol]): Boolean = bcs match {
Expand Down Expand Up @@ -418,19 +427,21 @@ object Denotations {
final def validFor = denot1.validFor & denot2.validFor
final def isType = false
final def signature(implicit ctx: Context) = Signature.OverloadedSignature
def atSignature(sig: Signature, site: Type, relaxed: Boolean)(implicit ctx: Context): SingleDenotation =
denot1.atSignature(sig, site, relaxed) orElse denot2.atSignature(sig, site, relaxed)
def atSignature(sig: Signature, site: Type, relaxed: Boolean)(implicit ctx: Context): Denotation =
derivedMultiDenotation(denot1.atSignature(sig, site, relaxed), denot2.atSignature(sig, site, relaxed))
def currentIfExists(implicit ctx: Context): Denotation =
derivedMultiDenotation(denot1.currentIfExists, denot2.currentIfExists)
def current(implicit ctx: Context): Denotation =
derivedMultiDenotation(denot1.current, denot2.current)
def altsWith(p: Symbol => Boolean): List[SingleDenotation] =
denot1.altsWith(p) ++ denot2.altsWith(p)
def suchThat(p: Symbol => Boolean): SingleDenotation = {
def suchThat(p: Symbol => Boolean)(implicit ctx: Context): SingleDenotation = {
val sd1 = denot1.suchThat(p)
val sd2 = denot2.suchThat(p)
if (sd1.exists)
if (sd2.exists) throw new TypeError(s"failure to disambiguate overloaded reference $this")
if (sd2.exists)
if (isDoubleDef(denot1.symbol, denot2.symbol)) doubleDefError(denot1, denot2)
else throw new TypeError(s"failure to disambiguate overloaded reference $this")
else sd1
else sd2
}
Expand Down Expand Up @@ -480,7 +491,7 @@ object Denotations {
def altsWith(p: Symbol => Boolean): List[SingleDenotation] =
if (exists && p(symbol)) this :: Nil else Nil

def suchThat(p: Symbol => Boolean): SingleDenotation =
def suchThat(p: Symbol => Boolean)(implicit ctx: Context): SingleDenotation =
if (exists && p(symbol)) this else NoDenotation

def hasAltWith(p: SingleDenotation => Boolean): Boolean =
Expand Down Expand Up @@ -645,14 +656,19 @@ object Denotations {
var startPid = nextTransformerId + 1
val transformer = ctx.denotTransformers(nextTransformerId)
//println(s"transforming $this with $transformer")
next = transformer.transform(cur)(ctx.withPhase(transformer)).syncWithParents
try {
next = transformer.transform(cur)(ctx.withPhase(transformer)).syncWithParents
} catch {
case ex: CyclicReference =>
println(s"error while transforming $this") // DEBUG
throw ex
}
if (next eq cur)
startPid = cur.validFor.firstPhaseId
else {
next match {
case next: ClassDenotation =>
assert(!next.is(Package), s"illegal transformation of package denotation by transformer ${ctx.withPhase(transformer).phase}")
next.resetFlag(Frozen)
case _ =>
}
next.insertAfter(cur)
Expand Down Expand Up @@ -900,6 +916,27 @@ object Denotations {
*/
case class NoQualifyingRef(alts: List[SingleDenotation])(implicit ctx: Context) extends ErrorDenotation

/** A double definition
*/
def isDoubleDef(sym1: Symbol, sym2: Symbol)(implicit ctx: Context): Boolean =
(sym1.exists && sym2.exists &&
(sym1 ne sym2) && (sym1.owner eq sym2.owner) &&
!sym1.is(Bridge) && !sym2.is(Bridge))

def doubleDefError(denot1: Denotation, denot2: Denotation, pre: Type = NoPrefix)(implicit ctx: Context): Nothing = {
val sym1 = denot1.symbol
val sym2 = denot2.symbol
def fromWhere = if (pre == NoPrefix) "" else i"\nwhen seen as members of $pre"
throw new MergeError(
i"""cannot merge
| $sym1: ${sym1.info} and
| $sym2: ${sym2.info};
|they are both defined in ${sym1.owner} but have matching signatures
| ${denot1.info} and
| ${denot2.info}$fromWhere""".stripMargin,
denot2.info, denot2.info)
}

// --------------- PreDenotations -------------------------------------------------

/** A PreDenotation represents a group of single denotations
Expand Down
36 changes: 18 additions & 18 deletions src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -379,53 +379,50 @@ object Flags {
/** Denotation is in train of being loaded and completed, used to catch cyclic dependencies */
final val Touched = commonFlag(48, "<touched>")

/** Class is not allowed to accept new members because fingerprint of subclass has been taken */
final val Frozen = commonFlag(49, "<frozen>")

/** An error symbol */
final val Erroneous = commonFlag(50, "<is-error>")
final val Erroneous = commonFlag(49, "<is-error>")

/** Class has been lifted out to package level, local value has been lifted out to class level */
final val Lifted = commonFlag(51, "<lifted>")
final val Lifted = commonFlag(50, "<lifted>")

/** Term member has been mixed in */
final val MixedIn = commonFlag(52, "<mixedin>")
final val MixedIn = commonFlag(51, "<mixedin>")

/** Symbol is a generated specialized member */
final val Specialized = commonFlag(53, "<specialized>")
final val Specialized = commonFlag(52, "<specialized>")

/** Symbol is a self name */
final val SelfName = termFlag(54, "<selfname>")
final val SelfName = termFlag(53, "<selfname>")

/** Symbol is an implementation class of a Scala2 trait */
final val ImplClass = typeFlag(54, "<implclass>")
final val ImplClass = typeFlag(53, "<implclass>")

final val SelfNameOrImplClass = SelfName.toCommonFlags

/** An existentially bound symbol (Scala 2.x only) */
final val Scala2ExistentialCommon = commonFlag(55, "<existential>")
final val Scala2ExistentialCommon = commonFlag(54, "<existential>")
final val Scala2Existential = Scala2ExistentialCommon.toTypeFlags

/** An overloaded symbol (Scala 2.x only) */
final val Scala2Overloaded = termFlag(56, "<overloaded>")
final val Scala2Overloaded = termFlag(55, "<overloaded>")

/** A module variable (Scala 2.x only) */
final val Scala2ModuleVar = termFlag(57, "<modulevar>")
final val Scala2ModuleVar = termFlag(56, "<modulevar>")

/** A definition that's initialized before the super call (Scala 2.x only) */
final val Scala2PreSuper = termFlag(58, "<presuper>")
final val Scala2PreSuper = termFlag(57, "<presuper>")

/** A macro (Scala 2.x only) */
final val Macro = commonFlag(59, "<macro>")
final val Macro = commonFlag(58, "<macro>")

/** A method that is known to have inherited default parameters */
final val InheritedDefaultParams = termFlag(60, "<inherited-default-param>")
final val InheritedDefaultParams = termFlag(59, "<inherited-default-param>")

/** A method that is known to have no default parameters */
final val NoDefaultParams = termFlag(61, "<no-default-param>")
final val NoDefaultParams = termFlag(60, "<no-default-param>")

/** A denotation that is valid in all run-ids */
final val Permanent = commonFlag(62, "<permanent>")
final val Permanent = commonFlag(61, "<permanent>")

// --------- Combined Flag Sets and Conjunctions ----------------------

Expand All @@ -448,7 +445,7 @@ object Flags {
final val FromStartFlags =
AccessFlags | Module | Package | Deferred | Final | MethodOrHKCommon | Param | ParamAccessor | Scala2ExistentialCommon |
InSuperCall | Touched | JavaStatic | CovariantOrOuter | ContravariantOrLabel | ExpandedName | AccessorOrSealed |
CaseAccessorOrBaseTypeArg | Fresh | Frozen | Erroneous | ImplicitCommon | Permanent | Synthetic |
CaseAccessorOrBaseTypeArg | Fresh | Erroneous | ImplicitCommon | Permanent | Synthetic |
LazyOrTrait | SuperAccessorOrScala2x | SelfNameOrImplClass

assert(FromStartFlags.isTermFlags && FromStartFlags.isTypeFlags)
Expand Down Expand Up @@ -525,6 +522,9 @@ object Flags {
/** Either method or lazy */
final val MethodOrLazy = Method | Lazy

/** Either method or lazy or deferred */
final val MethodOrLazyOrDeferred = Method | Lazy | Deferred

/** Labeled `private` or `final` */
final val PrivateOrFinal = Private | Final

Expand Down
Loading