Skip to content

Fix bootstrap #1270

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 17 commits into from
May 27, 2016
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
5 changes: 3 additions & 2 deletions src/dotty/annotation/internal/Child.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import scala.annotation.Annotation
* case class B() extends A
* case class C() extends A
*
* Then `A` would carry the annotations `@Child[B] @Child[C]` where
* `B`, `C` are TypeRefs.
* 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
2 changes: 1 addition & 1 deletion 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this happen in practice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there are tests that break (the tests don't start a full compiler).


/** If -Ydebug is on, the top of the stack trace where this context
* was created, otherwise `null`.
Expand Down
8 changes: 7 additions & 1 deletion src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,13 @@ 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 {
Expand Down
3 changes: 3 additions & 0 deletions src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,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
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@ object Symbols {

/** Subclass tests and casts */
final def isTerm(implicit ctx: Context): Boolean =
(if(isDefinedInCurrentRun) lastDenot else denot).isTerm
(if (defRunId == ctx.runId) lastDenot else denot).isTerm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not change the definition of isDefinedInCurrentRun ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's used elsewhere to mean: In a compilation unit that's currently being compiled.


final def isType(implicit ctx: Context): Boolean =
(if(isDefinedInCurrentRun) lastDenot else denot).isType
(if (defRunId == ctx.runId) lastDenot else denot).isType

final def isClass: Boolean = isInstanceOf[ClassSymbol]

Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/TypeErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
tr1 :: trs1.filterNot(_ isRef defn.ObjectClass)
case nil => nil
}
val erasedDecls = decls.filteredScope(d => !d.isType || d.isClass)
val erasedDecls = decls.filteredScope(sym => !sym.isType || sym.isClass)
tp.derivedClassInfo(NoPrefix, parents, erasedDecls, erasedRef(tp.selfType))
// can't replace selftype by NoType because this would lose the sourceModule link
}
Expand Down
11 changes: 11 additions & 0 deletions src/dotty/tools/dotc/core/tasty/TastyFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -485,4 +485,15 @@ object TastyFormat {
case PRIVATEqualified => "PRIVATEqualified"
case PROTECTEDqualified => "PROTECTEDqualified"
}

/** @return If non-negative, the number of leading references of a length/trees entry.
* If negative, minus the number of leading non-reference trees.
*/
def numRefs(tag: Int) = tag match {
Copy link
Contributor

@DarkDimius DarkDimius May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method seem to only be used by unpickler. Maybe move it there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is essentially an information about the format. So the place looks right to me. Otherwise put, if we change the format of some entries, this method needs to be updated in sync. With the information provided by it, we enable generic traversals of Tasty trees in other (future) modules as well.

case VALDEF | DEFDEF | TYPEDEF | TYPEPARAM | PARAM | NAMEDARG | RETURN | BIND |
SELFDEF | REFINEDtype => 1
case RENAMED | PARAMtype => 2
case POLYtype | METHODtype => -1
case _ => 0
}
}
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ class TreePickler(pickler: TastyPickler) {
case tpe: RefinedType =>
writeByte(REFINEDtype)
withLength {
pickleType(tpe.parent)
pickleName(tpe.refinedName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an incompatible change. Why was the order changed?

Copy link
Contributor Author

@odersky odersky May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To harmonize the layout. Non-trees now always come before trees in Tasty entries (except for some cases where trailing non-trees are optional as explained in numRefs.)

pickleType(tpe.parent)
pickleType(tpe.refinedInfo, richTypes = true)
}
case tpe: TypeAlias =>
Expand Down
Loading