Skip to content

Remove several forward refferences from Dotty codebase #769

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 4 commits into from
Closed
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
14 changes: 8 additions & 6 deletions src/dotty/tools/dotc/core/Periods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ object Periods {

final val Nowhere = new Period(0)

final val InitialPeriod = Period(InitialRunId, FirstPhaseId)

final val InvalidPeriod = Period(NoRunId, NoPhaseId)
/** The number of bits needed to encode a phase identifier. */
final val PhaseWidth = 6
final val PhaseMask = (1 << PhaseWidth) - 1
final val MaxPossiblePhaseId = PhaseMask

/** An ordinal number for compiler runs. First run has number 1. */
type RunId = Int
Expand All @@ -152,8 +154,8 @@ object Periods {
final val NoPhaseId = 0
final val FirstPhaseId = 1

/** The number of bits needed to encode a phase identifier. */
final val PhaseWidth = 6
final val PhaseMask = (1 << PhaseWidth) - 1
final val MaxPossiblePhaseId = PhaseMask

final val InitialPeriod = Period(InitialRunId, FirstPhaseId)

final val InvalidPeriod = Period(NoRunId, NoPhaseId)
}
17 changes: 10 additions & 7 deletions src/dotty/tools/dotc/parsing/JavaTokens.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ import collection.immutable.BitSet

object JavaTokens extends TokensCommon {
final val minToken = EMPTY
final val maxToken = DOUBLE

final val javaOnlyKeywords = tokenRange(INSTANCEOF, ASSERT)
final val sharedKeywords = BitSet( IF, FOR, ELSE, THIS, NULL, NEW, SUPER, ABSTRACT, FINAL, PRIVATE, PROTECTED,
OVERRIDE, EXTENDS, TRUE, FALSE, CLASS, IMPORT, PACKAGE, DO, THROW, TRY, CATCH, FINALLY, WHILE, RETURN )
final val primTypes = tokenRange(VOID, DOUBLE)
final val keywords = sharedKeywords | javaOnlyKeywords | primTypes
final val maxToken = 188

/** keywords */
final val INSTANCEOF = 101; enter(INSTANCEOF, "instanceof")
Expand Down Expand Up @@ -89,4 +83,13 @@ object JavaTokens extends TokensCommon {
final val LONG = 186; enter(LONG, "long")
final val FLOAT = 187; enter(FLOAT, "float")
final val DOUBLE = 188; enter(DOUBLE, "double")

assert(maxToken == DOUBLE, "change if maxToken changes")

final val sharedKeywords = BitSet( IF, FOR, ELSE, THIS, NULL, NEW, SUPER, ABSTRACT, FINAL, PRIVATE, PROTECTED,
OVERRIDE, EXTENDS, TRUE, FALSE, CLASS, IMPORT, PACKAGE, DO, THROW, TRY, CATCH, FINALLY, WHILE, RETURN )
final val javaOnlyKeywords = tokenRange(INSTANCEOF, ASSERT)

final val primTypes = tokenRange(VOID, DOUBLE)
final val keywords = sharedKeywords | javaOnlyKeywords | primTypes
}
4 changes: 3 additions & 1 deletion src/dotty/tools/dotc/parsing/Tokens.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ abstract class TokensCommon {

object Tokens extends TokensCommon {
final val minToken = EMPTY
final val maxToken = XMLSTART
final val maxToken = 96

final val INTERPOLATIONID = 10; enter(INTERPOLATIONID, "string interpolator")
final val SYMBOLLIT = 11; enter(SYMBOLLIT, "symbol literal") // TODO: deprecate
Expand Down Expand Up @@ -188,6 +188,8 @@ object Tokens extends TokensCommon {
/** XML mode */
final val XMLSTART = 96; enter(XMLSTART, "$XMLSTART$<") // TODO: deprecate

assert(XMLSTART == maxToken, "update if max token changes")

final val alphaKeywords = tokenRange(IF, FORSOME)
final val symbolicKeywords = tokenRange(USCORE, VIEWBOUND)
final val symbolicTokens = tokenRange(COMMA, VIEWBOUND)
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/util/Attachment.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ object Attachment {
private[Attachment] var next: Link[_] = null

final def pushAttachment[V](key: Key[V], value: V): Unit = {
assert(!getAttachment(key).isDefined, s"duplicate attachment for key $key")
assert(getAttachment(key).isEmpty, s"duplicate attachment for key $key")
next = new Link(key, value, next)
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/dotty/partest/DPConsoleRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPat
echo(statusLine(state))
if (!state.isOk && isDiffy) {
val differ = bold(red("% ")) + "diff "
state.transcript.dropWhile(s => !(s startsWith differ)) foreach (echo(_))
state.transcript.dropWhile(s => !(s startsWith differ)) foreach (echo)
// state.transcript find (_ startsWith differ) foreach (echo(_)) // original
}
}
Expand Down Expand Up @@ -248,7 +248,7 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
// so we ignore groups (tests suffixed with _1 and _2)
override def groupedFiles(sources: List[File]): List[List[File]] = {
val grouped = sources groupBy (_.group)
val flatGroup = List(grouped.keys.toList.sorted.map({ k => grouped(k) sortBy (_.getName) }).flatten)
val flatGroup = List(grouped.keys.toList.sorted.flatMap { k => grouped(k) sortBy (_.getName) })
try { // try/catch because of bug in partest that throws exception
if (flatGroup != super.groupedFiles(sources))
throw new java.lang.UnsupportedOperationException()
Expand Down
1 change: 0 additions & 1 deletion test/test/ContextEscapeDetector.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package test;

import org.junit.runner.Description;
import org.junit.runner.Result;
import org.junit.runner.notification.RunListener;
import org.junit.Assert;
Expand Down