diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 84a531c96c38..b442e5ef9fa8 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -65,8 +65,6 @@ trait Trees extends scala.reflect.internal.Trees { self: Global => } } - class PostfixSelect(qual: Tree, name: Name) extends Select(qual, name) - /** emitted by typer, eliminated by refchecks */ case class TypeTreeWithDeferredRefCheck()(val check: () => TypeTree) extends TypTree { override def transform(transformer: ApiTransformer): Tree = diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index 5825fa3ec7fd..5efd9e7251ed 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -171,8 +171,7 @@ trait MarkupParsers { xTakeUntil(handle.charData, () => r2p(start, mid, curOffset), "]]>") } - def xUnparsed: Tree = { - val start = curOffset + def xUnparsed(start: Int): Tree = { xTakeUntil(handle.unparsed, () => r2p(start, start, curOffset), "") } @@ -305,7 +304,7 @@ trait MarkupParsers { * | xmlTag1 '/' '>' */ def element: Tree = { - val start = curOffset + val start = curOffset - 1 // include < val (qname, attrMap) = xTag(()) if (ch == '/') { // empty element xToken("/>") @@ -314,7 +313,7 @@ trait MarkupParsers { else { // handle content xToken('>') if (qname == "xml:unparsed") - return xUnparsed + return xUnparsed(start) debugLastStartElement.push((start, qname)) val ts = content @@ -382,7 +381,7 @@ trait MarkupParsers { handle.isPattern = false val ts = new ArrayBuffer[Tree] - val start = curOffset + val start = curOffset - 1 // include < content_LT(ts) // parse more XML? @@ -446,7 +445,7 @@ trait MarkupParsers { * | Name [S] '/' '>' */ def xPattern: Tree = { - val start = curOffset + val start = curOffset - 1 // include < val qname = xName debugLastStartElement.push((start, qname)) xSpaceOpt() diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 8357a3330b1b..930d6ba85b1e 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -917,7 +917,7 @@ self => case _ => right :: Nil } def mkApply(fun: Tree, args: List[Tree]) = { - val apply = Apply(fun, args) + val apply = Apply(fun, args).updateAttachment(InfixAttachment) if (isMultiarg) apply.updateAttachment(MultiargInfixAttachment) apply } @@ -1301,12 +1301,12 @@ self => def identOrMacro(): Name = if (isMacro) rawIdent() else ident() - def selector(t0: Tree): Tree = { + def selector(start: Offset, t0: Tree): Tree = { val t = stripParens(t0) val point = if (isIdent) in.offset else in.lastOffset //scala/bug#8459 //assert(t.pos.isDefined, t) if (t != EmptyTree) - Select(t, ident(skipIt = false)) setPos r2p(t0.pos.start, point, in.lastOffset) + Select(t, ident(skipIt = false)) setPos r2p(start, point, in.lastOffset) else errorTermTree // has already been reported } @@ -1324,14 +1324,14 @@ self => in.nextToken() t = atPos(start) { This(tpnme.EMPTY) } if (!thisOK || in.token == DOT) { - t = selectors(t, typeOK, accept(DOT)) + t = selectors(start, t, typeOK, accept(DOT)) } } else if (in.token == SUPER) { in.nextToken() t = atPos(start) { Super(This(tpnme.EMPTY), mixinQualifierOpt()) } accept(DOT) - t = selector(t) - if (in.token == DOT) t = selectors(t, typeOK, in.skipToken()) + t = selector(start, t) + if (in.token == DOT) t = selectors(start, t, typeOK, in.skipToken()) } else { val tok = in.token val name = ident() @@ -1345,16 +1345,16 @@ self => in.nextToken() t = atPos(start) { This(name.toTypeName) } if (!thisOK || in.token == DOT) - t = selectors(t, typeOK, accept(DOT)) + t = selectors(start, t, typeOK, accept(DOT)) } else if (in.token == SUPER) { in.nextToken() t = atPos(start) { Super(This(name.toTypeName), mixinQualifierOpt()) } accept(DOT) - t = selector(t) - if (in.token == DOT) t = selectors(t, typeOK, in.skipToken()) + t = selector(start, t) + if (in.token == DOT) t = selectors(start, t, typeOK, in.skipToken()) } else { if (name == nme.ROOTPKG) t.updateAttachment(RootSelection) - t = selectors(t, typeOK, dotOffset) + t = selectors(start, t, typeOK, dotOffset) } } } @@ -1362,14 +1362,14 @@ self => } @tailrec - final def selectors(t: Tree, typeOK: Boolean, dotOffset: Offset): Tree = + final def selectors(start: Offset, t: Tree, typeOK: Boolean, dotOffset: Offset): Tree = if (typeOK && in.token == TYPE) { in.nextToken() atPos(t.pos.start, dotOffset) { SingletonTypeTree(t) } } else { - val t1 = selector(t) - if (in.token == DOT) { selectors(t1, typeOK, in.skipToken()) } + val t1 = selector(start, t) + if (in.token == DOT) { selectors(start, t1, typeOK, in.skipToken()) } else t1 } @@ -1399,7 +1399,7 @@ self => val id = atPos(start) { Ident(ident()) } if (in.token == DOT) { if (id.name == nme.ROOTPKG) id.updateAttachment(RootSelection) - selectors(id, typeOK = false, in.skipToken()) + selectors(start, id, typeOK = false, in.skipToken()) } else id } @@ -1813,20 +1813,21 @@ self => * }}} */ def prefixExpr(): Tree = - if (isUnaryOp) - atPos(in.offset) { + if (isUnaryOp) { + val start = in.offset + atPos(start) { if (lookingAhead(isExprIntro)) { val namePos = in.offset val uname = nme.toUnaryName(rawIdent().toTermName) if (uname == nme.UNARY_- && isNumericLit) // start at the -, not the number - simpleExprRest(literal(isNegated = true, start = namePos), canApply = true) + simpleExprRest(start, literal(isNegated = true, start = namePos), canApply = true) else Select(stripParens(simpleExpr()), uname) } else simpleExpr() } - else simpleExpr() + } else simpleExpr() def xmlLiteral(): Tree @@ -1845,6 +1846,7 @@ self => */ def simpleExpr(): Tree = { var canApply = true + val start = in.offset val t = if (isLiteral) literal() else in.token match { @@ -1870,16 +1872,16 @@ self => case _ => syntaxErrorOrIncompleteAnd("illegal start of simple expression", skipIt = true)(errorTermTree) } - simpleExprRest(t, canApply = canApply) + simpleExprRest(start, t, canApply = canApply) } @tailrec - final def simpleExprRest(t: Tree, canApply: Boolean): Tree = { + final def simpleExprRest(start: Offset, t: Tree, canApply: Boolean): Tree = { if (canApply) newLineOptWhenFollowedBy(LBRACE) in.token match { case DOT => in.nextToken() - simpleExprRest(selector(t), canApply = true) + simpleExprRest(start, selector(start, t), canApply = true) case LBRACKET => val t1 = stripParens(t) t1 match { @@ -1888,7 +1890,7 @@ self => while (in.token == LBRACKET) app = atPos(t.pos.start, in.offset)(TypeApply(app, exprTypeArgs())) - simpleExprRest(app, canApply = true) + simpleExprRest(start, app, canApply = true) case _ => t1 } @@ -1904,7 +1906,7 @@ self => } Apply(sel, argumentExprs()) } - simpleExprRest(app, canApply = true) + simpleExprRest(start, app, canApply = true) case USCORE => atPos(t.pos.start, in.skipToken()) { MethodValue(stripParens(t)) } case _ => @@ -1938,9 +1940,14 @@ self => * }}} */ def blockExpr(): Tree = atPos(in.offset) { + val start = in.offset inBraces { if (in.token == CASE) Match(EmptyTree, caseClauses()) else block() + } match { + case b: Block if b.pos == NoPosition => + b.setPos(r2p(start, start, in.lastOffset)) + case t => t } } @@ -2661,7 +2668,7 @@ self => in.nextToken() val t = atPos(start)(This(name)) accept(DOT) - val result = selector(t) + val result = selector(start, t) accept(DOT) result } diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala index d23d0d97ab58..a96034ffbc43 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala @@ -179,7 +179,7 @@ abstract class SymbolicXMLBuilder(p: Parsers#Parser, preserveWS: Boolean) { val buffer = ValDef(NoMods, _buf, TypeTree(), New(_scala_xml_NodeBuffer, ListOfNil)) val applies = args filterNot isEmptyText map (t => Apply(Select(Ident(_buf), _plus), List(t))) - atPos(pos)( Block(buffer :: applies.toList, Ident(_buf)) ) + atPos(pos)( gen.mkBlock(buffer :: applies.toList ::: List(Ident(_buf))) ) } /** Returns (Some(prefix) | None, rest) based on position of ':' */ @@ -271,6 +271,6 @@ abstract class SymbolicXMLBuilder(p: Parsers#Parser, preserveWS: Boolean) { args ) - atPos(pos.makeTransparent)( Block(nsResult, Block(attrResult, body)) ) + atPos(pos.makeTransparent)( gen.mkBlock(nsResult :+ gen.mkBlock(attrResult :+ body)) ) } } diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index eb329f8b3cdc..3fb66b334c6d 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -57,7 +57,7 @@ abstract class TreeBuilder { /** Tree for `od op`, start is start0 if od.pos is borked. */ def makePostfixSelect(start: Int, end: Int, od: Tree, op: Name): Tree = { - atPos(r2p(start, end, end + op.length)) { new PostfixSelect(od, op.encode) } + atPos(r2p(start, end, end + op.length)) { Select(od, op.encode) }.updateAttachment(PostfixAttachment) } /** Create tree representing a while loop */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 97d78749730c..456f6a3ac217 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -967,8 +967,11 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper } if (!meth.isConstructor && checkCanEtaExpand()) typedEtaExpansion(tree, mode, pt) - else if (arity == 0 && checkCanAutoApply()) adapt(typed(Apply(tree, Nil) setPos tree.pos), mode, pt, original) - else + else if (arity == 0 && checkCanAutoApply()) { + val apply = Apply(tree, Nil) setPos tree.pos + if (tree.hasAttachment[PostfixAttachment.type]) apply.updateAttachment(InfixAttachment) + adapt(typed(apply), mode, pt, original) + } else if (context.implicitsEnabled) MissingArgsForMethodTpeError(tree, meth) // `context.implicitsEnabled` implies we are not in a pattern else UnstableTreeError(tree) } @@ -5426,7 +5429,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper val qualTyped = checkDead(context, typedQualifier(qual, mode)) val tree1 = typedSelect(tree, qualTyped, name) - if (tree.isInstanceOf[PostfixSelect]) + if (tree.hasAttachment[PostfixAttachment.type]) checkFeature(tree.pos, currentRun.runDefinitions.PostfixOpsFeature, name.decode) val sym = tree1.symbol if (sym != null && sym.isOnlyRefinementMember && !sym.isMacro) diff --git a/src/reflect/scala/reflect/internal/StdAttachments.scala b/src/reflect/scala/reflect/internal/StdAttachments.scala index 4cb68fa65322..2b622e603e9f 100644 --- a/src/reflect/scala/reflect/internal/StdAttachments.scala +++ b/src/reflect/scala/reflect/internal/StdAttachments.scala @@ -73,6 +73,11 @@ trait StdAttachments { */ case object BackquotedIdentifierAttachment extends PlainAttachment + /** Indicates that a selection was postfix (on Select tree) */ + case object PostfixAttachment extends PlainAttachment + /** Indicates that a application was infix (on Apply tree) */ + case object InfixAttachment extends PlainAttachment + /** A pattern binding exempt from unused warning. * * Its host `Ident` has been created from a pattern2 binding, `case x @ p`. diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala index 61108d372dde..1f37378fce71 100644 --- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala +++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala @@ -56,6 +56,8 @@ trait JavaUniverseForce { self: runtime.JavaUniverse => this.SAMFunction this.DelambdafyTarget this.BackquotedIdentifierAttachment + this.PostfixAttachment + this.InfixAttachment this.NoWarnAttachment this.PatVarDefAttachment this.ForAttachment diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala index 099220d7cf4c..d3755f22f6da 100644 --- a/src/repl/scala/tools/nsc/interpreter/IMain.scala +++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala @@ -1234,7 +1234,7 @@ class IMain(val settings: Settings, parentClassLoaderOverride: Option[ClassLoade // This is really just trying to make the 100 or so implicits imported // by default into something readable. val memberGroups: List[List[Symbol]] = { - val groups = members groupBy (_.tpe.finalResultType) toList + val groups = members.groupBy(_.tpe.finalResultType).toList val (big, small) = groups partition (_._2.size > 3) val xss = ( (big sortBy (_._1.toString) map (_._2)) :+ diff --git a/test/files/neg/t2275a.check b/test/files/neg/t2275a.check index d3c429f5cb5b..3d434abd579b 100644 --- a/test/files/neg/t2275a.check +++ b/test/files/neg/t2275a.check @@ -3,7 +3,7 @@ t2275a.scala:4: error: in XML literal: in XML content, please use '}}' to expres ^ t2275a.scala:3: error: I encountered a '}' where I didn't expect one, maybe this tag isn't closed

- ^ + ^ t2275a.scala:4: error: ';' expected but 'else' found. }else{ ^ diff --git a/test/files/neg/t2275b.check b/test/files/neg/t2275b.check index 00fc8976d685..a16f0ae3836a 100644 --- a/test/files/neg/t2275b.check +++ b/test/files/neg/t2275b.check @@ -3,7 +3,7 @@ t2275b.scala:2: error: in XML literal: in XML content, please use '}}' to expres ^ t2275b.scala:2: error: I encountered a '}' where I didn't expect one, maybe this tag isn't closed
{
}xx - ^ + ^ t2275b.scala:3: error: '}' expected but eof found. } ^ diff --git a/test/files/neg/t3604.check b/test/files/neg/t3604.check index c6dbcd8863ca..8ae7921c4b07 100644 --- a/test/files/neg/t3604.check +++ b/test/files/neg/t3604.check @@ -3,5 +3,5 @@ t3604.scala:3: error: in XML literal: expected closing tag of abbr ^ t3604.scala:3: error: start tag was here: abbr> - ^ + ^ 2 errors diff --git a/test/files/neg/t3769.check b/test/files/neg/t3769.check index 7d9e30210be5..62b035d59443 100644 --- a/test/files/neg/t3769.check +++ b/test/files/neg/t3769.check @@ -3,5 +3,5 @@ t3769.scala:2: error: in XML literal: expected closing tag of a ^ t3769.scala:2: error: start tag was here: a> val x = {"text"} - ^ + ^ 2 errors diff --git a/test/files/neg/t4069.check b/test/files/neg/t4069.check index f010eff91ad2..bc55b17f89b3 100644 --- a/test/files/neg/t4069.check +++ b/test/files/neg/t4069.check @@ -9,7 +9,7 @@ t4069.scala:9: error: in XML literal: in XML content, please use '}}' to express ^ t4069.scala:4: error: I encountered a '}' where I didn't expect one, maybe this tag isn't closed
- ^ + ^ t4069.scala:10: error: '}' expected but eof found. } ^ diff --git a/test/files/neg/t5702-neg-ugly-xbrace.check b/test/files/neg/t5702-neg-ugly-xbrace.check index 768bff0f4155..7231bcf902a3 100644 --- a/test/files/neg/t5702-neg-ugly-xbrace.check +++ b/test/files/neg/t5702-neg-ugly-xbrace.check @@ -9,7 +9,7 @@ t5702-neg-ugly-xbrace.scala:13: error: in XML literal: in XML content, please us ^ t5702-neg-ugly-xbrace.scala:11: error: I encountered a '}' where I didn't expect one, maybe this tag isn't closed val {a, z@_*) = xml - ^ + ^ t5702-neg-ugly-xbrace.scala:14: error: illegal start of simple pattern } ^ diff --git a/test/files/neg/xmltruncated7.check b/test/files/neg/xmltruncated7.check index c8d72a686775..85b919c9a604 100644 --- a/test/files/neg/xmltruncated7.check +++ b/test/files/neg/xmltruncated7.check @@ -3,5 +3,5 @@ xmltruncated7.scala:2: error: in XML literal: in XML content, please use '}}' to ^ xmltruncated7.scala:2: error: I encountered a '}' where I didn't expect one, maybe this tag isn't closed

foo}:

- ^ + ^ 2 errors diff --git a/test/files/run/infixPostfixAttachments.check b/test/files/run/infixPostfixAttachments.check new file mode 100644 index 000000000000..a4842a4a25e2 --- /dev/null +++ b/test/files/run/infixPostfixAttachments.check @@ -0,0 +1,17 @@ +newSource1.scala:15: warning: Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method d, +or remove the empty argument list from its definition (Java-defined methods are exempt). +In Scala 3, an unapplied method like this will be eta-expanded into a function. + def t6 = this d + ^ +newSource1.scala:16: warning: Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method d, +or remove the empty argument list from its definition (Java-defined methods are exempt). +In Scala 3, an unapplied method like this will be eta-expanded into a function. + def t7 = this.d + ^ +t1 this.a(0) List(InfixAttachment) +t2 this.b(scala.Tuple2.apply[Int, Int](1, 2)).b(scala.Tuple2.apply[Int, Int](1, 2)).c(1, 2) List(InfixAttachment, MultiargInfixAttachment) +t2 this.b(scala.Tuple2.apply[Int, Int](1, 2)).b(scala.Tuple2.apply[Int, Int](1, 2)) List(InfixAttachment) +t2 this.b(scala.Tuple2.apply[Int, Int](1, 2)) List(InfixAttachment) +t6 this.d() List(InfixAttachment) +t6 this.d List(PostfixAttachment) +t8 this.e List(PostfixAttachment) diff --git a/test/files/run/infixPostfixAttachments.scala b/test/files/run/infixPostfixAttachments.scala new file mode 100644 index 000000000000..a5505a456b5b --- /dev/null +++ b/test/files/run/infixPostfixAttachments.scala @@ -0,0 +1,37 @@ +import scala.tools.partest._ + +object Test extends CompilerTest { + import global._ + override def extraSettings = super.extraSettings + " -Yrangepos -Ystop-after:typer -deprecation" + + override def code = + """class C { + | import scala.language.postfixOps + | + | def a(x: Any) = this + | def b(x: (Any, Any)) = this + | def c(x: Any, y: Any) = this + | def d() = this + | def e = this + | + | def t1 = this a 0 + | def t2 = this b (1, 2) b ((1, 2)) c (1, 2) + | def t3 = this.b(1, 2).b((1, 2)).c(1, 2) + | // def t4 = this d () // not allowed in 2.13 + | def t5 = this.d() + | def t6 = this d + | def t7 = this.d + | def t8 = this e + | def t9 = this.e + |} + |""".stripMargin + + def check(source: String, unit: CompilationUnit): Unit = unit.body foreach { + case dd: DefDef if dd.name.startsWith("t") => + dd.rhs.foreach(t => { + if (!t.attachments.isEmpty) + println(s"${dd.symbol.name} $t ${t.attachments.all.toList.sortBy(_.toString)}") + }) + case _ => + } +} diff --git a/test/files/run/t12597.check b/test/files/run/t12597.check new file mode 100644 index 000000000000..59f68a938017 --- /dev/null +++ b/test/files/run/t12597.check @@ -0,0 +1,10 @@ +List((26,30)) +List((26,33)) +List((26,42), (26,33)) +List((26,44), (27,34)) +List((26,46), (28,35)) +List((26,37), (26,26), (26,33), (33,37)) +List((26,46), (26,37), (26,26), (26,33), (33,37)) +List((26,36), (26,27)) +List((26,36), (26,27)) +List((26,51), (26,42), (28,37), (36,37), (39,40)) diff --git a/test/files/run/t12597.scala b/test/files/run/t12597.scala new file mode 100644 index 000000000000..f3e75da8e848 --- /dev/null +++ b/test/files/run/t12597.scala @@ -0,0 +1,31 @@ +import scala.tools.partest._ +import scala.collection.mutable.LinkedHashMap + +object Test extends CompilerTest { + import global._ + override def extraSettings = super.extraSettings + " -Yrangepos -Ystop-after:parser" + val tests = List( + "class A1 { def t =
}", + "class A2 { def t = }", + "class A3 { def t = .toString }", + "class A4 { def t = ().toString }", + "class A5 { def t = { }.toString }", + "class A6 { def t = }", + "class A7 { def t = .toString }", + "class B1 { def t(c: A1) = c.toString }", + "class B2 { def t(c: A1) = c toString }", + "class B3 { def t(c: A1) = { val x = c; x }.toString }", + // ^ 26 ^ 36 + ) + + override def sources = tests + + def check(source: String, unit: CompilationUnit): Unit = unit.body foreach { + case dd: DefDef if dd.name.startsWith("t") => + val poss = dd.rhs.collect { + case t if t.pos != NoPosition => (t.pos.start, t.pos.end) + }.distinct + println(poss) + case _ => + } +} diff --git a/test/files/run/t3368-b.check b/test/files/run/t3368-b.check index 4cbe98c577f5..8a079eae516e 100644 --- a/test/files/run/t3368-b.check +++ b/test/files/run/t3368-b.check @@ -15,34 +15,18 @@ package { def $init$() = { () }; - def y = { - { - new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, false, ({ - val $buf = new _root_.scala.xml.NodeBuffer(); - $buf.$amp$plus({ - { - new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true) - } - }); - $buf.$amp$plus(new _root_.scala.xml.Text("start")); - $buf.$amp$plus(new _root_.scala.xml.PCData("hi & bye")); - $buf.$amp$plus({ - { - new _root_.scala.xml.Elem(null, "c", _root_.scala.xml.Null, $scope, true) - } - }); - $buf.$amp$plus(new _root_.scala.xml.Text("world")); - $buf.$amp$plus({ - { - new _root_.scala.xml.Elem(null, "d", _root_.scala.xml.Null, $scope, true) - } - }); - $buf.$amp$plus(new _root_.scala.xml.Text("stuff")); - $buf.$amp$plus(new _root_.scala.xml.PCData("red & black")); - $buf - }: _*)) - } - } + def y = new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, false, ({ + val $buf = new _root_.scala.xml.NodeBuffer(); + $buf.$amp$plus(new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true)); + $buf.$amp$plus(new _root_.scala.xml.Text("start")); + $buf.$amp$plus(new _root_.scala.xml.PCData("hi & bye")); + $buf.$amp$plus(new _root_.scala.xml.Elem(null, "c", _root_.scala.xml.Null, $scope, true)); + $buf.$amp$plus(new _root_.scala.xml.Text("world")); + $buf.$amp$plus(new _root_.scala.xml.Elem(null, "d", _root_.scala.xml.Null, $scope, true)); + $buf.$amp$plus(new _root_.scala.xml.Text("stuff")); + $buf.$amp$plus(new _root_.scala.xml.PCData("red & black")); + $buf + }: _*)) }; abstract trait Z extends scala.AnyRef { def $init$() = { @@ -55,35 +39,23 @@ package { $buf.$amp$plus(new _root_.scala.xml.PCData("hello, world")); $buf }; - def f = { - { - new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ - val $buf = new _root_.scala.xml.NodeBuffer(); - $buf.$amp$plus(new _root_.scala.xml.Text("x")); - $buf.$amp$plus(new _root_.scala.xml.PCData("hello, world")); - $buf - }: _*)) - } - }; - def g = { - { - new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ - val $buf = new _root_.scala.xml.NodeBuffer(); - $buf.$amp$plus(new _root_.scala.xml.PCData("hello, world")); - $buf - }: _*)) - } - }; - def h = { - { - new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ - val $buf = new _root_.scala.xml.NodeBuffer(); - $buf.$amp$plus(new _root_.scala.xml.PCData("hello, world")); - $buf.$amp$plus(new _root_.scala.xml.PCData("hello, world")); - $buf - }: _*)) - } - } + def f = new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ + val $buf = new _root_.scala.xml.NodeBuffer(); + $buf.$amp$plus(new _root_.scala.xml.Text("x")); + $buf.$amp$plus(new _root_.scala.xml.PCData("hello, world")); + $buf + }: _*)); + def g = new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ + val $buf = new _root_.scala.xml.NodeBuffer(); + $buf.$amp$plus(new _root_.scala.xml.PCData("hello, world")); + $buf + }: _*)); + def h = new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ + val $buf = new _root_.scala.xml.NodeBuffer(); + $buf.$amp$plus(new _root_.scala.xml.PCData("hello, world")); + $buf.$amp$plus(new _root_.scala.xml.PCData("hello, world")); + $buf + }: _*)) } } diff --git a/test/files/run/t3368.check b/test/files/run/t3368.check index e0c10cc0ddb2..ee95d0242798 100644 --- a/test/files/run/t3368.check +++ b/test/files/run/t3368.check @@ -15,32 +15,16 @@ package { def $init$() = { () }; - def y = { - { - new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, false, ({ - val $buf = new _root_.scala.xml.NodeBuffer(); - $buf.$amp$plus({ - { - new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true) - } - }); - $buf.$amp$plus(new _root_.scala.xml.Text("starthi & bye")); - $buf.$amp$plus({ - { - new _root_.scala.xml.Elem(null, "c", _root_.scala.xml.Null, $scope, true) - } - }); - $buf.$amp$plus(new _root_.scala.xml.Text("world")); - $buf.$amp$plus({ - { - new _root_.scala.xml.Elem(null, "d", _root_.scala.xml.Null, $scope, true) - } - }); - $buf.$amp$plus(new _root_.scala.xml.Text("stuffred & black")); - $buf - }: _*)) - } - } + def y = new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, false, ({ + val $buf = new _root_.scala.xml.NodeBuffer(); + $buf.$amp$plus(new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true)); + $buf.$amp$plus(new _root_.scala.xml.Text("starthi & bye")); + $buf.$amp$plus(new _root_.scala.xml.Elem(null, "c", _root_.scala.xml.Null, $scope, true)); + $buf.$amp$plus(new _root_.scala.xml.Text("world")); + $buf.$amp$plus(new _root_.scala.xml.Elem(null, "d", _root_.scala.xml.Null, $scope, true)); + $buf.$amp$plus(new _root_.scala.xml.Text("stuffred & black")); + $buf + }: _*)) }; abstract trait Z extends scala.AnyRef { def $init$() = { @@ -53,33 +37,21 @@ package { $buf.$amp$plus(new _root_.scala.xml.Text("hello, world")); $buf }; - def f = { - { - new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ - val $buf = new _root_.scala.xml.NodeBuffer(); - $buf.$amp$plus(new _root_.scala.xml.Text("xhello, world")); - $buf - }: _*)) - } - }; - def g = { - { - new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ - val $buf = new _root_.scala.xml.NodeBuffer(); - $buf.$amp$plus(new _root_.scala.xml.Text("hello, world")); - $buf - }: _*)) - } - }; - def h = { - { - new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ - val $buf = new _root_.scala.xml.NodeBuffer(); - $buf.$amp$plus(new _root_.scala.xml.Text("hello, worldhello, world")); - $buf - }: _*)) - } - } + def f = new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ + val $buf = new _root_.scala.xml.NodeBuffer(); + $buf.$amp$plus(new _root_.scala.xml.Text("xhello, world")); + $buf + }: _*)); + def g = new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ + val $buf = new _root_.scala.xml.NodeBuffer(); + $buf.$amp$plus(new _root_.scala.xml.Text("hello, world")); + $buf + }: _*)); + def h = new _root_.scala.xml.Elem(null, "foo", _root_.scala.xml.Null, $scope, false, ({ + val $buf = new _root_.scala.xml.NodeBuffer(); + $buf.$amp$plus(new _root_.scala.xml.Text("hello, worldhello, world")); + $buf + }: _*)) } } diff --git a/test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala b/test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala index 48b8b7f1647f..6404ba5f8ca6 100644 --- a/test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala +++ b/test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala @@ -24,7 +24,7 @@ object Delambdafy { } println(result) lazy val _foo = foo(result) { - case x :: xs if x isDefined => x.get.length + case x :: xs if x.isDefined => x.get.length case _ => 0 } println(_foo) diff --git a/test/scalacheck/redblacktree.scala b/test/scalacheck/redblacktree.scala index 02c7597548b3..328da422cc5c 100644 --- a/test/scalacheck/redblacktree.scala +++ b/test/scalacheck/redblacktree.scala @@ -202,8 +202,8 @@ object TestRange extends RedBlackTreeTest("RedBlackTree.range") { property("range boundaries respected") = forAll(genInput) { case (tree, parm, newTree) => val from = parm._1 flatMap (nodeAt(tree, _) map (_._1)) val to = parm._2 flatMap (nodeAt(tree, _) map (_._1)) - ("lower boundary" |: (from forall ( key => keysIterator(newTree) forall (key <=)))) && - ("upper boundary" |: (to forall ( key => keysIterator(newTree) forall (key >)))) + ("lower boundary" |: (from forall ( key => keysIterator(newTree) forall (key.<=)))) && + ("upper boundary" |: (to forall ( key => keysIterator(newTree) forall (key.>)))) } property("range returns all elements") = forAll(genInput) { case (tree, parm, newTree) =>