8000 Remove logic to check if a named arg could be an assignment (and enable `-Xsource:2.13` by default) by lrytz · Pull Request #6092 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Remove logic to check if a named arg could be an assignment (and enable -Xsource:2.13 by default) #6092

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 6 commits into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Changes to allow compilation with -Xsource:2.13
Nullary methods are no longer eta-expanded.
Assignments in paramter position need to be wrapped in brackets.
  • Loading branch information
lrytz committed Sep 22, 2017
commit ed914a8d67e162ae399c500e58718e895bd7271f
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ self =>
* }}}
*/
def pattern3(): Tree = {
val top = simplePattern(badPattern3)
val top = simplePattern(() => badPattern3())
val base = opstack
// See scala/bug#3189, scala/bug#4832 for motivation. Cf scala/bug#3480 for counter-motivation.
def isCloseDelim = in.token match {
Expand All @@ -1995,7 +1995,7 @@ self =>
case _ => EmptyTree
}
def loop(top: Tree): Tree = reducePatternStack(base, top) match {
case next if isIdent && !isRawBar => pushOpInfo(next) ; loop(simplePattern(badPattern3))
case next if isIdent && !isRawBar => pushOpInfo(next) ; loop(simplePattern(() => badPattern3()))
case next => next
}
checkWildStar orElse stripParens(loop(top))
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,9 @@ trait Scanners extends ScannersCommon {
def fetchSingleQuote() = {
nextChar()
if (isIdentifierStart(ch))
charLitOr(getIdentRest)
charLitOr(() => getIdentRest())
else if (isOperatorPart(ch) && (ch != '\\'))
charLitOr(getOperatorRest)
charLitOr(() => getOperatorRest())
else if (!isAtEnd && (ch != SU && ch != CR && ch != LF || isUnicodeEscape)) {
val isEmptyCharLit = (ch == '\'')
getLitChar()
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ abstract class BTypes {
}
}

def reInitialize(): Unit = frontendSynch(isInit = false)
def reInitialize(): Unit = frontendSynch { isInit = false }
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/compiler/scala/tools/nsc/javac/JavaParsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
if (in.token == LT) {
in.nextToken()
val t1 = convertToTypeId(t)
val args = repsep(typeArg, COMMA)
val args = repsep(() => typeArg(), COMMA)
acceptClosingAngle()
atPos(t1.pos) {
val t2: Tree = AppliedTypeTree(t1, args)
Expand Down Expand Up @@ -401,7 +401,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
def typeParams(): List[TypeDef] =
if (in.token == LT) {
in.nextToken()
val tparams = repsep(typeParam, COMMA)
val tparams = repsep(() => typeParam(), COMMA)
acceptClosingAngle()
tparams
} else List()
Expand All @@ -428,7 +428,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {

def formalParams(): List[ValDef] = {
accept(LPAREN)
val vparams = if (in.token == RPAREN) List() else repsep(formalParam, COMMA)
val vparams = if (in.token == RPAREN) List() else repsep(() => formalParam(), COMMA)
accept(RPAREN)
vparams
}
Expand All @@ -449,7 +449,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
def optThrows() {
if (in.token == THROWS) {
in.nextToken()
repsep(typ, COMMA)
repsep(() => typ(), COMMA)
}
}

Expand Down Expand Up @@ -679,7 +679,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
def interfacesOpt() =
if (in.token == IMPLEMENTS) {
in.nextToken()
repsep(typ, COMMA)
repsep(() => typ(), COMMA)
} else {
List()
}
Expand Down Expand Up @@ -711,7 +711,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
val parents =
if (in.token == EXTENDS) {
in.nextToken()
repsep(typ, COMMA)
repsep(() => typ(), COMMA)
} else {
List(javaLangObject())
}
Expand Down
6D40
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ trait MatchOptimization extends MatchTreeMaking with MatchAnalysis {
reusedTest <- test.reuses;
nextDeps <- dependencies.get(reusedTest);
diff <- (nextDeps -- currDeps).headOption;
_ <- Some(currDeps = nextDeps))
_ <- Some({ currDeps = nextDeps }))
yield diff).nonEmpty
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Typers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (immediate) {
action()
} else {
unit.toCheck += action
unit.toCheck += (() => action( 9E88 ))
true
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/compiler/scala/tools/nsc/util/ShowPickled.scala
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,17 @@ object ShowPickled extends Names {
case CONSTANTtpe =>
printTypeRef(); printConstantRef()
case TYPEREFtpe =>
printTypeRef(); printSymbolRef(); buf.until(end, printTypeRef)
printTypeRef(); printSymbolRef(); buf.until(end, () => printTypeRef())
case TYPEBOUNDStpe =>
printTypeRef(); printTypeRef()
case REFINEDtpe =>
printSymbolRef(); buf.until(end, printTypeRef)
printSymbolRef(); buf.until(end, () => printTypeRef())
case CLASSINFOtpe =>
printSymbolRef(); buf.until(end, printTypeRef)
printSymbolRef(); buf.until(end, () => printTypeRef())
case METHODtpe | IMPLICITMETHODtpe =>
printTypeRef(); buf.until(end, printTypeRef)
printTypeRef(); buf.until(end, () => printTypeRef())
case POLYtpe =>
printTypeRef(); buf.until(end, printSymbolRef)
printTypeRef(); buf.until(end, () => printSymbolRef())
case LITERALboolean =>
out.print(if (buf.readLong(len) == 0L) " false" else " true")
case LITERALbyte =>
Expand All @@ -246,17 +246,17 @@ object ShowPickled extends Names {
case LITERALclass =>
printTypeRef()
case CHILDREN =>
printSymbolRef(); buf.until(end, printSymbolRef)
printSymbolRef(); buf.until(end, () => printSymbolRef())
case SYMANNOT =>
printSymbolRef(); printTypeRef(); buf.until(end, printAnnotArgRef)
printSymbolRef(); printTypeRef(); buf.until(end, () => printAnnotArgRef())
case ANNOTATEDtpe =>
printTypeRef(); buf.until(end, printAnnotInfoRef)
printTypeRef(); buf.until(end, () => printAnnotInfoRef())
case ANNOTINFO =>
printTypeRef(); buf.until(end, printAnnotArgRef)
printTypeRef(); buf.until(end, () => printAnnotArgRef())
case ANNOTARGARRAY =>
buf.until(end, printConstAnnotArgRef)
buf.until(end, () => printConstAnnotArgRef())
case EXISTENTIALtpe =>
printTypeRef(); buf.until(end, printSymbolRef)
printTypeRef(); buf.until(end, () => printSymbolRef())

case _ =>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Tester(ntests: Int, inputs: Array[SourceFile], settings: Settings) {
/**/
new Change(sfidx, randomPositionIn(inputs(sfidx)), randomNumChars(), rand.nextBoolean())
}
doTest(sfidx, changes, testPositions, otherTest) match {
doTest(sfidx, changes, testPositions, () => otherTest()) match {
case Some(errortrace) =>
println(errortrace)
minimize(errortrace)
Expand Down
2 changes: 1 addition & 1 deletion src/library/scala/sys/process/BasicIO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ object BasicIO {
*/
def processFully(processLine: String => Unit): InputStream => Unit = in => {
val reader = new BufferedReader(new InputStreamReader(in))
try processLinesFully(processLine)(reader.readLine)
try processLinesFully(processLine)(() => reader.readLine())
finally reader.close()
}

Expand Down
30 changes: 15 additions & 15 deletions src/reflect/scala/reflect/internal/pickling/UnPickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ abstract class UnPickler {
}

private def maybeReadSymbol(): Either[Int, Symbol] = readNat() match {
case index if isSymbolRef(index) => Right(at(index, readSymbol))
case index if isSymbolRef(index) => Right(at(index, () => readSymbol()))
case index => Left(index)
}

Expand Down Expand Up @@ -269,7 +269,7 @@ abstract class UnPickler {

// symbols that were pickled with Pickler.writeSymInfo
val nameref = readNat()
val name = at(nameref, readName)
val name = at(nameref, () => readName())
val owner = readSymbolRef()
val flags = pickledToRawFlags(readLongNat())

Expand Down Expand Up @@ -339,7 +339,7 @@ abstract class UnPickler {
sym

case MODULEsym =>
val moduleClass = at(inforef, () => readType()).typeSymbol // after NMT_TRANSITION, we can leave off the () => ... ()
val moduleClass = at(inforef, () => readType()).typeSymbol
if (isModuleRoot) moduleRoot setFlag pflags
else owner.newLinkedModule(moduleClass, pflags)

Expand Down Expand Up @@ -447,9 +447,9 @@ abstract class UnPickler {
* as a Constant or a Tree.
*/
protected def readAnnotArg(i: Int): Tree = bytes(index(i)) match {
case TREE => at(i, readTree)
case TREE => at(i, () => readTree())
case _ =>
val const = at(i, readConstant)
val const = at(i, () => readConstant())
Literal(const) setType const.tpe
}

Expand All @@ -461,9 +461,9 @@ abstract class UnPickler {
until(end, () => readClassfileAnnotArg(readNat())).toArray(JavaArgumentTag)
}
protected def readClassfileAnnotArg(i: Int): ClassfileAnnotArg = bytes(index(i)) match {
case ANNOTINFO => NestedAnnotArg(at(i, readAnnotation))
case ANNOTINFO => NestedAnnotArg(at(i, () => readAnnotation()))
case ANNOTARGARRAY => at(i, () => ArrayAnnotArg(readArrayAnnot()))
case _ => LiteralAnnotArg(at(i, readConstant))
case _ => LiteralAnnotArg(at(i, () => readConstant()))
}

/** Read an AnnotationInfo. Not to be called directly, use
Expand All @@ -476,7 +476,7 @@ abstract class UnPickler {
while (readIndex != end) {
val argref = readNat()
if (isNameEntry(argref)) {
val name = at(argref, readName)
val name = at(argref, () => readName())
val arg = readClassfileAnnotArg(readNat())
assocs += ((name, arg))
}
Expand Down Expand Up @@ -635,12 +635,12 @@ abstract class UnPickler {
r.asInstanceOf[Symbol]
}

protected def readNameRef(): Name = at(readNat(), readName)
protected def readTypeRef(): Type = at(readNat(), () => readType()) // after the NMT_TRANSITION period, we can leave off the () => ... ()
protected def readConstantRef(): Constant = at(readNat(), readConstant)
protected def readAnnotationRef(): AnnotationInfo = at(readNat(), readAnnotation)
protected def readModifiersRef(): Modifiers = at(readNat(), readModifiers)
protected def readTreeRef(): Tree = at(readNat(), readTree)
protected def readNameRef(): Name = at(readNat(), () => readName())
protected def readTypeRef(): Type = at(readNat(), () => readType())
protected def readConstantRef(): Constant = at(readNat(), () => readConstant())
protected def readAnnotationRef(): AnnotationInfo = at(readNat(), () => readAnnotation())
protected def readModifiersRef(): Modifiers = at(readNat(), () => readModifiers())
protected def readTreeRef(): Tree = at(readNat(), () => readTree())

protected def readTypeNameRef(): TypeName = readNameRef().toTypeName

Expand Down Expand Up @@ -750,7 +750,7 @@ abstract class UnPickler {
override def completeInternal(sym: Symbol) = try {
super.completeInternal(sym)

var alias = at(j, readSymbol)
var alias = at(j, () => readSymbol())
if (alias.isOverloaded)
alias = slowButSafeEnteringPhase(picklerPhase)((alias suchThat (alt => sym.tpe =:= sym.owner.thisType.memberType(alt))))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,18 @@ class ILoop(config: ShellConfig, inOverride: BufferedReader = null,
cmd("line", "<id>|<line>", "place line(s) at the end of history", lineCommand),
cmd("load", "<path>", "interpret lines in a file", loadCommand, fileCompletion),
cmd("paste", "[-raw] [path]", "enter paste mode or paste a file", pasteCommand, fileCompletion),
nullary("power", "enable power user mode", powerCmd),
nullary("power", "enable power user mode", () => powerCmd()),
nullary("quit", "exit the interpreter", () => Result(keepRunning = false, None)),
cmd("replay", "[options]", "reset the repl and replay all previous commands", replayCommand, settingsCompletion),
cmd("require", "<path>", "add a jar to the classpath", require),
cmd("reset", "[options]", "reset the repl to its initial state, forgetting all session entries", resetCommand, settingsCompletion),
cmd("save", "<path>", "save replayable session to a file", saveCommand, fileCompletion),
shCommand,
cmd("settings", "<options>", "update compiler options, if possible; see reset", changeSettings, settingsCompletion),
nullary("silent", "disable/enable automatic printing of results", verbosity),
nullary("silent", "disable/enable automatic printing of results", () => verbosity()),
cmd("type", "[-v] <expr>", "display the type of an expression without evaluating it", typeCommand),
cmdWithHelp("kind", kindUsage, "display the kind of a type. see also :help kind", Some(kindCommandDetailedHelp), kindCommand),
nullary("warnings", "show the suppressed warnings from the most recent line which had any", warningsCommand)
nullary("warnings", "show the suppressed warnings from the most recent line which had any", () => warningsCommand())
)

/** Power user commands */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
indent
printClass(level, c)
case m: MethodSymbol =>
printMethod(level, m, indent)
printMethod(level, m, () => indent())
case a: AliasSymbol =>
indent
printAlias(level, a)
Expand Down
0