summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-09-18 07:48:57 -0700
committerPaul Phillips <paulp@improving.org>2013-09-18 12:13:06 -0700
commitf7a315adf63fdac2a7f95f87b88e03d4139af863 (patch)
tree6486f3d8f7bb4a462497b170ab84c65784669b29
parent1c8bbd7ec5b8859f75abfbc4e70482dede2b7007 (diff)
downloadscala-f7a315adf63fdac2a7f95f87b88e03d4139af863.tar.gz
scala-f7a315adf63fdac2a7f95f87b88e03d4139af863.tar.bz2
scala-f7a315adf63fdac2a7f95f87b88e03d4139af863.zip
SI-7854, SI-6768 better parsing/positioning in parser
The parser hole I found while working on the generated positions serves as the umbrella for a host of improvements. Upgraded positions assigned during some specific challenging situations mostly involving the creation of synthetic trees, e.g. for comprehensions and closures. While doing so improved some error messages. Eliminated some of the most glaring duplication in the parser. It's written like there is some payoff associated with being spectacularly imperative. Not so far.
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala460
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala9
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala43
-rw-r--r--src/reflect/scala/reflect/internal/TreeGen.scala67
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala7
-rw-r--r--test/files/continuations-run/t5472.check2
-rw-r--r--test/files/neg/classmanifests_new_deprecations.check4
-rw-r--r--test/files/neg/divergent-implicit.check4
-rw-r--r--test/files/neg/for-comprehension-old.check8
-rw-r--r--test/files/neg/found-req-variance.check20
-rw-r--r--test/files/neg/lazyvals.check4
-rw-r--r--test/files/neg/multi-array.check2
-rw-r--r--test/files/neg/names-defaults-neg.check2
-rw-r--r--test/files/neg/nested-annotation.check2
-rw-r--r--test/files/neg/no-implicit-to-anyref.check2
-rw-r--r--test/files/neg/no-predef.check2
-rw-r--r--test/files/neg/parser-errors.check16
-rw-r--r--test/files/neg/parser-errors.scala2
-rw-r--r--test/files/neg/parser-import-errors.check28
-rw-r--r--test/files/neg/parser-import-errors.scala49
-rw-r--r--test/files/neg/primitive-sigs-1.check2
-rw-r--r--test/files/neg/protected-constructors.check4
-rw-r--r--test/files/neg/saito.check2
-rw-r--r--test/files/neg/sensitive.check2
-rw-r--r--test/files/neg/stringinterpolation_macro-neg.check2
-rw-r--r--test/files/neg/t0209.check2
-rw-r--r--test/files/neg/t1038.check2
-rw-r--r--test/files/neg/t1623.check2
-rw-r--r--test/files/neg/t1705.check2
-rw-r--r--test/files/neg/t2775.check2
-rw-r--r--test/files/neg/t3453.check8
-rw-r--r--test/files/neg/t3692-new.check2
-rw-r--r--test/files/neg/t3977.check2
-rw-r--r--test/files/neg/t4163.check7
-rw-r--r--test/files/neg/t4417.check2
-rw-r--r--test/files/neg/t4727.check2
-rw-r--r--test/files/neg/t4851.check12
-rw-r--r--test/files/neg/t4987.check2
-rw-r--r--test/files/neg/t5120.check4
-rw-r--r--test/files/neg/t5666.check24
-rw-r--r--test/files/neg/t5761.check2
-rw-r--r--test/files/neg/t5803.check2
-rw-r--r--test/files/neg/t6074.check2
-rw-r--r--test/files/neg/t6601.check2
-rw-r--r--test/files/neg/t6667b.check4
-rw-r--r--test/files/neg/t7385.check9
-rw-r--r--test/files/neg/t7473.check12
-rw-r--r--test/files/neg/t771.check2
-rw-r--r--test/files/pos/t7854.scala5
-rw-r--r--test/files/run/existential-rangepos.check4
-rw-r--r--test/files/run/t5603.check12
-rw-r--r--test/files/run/t6768.check2
52 files changed, 464 insertions, 414 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 07e24900e9..05ad2dbc57 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -303,6 +303,15 @@ self =>
def o2p(offset: Int): Position
def r2p(start: Int, mid: Int, end: Int): Position
+ /** Creates a range position from the given start offset to
+ * the value of in.lastOffset.
+ */
+ def rangeSince(start: Int): Position = r2p(start, start, in.lastOffset)
+
+ /** Like in.skipToken, but returns a range position surrounding the skipped token.
+ */
+ def skipTokenRange(): Position = rangeSince(in.skipToken())
+
/** whether a non-continuable syntax error has been seen */
private var lastErrorOffset : Int = -1
@@ -568,8 +577,9 @@ self =>
and
}
- def expectedMsgTemplate(exp: String, fnd: String) = s"$exp expected but $fnd found."
- def expectedMsg(token: Int): String = expectedMsgTemplate(token2string(token), token2string(in.token))
+ def expectedMsgTemplate(expected: String, found: String): String = s"$expected expected but $found found."
+ def expectedMsg(expected: Int, found: Int): String = expectedMsgTemplate(token2string(expected), token2string(found))
+ def expectedMsg(token: Int): String = expectedMsg(token, in.token)
/** Consume one token of the specified type, or signal an error if it is not there. */
def accept(token: Int): Int = {
@@ -587,6 +597,10 @@ self =>
if (in.token == token) in.nextToken()
offset
}
+ /** If the given token is available for consumption, consume it and return true.
+ * Otherwise, do nothing and return false.
+ */
+ def acceptIfPresent(token: Int) = (in.token == token) && { accept(token) ; true }
/** {{{
* semi = nl {nl} | `;`
@@ -703,14 +717,24 @@ self =>
/* ---------- TREE CONSTRUCTION ------------------------------------------- */
- def atPos[T <: Tree](offset: Int)(t: T): T = atPos(r2p(offset, offset, in.lastOffset max offset))(t)
- def atPos[T <: Tree](start: Int, point: Int)(t: T): T = atPos(r2p(start, point, in.lastOffset max start))(t)
+ def atPos[T <: Tree](start: Int)(t: T): T = atPos[T](start, start)(t)
+ def atPos[T <: Tree](start: Int, point: Int)(t: T): T = atPos[T](start, point, in.lastOffset max start)(t)
def atPos[T <: Tree](start: Int, point: Int, end: Int)(t: T): T = atPos(r2p(start, point, end))(t)
def atPos[T <: Tree](pos: Position)(t: T): T = global.atPos(pos)(t)
def atInPos[T <: Tree](t: T): T = atPos(o2p(in.offset))(t)
def setInPos[T <: Tree](t: T): T = t setPos o2p(in.offset)
+ /** Use with caution. */
+ def peekahead(): Unit = {
+ in.prev copyFrom in
+ in.nextToken()
+ }
+ def pushback(): Unit = {
+ in.next copyFrom in
+ in copyFrom in.prev
+ }
+
/** Convert tree to formal parameter list. */
def convertToParams(tree: Tree): List[ValDef] = tree match {
case Parens(ts) => ts map convertToParam
@@ -749,10 +773,9 @@ self =>
if (!sepFirst)
ts += part
- while (in.token == separator) {
- in.nextToken()
+ while (acceptIfPresent(separator))
ts += part
- }
+
ts.toList
}
@inline final def commaSeparated[T](part: => T): List[T] = tokenSeparated(COMMA, sepFirst = false, part)
@@ -829,10 +852,8 @@ self =>
private def tupleInfixType(start: Int) = {
in.nextToken()
- if (in.token == RPAREN) {
- in.nextToken()
+ if (acceptIfPresent(RPAREN))
atPos(start, accept(ARROW)) { makeFunctionTypeTree(Nil, typ()) }
- }
else {
val ts = functionTypes()
accept(RPAREN)
@@ -936,13 +957,8 @@ self =>
)
def compoundTypeRest(t: Tree): Tree = {
- val ts = new ListBuffer[Tree] += t
- while (in.token == WITH) {
- in.nextToken()
- ts += annotType()
- }
+ val types = t :: tokenSeparated(WITH, sepFirst = true, annotType())
newLineOptWhenFollowedBy(LBRACE)
- val types = ts.toList
val braceOffset = in.offset
val hasRefinement = in.token == LBRACE
val refinements = if (hasRefinement) refinement() else Nil
@@ -956,7 +972,7 @@ self =>
}
// The second case includes an empty refinement - refinements is empty, but
// it still gets a CompoundTypeTree.
- ts.toList match {
+ types match {
case tp :: Nil if !hasRefinement => tp // single type, no refinement, already positioned
case tps => atPos(t.pos.startOrPoint)(CompoundTypeTree(Template(tps, emptyValDef, refinements)))
}
@@ -1024,19 +1040,19 @@ self =>
def path(thisOK: Boolean, typeOK: Boolean): Tree = {
val start = in.offset
var t: Tree = null
- if (in.token == THIS) {
- in.nextToken()
+ if (acceptIfPresent(THIS)) {
t = atPos(start) { This(tpnme.EMPTY) }
if (!thisOK || in.token == DOT) {
t = selectors(t, typeOK, accept(DOT))
}
- } else if (in.token == SUPER) {
- in.nextToken()
+ }
+ else if (acceptIfPresent(SUPER)) {
t = atPos(start) { Super(This(tpnme.EMPTY), mixinQualifierOpt()) }
accept(DOT)
t = selector(t)
if (in.token == DOT) t = selectors(t, typeOK, in.skipToken())
- } else {
+ }
+ else {
val tok = in.token
val name = ident()
t = atPos(start) {
@@ -1045,18 +1061,18 @@ self =>
}
if (in.token == DOT) {
val dotOffset = in.skipToken()
- if (in.token == THIS) {
- in.nextToken()
+ if (acceptIfPresent(THIS)) {
t = atPos(start) { This(name.toTypeName) }
if (!thisOK || in.token == DOT)
t = selectors(t, typeOK, accept(DOT))
- } else if (in.token == SUPER) {
- in.nextToken()
+ }
+ else if (acceptIfPresent(SUPER)) {
t = atPos(start) { Super(This(name.toTypeName), mixinQualifierOpt()) }
accept(DOT)
t = selector(t)
if (in.token == DOT) t = selectors(t, typeOK, in.skipToken())
- } else {
+ }
+ else {
t = selectors(t, typeOK, dotOffset)
}
}
@@ -1065,10 +1081,8 @@ self =>
}
def selectors(t: Tree, typeOK: Boolean, dotOffset: Int): Tree =
- if (typeOK && in.token == TYPE) {
- in.nextToken()
+ if (typeOK && acceptIfPresent(TYPE))
atPos(t.pos.startOrPoint, dotOffset) { SingletonTypeTree(t) }
- }
else {
val t1 = selector(t)
if (in.token == DOT) { selectors(t1, typeOK, in.skipToken()) }
@@ -1165,10 +1179,10 @@ self =>
private def freshPlaceholder(): Tree = {
val start = in.offset
val pname = freshName("x$")
- in.nextToken()
+ accept(USCORE)
val id = atPos(start)(Ident(pname))
val param = atPos(id.pos.focus)(gen.mkSyntheticParam(pname.toTermName))
- placeholderParams = param :: placeholderParams
+ placeholderParams ::= param
id
}
@@ -1211,7 +1225,7 @@ self =>
/* ------------- NEW LINES ------------------------------------------------- */
def newLineOpt() {
- if (in.token == NEWLINE) in.nextToken()
+ acceptIfPresent(NEWLINE)
}
def newLinesOpt() {
@@ -1235,9 +1249,7 @@ self =>
* TypedOpt ::= [`:' Type]
* }}}
*/
- def typedOpt(): Tree =
- if (in.token == COLON) { in.nextToken(); typ() }
- else TypeTree()
+ def typedOpt(): Tree = if (acceptIfPresent(COLON)) typ() else TypeTree()
def typeOrInfixType(location: Int): Tree =
if (location == Local) typ()
@@ -1261,16 +1273,9 @@ self =>
/* ----------- EXPRESSIONS ------------------------------------------------ */
- def condExpr(): Tree = {
- if (in.token == LPAREN) {
- in.nextToken()
- val r = expr()
- accept(RPAREN)
- r
- } else {
- accept(LPAREN)
- newLiteral(true)
- }
+ def condExpr(): Tree = in.token match {
+ case LPAREN => inParens(expr())
+ case _ => syntaxErrorOrIncompleteAnd("parenthesized conditional expression expected", skipIt = false)(newLiteral(true))
}
/* hook for IDE, unlike expression can be stubbed
@@ -1311,8 +1316,7 @@ self =>
val cond = condExpr()
newLinesOpt()
val thenp = expr()
- val elsep = if (in.token == ELSE) { in.nextToken(); expr() }
- else literalUnit
+ val elsep = if (acceptIfPresent(ELSE)) expr() else literalUnit
If(cond, thenp, elsep)
}
parseIf
@@ -1321,23 +1325,19 @@ self =>
val body = in.token match {
case LBRACE => inBracesOrUnit(block())
case LPAREN => inParensOrUnit(expr())
- case _ => expr()
+ case _ => expr()
}
def catchFromExpr() = List(makeCatchFromExpr(expr()))
- val catches: List[CaseDef] =
- if (in.token != CATCH) Nil
- else {
- in.nextToken()
+ val catches: List[CaseDef] = (
+ if (!acceptIfPresent(CATCH)) Nil else {
if (in.token != LBRACE) catchFromExpr()
else inBracesOrNil {
if (isCaseDefStart) caseClauses()
else catchFromExpr()
}
}
- val finalizer = in.token match {
- case FINALLY => in.nextToken(); expr()
- case _ => EmptyTree
- }
+ )
+ val finalizer = if (acceptIfPresent(FINALLY)) expr() else EmptyTree
Try(body, catches, finalizer)
}
parseTry
@@ -1348,7 +1348,7 @@ self =>
val cond = condExpr()
newLinesOpt()
val body = expr()
- makeWhile(start, cond, body)
+ makeWhile(cond, body)
}
}
parseWhile
@@ -1367,16 +1367,15 @@ self =>
case FOR =>
val start = in.skipToken()
def parseFor = atPos(start) {
- val enums =
+ val enums = (
if (in.token == LBRACE) inBracesOrNil(enumerators())
else inParensOrNil(enumerators())
+ )
newLinesOpt()
- if (in.token == YIELD) {
- in.nextToken()
+ if (acceptIfPresent(YIELD))
makeForYield(enums, expr())
- } else {
+ else
makeFor(enums, expr())
- }
}
def adjustStart(tree: Tree) =
if (tree.pos.isRange && start < tree.pos.start)
@@ -1467,9 +1466,8 @@ self =>
val param0 = convertToParam {
atPos(in.offset) {
Ident(ident()) match {
- case expr if in.token == COLON =>
- in.nextToken() ; Typed(expr, typeOrInfixType(location))
- case expr => expr
+ case expr if acceptIfPresent(COLON) => Typed(expr, typeOrInfixType(location))
+ case expr => expr
}
}
}
@@ -1545,32 +1543,28 @@ self =>
* }}}
*/
def simpleExpr(): Tree = {
- var canApply = true
- val t =
- if (isLiteral) literal()
- else in.token match {
- case XMLSTART =>
- xmlLiteral()
- case IDENTIFIER | BACKQUOTED_IDENT | THIS | SUPER =>
- path(thisOK = true, typeOK = false)
- case USCORE =>
- freshPlaceholder()
- case LPAREN =>
- atPos(in.offset)(makeParens(commaSeparated(expr())))
- case LBRACE =>
- canApply = false
- blockExpr()
- case NEW =>
- canApply = false
- val nstart = in.skipToken()
- val npos = r2p(nstart, nstart, in.lastOffset)
- val tstart = in.offset
- val (parents, self, stats) = template()
- val cpos = r2p(tstart, tstart, in.lastOffset max tstart)
- gen.mkNew(parents, self, stats, npos, cpos)
- case _ =>
- syntaxErrorOrIncompleteAnd("illegal start of simple expression", skipIt = true)(errorTermTree)
- }
+ val canApply = in.token match {
+ case LBRACE | NEW => false
+ case _ => true
+ }
+ def mkNew(): Tree = {
+ val npos = skipTokenRange()
+ val tstart = in.offset
+ val (parents, self, stats) = template()
+ val cpos = rangeSince(tstart)
+
+ gen.mkNew(parents, self, stats, npos, cpos)
+ }
+ val t = in.token match {
+ case _ if isLiteral => literal()
+ case XMLSTART => xmlLiteral()
+ case IDENTIFIER | BACKQUOTED_IDENT | THIS | SUPER => path(thisOK = true, typeOK = false)
+ case USCORE => freshPlaceholder()
+ case LPAREN => atPos(in.offset)(makeParens(commaSeparated(expr())))
+ case LBRACE => blockExpr()
+ case NEW => mkNew()
+ case _ => syntaxErrorOrIncompleteAnd("illegal start of simple expression", skipIt = true)(errorTermTree)
+ }
simpleExprRest(t, canApply = canApply)
}
@@ -1677,9 +1671,9 @@ self =>
* Guard ::= if PostfixExpr
* }}}
*/
- def guard(): Tree =
- if (in.token == IF) { in.nextToken(); stripParens(postfixExpr()) }
- else EmptyTree
+ def guard(): Tree = if (acceptIfPresent(IF)) guardExpr() else EmptyTree
+
+ def guardExpr(): Tree = stripParens(postfixExpr())
/** {{{
* Enumerators ::= Generator {semi Enumerator}
@@ -1704,27 +1698,26 @@ self =>
* }}}
*/
def generator(enums: ListBuffer[Enumerator], eqOK: Boolean) {
- val start = in.offset
- val hasVal = in.token == VAL
- if (hasVal)
- in.nextToken()
+ val start = in.offset
+ val hasVal = acceptIfPresent(VAL)
+ val pat = noSeq.pattern1()
+ val point = in.offset
+ val equalsBody = equalsExprOpt()
+ val hasEq = !equalsBody.isEmpty
+
+ if (hasVal && !hasEq)
+ syntaxError(in.offset, "val in for comprehension must be followed by assignment")
+ else if (hasEq && !eqOK)
+ syntaxError(point, "for comprehension must start with generator: " + expectedMsg(expected = LARROW, found = EQUALS))
+ else if (hasVal)
+ deprecationWarning(start, "val keyword in for comprehension is deprecated")
+
+ val rhs = equalsBody orElse { accept(LARROW) ; expr() }
- val pat = noSeq.pattern1()
- val point = in.offset
- val hasEq = in.token == EQUALS
-
- if (hasVal) {
- if (hasEq) deprecationWarning(in.offset, "val keyword in for comprehension is deprecated")
- else syntaxError(in.offset, "val in for comprehension must be followed by assignment")
- }
-
- if (hasEq && eqOK) in.nextToken()
- else accept(LARROW)
- val rhs = expr()
enums += makeGenerator(r2p(start, point, in.lastOffset max start), pat, hasEq, rhs)
// why max above? IDE stress tests have shown that lastOffset could be less than start,
// I guess this happens if instead if a for-expression we sit on a closing paren.
- while (in.token == IF) enums += makeFilter(in.offset, guard())
+ enums ++= tokenSeparated(IF, sepFirst = true, makeFilter(in.offset, guardExpr()))
}
def makeFilter(start: Int, tree: Tree) = Filter(r2p(start, tree.pos.point, tree.pos.endOrPoint), tree)
@@ -1832,14 +1825,6 @@ self =>
var top = simplePattern(badPattern3)
// after peekahead
def acceptWildStar() = atPos(top.pos.startOrPoint, in.prev.offset)(Star(stripParens(top)))
- def peekahead() = {
- in.prev copyFrom in
- in.nextToken()
- }
- def pushback() = {
- in.next copyFrom in
- in copyFrom in.prev
- }
// See SI-3189, SI-4832 for motivation. Cf SI-3480 for counter-motivation.
// TODO: dredge out the remnants of regexp patterns.
// /{/ peek for _*) or _*} (for xml escape)
@@ -2013,16 +1998,15 @@ self =>
* }}}
*/
def accessQualifierOpt(mods: Modifiers): Modifiers = {
- var result = mods
- if (in.token == LBRACKET) {
- in.nextToken()
- if (mods.hasAccessBoundary)
- syntaxError("duplicate private/protected qualifier", skipIt = false)
- result = if (in.token == THIS) { in.nextToken(); mods | Flags.LOCAL }
- else Modifiers(mods.flags, identForType())
- accept(RBRACKET)
+ def newModifiers(): Modifiers = (
+ if (acceptIfPresent(THIS)) mods | Flags.LOCAL // private/protected[this]
+ else Modifiers(mods.flags, identForType()) // private/protected[foo]
+ )
+ in.token match {
+ case LBRACKET if mods.hasAccessBoundary => syntaxError("duplicate private/protected qualifier", skipIt = false) ; mods
+ case LBRACKET => inBrackets(newModifiers())
+ case _ => mods
}
- result
}
private val flagTokens: Map[Int, Long] = Map(
@@ -2160,25 +2144,24 @@ self =>
}
paramType()
}
- val default =
- if (in.token == EQUALS) {
- in.nextToken()
+ val default = (
+ if (acceptIfPresent(EQUALS)) {
mods |= Flags.DEFAULTPARAM
expr()
- } else EmptyTree
+ }
+ else EmptyTree
+ )
atPos(start, if (name == nme.ERROR) start else nameOffset) {
ValDef((mods | implicitmod.toLong | bynamemod) withAnnotations annots, name.toTermName, tpt, default)
}
}
- def paramClause(): List[ValDef] = {
- if (in.token == RPAREN)
- return Nil
+ def paramClause(): List[ValDef] = in.token match {
+ case RPAREN => Nil
+ case _ =>
+ if (acceptIfPresent(IMPLICIT))
+ implicitmod = Flags.IMPLICIT
- if (in.token == IMPLICIT) {
- in.nextToken()
- implicitmod = Flags.IMPLICIT
- }
- commaSeparated(param())
+ commaSeparated(param())
}
val vds = new ListBuffer[List[ValDef]]
val start = in.offset
@@ -2186,8 +2169,7 @@ self =>
if (ofCaseClass && in.token != LPAREN)
syntaxError(in.lastOffset, "case classes without a parameter list are not allowed;\n"+
"use either case objects or case classes with an explicit `()' as a parameter list.")
- while (implicitmod == 0 && in.token == LPAREN) {
- in.nextToken()
+ while (implicitmod == 0 && acceptIfPresent(LPAREN)) {
vds += paramClause()
accept(RPAREN)
caseParam = false
@@ -2211,18 +2193,16 @@ self =>
def paramType(): Tree = paramType(useStartAsPosition = false)
def paramType(useStartAsPosition: Boolean): Tree = {
val start = in.offset
- in.token match {
- case ARROW =>
+ if (acceptIfPresent(ARROW))
+ atPos(start)(byNameApplication(typ()))
+ else {
+ val t = typ()
+ if (isRawStar) {
in.nextToken()
- atPos(start)(byNameApplication(typ()))
- case _ =>
- val t = typ()
- if (isRawStar) {
- in.nextToken()
- if (useStartAsPosition) atPos(start)(repeatedApplication(t))
- else atPos(t.pos.startOrPoint, t.pos.point)(repeatedApplication(t))
- }
- else t
+ if (useStartAsPosition) atPos(start)(repeatedApplication(t))
+ else atPos(t.pos.startOrPoint, t.pos.point)(repeatedApplication(t))
+ }
+ else t
}
}
@@ -2257,14 +2237,13 @@ self =>
}
if (contextBoundBuf ne null) {
while (in.token == VIEWBOUND) {
- contextBoundBuf += atPos(in.skipToken()) {
- makeFunctionTypeTree(List(Ident(pname)), typ())
- }
+ contextBoundBuf += atPos(in.skipToken())(makeFunctionTypeTree(List(Ident(pname)), typ()))
}
while (in.token == COLON) {
- contextBoundBuf += atPos(in.skipToken()) {
- AppliedTypeTree(typ(), List(Ident(pname)))
- }
+ val start = in.skipToken()
+ val tycon = typ()
+ val applied = atPos(tycon.pos withStart start)(AppliedTypeTree(tycon, Ident(pname) :: Nil))
+ contextBoundBuf += applied
}
}
param
@@ -2290,7 +2269,7 @@ self =>
t setPos o2p(in.offset)
}
- def bound(tok: Int): Tree = if (in.token == tok) { in.nextToken(); typ() } else EmptyTree
+ def bound(tok: Int): Tree = if (acceptIfPresent(tok)) typ() else EmptyTree
/* -------- DEFS ------------------------------------------- */
@@ -2302,11 +2281,10 @@ self =>
def importClause(): List[Tree] = {
val offset = accept(IMPORT)
commaSeparated(importExpr()) match {
- case Nil => Nil
+ case Nil => Nil
case t :: rest =>
// The first import should start at the position of the keyword.
- t.setPos(t.pos.withStart(offset))
- t :: rest
+ (t setPos (t.pos withStart offset)) :: rest
}
}
@@ -2335,12 +2313,9 @@ self =>
case _ =>
val nameOffset = in.offset
val name = ident()
- if (in.token == DOT) {
+ if (acceptIfPresent(DOT))
// import foo.bar.ident.<unknown> and so create a select node and recurse.
- val t = atPos(start, if (name == nme.ERROR) in.offset else nameOffset)(Select(expr, name))
- in.nextToken()
- return loop(t)
- }
+ return loop(atPos(start, if (name == nme.ERROR) in.offset else nameOffset)(Select(expr, name)))
// import foo.bar.Baz;
else List(makeImportSelector(name, nameOffset))
}
@@ -2371,30 +2346,27 @@ self =>
selectors
}
- def wildcardOrIdent() = {
- if (in.token == USCORE) { in.nextToken() ; nme.WILDCARD }
- else ident()
- }
+ def wildcardOrIdent() = if (acceptIfPresent(USCORE)) nme.WILDCARD else ident()
/** {{{
* ImportSelector ::= Id [`=>' Id | `=>' `_']
* }}}
*/
def importSelector(): ImportSelector = {
- val start = in.offset
- val name = wildcardOrIdent()
- var renameOffset = -1
- val rename = in.token match {
- case ARROW =>
- in.nextToken()
- renameOffset = in.offset
- wildcardOrIdent()
- case _ if name == nme.WILDCARD => null
- case _ =>
- renameOffset = start
- name
- }
- ImportSelector(name, start, rename, renameOffset)
+ val start = in.offset
+ val name = wildcardOrIdent()
+
+ // The first case is overly cleverly using named arguments to reverse the
+ // positions of the last two parameters, because reading the rename will
+ // move the value of in.offset. Hey, I didn't invent side effects, I too am
+ // a victim here. I can't find a single place where the rename position
+ // is used anyway.
+ if (acceptIfPresent(ARROW))
+ ImportSelector(name, start, renamePos = in.offset, rename = wildcardOrIdent())
+ else if (name == nme.WILDCARD)
+ ImportSelector(name, start, null, -1)
+ else
+ ImportSelector(name, start, name, start)
}
/** {{{
@@ -2433,6 +2405,8 @@ self =>
defOrDcl(caseAwareTokenOffset, modifiers() withAnnotations annots)
}
+ def equalsExprOpt(): Tree = if (acceptIfPresent(EQUALS)) expr() else EmptyTree
+
/** {{{
* PatDef ::= Pattern2 {`,' Pattern2} [`:' Type] `=' Expr
* ValDcl ::= Id {`,' Id} `:' Type
@@ -2440,45 +2414,55 @@ self =>
* }}}
*/
def patDefOrDcl(pos : Int, mods: Modifiers): List[Tree] = {
- var newmods = mods
in.nextToken()
- val lhs = commaSeparated(stripParens(noSeq.pattern2()))
- val tp = typedOpt()
- val rhs =
- if (tp.isEmpty || in.token == EQUALS) {
- accept(EQUALS)
- if (!tp.isEmpty && newmods.isMutable &&
- (lhs.toList forall (_.isInstanceOf[Ident])) && in.token == USCORE) {
- in.nextToken()
- newmods = newmods | Flags.DEFAULTINIT
- EmptyTree
- } else {
- expr()
- }
- } else {
- newmods = newmods | Flags.DEFERRED
- EmptyTree
- }
- def mkDefs(p: Tree, tp: Tree, rhs: Tree): List[Tree] = {
- //Console.println("DEBUG: p = "+p.toString()); // DEBUG
- val trees =
- makePatDef(newmods,
- if (tp.isEmpty) p
- else Typed(p, tp) setPos (p.pos union tp.pos),
- rhs)
- if (newmods.isDeferred) {
- trees match {
- case List(ValDef(_, _, _, EmptyTree)) =>
- if (mods.isLazy) syntaxError(p.pos, "lazy values may not be abstract", skipIt = false)
- case _ => syntaxError(p.pos, "pattern definition may not be abstract", skipIt = false)
- }
+
+ val lhses = commaSeparated(stripParens(noSeq.pattern2()))
+ val lhs = lhses.last
+ val tpt = typedOpt()
+ val ascriptedLhs = if (tpt.isEmpty) lhs else atPos(lhs.pos union tpt.pos)(Typed(lhs, tpt))
+ val hasEq = acceptIfPresent(EQUALS)
+ // SI-7854 an underscore following the equals doesn't necessarily mean default initialization.
+ val isDefaultInit = hasEq && in.token == USCORE && {
+ peekahead()
+ isStatSep || isStatSeqEnd || { pushback() ; false }
+ }
+ val rhs = if (hasEq && !isDefaultInit) expr() else EmptyTree
+ def allIdents = lhses forall (_.isInstanceOf[Ident])
+
+ def defaultInitFlag(): Long = {
+ if (!allIdents)
+ syntaxError(lhs.pos, "pattern definition is ineligible for default initialization", skipIt = false)
+ else if (!mods.isMutable)
+ syntaxError(lhs.pos, "only vars are eligible for default initialization", skipIt = false)
+ else if (tpt.isEmpty)
+ syntaxError(lhs.pos, "an explicit type is required for default initialization", skipIt = false)
+
+ Flags.DEFAULTINIT
+ }
+ def deferredFlag(): Long = {
+ if (mods.isLazy) // e.g. lazy val foo: Int
+ syntaxError(lhs.pos, "lazy values may not be abstract", skipIt = false)
+ else if (!allIdents) // e.g. val Some(x)
+ syntaxError(lhs.pos, "pattern definition may not be abstract", skipIt = false)
+
+ Flags.DEFERRED
+ }
+ val newmods = mods | (
+ if (isDefaultInit) defaultInitFlag()
+ else if (rhs.isEmpty) deferredFlag()
+ else 0L
+ )
+
+ def makeValDefs(decl: Tree): List[Tree] = {
+ val newTpt = if (tpt.isEmpty) decl else Typed(decl, tpt.duplicate setPos tpt.pos.focus) setPos decl.pos.focus
+ makePatDef(newmods, newTpt, rhs.duplicate setPos rhs.pos.focus) match {
+ case tree :: Nil => (tree setPos decl.pos) :: Nil
+ case trees => trees map (_ setPos decl.pos.focus)
}
- trees
}
- val trees = (lhs.toList.init flatMap (mkDefs(_, tp.duplicate, rhs.duplicate))) ::: mkDefs(lhs.last, tp, rhs)
- val hd = trees.head
- hd setPos hd.pos.withStart(pos)
- ensureNonOverlapping(hd, trees.tail)
+
+ val trees = (lhses.init flatMap makeValDefs) ::: makePatDef(newmods, ascriptedLhs, rhs)
+ ensureNonOverlapping(trees.last, trees.init)
trees
}
@@ -2523,7 +2507,8 @@ self =>
in.nextToken()
if (in.token == THIS) {
atPos(start, in.skipToken()) {
- val vparamss = paramClauses(nme.CONSTRUCTOR, classContextBounds map (_.duplicate), ofCaseClass = false)
+ val cbounds = classContextBounds map (_.duplicate)
+ val vparamss = paramClauses(nme.CONSTRUCTOR, cbounds, ofCaseClass = false)
newLineOptWhenFollowedBy(LBRACE)
val rhs = in.token match {
case LBRACE => atPos(in.offset) { constrBlock(vparamss) }
@@ -2547,7 +2532,8 @@ self =>
// i.e. (B[T] or T => B)
val contextBoundBuf = new ListBuffer[Tree]
val tparams = typeParamClauseOpt(name, contextBoundBuf)
- val vparamss = paramClauses(name, contextBoundBuf.toList, ofCaseClass = false)
+ val cbounds = contextBoundBuf.toList
+ val vparamss = paramClauses(name, cbounds, ofCaseClass = false)
newLineOptWhenFollowedBy(LBRACE)
var restype = fromWithinReturnType(typedOpt())
val rhs =
@@ -2707,8 +2693,9 @@ self =>
val result = gen.mkClassDef(mods1, name, tparams, template)
// Context bounds generate implicit parameters (part of the template) with types
// from tparams: we need to ensure these don't overlap
- if (!classContextBounds.isEmpty)
+ if (classContextBounds.nonEmpty)
ensureNonOverlapping(template, tparams)
+
result
}
}
@@ -2770,18 +2757,15 @@ self =>
* }}}
*/
def templateParents(): List[Tree] = {
- val parents = new ListBuffer[Tree]
- def readAppliedParent() = {
+ def readAppliedParent(): Tree = {
val start = in.offset
val parent = startAnnotType()
- parents += (in.token match {
+ in.token match {
case LPAREN => atPos(start)((parent /: multipleArgumentExprs())(Apply.apply))
case _ => parent
- })
+ }
}
- readAppliedParent()
- while (in.token == WITH) { in.nextToken(); readAppliedParent() }
- parents.toList
+ tokenSeparated(WITH, sepFirst = false, readAppliedParent())
}
/** {{{
@@ -2815,9 +2799,9 @@ self =>
def ensureEarlyDef(tree: Tree): Tree = tree match {
case vdef @ ValDef(mods, _, _, _) if !mods.isDeferred =>
copyValDef(vdef)(mods = mods | Flags.PRESUPER)
- case tdef @ TypeDef(mods, name, tparams, rhs) =>
+ case tdef @ TypeDef(mods, _, _, _) =>
deprecationWarning(tdef.pos.point, "early type members are deprecated. Move them to the regular body: the semantics are the same.")
- treeCopy.TypeDef(tdef, mods | Flags.PRESUPER, name, tparams, rhs)
+ copyTypeDef(tdef)(mods = mods | Flags.PRESUPER)
case docdef @ DocDef(comm, rhs) =>
treeCopy.DocDef(docdef, comm, rhs)
case stat if !stat.isEmpty =>
@@ -2852,7 +2836,6 @@ self =>
)
val parentPos = o2p(in.offset)
val tstart1 = if (body.isEmpty && in.lastOffset < tstart) in.lastOffset else tstart
-
atPos(tstart1) {
// Exclude only the 9 primitives plus AnyVal.
if (inScalaRootPackage && ScalaValueClassNames.contains(name))
@@ -3103,10 +3086,9 @@ self =>
def compilationUnit(): PackageDef = checkNoEscapingPlaceholders {
def topstats(): List[Tree] = {
val ts = new ListBuffer[Tree]
- while (in.token == SEMI) in.nextToken()
+ while (acceptIfPresent(SEMI)) ()
val start = in.offset
- if (in.token == PACKAGE) {
- in.nextToken()
+ if (acceptIfPresent(PACKAGE)) {
if (in.token == OBJECT) {
// TODO - this next line is supposed to be
// ts += packageObjectDef(start)
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 6957f85689..5ef40923b4 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -52,6 +52,15 @@ trait Scanners extends ScannersCommon {
type Offset = Int
trait TokenData extends CommonTokenData {
+ override def toString = s"""
+ |TokenData(
+ | token $token ${token2string(token)}
+ | offset $offset
+ | last $lastOffset
+ | name $name
+ | strVal $strVal
+ | base $base
+ |)""".stripMargin.trim
/** the next token */
var token: Int = EMPTY
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index 91ff530e05..976e578afd 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -206,22 +206,21 @@ abstract class TreeBuilder {
}
/** Create tree representing a while loop */
- def makeWhile(startPos: Int, cond: Tree, body: Tree): Tree = {
- val lname = freshTermName(nme.WHILE_PREFIX)
- def default = wrappingPos(List(cond, body)) match {
- case p if p.isDefined => p.endOrPoint
- case _ => startPos
- }
- val continu = atPos(o2p(body.pos pointOrElse default)) { Apply(Ident(lname), Nil) }
- val rhs = If(cond, Block(List(body), continu), Literal(Constant(())))
- LabelDef(lname, Nil, rhs)
+ def makeWhile(cond: Tree, body: Tree): Tree = {
+ val lname = freshTermName(nme.WHILE_PREFIX)
+ val continu = atPos(cond.pos.focus)(Apply(Ident(lname), Nil))
+ val rhs = atPos(cond.pos union body.pos)(If(cond, atPos(body.pos)(Block(body :: Nil, continu)), Literal(Constant(()))))
+
+ atPos(rhs.pos)(LabelDef(lname, Nil, rhs))
}
/** Create tree representing a do-while loop */
def makeDoWhile(lname: TermName, body: Tree, cond: Tree): Tree = {
- val continu = Apply(Ident(lname), Nil)
- val rhs = Block(List(body), If(cond, continu, Literal(Constant(()))))
- LabelDef(lname, Nil, rhs)
+ val continu = atPos(cond.pos.focus)(Apply(Ident(lname), Nil))
+ val condition = atPos(cond.pos)(If(cond, continu, Literal(Constant(()))))
+ val rhs = atPos(cond.pos union body.pos)(Block(body :: Nil, condition))
+
+ atPos(rhs.pos)(LabelDef(lname, Nil, rhs))
}
/** Create block of statements `stats` */
@@ -313,19 +312,13 @@ abstract class TreeBuilder {
* The closure is assigned a transparent position with the point at pos.point and
* the limits given by pat and body.
*/
- def makeClosure(pos: Position, pat: Tree, body: Tree): Tree = {
- def splitpos = wrappingPos(List(pat, body)).withPoint(pos.point).makeTransparent
- matchVarPattern(pat) match {
- case Some((name, tpt)) =>
- Function(
- List(atPos(pat.pos) { ValDef(Modifiers(PARAM), name.toTermName, tpt, EmptyTree) }),
- body) setPos splitpos
- case None =>
- atPos(splitpos) {
- makeVisitor(List(CaseDef(pat, EmptyTree, body)), checkExhaustive = false)
- }
+ def makeClosure(pos: Position, pat: Tree, body: Tree): Tree =
+ atPos((pos union pat.pos union body.pos).makeTransparent) {
+ matchVarPattern(pat) match {
+ case Some((name, tpt)) => Function(atPos(pat.pos)(ValDef(Modifiers(PARAM), name.toTermName, tpt, EmptyTree)) :: Nil, body)
+ case None => makeVisitor(CaseDef(pat, body) :: Nil, checkExhaustive = false)
+ }
}
- }
/* Make an application qual.meth(pat => body) positioned at `pos`.
*/
@@ -503,7 +496,7 @@ abstract class TreeBuilder {
tmp, TypeTree(), matchExpr)
}
var cnt = 0
- val restDefs = for ((vname, tpt, pos) <- vars) yield atPos(pos) {
+ val restDefs = for ((vname, tpt, pos) <- vars) yield atPos(pos.focus) {
cnt += 1
ValDef(mods, vname.toTermName, tpt, Select(Ident(tmp), newTermName("_" + cnt)))
}
diff --git a/src/reflect/scala/reflect/internal/TreeGen.scala b/src/reflect/scala/reflect/internal/TreeGen.scala
index 72e1ee107b..a8af3e0f0e 100644
--- a/src/reflect/scala/reflect/internal/TreeGen.scala
+++ b/src/reflect/scala/reflect/internal/TreeGen.scala
@@ -280,7 +280,7 @@ abstract class TreeGen extends macros.TreeBuilder {
/** Builds a tuple */
def mkTuple(elems: List[Tree]): Tree =
- if (elems.isEmpty) Literal(Constant(()))
+ if (elems.isEmpty) mkUnit()
else Apply(
Select(mkAttributedRef(TupleClass(elems.length).caseModule), nme.apply),
elems)
@@ -326,8 +326,7 @@ abstract class TreeGen extends macros.TreeBuilder {
* body
* }
*/
- def mkTemplate(parents: List[Tree], self: ValDef, constrMods: Modifiers,
- vparamss: List[List[ValDef]], body: List[Tree], superPos: Position = NoPosition): Template = {
+ def mkTemplate(parents: List[Tree], self: ValDef, constrMods: Modifiers, vparamss: List[List[ValDef]], body: List[Tree], superPos: Position = NoPosition): Template = {
/* Add constructor to template */
// create parameters for <init> as synthetic trees.
@@ -398,51 +397,41 @@ abstract class TreeGen extends macros.TreeBuilder {
* @param npos the position of the new
* @param cpos the position of the anonymous class starting with parents
*/
- def mkNew(parents: List[Tree], self: ValDef, stats: List[Tree],
- npos: Position, cpos: Position): Tree =
- if (parents.isEmpty)
- mkNew(List(scalaAnyRefConstr), self, stats, npos, cpos)
- else if (parents.tail.isEmpty && stats.isEmpty) {
- // `Parsers.template` no longer differentiates tpts and their argss
- // e.g. `C()` will be represented as a single tree Apply(Ident(C), Nil)
- // instead of parents = Ident(C), argss = Nil as before
- // this change works great for things that are actually templates
- // but in this degenerate case we need to perform postprocessing
- val app = treeInfo.dissectApplied(parents.head)
- atPos(npos union cpos) { New(app.callee, app.argss) }
- } else {
- val x = tpnme.ANON_CLASS_NAME
- atPos(npos union cpos) {
- Block(
- List(
- atPos(cpos) {
- ClassDef(
- Modifiers(FINAL), x, Nil,
- mkTemplate(parents, self, NoMods, ListOfNil, stats, cpos.focus))
- }),
- atPos(npos) {
- New(
- Ident(x) setPos npos.focus,
- Nil)
- }
- )
- }
+ def mkNew(parents: List[Tree], self: ValDef, stats: List[Tree], npos: Position, cpos: Position): Tree = {
+ def enclosingPos = wrappingPos(cpos, parents ::: List(self) ::: stats)
+ def upos = cpos union npos
+ def anonTemplate = atPos(cpos)(mkTemplate(parents, self, NoMods, ListOfNil, stats, cpos))
+ def anonClass = atPos(anonTemplate.pos.makeTransparent)(ClassDef(Modifiers(FINAL), tpnme.ANON_CLASS_NAME, Nil, anonTemplate))
+ def anonNew = atPos(npos)(New(Ident(tpnme.ANON_CLASS_NAME) setPos cpos.focus, Nil))
+
+ // `Parsers.template` no longer differentiates tpts and their argss
+ // e.g. `C()` will be represented as a single tree Apply(Ident(C), Nil)
+ // instead of parents = Ident(C), argss = Nil as before
+ // this change works great for things that are actually templates
+ // but in this degenerate case we need to perform postprocessing
+ parents match {
+ case Nil => mkNew(List(scalaAnyRefConstr), self, stats, npos, cpos)
+ case treeInfo.AppliedArgs(callee, argss) :: Nil if stats.isEmpty => atPos(upos)(New(callee, argss))
+ case _ => atPos(upos)(mkBlock(anonClass :: anonNew :: Nil))
}
+ }
/** Create a tree representing the function type (argtpes) => restpe */
def mkFunctionTypeTree(argtpes: List[Tree], restpe: Tree): Tree =
AppliedTypeTree(rootScalaDot(newTypeName("Function" + argtpes.length)), argtpes ::: List(restpe))
+ def mkUnit() = Literal(Constant(()))
+
/** Create block of statements `stats` */
- def mkBlock(stats: List[Tree]): Tree =
- if (stats.isEmpty) Literal(Constant(()))
- else if (!stats.last.isTerm) Block(stats, Literal(Constant(())))
- else if (stats.length == 1) stats.head
- else Block(stats.init, stats.last)
+ def mkBlock(stats: List[Tree]): Tree = stats match {
+ case stats if stats.isEmpty || !stats.last.isTerm => mkBlock(stats :+ mkUnit())
+ case stat :: Nil => stat
+ case stats => Block(stats.init, stats.last)
+ }
def mkTreeOrBlock(stats: List[Tree]) = stats match {
- case Nil => EmptyTree
+ case Nil => EmptyTree
case head :: Nil => head
- case _ => gen.mkBlock(stats)
+ case _ => gen.mkBlock(stats)
}
}
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index 34fe0afb1a..1b763b8632 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -773,6 +773,13 @@ abstract class TreeInfo {
unapply(dissectApplied(tree))
}
+ object AppliedArgs {
+ def unapply(tree: Tree): Some[(Tree, List[List[Tree]])] = tree match {
+ case Apply(AppliedArgs(fn, argss), args) => Some((fn, argss :+ args))
+ case _ => Some((tree, Nil))
+ }
+ }
+
/** Locates the synthetic Apply node corresponding to an extractor's call to
* unapply (unwrapping nested Applies) and returns the fun part of that Apply.
*/
diff --git a/test/files/continuations-run/t5472.check b/test/files/continuations-run/t5472.check
index 3192c746eb..1af7767f6d 100644
--- a/test/files/continuations-run/t5472.check
+++ b/test/files/continuations-run/t5472.check
@@ -5,7 +5,7 @@ t5472.scala:12: warning: expression case4(){
case5()
} is cps-transformed unexpectedly
(location, accessors) <- new ContinuationizedParallelIterable(map)
- ^
+ ^
t5472.scala:12: warning: expression matchEnd3(x: Int){
x
} is cps-transformed unexpectedly
diff --git a/test/files/neg/classmanifests_new_deprecations.check b/test/files/neg/classmanifests_new_deprecations.check
index fd1e2728c3..39b6bf216c 100644
--- a/test/files/neg/classmanifests_new_deprecations.check
+++ b/test/files/neg/classmanifests_new_deprecations.check
@@ -1,6 +1,6 @@
classmanifests_new_deprecations.scala:2: warning: type ClassManifest in object Predef is deprecated: Use `scala.reflect.ClassTag` instead
def cm1[T: ClassManifest] = ???
- ^
+ ^
classmanifests_new_deprecations.scala:3: warning: type ClassManifest in object Predef is deprecated: Use `scala.reflect.ClassTag` instead
def cm2[T](implicit evidence$1: ClassManifest[T]) = ???
^
@@ -9,7 +9,7 @@ classmanifests_new_deprecations.scala:4: warning: type ClassManifest in object P
^
classmanifests_new_deprecations.scala:6: warning: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead
def rcm1[T: scala.reflect.ClassManifest] = ???
- ^
+ ^
classmanifests_new_deprecations.scala:7: warning: type ClassManifest in package reflect is deprecated: Use scala.reflect.ClassTag instead
def rcm2[T](implicit evidence$1: scala.reflect.ClassManifest[T]) = ???
^
diff --git a/test/files/neg/divergent-implicit.check b/test/files/neg/divergent-implicit.check
index 5f20df1b91..b5c607cf59 100644
--- a/test/files/neg/divergent-implicit.check
+++ b/test/files/neg/divergent-implicit.check
@@ -10,9 +10,9 @@ starting with method cast in object Test1
divergent-implicit.scala:14: error: diverging implicit expansion for type Test2.Baz => Test2.Bar
starting with method baz2bar in object Test2
val x: Bar = new Foo
- ^
+ ^
divergent-implicit.scala:15: error: diverging implicit expansion for type Test2.Foo => Test2.Bar
starting with method foo2bar in object Test2
val y: Bar = new Baz
- ^
+ ^
four errors found
diff --git a/test/files/neg/for-comprehension-old.check b/test/files/neg/for-comprehension-old.check
index 1ecaf12af4..fc04beca53 100644
--- a/test/files/neg/for-comprehension-old.check
+++ b/test/files/neg/for-comprehension-old.check
@@ -1,15 +1,15 @@
for-comprehension-old.scala:3: warning: val keyword in for comprehension is deprecated
for (x <- 1 to 5 ; val y = x) yield x+y // fail
- ^
+ ^
for-comprehension-old.scala:5: warning: val keyword in for comprehension is deprecated
for (val x <- 1 to 5 ; val y = x) yield x+y // fail
- ^
+ ^
for-comprehension-old.scala:8: warning: val keyword in for comprehension is deprecated
for (z <- 1 to 2 ; x <- 1 to 5 ; val y = x) yield x+y // fail
- ^
+ ^
for-comprehension-old.scala:10: warning: val keyword in for comprehension is deprecated
for (z <- 1 to 2 ; val x <- 1 to 5 ; val y = x) yield x+y // fail
- ^
+ ^
for-comprehension-old.scala:4: error: val in for comprehension must be followed by assignment
for (val x <- 1 to 5 ; y = x) yield x+y // fail
^
diff --git a/test/files/neg/found-req-variance.check b/test/files/neg/found-req-variance.check
index cc26458ac5..55a01012a9 100644
--- a/test/files/neg/found-req-variance.check
+++ b/test/files/neg/found-req-variance.check
@@ -4,56 +4,56 @@ found-req-variance.scala:22: error: type mismatch;
Note: B <: A, but class Inv is invariant in type T.
You may wish to define T as +T instead. (SLS 4.5)
def f2 = Set[Inv[A]]() + new Inv[B]
- ^
+ ^
found-req-variance.scala:23: error: type mismatch;
found : Inv[C]
required: Inv[A]
Note: C <: A, but class Inv is invariant in type T.
You may wish to define T as +T instead. (SLS 4.5)
def f3 = Set[Inv[A]]() + new Inv[C]
- ^
+ ^
found-req-variance.scala:24: error: type mismatch;
found : Inv[A]
required: Inv[B]
Note: A >: B, but class Inv is invariant in type T.
You may wish to define T as -T instead. (SLS 4.5)
def f4 = Set[Inv[B]]() + new Inv[A]
- ^
+ ^
found-req-variance.scala:26: error: type mismatch;
found : Inv[C]
required: Inv[B]
Note: C <: B, but class Inv is invariant in type T.
You may wish to define T as +T instead. (SLS 4.5)
def f6 = Set[Inv[B]]() + new Inv[C]
- ^
+ ^
found-req-variance.scala:27: error: type mismatch;
found : Inv[A]
required: Inv[C]
Note: A >: C, but class Inv is invariant in type T.
You may wish to define T as -T instead. (SLS 4.5)
def f7 = Set[Inv[C]]() + new Inv[A]
- ^
+ ^
found-req-variance.scala:28: error: type mismatch;
found : Inv[B]
required: Inv[C]
Note: B >: C, but class Inv is invariant in type T.
You may wish to define T as -T instead. (SLS 4.5)
def f8 = Set[Inv[C]]() + new Inv[B]
- ^
+ ^
found-req-variance.scala:34: error: type mismatch;
found : MultiInv[A]
required: Multi[A,B,C]
Note: A >: B (and MultiInv[A] <: Multi[A,A,C]), but class Multi is invariant in type Inv.
You may wish to define Inv as -Inv instead. (SLS 4.5)
def g4 = Set[Multi[A, B, C]]() + new MultiInv[A]
- ^
+ ^
found-req-variance.scala:36: error: type mismatch;
found : MultiInv[C]
required: Multi[A,B,C]
Note: C <: B (and MultiInv[C] <: Multi[A,C,C]), but class Multi is invariant in type Inv.
You may wish to define Inv as +Inv instead. (SLS 4.5)
def g6 = Set[Multi[A, B, C]]() + new MultiInv[C]
- ^
+ ^
found-req-variance.scala:47: error: type mismatch;
found : FF1[A,A]
required: FF1[B,B]
@@ -160,7 +160,7 @@ found-req-variance.scala:94: error: type mismatch;
Note: Int <: AnyVal (and Misc.MyData <: Misc.Data[Int]), but class Data is invariant in type A.
You may wish to define A as +A instead. (SLS 4.5)
def f1 = Set[Data[AnyVal]]() + new MyData
- ^
+ ^
found-req-variance.scala:100: error: type mismatch;
found : Set[String]
required: Set[CharSequence]
@@ -174,7 +174,7 @@ found-req-variance.scala:104: error: type mismatch;
Note: String <: Object, but class Trippy is invariant in type T2.
You may wish to define T2 as +T2 instead. (SLS 4.5)
def g1 = Set[Trippy[AnyRef, AnyRef, AnyRef]]() + new Trippy[String, String, String]
- ^
+ ^
found-req-variance.scala:105: error: type mismatch;
found : scala.collection.immutable.Map[AnyRef,String]
required: Map[String,String]
diff --git a/test/files/neg/lazyvals.check b/test/files/neg/lazyvals.check
index c4daf9d842..1ae8b13d92 100644
--- a/test/files/neg/lazyvals.check
+++ b/test/files/neg/lazyvals.check
@@ -7,9 +7,9 @@ lazyvals.scala:9: error: lazy not allowed here. Only vals can be lazy
lazyvals.scala:12: error: lazy not allowed here. Only vals can be lazy
lazy def q: Double = 0.0
^
-lazyvals.scala:15: error: '=' expected but ';' found.
+lazyvals.scala:15: error: lazy values may not be abstract
lazy val t;
- ^
+ ^
lazyvals.scala:20: error: lazy not allowed here. Only vals can be lazy
lazy trait T {}
^
diff --git a/test/files/neg/multi-array.check b/test/files/neg/multi-array.check
index 511caa126f..6bdeb34c9e 100644
--- a/test/files/neg/multi-array.check
+++ b/test/files/neg/multi-array.check
@@ -1,4 +1,4 @@
multi-array.scala:7: error: too many arguments for constructor Array: (_length: Int)Array[T]
val a: Array[Int] = new Array(10, 10)
- ^
+ ^
one error found
diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check
index cdc12c2490..4966779cc3 100644
--- a/test/files/neg/names-defaults-neg.check
+++ b/test/files/neg/names-defaults-neg.check
@@ -97,7 +97,7 @@ names-defaults-neg.scala:82: error: type mismatch;
required: String
Error occurred in an application involving default arguments.
new A2[String]()
- ^
+ ^
names-defaults-neg.scala:86: error: module extending its companion class cannot use default constructor arguments
object C extends C()
^
diff --git a/test/files/neg/nested-annotation.check b/test/files/neg/nested-annotation.check
index ca263943fe..c077d35a29 100644
--- a/test/files/neg/nested-annotation.check
+++ b/test/files/neg/nested-annotation.check
@@ -5,6 +5,6 @@ class ComplexAnnotation(val value: Annotation) extends ClassfileAnnotation
^
nested-annotation.scala:8: error: nested classfile annotations must be defined in java; found: inline
@ComplexAnnotation(new inline) def bippy(): Int = 1
- ^
+ ^
one warning found
one error found
diff --git a/test/files/neg/no-implicit-to-anyref.check b/test/files/neg/no-implicit-to-anyref.check
index fe417ad8b0..5ab5fd12a1 100644
--- a/test/files/neg/no-implicit-to-anyref.check
+++ b/test/files/neg/no-implicit-to-anyref.check
@@ -18,5 +18,5 @@ Note that AV extends Any, not AnyRef.
Such types can participate in value classes, but instances
cannot appear in singleton types or in reference comparisons.
new AV(0): AnyRef
- ^
+ ^
four errors found
diff --git a/test/files/neg/no-predef.check b/test/files/neg/no-predef.check
index a63d8c5ba5..fc538892ef 100644
--- a/test/files/neg/no-predef.check
+++ b/test/files/neg/no-predef.check
@@ -7,7 +7,7 @@ no-predef.scala:3: error: type mismatch;
found : java.lang.Long
required: scala.Long
def f2 = new java.lang.Long(5) : Long
- ^
+ ^
no-predef.scala:4: error: value map is not a member of String
def f3 = "abc" map (_ + 1)
^
diff --git a/test/files/neg/parser-errors.check b/test/files/neg/parser-errors.check
index ab13ee0921..0ab3331c0c 100644
--- a/test/files/neg/parser-errors.check
+++ b/test/files/neg/parser-errors.check
@@ -1,16 +1,16 @@
parser-errors.scala:1: error: lazy values may not be abstract
abstract class A1 { lazy val foo: Int }
^
-parser-errors.scala:2: error: '=' expected but '}' found.
+parser-errors.scala:2: error: pattern definition may not be abstract
abstract class A2 { val Some(x) }
- ^
-parser-errors.scala:3: error: unbound placeholder parameter
-abstract class A3 { var x = _ }
^
-parser-errors.scala:4: error: unbound placeholder parameter
+parser-errors.scala:3: error: an explicit type is required for default initialization
+abstract class A3 { var x = _ }
+ ^
+parser-errors.scala:4: error: only vars are eligible for default initialization
abstract class A4 { val x: Int = _ }
- ^
-parser-errors.scala:5: error: unbound placeholder parameter
+ ^
+parser-errors.scala:5: error: pattern definition is ineligible for default initialization
abstract class A5 { var Some(x) = _ }
- ^
+ ^
5 errors found
diff --git a/test/files/neg/parser-errors.scala b/test/files/neg/parser-errors.scala
index 1bf121f68f..7b1a290629 100644
--- a/test/files/neg/parser-errors.scala
+++ b/test/files/neg/parser-errors.scala
@@ -2,4 +2,4 @@ abstract class A1 { lazy val foo: Int }
abstract class A2 { val Some(x) }
abstract class A3 { var x = _ }
abstract class A4 { val x: Int = _ }
-abstract class A5 { var Some(x) = _ } \ No newline at end of file
+abstract class A5 { var Some(x) = _ }
diff --git a/test/files/neg/parser-import-errors.check b/test/files/neg/parser-import-errors.check
new file mode 100644
index 0000000000..e211c275a6
--- /dev/null
+++ b/test/files/neg/parser-import-errors.check
@@ -0,0 +1,28 @@
+parser-import-errors.scala:12: error: not found: type B1
+ new B1
+ ^
+parser-import-errors.scala:13: error: not found: type C1
+ new C1
+ ^
+parser-import-errors.scala:19: error: object X1 is not a member of package p1
+ import p1.{ A1 => X1, X1 => A1 }
+ ^
+parser-import-errors.scala:21: error: not found: type A1
+ new A1
+ ^
+parser-import-errors.scala:22: error: not found: type B1
+ new B1
+ ^
+parser-import-errors.scala:23: error: not found: type C1
+ new C1
+ ^
+parser-import-errors.scala:33: error: not found: type C1
+ new C1
+ ^
+parser-import-errors.scala:38: error: A1 appears twice as a target of a renaming
+ import p1.{ A1, B1 => A1 }
+ ^
+parser-import-errors.scala:45: error: object Z1 is not a member of package p1
+ import p1.{ Z1, B1 => Z1 }
+ ^
+9 errors found
diff --git a/test/files/neg/parser-import-errors.scala b/test/files/neg/parser-import-errors.scala
new file mode 100644
index 0000000000..010bb95a1e
--- /dev/null
+++ b/test/files/neg/parser-import-errors.scala
@@ -0,0 +1,49 @@
+package p1 {
+ class A1
+ class B1
+ class C1
+}
+
+package p2 {
+ import p1.{ A1, B1 => Q1, C1 => _ }
+
+ class X {
+ new A1
+ new B1
+ new C1
+ new Q1
+ }
+}
+
+package p3 {
+ import p1.{ A1 => X1, X1 => A1 }
+ class X {
+ new A1
+ new B1
+ new C1
+ new X1
+ }
+}
+
+package p4 {
+ import p1.{ A1 => B1, B1 => A1 }
+ class X {
+ new A1
+ new B1
+ new C1
+ }
+}
+
+package p5 {
+ import p1.{ A1, B1 => A1 }
+ class X {
+ new A1
+ }
+}
+
+package p6 {
+ import p1.{ Z1, B1 => Z1 }
+ class X {
+ new Z1
+ }
+}
diff --git a/test/files/neg/primitive-sigs-1.check b/test/files/neg/primitive-sigs-1.check
index 77dc457a49..d0619fa1d3 100644
--- a/test/files/neg/primitive-sigs-1.check
+++ b/test/files/neg/primitive-sigs-1.check
@@ -2,5 +2,5 @@ B.scala:3: error: type mismatch;
found : Bippy
required: AC[Integer]
J.f(new Bippy())
- ^
+ ^
one error found
diff --git a/test/files/neg/protected-constructors.check b/test/files/neg/protected-constructors.check
index f44d7db9b9..b636d076e4 100644
--- a/test/files/neg/protected-constructors.check
+++ b/test/files/neg/protected-constructors.check
@@ -1,12 +1,12 @@
protected-constructors.scala:17: error: too many arguments for constructor Foo1: ()dingus.Foo1
val foo1 = new Foo1("abc")
- ^
+ ^
protected-constructors.scala:18: error: constructor Foo2 in class Foo2 cannot be accessed in object P
Access to protected constructor Foo2 not permitted because
enclosing object P in package hungus is not a subclass of
class Foo2 in package dingus where target is defined
val foo2 = new Foo2("abc")
- ^
+ ^
protected-constructors.scala:19: error: class Foo3 in object Ding cannot be accessed in object dingus.Ding
Access to protected class Foo3 not permitted because
enclosing object P in package hungus is not a subclass of
diff --git a/test/files/neg/saito.check b/test/files/neg/saito.check
index 061a45b76e..f78b300b4c 100644
--- a/test/files/neg/saito.check
+++ b/test/files/neg/saito.check
@@ -1,4 +1,4 @@
saito.scala:10: error: class A cannot be instantiated because it does not conform to its self-type A with B
val a: A = new A; // should not be allowed
- ^
+ ^
one error found
diff --git a/test/files/neg/sensitive.check b/test/files/neg/sensitive.check
index 32d988ec97..9270e639c3 100644
--- a/test/files/neg/sensitive.check
+++ b/test/files/neg/sensitive.check
@@ -1,4 +1,4 @@
sensitive.scala:17: error: constructor Sensitive in class Sensitive cannot be accessed in object Attacker
val y = new Sensitive()
- ^
+ ^
one error found
diff --git a/test/files/neg/stringinterpolation_macro-neg.check b/test/files/neg/stringinterpolation_macro-neg.check
index 457f497f2f..fa4f2c9472 100644
--- a/test/files/neg/stringinterpolation_macro-neg.check
+++ b/test/files/neg/stringinterpolation_macro-neg.check
@@ -1,6 +1,6 @@
stringinterpolation_macro-neg.scala:8: error: too few parts
new StringContext().f()
- ^
+ ^
stringinterpolation_macro-neg.scala:9: error: too few arguments for interpolated string
new StringContext("", " is ", "%2d years old").f(s)
^
diff --git a/test/files/neg/t0209.check b/test/files/neg/t0209.check
index 1904e58e7a..4ba5fef4e9 100644
--- a/test/files/neg/t0209.check
+++ b/test/files/neg/t0209.check
@@ -2,5 +2,5 @@ t0209.scala:15: error: type mismatch;
found : C
required: _1.type where val _1: A
(new B: A).f(new C)
- ^
+ ^
one error found
diff --git a/test/files/neg/t1038.check b/test/files/neg/t1038.check
index b191b89ad1..c74d8b338f 100644
--- a/test/files/neg/t1038.check
+++ b/test/files/neg/t1038.check
@@ -1,5 +1,5 @@
t1038.scala:4: error: not enough arguments for constructor X: (x: Int)X.
Unspecified value parameter x.
val a = new X
- ^
+ ^
one error found
diff --git a/test/files/neg/t1623.check b/test/files/neg/t1623.check
index 251039ad30..e30db5cddd 100644
--- a/test/files/neg/t1623.check
+++ b/test/files/neg/t1623.check
@@ -1,4 +1,4 @@
t1623.scala:11: error: class BImpl cannot be instantiated because it does not conform to its self-type test.BImpl with test.A
val b = new BImpl
- ^
+ ^
one error found
diff --git a/test/files/neg/t1705.check b/test/files/neg/t1705.check
index 7f75bd0fb5..12f5c27de6 100644
--- a/test/files/neg/t1705.check
+++ b/test/files/neg/t1705.check
@@ -1,6 +1,6 @@
t1705.scala:9: error: can't existentially abstract over parameterized type this.T[Z]
val c = new C{
- ^
+ ^
t1705.scala:14: error: can't existentially abstract over parameterized type C[String]
val x1 = {
^
diff --git a/test/files/neg/t2775.check b/test/files/neg/t2775.check
index 934a970f2e..2c901665d6 100644
--- a/test/files/neg/t2775.check
+++ b/test/files/neg/t2775.check
@@ -1,4 +1,4 @@
t2775.scala:1: error: cannot find class tag for element type B.this.T
trait B[S] { type T = S; val c = new Array[T](1) }
- ^
+ ^
one error found
diff --git a/test/files/neg/t3453.check b/test/files/neg/t3453.check
index 52c948128c..2472e8b212 100644
--- a/test/files/neg/t3453.check
+++ b/test/files/neg/t3453.check
@@ -2,20 +2,20 @@ t3453.scala:18: error: type mismatch;
found : A
required: B
new A
- ^
+ ^
t3453.scala:36: error: type mismatch;
found : A
required: B
new A
- ^
+ ^
t3453.scala:50: error: type mismatch;
found : A
required: B
new A
- ^
+ ^
t3453.scala:64: error: type mismatch;
found : A
required: B
new A
- ^
+ ^
four errors found
diff --git a/test/files/neg/t3692-new.check b/test/files/neg/t3692-new.check
index 9b96449930..358eaed41e 100644
--- a/test/files/neg/t3692-new.check
+++ b/test/files/neg/t3692-new.check
@@ -9,7 +9,7 @@ t3692-new.scala:16: warning: non-variable type argument Int in type pattern Map[
^
t3692-new.scala:15: warning: unreachable code
case m1: Map[Int, V] => new java.util.HashMap[Integer, V]
- ^
+ ^
t3692-new.scala:4: warning: Tester has a main method with parameter type Array[String], but Tester will not be a runnable program.
Reason: main method must have exact signature (Array[String])Unit
object Tester {
diff --git a/test/files/neg/t3977.check b/test/files/neg/t3977.check
index 72335a0926..4242059463 100644
--- a/test/files/neg/t3977.check
+++ b/test/files/neg/t3977.check
@@ -1,4 +1,4 @@
t3977.scala:12: error: could not find implicit value for parameter w: False#If[E]
new NoNull
- ^
+ ^
one error found
diff --git a/test/files/neg/t4163.check b/test/files/neg/t4163.check
index 47bc78d31c..a09a522e3a 100644
--- a/test/files/neg/t4163.check
+++ b/test/files/neg/t4163.check
@@ -1,7 +1,4 @@
-t4163.scala:4: error: '<-' expected but '=' found.
+t4163.scala:4: error: for comprehension must start with generator: '<-' expected but '=' found.
x = 3
^
-t4163.scala:5: error: illegal start of simple expression
- y <- 0 to 100
-^
-two errors found
+one error found
diff --git a/test/files/neg/t4417.check b/test/files/neg/t4417.check
index dbd0f1df46..dfc9feca24 100644
--- a/test/files/neg/t4417.check
+++ b/test/files/neg/t4417.check
@@ -3,5 +3,5 @@ t4417.scala:11: error: constructor Pixel$mcD$sp in class Pixel$mcD$sp cannot be
enclosing object Pixel is not a subclass of
class Pixel$mcD$sp where target is defined
def apply(v: Double): Pixel1d = new Pixel1d(v)
- ^
+ ^
one error found
diff --git a/test/files/neg/t4727.check b/test/files/neg/t4727.check
index a17cdde044..55d4d01b97 100644
--- a/test/files/neg/t4727.check
+++ b/test/files/neg/t4727.check
@@ -1,5 +1,5 @@
t4727.scala:5: error: an expression of type Null is ineligible for implicit conversion
Error occurred in an application involving default arguments.
new C[Int]
- ^
+ ^
one error found
diff --git a/test/files/neg/t4851.check b/test/files/neg/t4851.check
index 4f2919807e..6d0f424e82 100644
--- a/test/files/neg/t4851.check
+++ b/test/files/neg/t4851.check
@@ -3,19 +3,19 @@ S.scala:2: warning: Adapting argument list by inserting (): leaky (Object-receiv
given arguments: <none>
after adaptation: new J((): Unit)
val x1 = new J
- ^
+ ^
S.scala:3: warning: Adapting argument list by inserting (): leaky (Object-receiving) target makes this especially dangerous.
signature: J(x: Any): J
given arguments: <none>
after adaptation: new J((): Unit)
val x2 = new J()
- ^
+ ^
S.scala:4: warning: Adapting argument list by creating a 5-tuple: this may not be what you want.
signature: J(x: Any): J
given arguments: 1, 2, 3, 4, 5
after adaptation: new J((1, 2, 3, 4, 5): (Int, Int, Int, Int, Int))
val x3 = new J(1, 2, 3, 4, 5)
- ^
+ ^
S.scala:6: warning: Adapting argument list by creating a 3-tuple: this may not be what you want.
signature: Some.apply[A](x: A): Some[A]
given arguments: 1, 2, 3
@@ -27,19 +27,19 @@ S.scala:7: warning: Adapting argument list by creating a 3-tuple: this may not b
given arguments: 1, 2, 3
after adaptation: new Some((1, 2, 3): (Int, Int, Int))
val y2 = new Some(1, 2, 3)
- ^
+ ^
S.scala:9: warning: Adapting argument list by inserting (): this is unlikely to be what you want.
signature: J2[T](x: T): J2[T]
given arguments: <none>
after adaptation: new J2((): Unit)
val z1 = new J2
- ^
+ ^
S.scala:10: warning: Adapting argument list by inserting (): this is unlikely to be what you want.
signature: J2[T](x: T): J2[T]
given arguments: <none>
after adaptation: new J2((): Unit)
val z2 = new J2()
- ^
+ ^
S.scala:14: warning: Adapting argument list by creating a 3-tuple: this may not be what you want.
signature: Test.anyId(a: Any): Any
given arguments: 1, 2, 3
diff --git a/test/files/neg/t4987.check b/test/files/neg/t4987.check
index 8d7344d27b..ee058f0ac1 100644
--- a/test/files/neg/t4987.check
+++ b/test/files/neg/t4987.check
@@ -1,4 +1,4 @@
t4987.scala:2: error: constructor Foo2 in class Foo2 cannot be accessed in object Bar2
object Bar2 { new Foo2(0, 0) }
- ^
+ ^
one error found
diff --git a/test/files/neg/t5120.check b/test/files/neg/t5120.check
index 34d4ebde31..fc65ca16a5 100644
--- a/test/files/neg/t5120.check
+++ b/test/files/neg/t5120.check
@@ -2,11 +2,11 @@ t5120.scala:11: error: type mismatch;
found : Object
required: _1
List(str, other) foreach (_.x1 = new AnyRef)
- ^
+ ^
t5120.scala:25: error: type mismatch;
found : Thread
required: h.T
(which expands to) _2
List(str, num).foreach(h => h.f1 = new Thread())
- ^
+ ^
two errors found
diff --git a/test/files/neg/t5666.check b/test/files/neg/t5666.check
index 1c714796ba..da6b9d73e7 100644
--- a/test/files/neg/t5666.check
+++ b/test/files/neg/t5666.check
@@ -1,37 +1,37 @@
t5666.scala:2: error: class Any is abstract; cannot be instantiated
new Any
- ^
+ ^
t5666.scala:3: error: class AnyVal is abstract; cannot be instantiated
new AnyVal
- ^
+ ^
t5666.scala:4: error: class Double is abstract; cannot be instantiated
new Double
- ^
+ ^
t5666.scala:5: error: class Float is abstract; cannot be instantiated
new Float
- ^
+ ^
t5666.scala:6: error: class Long is abstract; cannot be instantiated
new Long
- ^
+ ^
t5666.scala:7: error: class Int is abstract; cannot be instantiated
new Int
- ^
+ ^
t5666.scala:8: error: class Char is abstract; cannot be instantiated
new Char
- ^
+ ^
t5666.scala:9: error: class Short is abstract; cannot be instantiated
new Short
- ^
+ ^
t5666.scala:10: error: class Byte is abstract; cannot be instantiated
new Byte
- ^
+ ^
t5666.scala:11: error: class Boolean is abstract; cannot be instantiated
new Boolean
- ^
+ ^
t5666.scala:12: error: class Unit is abstract; cannot be instantiated
new Unit
- ^
+ ^
t5666.scala:13: error: class Nothing is abstract; cannot be instantiated
new Nothing
- ^
+ ^
12 errors found
diff --git a/test/files/neg/t5761.check b/test/files/neg/t5761.check
index 89d766fe34..8086af2fcf 100644
--- a/test/files/neg/t5761.check
+++ b/test/files/neg/t5761.check
@@ -5,7 +5,7 @@ Unspecified value parameter x.
t5761.scala:8: error: not enough arguments for constructor D: (x: Int)D[Int].
Unspecified value parameter x.
println(new D[Int]()) // no crash
- ^
+ ^
t5761.scala:9: error: not enough arguments for constructor D: (x: Int)D[Int].
Unspecified value parameter x.
println(new D[Int]{}) // crash
diff --git a/test/files/neg/t5803.check b/test/files/neg/t5803.check
index 6a2de2e1df..c4f901e511 100644
--- a/test/files/neg/t5803.check
+++ b/test/files/neg/t5803.check
@@ -1,4 +1,4 @@
t5803.scala:3: error: could not find implicit value for parameter ev: Nothing
new Foo(): String
- ^
+ ^
one error found
diff --git a/test/files/neg/t6074.check b/test/files/neg/t6074.check
index 38670e5b3d..6abf5e2906 100644
--- a/test/files/neg/t6074.check
+++ b/test/files/neg/t6074.check
@@ -1,4 +1,4 @@
t6074.scala:5: error: constructor A in class A cannot be accessed in object T
def t = new A()
- ^
+ ^
one error found
diff --git a/test/files/neg/t6601.check b/test/files/neg/t6601.check
index 1410e1b11a..b05c67ad9a 100644
--- a/test/files/neg/t6601.check
+++ b/test/files/neg/t6601.check
@@ -1,4 +1,4 @@
AccessPrivateConstructor_2.scala:2: error: constructor PrivateConstructor in class PrivateConstructor cannot be accessed in class AccessPrivateConstructor
new PrivateConstructor("") // Scalac should forbid accessing to the private constructor!
- ^
+ ^
one error found
diff --git a/test/files/neg/t6667b.check b/test/files/neg/t6667b.check
index 99cea9a47c..a8705fa1c2 100644
--- a/test/files/neg/t6667b.check
+++ b/test/files/neg/t6667b.check
@@ -3,11 +3,11 @@ t6667b.scala:16: error: ambiguous implicit values:
and value b of type Test.Box
match expected type Test.Box
new Test()
- ^
+ ^
t6667b.scala:19: error: ambiguous implicit values:
both value a in object Test of type => Test.Box
and value b of type Test.Box
match expected type Test.Box
new Test()
- ^
+ ^
two errors found
diff --git a/test/files/neg/t7385.check b/test/files/neg/t7385.check
index 70d3c3fb61..c196ec0b4f 100644
--- a/test/files/neg/t7385.check
+++ b/test/files/neg/t7385.check
@@ -1,10 +1,7 @@
-t7385.scala:2: error: '(' expected but identifier found.
+t7385.scala:2: error: parenthesized conditional expression expected
do { println("bippy") } while i<10
^
-t7385.scala:6: error: '(' expected but identifier found.
+t7385.scala:6: error: parenthesized conditional expression expected
while i<10 { () }
^
-t7385.scala:7: error: illegal start of simple expression
-}
-^
-three errors found
+two errors found
diff --git a/test/files/neg/t7473.check b/test/files/neg/t7473.check
index 488baef94e..c686466a44 100644
--- a/test/files/neg/t7473.check
+++ b/test/files/neg/t7473.check
@@ -1,13 +1,7 @@
-t7473.scala:5: error: '<-' expected but '=' found.
+t7473.scala:5: error: for comprehension must start with generator: '<-' expected but '=' found.
for (x = Option(i); if x == j) yield 42 //t7473.scala:4: error: '<-' expected but '=' found.
^
-t7473.scala:5: error: illegal start of simple expression
- for (x = Option(i); if x == j) yield 42 //t7473.scala:4: error: '<-' expected but '=' found.
- ^
-t7473.scala:8: error: '<-' expected but '=' found.
+t7473.scala:8: error: for comprehension must start with generator: '<-' expected but '=' found.
(for (x = Option(i); if x == j) yield 42) toList
^
-t7473.scala:8: error: illegal start of simple expression
- (for (x = Option(i); if x == j) yield 42) toList
- ^
-four errors found
+two errors found
diff --git a/test/files/neg/t771.check b/test/files/neg/t771.check
index c0d1e002f8..51b0c97f8c 100644
--- a/test/files/neg/t771.check
+++ b/test/files/neg/t771.check
@@ -1,4 +1,4 @@
t771.scala:4: error: trait Iterator is abstract; cannot be instantiated
def c[A](it:java.util.Iterator[A]) = new scala.Iterator[A]
- ^
+ ^
one error found
diff --git a/test/files/pos/t7854.scala b/test/files/pos/t7854.scala
new file mode 100644
index 0000000000..d4de7dfe38
--- /dev/null
+++ b/test/files/pos/t7854.scala
@@ -0,0 +1,5 @@
+class A {
+ var f: Int => Unit = _ => ()
+
+ f = null
+}
diff --git a/test/files/run/existential-rangepos.check b/test/files/run/existential-rangepos.check
index 6c4e86dedc..f426c6471f 100644
--- a/test/files/run/existential-rangepos.check
+++ b/test/files/run/existential-rangepos.check
@@ -5,9 +5,9 @@
[76][76][76]A.super.<init>();
[20]()
};
- [28/24:51]private[this] val foo: [28]Set[_ <: T] = [47:51]null;
+ [28:51]private[this] val foo: [28]Set[_ <: T] = [47:51]null;
[28]<stable> <accessor> def foo: [28]Set[_ <: T] = [28][28]A.this.foo;
- [58/54:74]<stable> <accessor> def bar: [58]Set[_ <: T]
+ [58:74]<stable> <accessor> def bar: [58]Set[_ <: T]
}
}
diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check
index 255e9356b9..46fcdd4470 100644
--- a/test/files/run/t5603.check
+++ b/test/files/run/t5603.check
@@ -4,18 +4,18 @@
[15]def $init$() = [15]{
[15]()
};
- [27/23:39]val name: [33:39]String;
- [50/46:76]val msg = [71/56:76][71/56:72][56:71]"How are you, ".$plus([72:76]name)
+ [27:39]val name: [33:39]String;
+ [50:76]val msg = [71/56:76][71/56:72][56:71]"How are you, ".$plus([72:76]name)
};
[93/87:209]class C extends [94:209][151:159]Greeting {
- [123/119:139]val nameElse = _;
+ [123:139]val nameElse = _;
[95:101]<paramaccessor> private[this] val i: [98:101]Int = _;
- <119:139>def <init>([95]i: [98]Int) = <119:139>{
- <119:139>val nameElse = <134:139>"Bob";
+ <123:139>def <init>([95]i: [98]Int) = <123:139>{
+ <123:139>val nameElse = <134:139>"Bob";
[X][X][X]super.<init>();
[94]()
};
- [172/168:184]val name = [179:184]"avc";
+ [172:184]val name = [179:184]"avc";
[198/191:203][191:198]println([199:202]msg)
};
[222/215:241]object Test extends [227:241][235:238]App {
diff --git a/test/files/run/t6768.check b/test/files/run/t6768.check
index bf4f6ea2a1..64df4568ec 100644
--- a/test/files/run/t6768.check
+++ b/test/files/run/t6768.check
@@ -6,7 +6,7 @@
[9]()
};
[17/13:31]def f1: [17]Some[String] = [26/22:31][22:26][22:26]scala.Some.apply[[22]String]([27:30]"a");
- [38/34:56]def f2: [38]Some[String] = [43:56][43/47:51][43/47:51]new [47:51]<type: [47:51]scala.Some>([52:55]"b")
+ [38/34:56]def f2: [38]Some[String] = [47/43:56][47:51][47:51]new [47:51]<type: [47:51]scala.Some>([52:55]"b")
}
}