From 217e8dcbcaabca3a3498163b84b3a8bf2cc898d3 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 28 Jan 2021 11:22:42 +0100 Subject: [PATCH 1/7] Use p* for vararg patterns --- .../dotty/tools/dotc/parsing/Parsers.scala | 47 +++++++++---------- .../tools/dotc/printing/RefinedPrinter.scala | 18 +++++-- docs/docs/internals/syntax.md | 4 +- docs/docs/reference/syntax.md | 6 +-- tests/invalid/pos/t3577.scala | 32 ------------- tests/neg/t5702-neg-bad-and-wild.scala | 10 ++-- tests/{neg-strict => pos}/i1059.scala | 0 tests/pos/t3577.scala | 12 +++++ 8 files changed, 58 insertions(+), 71 deletions(-) delete mode 100644 tests/invalid/pos/t3577.scala rename tests/{neg-strict => pos}/i1059.scala (100%) create mode 100644 tests/pos/t3577.scala diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index f299d73758a1..2d422eb2b957 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1524,7 +1524,7 @@ object Parsers { /** Is current ident a `*`, and is it followed by a `)` or `,`? */ def isPostfixStar: Boolean = - in.name == nme.raw.STAR && { + in.isIdent(nme.raw.STAR) && { val nxt = in.lookahead.token nxt == RPAREN || nxt == COMMA } @@ -2610,37 +2610,43 @@ object Parsers { ascription(p, location) else p - /** Pattern2 ::= [id `as'] InfixPattern + /** Pattern2 ::= InfixPattern [‘*’] */ - val pattern2: () => Tree = () => infixPattern() match { + def pattern3(): Tree = + val p = infixPattern() + if isPostfixStar then + atSpan(in.skipToken()) { + Typed(p, Ident(tpnme.WILDCARD_STAR)) + } + else p + + /** Pattern2 ::= [id `@'] Pattern3 + */ + val pattern2: () => Tree = () => pattern3() match case p @ Ident(name) if in.token == AT => val offset = in.skipToken() - infixPattern() match { - case pt @ Ident(tpnme.WILDCARD_STAR) => // compatibility for Scala2 `x @ _*` syntax - warnMigration(p) - atSpan(startOffset(p), offset) { Typed(p, pt) } + pattern3() match { case pt @ Bind(nme.WILDCARD, pt1: Typed) if pt.mods.is(Given) => atSpan(startOffset(p), 0) { Bind(name, pt1).withMods(pt.mods) } + case Typed(Ident(nme.WILDCARD), pt @ Ident(tpnme.WILDCARD_STAR)) => + atSpan(startOffset(p), 0) { Typed(p, pt) } case pt => atSpan(startOffset(p), 0) { Bind(name, pt) } } - case p @ Ident(tpnme.WILDCARD_STAR) => - warnMigration(p) - atSpan(startOffset(p)) { Typed(Ident(nme.WILDCARD), p) } case p => p - } - private def warnMigration(p: Tree) = + private def warnStarMigration(p: Tree) = if sourceVersion.isAtLeast(`3.1`) then report.errorOrMigrationWarning( - "The syntax `x @ _*` is no longer supported; use `x : _*` instead", + em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead", in.sourcePos(startOffset(p))) /** InfixPattern ::= SimplePattern {id [nl] SimplePattern} */ def infixPattern(): Tree = - infixOps(simplePattern(), in.canStartExprTokens, simplePattern, isOperator = in.name != nme.raw.BAR) + infixOps(simplePattern(), in.canStartExprTokens, simplePattern, + isOperator = in.name != nme.raw.BAR && !isPostfixStar) /** SimplePattern ::= PatVar * | Literal @@ -2659,16 +2665,7 @@ object Parsers { case id @ Ident(nme.raw.MINUS) if isNumericLit => literal(startOffset(id)) case t => simplePatternRest(t) case USCORE => - val wildIdent = wildcardIdent() - - // compatibility for Scala2 `x @ _*` and `_*` syntax - // `x: _*' is parsed in `ascription' - if (isIdent(nme.raw.STAR)) { - in.nextToken() - if (in.token != RPAREN) syntaxError(SeqWildcardPatternPos(), wildIdent.span) - atSpan(wildIdent.span) { Ident(tpnme.WILDCARD_STAR) } - } - else wildIdent + wildcardIdent() case LPAREN => atSpan(in.offset) { makeTupleOrParens(inParens(patternsOpt())) } case QUOTE => @@ -2710,7 +2707,7 @@ object Parsers { if (in.token == RPAREN) Nil else patterns(location) /** ArgumentPatterns ::= ‘(’ [Patterns] ‘)’ - * | ‘(’ [Patterns ‘,’] Pattern2 ‘:’ ‘_’ ‘*’ ‘)’ + * | ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’ */ def argumentPatterns(): List[Tree] = inParens(patternsOpt(Location.InPatternArgs)) diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index aafdc006591b..c87418568e56 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -415,10 +415,20 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { } case Typed(expr, tpt) => changePrec(InfixPrec) { - val exprText = toText(expr) - val line = exprText.lastLine - val colon = if (!line.isEmpty && isOperatorPart(line.last)) " :" else ":" - exprText ~ colon ~ toText(tpt) } + if isWildcardStarArg(tree) then + expr match + case Ident(nme.WILDCARD_STAR) => + // `_*` is used as a wildcard name to indicate a vararg splice pattern; + // avoid the double `*` in this case. + toText(expr) + case _ => + toText(expr) ~ "*" + else + val exprText = toText(expr) + val line = exprText.lastLine + val colon = if !line.isEmpty && isOperatorPart(line.last) then " :" else ":" + exprText ~ colon ~ toText(tpt) + } case NamedArg(name, arg) => toText(name) ~ " = " ~ toText(arg) case Assign(lhs, rhs) => diff --git a/docs/docs/internals/syntax.md b/docs/docs/internals/syntax.md index 26f967d96846..447587c16699 100644 --- a/docs/docs/internals/syntax.md +++ b/docs/docs/internals/syntax.md @@ -252,7 +252,7 @@ ExprsInParens ::= ExprInParens {‘,’ ExprInParens} ExprInParens ::= PostfixExpr ‘:’ Type -- normal Expr allows only RefinedType here | Expr ParArgumentExprs ::= ‘(’ [‘using’] ExprsInParens ‘)’ exprs - | ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘:’ ‘_’ ‘*’ ‘)’ exprs :+ Typed(expr, Ident(wildcardStar)) + | ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘*’ ‘)’ exprs :+ Typed(expr, Ident(wildcardStar)) ArgumentExprs ::= ParArgumentExprs | BlockExpr BlockExpr ::= <<< (CaseClauses | Block) >>> @@ -297,7 +297,7 @@ PatVar ::= varid | ‘_’ Patterns ::= Pattern {‘,’ Pattern} ArgumentPatterns ::= ‘(’ [Patterns] ‘)’ Apply(fn, pats) - | ‘(’ [Patterns ‘,’] Pattern2 ‘:’ ‘_’ ‘*’ ‘)’ + | ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’ ``` ### Type and Value Parameters diff --git a/docs/docs/reference/syntax.md b/docs/docs/reference/syntax.md index d271de2a8369..209ac2fb2322 100644 --- a/docs/docs/reference/syntax.md +++ b/docs/docs/reference/syntax.md @@ -248,7 +248,7 @@ ExprsInParens ::= ExprInParens {‘,’ ExprInParens} ExprInParens ::= PostfixExpr ‘:’ Type | Expr ParArgumentExprs ::= ‘(’ [‘using’] ExprsInParens ‘)’ - | ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘:’ ‘_’ ‘*’ ‘)’ + | ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘*’ ‘)’ ArgumentExprs ::= ParArgumentExprs | BlockExpr BlockExpr ::= <<< (CaseClauses | Block) >>> @@ -277,7 +277,7 @@ TypeCaseClause ::= ‘case’ InfixType ‘=>’ Type [nl] Pattern ::= Pattern1 { ‘|’ Pattern1 } Pattern1 ::= Pattern2 [‘:’ RefinedType] -Pattern2 ::= [id ‘@’] InfixPattern +Pattern2 ::= [id ‘@’] InfixPattern [‘*’] InfixPattern ::= SimplePattern { id [nl] SimplePattern } SimplePattern ::= PatVar | Literal @@ -291,7 +291,7 @@ PatVar ::= varid | ‘_’ Patterns ::= Pattern {‘,’ Pattern} ArgumentPatterns ::= ‘(’ [Patterns] ‘)’ - | ‘(’ [Patterns ‘,’] Pattern2 ‘:’ ‘_’ ‘*’ ‘)’ + | ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’ ``` ### Type and Value Parameters diff --git a/tests/invalid/pos/t3577.scala b/tests/invalid/pos/t3577.scala deleted file mode 100644 index e94b69b4b3ab..000000000000 --- a/tests/invalid/pos/t3577.scala +++ /dev/null @@ -1,32 +0,0 @@ -case class Check[A](val value: A) - -case class C2(checks: Check[_]*); - -object C { - def m(x : C2): Any = (null: Any) match { - case C2(_, rest : _*) => { - // Invalid: Vararg pattern cannot be split between normal and :_* patterns. - // This split also does not work for vararg arguments, so there's no - // good argument it should work for patterns - rest.map(_.value) - } - } -} - -/////////////////// - -object Container { - trait Exp[+T] - abstract class FuncExp[-S, +T] - - sealed abstract class FoundNode[T, Repr] { - def optimize[TupleT, U, That](parentNode: FlatMap[T, Repr, U, That]): Any - def optimize2[TupleT, U, That](parentNode: Any): Any - } - - class FlatMap[T, Repr, U, That] - - val Seq(fn: FoundNode[t, repr]) = Seq[FoundNode[_, _]]() - fn.optimize(null) // was: scala.MatchError: ? (of class BoundedWildcardType) @ Variances#varianceInType - fn.optimize2(null) // was: fatal error: bad type: ?(class scala.reflect.internal.Types$BoundedWildcardType) @ Pickle.putType -} diff --git a/tests/neg/t5702-neg-bad-and-wild.scala b/tests/neg/t5702-neg-bad-and-wild.scala index 7566828256a8..8b3388ef65e5 100644 --- a/tests/neg/t5702-neg-bad-and-wild.scala +++ b/tests/neg/t5702-neg-bad-and-wild.scala @@ -7,13 +7,13 @@ object Test { val is = List(1,2,3) is match { - case List(1, _*,) => // error // error // error: bad use of _* (a sequence pattern must be the last pattern) + case List(1, _*,) => // error // // error: bad use of _* (a sequence pattern must be the last pattern) // illegal start of simple pattern - case List(1, _*3,) => // error // error: illegal start of simple pattern + case List(1, _*3,) => // error // error // error: illegal start of simple pattern //case List(1, _*3:) => // poor recovery by parens - case List(1, x*) => // error: use _* to match a sequence - case List(x*, 1) => // error: trailing * is not a valid pattern - case (1, x*) => // error: trailing * is not a valid pattern + case List(1, x*) => // ok + case List(x*, 1) => //ok + case (1, x*) => //ok case (1, x: _*) => // error: bad use of _* (sequence pattern not allowed) } diff --git a/tests/neg-strict/i1059.scala b/tests/pos/i1059.scala similarity index 100% rename from tests/neg-strict/i1059.scala rename to tests/pos/i1059.scala diff --git a/tests/pos/t3577.scala b/tests/pos/t3577.scala new file mode 100644 index 000000000000..754ed01f0174 --- /dev/null +++ b/tests/pos/t3577.scala @@ -0,0 +1,12 @@ +case class Check[A](val value: A) + +case class C2(checks: Check[_]*); + +object C { + def m(x : C2): Any = (null: Any) match { + case C2(_, rest*) => { + rest.map(_.value) + } + } +} + From 34afeeecca072ea0d56753f371683c32649b283f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 28 Jan 2021 14:46:24 +0100 Subject: [PATCH 2/7] Use p* for vararg splices in expressions --- .../dotty/tools/dotc/parsing/Parsers.scala | 81 +++++++++++-------- .../tools/dotc/reporting/ErrorMessageID.scala | 2 +- .../dotty/tools/dotc/reporting/messages.scala | 32 +------- tests/neg/t1625.scala | 2 +- tests/neg/t1625b.scala | 2 +- tests/neg/t5702-neg-bad-and-wild.scala | 2 +- 6 files changed, 56 insertions(+), 65 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 2d422eb2b957..f60ef3c9ced9 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -919,7 +919,20 @@ object Parsers { val next = in.lookahead.token next == LBRACKET || next == LPAREN -/* --------- OPERAND/OPERATOR STACK --------------------------------------- */ + /** Is current ident a `*`, and is it followed by a `)` or `, )`? */ + def followingIsVararg(): Boolean = + in.isIdent(nme.raw.STAR) && { + val lookahead = in.LookaheadScanner() + lookahead.nextToken() + lookahead.token == RPAREN + || lookahead.token == COMMA + && { + lookahead.nextToken() + lookahead.token == RPAREN + } + } + + /* --------- OPERAND/OPERATOR STACK --------------------------------------- */ var opStack: List[OpInfo] = Nil @@ -956,8 +969,8 @@ object Parsers { */ def infixOps( first: Tree, canStartOperand: Token => Boolean, operand: () => Tree, - isType: Boolean = false, - isOperator: => Boolean = true, + isType: Boolean, + isOperator: => Boolean, maybePostfix: Boolean = false): Tree = { val base = opStack @@ -1522,15 +1535,9 @@ object Parsers { */ def infixType(): Tree = infixTypeRest(refinedType()) - /** Is current ident a `*`, and is it followed by a `)` or `,`? */ - def isPostfixStar: Boolean = - in.isIdent(nme.raw.STAR) && { - val nxt = in.lookahead.token - nxt == RPAREN || nxt == COMMA - } - def infixTypeRest(t: Tree): Tree = - infixOps(t, canStartTypeTokens, refinedType, isType = true, isOperator = !isPostfixStar) + infixOps(t, canStartTypeTokens, refinedType, isType = true, + isOperator = !followingIsVararg()) /** RefinedType ::= WithType {[nl] Refinement} */ @@ -2046,7 +2053,7 @@ object Parsers { case t => syntaxError(em"`inline` must be followed by an `if` or a `match`", start) t - else expr1Rest(postfixExpr(), location) + else expr1Rest(postfixExpr(location), location) end expr1 def expr1Rest(t: Tree, location: Location): Tree = in.token match @@ -2068,22 +2075,23 @@ object Parsers { def ascription(t: Tree, location: Location): Tree = atSpan(startOffset(t)) { in.token match { - case USCORE => + case USCORE if in.lookahead.isIdent(nme.raw.STAR) => val uscoreStart = in.skipToken() - if isIdent(nme.raw.STAR) then - in.nextToken() - if !(location.inArgs && in.token == RPAREN) then - if opStack.nonEmpty then - report.errorOrMigrationWarning( - em"""`_*` can be used only for last argument of method application. - |It is no longer allowed in operands of infix operations.""", - in.sourcePos(uscoreStart)) - else - syntaxError(SeqWildcardPatternPos(), uscoreStart) - Typed(t, atSpan(uscoreStart) { Ident(tpnme.WILDCARD_STAR) }) + val isVarargSplice = location.inArgs && followingIsVararg() + in.nextToken() + if isVarargSplice then + if sourceVersion.isAtLeast(`3.1`) then + report.errorOrMigrationWarning( + em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead", + in.sourcePos(uscoreStart)) + else if opStack.nonEmpty then + report.errorOrMigrationWarning( + em"""`_*` can be used only for last argument of method application. + |It is no longer allowed in operands of infix operations.""", + in.sourcePos(uscoreStart)) else - syntaxErrorOrIncomplete(IncorrectRepeatedParameterSyntax()) - t + syntaxError(SeqWildcardPatternPos(), uscoreStart) + Typed(t, atSpan(uscoreStart) { Ident(tpnme.WILDCARD_STAR) }) case AT if !location.inPattern => annotations().foldLeft(t)(Annotated) case _ => @@ -2200,10 +2208,18 @@ object Parsers { * | InfixExpr id [nl] InfixExpr * | InfixExpr MatchClause */ - def postfixExpr(): Tree = postfixExprRest(prefixExpr()) + def postfixExpr(location: Location = Location.ElseWhere): Tree = + val t = postfixExprRest(prefixExpr(), location) + if location.inArgs && followingIsVararg() then + Typed(t, atSpan(in.skipToken()) { Ident(tpnme.WILDCARD_STAR) }) + else + t - def postfixExprRest(t: Tree): Tree = - infixOps(t, in.canStartExprTokens, prefixExpr, maybePostfix = true) + def postfixExprRest(t: Tree, location: Location = Location.ElseWhere): Tree = + infixOps(t, in.canStartExprTokens, prefixExpr, + isType = false, + isOperator = !(location.inArgs && followingIsVararg()), + maybePostfix = true) /** PrefixExpr ::= [`-' | `+' | `~' | `!'] SimpleExpr */ @@ -2331,7 +2347,7 @@ object Parsers { if (in.token == RPAREN) Nil else commaSeparated(exprInParens) /** ParArgumentExprs ::= `(' [‘using’] [ExprsInParens] `)' - * | `(' [ExprsInParens `,'] PostfixExpr `:' `_' `*' ')' + * | `(' [ExprsInParens `,'] PostfixExpr `*' ')' */ def parArgumentExprs(): (List[Tree], Boolean) = inParens { if in.token == RPAREN then @@ -2614,7 +2630,7 @@ object Parsers { */ def pattern3(): Tree = val p = infixPattern() - if isPostfixStar then + if followingIsVararg() then atSpan(in.skipToken()) { Typed(p, Ident(tpnme.WILDCARD_STAR)) } @@ -2646,7 +2662,8 @@ object Parsers { */ def infixPattern(): Tree = infixOps(simplePattern(), in.canStartExprTokens, simplePattern, - isOperator = in.name != nme.raw.BAR && !isPostfixStar) + isType = false, + isOperator = in.name != nme.raw.BAR && !followingIsVararg()) /** SimplePattern ::= PatVar * | Literal diff --git a/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala b/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala index 824fdc177bad..c4839a4c3550 100644 --- a/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala +++ b/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala @@ -35,7 +35,7 @@ enum ErrorMessageID extends java.lang.Enum[ErrorMessageID] { IllegalVariableInPatternAlternativeID, IdentifierExpectedID, AuxConstructorNeedsNonImplicitParameterID, - IncorrectRepeatedParameterSyntaxID, + VarArgsParamMustComeLastID, IllegalLiteralID, PatternMatchExhaustivityID, MatchCaseUnreachableID, diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index b06bdfea1621..eed9490ee3c1 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -779,32 +779,6 @@ import transform.SymUtils._ |""" } - class IncorrectRepeatedParameterSyntax()(using Context) - extends SyntaxMsg(IncorrectRepeatedParameterSyntaxID) { - def msg = "'*' expected" - def explain = - em"""|Expected * in ${hl("_*")} operator. - | - |The ${hl("_*")} operator can be used to supply a sequence-based argument - |to a method with a variable-length or repeated parameter. It is used - |to expand the sequence to a variable number of arguments, such that: - |${hl("func(args: _*)")} would expand to ${hl("func(arg1, arg2 ... argN)")}. - | - |Below is an example of how a method with a variable-length - |parameter can be declared and used. - | - |Squares the arguments of a variable-length parameter: - |${hl("def square(args: Int*) = args.map(a => a * a)")} - | - |Usage: - |${hl("square(1, 2, 3) // res0: List[Int] = List(1, 4, 9)")} - | - |Secondary Usage with ${hl("_*")}: - |${hl("val ints = List(2, 3, 4) // ints: List[Int] = List(2, 3, 4)")} - |${hl("square(ints: _*) // res1: List[Int] = List(4, 9, 16)")} - |""".stripMargin - } - class IllegalLiteral()(using Context) extends SyntaxMsg(IllegalLiteralID) { def msg = "Illegal literal" @@ -865,11 +839,11 @@ import transform.SymUtils._ class SeqWildcardPatternPos()(using Context) extends SyntaxMsg(SeqWildcardPatternPosID) { - def msg = em"""${hl("_*")} can be used only for last argument""" + def msg = em"""${hl("*")} can be used only for last argument""" def explain = { val code = """def sumOfTheFirstTwo(list: List[Int]): Int = list match { - | case List(first, second, x:_*) => first + second + | case List(first, second, x*) => first + second | case _ => 0 |}""" em"""|Sequence wildcard pattern is expected at the end of an argument list. @@ -1274,7 +1248,7 @@ import transform.SymUtils._ } class VarArgsParamMustComeLast()(using Context) - extends SyntaxMsg(IncorrectRepeatedParameterSyntaxID) { + extends SyntaxMsg(VarArgsParamMustComeLastID) { def msg = em"""${hl("varargs")} parameter must come last""" def explain = em"""|The ${hl("varargs")} field must be the last field in the method signature. diff --git a/tests/neg/t1625.scala b/tests/neg/t1625.scala index aabb1ecea2e9..e98ce985238e 100644 --- a/tests/neg/t1625.scala +++ b/tests/neg/t1625.scala @@ -1,3 +1,3 @@ trait T3 { - def foo(x: String*, y: String*, c: String*): Int // error // error: varargs parameter must come last + def foo(x: String*, y: String*, c: String*): Int // error: an identifier expected, but ',' found } \ No newline at end of file diff --git a/tests/neg/t1625b.scala b/tests/neg/t1625b.scala index f2c544f424c3..4c4633c62d23 100644 --- a/tests/neg/t1625b.scala +++ b/tests/neg/t1625b.scala @@ -1,3 +1,3 @@ object T5 { - case class Abc(x: String*, c: String*) // error // error: varargs parameter must come last AND found: String* required: String + case class Abc(x: String*, c: String*) // error: identifier expected but `,` found } diff --git a/tests/neg/t5702-neg-bad-and-wild.scala b/tests/neg/t5702-neg-bad-and-wild.scala index 8b3388ef65e5..d0fe356a59d8 100644 --- a/tests/neg/t5702-neg-bad-and-wild.scala +++ b/tests/neg/t5702-neg-bad-and-wild.scala @@ -12,7 +12,7 @@ object Test { case List(1, _*3,) => // error // error // error: illegal start of simple pattern //case List(1, _*3:) => // poor recovery by parens case List(1, x*) => // ok - case List(x*, 1) => //ok + case List(x*, 1) => // error: pattern expected case (1, x*) => //ok case (1, x: _*) => // error: bad use of _* (sequence pattern not allowed) } From 2f461f830284809fe6456893af5f3cdd2014d769 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 28 Jan 2021 15:55:24 +0100 Subject: [PATCH 3/7] Update tests to use new syntax --- .../string-interpolation-macro/Macro.scala | 4 +- ...b5f29d6fcab5893656be0307f2b8933b1498.scala | 2 +- ...7074d074a942f48e3e24845e7f7054b76b69.scala | 2 +- ...fdb2a05d078e9c400f45d1fe12fa769a1c1f.scala | 2 +- ...e8db3233023ed7a8795d01bbc03b6b063a8b.scala | 2 +- tests/init/crash/i6858.scala | 6 +- tests/neg-macros/i6432/Macro_1.scala | 2 +- tests/neg-macros/i6432b/Macro_1.scala | 2 +- tests/neg-macros/i6436.check | 4 +- tests/neg-macros/i6436.scala | 2 +- .../quote-interpolator-core-old.scala | 2 +- .../Macro_1.scala | 2 +- .../Macro_1.scala | 2 +- tests/neg-scalajs/reflective-calls.scala | 4 +- tests/neg/applydynamic_sip.scala | 6 +- tests/neg/creator-ambiguous.scala | 4 +- tests/neg/i1643.scala | 8 +-- tests/neg/i4922.scala | 2 +- tests/neg/i4984.scala | 8 +-- tests/neg/i533/Test.scala | 2 +- tests/neg/i7972.scala | 14 ++-- tests/neg/i8407.scala | 6 -- tests/neg/i8715.scala | 2 - tests/neg/i9298.scala | 2 +- tests/neg/i9749.scala | 2 +- tests/neg/repeatedArgs213.scala | 24 +++---- tests/neg/t5702-neg-bad-and-wild.scala | 10 +-- tests/patmat/i6490.scala | 2 +- tests/patmat/i8757.scala | 8 +-- tests/patmat/t8178.scala | 2 +- tests/patmat/t9232.scala | 6 +- tests/pending/run/caseClassEquality.scala | 4 +- tests/pending/run/patmat-behavior-2.scala | 6 +- tests/pending/run/patmat-behavior.scala | 72 +++++++++---------- .../run/patmat-mix-case-extractor.scala | 22 +++--- tests/pending/run/patmatnew.scala | 2 +- tests/pending/run/sequenceComparisons.scala | 36 +++++----- tests/pending/run/t2800.scala | 16 ++--- tests/pending/run/t3530.scala | 2 +- tests/pending/run/t7039.scala | 2 +- tests/pending/run/t9003.scala | 2 +- tests/pos-java-interop/i9912/Test.scala | 2 +- tests/pos-macros/i6253.scala | 2 +- tests/pos-macros/i6435.scala | 4 +- tests/pos-macros/i8866c/Macro_1.scala | 2 +- tests/pos-macros/i9321/macros.scala | 2 +- tests/pos-macros/quotedPatterns-4.scala | 2 +- tests/pos-scala2/i8715b.scala | 2 +- .../CollectionStrawMan1.scala | 2 +- .../CollectionStrawMan4.scala | 4 +- .../CollectionStrawMan5.scala | 4 +- .../CollectionStrawMan6.scala | 4 +- tests/pos/arrays2.scala | 8 +-- tests/pos/gadt-accumulatable.scala | 4 +- tests/pos/i1059.scala | 8 +-- tests/pos/i3248.scala | 2 +- tests/pos/i3669.scala | 2 +- tests/pos/i4785.scala | 8 +-- tests/pos/i5140/S.scala | 2 +- tests/pos/i5411.scala | 2 +- tests/pos/i6849a.scala | 2 +- tests/pos/i8056.scala | 4 +- tests/pos/i8715.scala | 2 + tests/pos/i9749.scala | 2 +- tests/pos/opaque-immutable-array.scala | 2 +- tests/pos/patmatSeq.scala | 2 +- tests/pos/reference/extension-methods.scala | 2 +- tests/pos/reference/vararg-patterns.scala | 4 +- tests/pos/repeatedArgs213.scala | 12 ++-- tests/pos/sequence-argument/B_2.scala | 24 +++---- tests/pos/t1136.scala | 2 +- tests/pos/t2698.scala | 2 +- tests/pos/t2945.scala | 4 +- tests/pos/t3859.scala | 2 +- tests/pos/t3972.scala | 2 +- tests/pos/t4173.scala | 2 +- tests/pos/t4269.scala | 2 +- tests/pos/t5859.scala | 14 ++-- tests/pos/test-desugar.scala | 2 +- tests/pos/trailingCommas/trailingCommas.scala | 8 +-- tests/pos/vararg-pattern.scala | 4 +- tests/pos/varargs-position.scala | 6 +- tests/pos/varargs.scala | 4 +- .../interpreter/jvm/Interpreter.scala | 2 +- .../interpreter/jvm/JVMReflection.scala | 10 +-- .../colltest4/CollectionStrawMan4_1.scala | 4 +- .../f-interpolation-1/FQuote_1.scala | 2 +- tests/run-macros/i6253-b/quoted_1.scala | 2 +- tests/run-macros/i6253-c/quoted_1.scala | 2 +- tests/run-macros/i6253/quoted_1.scala | 4 +- .../quote-matcher-runtime/quoted_2.scala | 6 +- .../quoted_1.scala | 4 +- .../quoted_1.scala | 6 +- .../quoted_1.scala | 4 +- .../run-macros/quote-toExprOfSeq/Test_2.scala | 2 +- .../quoted-matching-docs-2/Macro_1.scala | 4 +- .../quoted-matching-docs-2/Test_2.scala | 4 +- .../quoted-matching-docs/Test_2.scala | 4 +- .../refined-selectable-macro/Macro_1.scala | 2 +- .../refined-selectable-macro/Macro_2.scala | 2 +- .../string-context-implicits/Macro_1.scala | 4 +- .../tasty-interpolation-1/Macro.scala | 10 +-- .../Macros_1.scala | 6 +- .../xml-interpolation-2/Test_2.scala | 2 +- .../xml-interpolation-4/Macros_1.scala | 2 +- tests/run/CollectionTests.scala | 4 +- tests/run/adding-growing-set.scala | 2 +- tests/run/applydynamic_sip.scala | 6 +- tests/run/array-charSeq.scala | 2 +- tests/run/bitsets.scala | 34 ++++----- tests/run/byNameVarargs/i499.scala | 6 +- .../run/colltest5/CollectionStrawMan5_1.scala | 4 +- .../run/colltest6/CollectionStrawMan6_1.scala | 4 +- tests/run/correct-bind.scala | 2 +- tests/run/decorators/sample-program.scala | 2 +- tests/run/dynamicDynamicTests.scala | 10 +-- tests/run/i3207.scala | 2 +- tests/run/i3248.scala | 4 +- tests/run/i3248b.scala | 4 +- tests/run/i3248c.scala | 4 +- tests/run/i3248d.scala | 6 +- tests/run/i533/Test.scala | 2 +- tests/run/i6490.scala | 2 +- tests/run/i6490b.scala | 2 +- tests/run/i6858.scala | 6 +- tests/run/i7212/CompatVargs.scala | 2 +- tests/run/iarrays.scala | 2 +- tests/run/indexedSeq.scala | 2 +- tests/run/java-varargs-2/Test.scala | 12 ++-- tests/run/java-varargs/Test_2.scala | 12 ++-- tests/run/mutable-treeset.scala | 2 +- tests/run/opaque-immutable-array-xm.scala | 2 +- ...ng-context-implicits-with-conversion.scala | 2 +- tests/run/string-extractor.scala | 8 +-- tests/run/t1360.scala | 4 +- tests/run/t3488.scala | 4 +- tests/run/t4024.scala | 6 +- tests/run/t4288.scala | 8 +-- tests/run/t5867.scala | 2 +- tests/run/t5879.scala | 4 +- tests/run/t6443-varargs.scala | 2 +- tests/run/t6611.scala | 20 +++--- tests/run/t6611b.scala | 2 +- tests/run/t889.scala | 4 +- tests/run/value-class-extractor-seq.check | 2 +- tests/run/value-class-extractor-seq.scala | 4 +- tests/run/view-iterator-stream.scala | 2 +- 147 files changed, 392 insertions(+), 398 deletions(-) delete mode 100644 tests/neg/i8407.scala delete mode 100644 tests/neg/i8715.scala create mode 100644 tests/pos/i8715.scala diff --git a/tests/bench/string-interpolation-macro/Macro.scala b/tests/bench/string-interpolation-macro/Macro.scala index e5d987e4bb4c..4c5ba3cca029 100644 --- a/tests/bench/string-interpolation-macro/Macro.scala +++ b/tests/bench/string-interpolation-macro/Macro.scala @@ -9,8 +9,8 @@ object Macro { var res: Expr[String] = null for _ <- 0 to 5_000 do (strCtxExpr, argsExpr) match { - case ('{ StringContext(${Varargs(Exprs(parts))}: _*) }, Varargs(Exprs(args))) => - res = Expr(StringContext(parts: _*).s(args: _*)) + case ('{ StringContext(${Varargs(Exprs(parts))}*) }, Varargs(Exprs(args))) => + res = Expr(StringContext(parts*).s(args*)) case _ => ??? } res diff --git a/tests/fuzzy/86ffb5f29d6fcab5893656be0307f2b8933b1498.scala b/tests/fuzzy/86ffb5f29d6fcab5893656be0307f2b8933b1498.scala index f7f87886a6ee..2f8f7f81726f 100644 --- a/tests/fuzzy/86ffb5f29d6fcab5893656be0307f2b8933b1498.scala +++ b/tests/fuzzy/86ffb5f29d6fcab5893656be0307f2b8933b1498.scala @@ -3,5 +3,5 @@ def i1: Unit = { val i2: Unit = { def this(i3: Int): Unit => Unit = { val i4 = 0 -i3(i2) = i3.i5 contains i4+ 1 else 1 + (i4: _*) * (0 i5 else i7 = + (classOf) < [Int](2)) } +i3(i2) = i3.i5 contains i4+ 1 else 1 + (i4*) * (0 i5 else i7 = + (classOf) < [Int](2)) } } \ No newline at end of file diff --git a/tests/fuzzy/AE-c00f7074d074a942f48e3e24845e7f7054b76b69.scala b/tests/fuzzy/AE-c00f7074d074a942f48e3e24845e7f7054b76b69.scala index 917f41f83b0e..a2cd9f537b4e 100755 --- a/tests/fuzzy/AE-c00f7074d074a942f48e3e24845e7f7054b76b69.scala +++ b/tests/fuzzy/AE-c00f7074d074a942f48e3e24845e7f7054b76b69.scala @@ -1 +1 @@ -class I0 { List(null: _*) } +class I0 { List(null*) } diff --git a/tests/fuzzy/ba77fdb2a05d078e9c400f45d1fe12fa769a1c1f.scala b/tests/fuzzy/ba77fdb2a05d078e9c400f45d1fe12fa769a1c1f.scala index 300bc0c0abd3..1b07336b98e4 100644 --- a/tests/fuzzy/ba77fdb2a05d078e9c400f45d1fe12fa769a1c1f.scala +++ b/tests/fuzzy/ba77fdb2a05d078e9c400f45d1fe12fa769a1c1f.scala @@ -2,7 +2,7 @@ import language.List class i0 { def main(i1: Array[String]): Unit = try { -case List(_, _: _*) => 0 case List(1, 2) => i2 :: i1 - 1 } +case List(_, _*) => 0 case List(1, 2) => i2 :: i1 - 1 } println() case _ (1 diff --git a/tests/fuzzy/ed71e8db3233023ed7a8795d01bbc03b6b063a8b.scala b/tests/fuzzy/ed71e8db3233023ed7a8795d01bbc03b6b063a8b.scala index 24681fd51296..c5d2a60c76b2 100644 --- a/tests/fuzzy/ed71e8db3233023ed7a8795d01bbc03b6b063a8b.scala +++ b/tests/fuzzy/ed71e8db3233023ed7a8795d01bbc03b6b063a8b.scala @@ -1,6 +1,6 @@ class i0 { def i1: Nothing = { -def this(i2: Dynamic): Int = i2.i3(i4: _*) +def this(i2: Dynamic): Int = i2.i3(i4*) } } var i3 = 0 diff --git a/tests/init/crash/i6858.scala b/tests/init/crash/i6858.scala index d849e91733f1..7f379a078456 100644 --- a/tests/init/crash/i6858.scala +++ b/tests/init/crash/i6858.scala @@ -1,10 +1,10 @@ object Test extends App { - inline def foo(ys: Int*): Unit = bar(ys: _*) + inline def foo(ys: Int*): Unit = bar(ys*) def bar(ys: Int*) = () val xs: Array[Int] = new Array[Int](3) - foo(xs: _*) + foo(xs*) val ys: Seq[Int] = new Array[Int](3) - foo(ys: _*) + foo(ys*) } diff --git a/tests/neg-macros/i6432/Macro_1.scala b/tests/neg-macros/i6432/Macro_1.scala index 5e43d8f84536..8ef85c0e9b26 100644 --- a/tests/neg-macros/i6432/Macro_1.scala +++ b/tests/neg-macros/i6432/Macro_1.scala @@ -8,7 +8,7 @@ object Macro { def impl(sc: Expr[StringContext])(using Quotes) : Expr[Unit] = { import quotes.reflect._ sc match { - case '{ StringContext(${Varargs(parts)}: _*) } => + case '{ StringContext(${Varargs(parts)}*) } => for (part @ Expr(s) <- parts) report.error(s, part.asTerm.pos) } diff --git a/tests/neg-macros/i6432b/Macro_1.scala b/tests/neg-macros/i6432b/Macro_1.scala index 5e43d8f84536..8ef85c0e9b26 100644 --- a/tests/neg-macros/i6432b/Macro_1.scala +++ b/tests/neg-macros/i6432b/Macro_1.scala @@ -8,7 +8,7 @@ object Macro { def impl(sc: Expr[StringContext])(using Quotes) : Expr[Unit] = { import quotes.reflect._ sc match { - case '{ StringContext(${Varargs(parts)}: _*) } => + case '{ StringContext(${Varargs(parts)}*) } => for (part @ Expr(s) <- parts) report.error(s, part.asTerm.pos) } diff --git a/tests/neg-macros/i6436.check b/tests/neg-macros/i6436.check index 401217e747f4..d861ad90717d 100644 --- a/tests/neg-macros/i6436.check +++ b/tests/neg-macros/i6436.check @@ -1,6 +1,6 @@ -- Error: tests/neg-macros/i6436.scala:5:9 ----------------------------------------------------------------------------- -5 | case '{ StringContext(${Varargs(parts)}: _*) } => // error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +5 | case '{ StringContext(${Varargs(parts)}*) } => // error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | no implicit argument of type scala.quoted.Quotes was found -- [E006] Not Found Error: tests/neg-macros/i6436.scala:6:34 ----------------------------------------------------------- 6 | val ps: Seq[Expr[String]] = parts // error diff --git a/tests/neg-macros/i6436.scala b/tests/neg-macros/i6436.scala index bd3ff515ca29..a7f0bda94419 100644 --- a/tests/neg-macros/i6436.scala +++ b/tests/neg-macros/i6436.scala @@ -2,7 +2,7 @@ import scala.quoted._ def f(sc: quoted.Expr[StringContext]): Unit = { sc match { - case '{ StringContext(${Varargs(parts)}: _*) } => // error + case '{ StringContext(${Varargs(parts)}*) } => // error val ps: Seq[Expr[String]] = parts // error } } \ No newline at end of file diff --git a/tests/neg-macros/quote-interpolator-core-old.scala b/tests/neg-macros/quote-interpolator-core-old.scala index bb99ff40b180..cd613c584ede 100644 --- a/tests/neg-macros/quote-interpolator-core-old.scala +++ b/tests/neg-macros/quote-interpolator-core-old.scala @@ -19,7 +19,7 @@ object FInterpolation { def fInterpolation(sc: StringContext, args: Seq[Expr[Any]])(using Quotes): Expr[String] = { val str: Expr[String] = Expr(sc.parts.mkString("")) val args1: Expr[Seq[Any]] = liftSeq(args) - '{ $str.format($args1: _*) } + '{ $str.format($args1*) } } def hello = "hello" diff --git a/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala b/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala index 87497ea6fc99..90cf7e6a441c 100644 --- a/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala +++ b/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala @@ -12,7 +12,7 @@ object FIntepolator { def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using Quotes) : Expr[String] = { import quotes.reflect._ report.error("there are no parts", strCtxExpr.asTerm.underlyingArgument.pos) - '{ ($strCtxExpr).s($argsExpr: _*) } + '{ ($strCtxExpr).s($argsExpr*) } } } diff --git a/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala b/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala index e17734b11e85..0ff212d8489e 100644 --- a/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala +++ b/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala @@ -11,7 +11,7 @@ object FIntepolator { def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using Quotes) : Expr[String] = { import quotes.reflect._ report.error("there are no args", argsExpr.asTerm.underlyingArgument.pos) - '{ ($strCtxExpr).s($argsExpr: _*) } + '{ ($strCtxExpr).s($argsExpr*) } } } diff --git a/tests/neg-scalajs/reflective-calls.scala b/tests/neg-scalajs/reflective-calls.scala index 444ee364e8ff..b241e9c72864 100644 --- a/tests/neg-scalajs/reflective-calls.scala +++ b/tests/neg-scalajs/reflective-calls.scala @@ -28,12 +28,12 @@ object Test { def classOfVarArgs(): Unit = { val receiver: ReflectSel = ??? val classOfs: List[Class[_]] = List(classOf[String], classOf[List[_]]) - receiver.applyDynamic("foo", classOfs: _*)("bar", Nil) // error + receiver.applyDynamic("foo", classOfs*)("bar", Nil) // error } def argsVarArgs(): Unit = { val receiver: ReflectSel = ??? val args: List[Any] = List("bar", Nil) - receiver.applyDynamic("foo", classOf[String], classOf[List[_]])(args: _*) // error + receiver.applyDynamic("foo", classOf[String], classOf[List[_]])(args*) // error } } diff --git a/tests/neg/applydynamic_sip.scala b/tests/neg/applydynamic_sip.scala index 86cff5fc4d57..bf0283c57b86 100644 --- a/tests/neg/applydynamic_sip.scala +++ b/tests/neg/applydynamic_sip.scala @@ -5,9 +5,9 @@ object Test extends App { val a = "a" val a2 = "a2" - qual.sel(a, a2: _*) // error - qual.sel(arg = a, a2: _*) // error - qual.sel(arg, arg2 = "a2", a2: _*) // error + qual.sel(a, a2*) // error + qual.sel(arg = a, a2*) // error + qual.sel(arg, arg2 = "a2", a2*) // error class Bad1 extends Dynamic { def selectDynamic(n: Int) = n diff --git a/tests/neg/creator-ambiguous.scala b/tests/neg/creator-ambiguous.scala index dd476933db1e..9fd6bd6d0392 100644 --- a/tests/neg/creator-ambiguous.scala +++ b/tests/neg/creator-ambiguous.scala @@ -8,9 +8,9 @@ object Test: object Record: - inline def apply[R <: Record](elems: (String, Any)*) : R = new Record(elems: _*).asInstanceOf[R] + inline def apply[R <: Record](elems: (String, Any)*) : R = new Record(elems*).asInstanceOf[R] - def fromUntypedTuple(elems: (String, Any)*): Record = Record(elems: _*) // error: ambiguous overload + def fromUntypedTuple(elems: (String, Any)*): Record = Record(elems*) // error: ambiguous overload def apply(x: String): Test = Test(x ++ x) diff --git a/tests/neg/i1643.scala b/tests/neg/i1643.scala index 1e3affa7f1c9..a10422de6eab 100644 --- a/tests/neg/i1643.scala +++ b/tests/neg/i1643.scala @@ -1,10 +1,10 @@ trait T extends Array { // error // error - def t1(as: String*): Array[String] = { varargs1(as: _*) } // error - def t2(as: String*): Array[String] = { super.varargs1(as: _*) } // error + def t1(as: String*): Array[String] = { varargs1(as*) } // error + def t2(as: String*): Array[String] = { super.varargs1(as*) } // error } class C extends Base_1 { // error - def c1(as: String*): Array[String] = { varargs1(as: _*) } // error - def c2(as: String*): Array[String] = { super.varargs1(as: _*) } // error + def c1(as: String*): Array[String] = { varargs1(as*) } // error + def c2(as: String*): Array[String] = { super.varargs1(as*) } // error } object Test extends App { val t = new T {} // error diff --git a/tests/neg/i4922.scala b/tests/neg/i4922.scala index 9c3ddc849a0b..f8c87336dbc7 100644 --- a/tests/neg/i4922.scala +++ b/tests/neg/i4922.scala @@ -9,7 +9,7 @@ object A { object Main { def main(args: Array[String]): Unit = { val seq: Seq[Int] = 2 match { - case A(xs: _*) => xs // error // error + case A(xs*) => xs // error // error } } } diff --git a/tests/neg/i4984.scala b/tests/neg/i4984.scala index fd35940e0731..8e82d4183ef4 100644 --- a/tests/neg/i4984.scala +++ b/tests/neg/i4984.scala @@ -26,13 +26,13 @@ object Array3 { object Test { def test(xs: Array[Int]): Int = xs match { case Array2(x, y) => 1 // error - case Array2(x, y, xs: _*) => 2 // error - case Array2(xs: _*) => 3 // error + case Array2(x, y, xs*) => 2 // error + case Array2(xs*) => 3 // error } def test2(xs: Array[Int]): Int = xs match { case Array3(x, y) => 1 // error - case Array3(x, y, xs: _*) => 2 // error - case Array3(xs: _*) => 3 // error + case Array3(x, y, xs*) => 2 // error + case Array3(xs*) => 3 // error } } diff --git a/tests/neg/i533/Test.scala b/tests/neg/i533/Test.scala index 80326f9c3af5..97d0d88d8cc8 100644 --- a/tests/neg/i533/Test.scala +++ b/tests/neg/i533/Test.scala @@ -3,6 +3,6 @@ object Test { val x = new Array[Int](1) x(0) = 10 println(JA.get(x)) // error - println(JA.getVarargs(x: _*)) // now OK. + println(JA.getVarargs(x*)) // now OK. } } diff --git a/tests/neg/i7972.scala b/tests/neg/i7972.scala index abe3185d6b03..bde0e27357b3 100644 --- a/tests/neg/i7972.scala +++ b/tests/neg/i7972.scala @@ -1,18 +1,18 @@ object O { - def m1(a: Int*) = (a: _*) // error // error: Cannot return repeated parameter type Int* - def m2(a: Int*) = { // error: Cannot return repeated parameter type Int* - val b = (a: _*) // error // error: Cannot return repeated parameter type Int* + def m1(a: Int*) = (a*) // error + def m2(a: Int*) = { + val b = (a*) // error b } def m3(a: Int*): Any = { - val b = (a: _*) // error // error: Cannot return repeated parameter type Int* + val b = (a*) // error b } - def m4(a: 2*) = (a: _*) // error // error: Cannot return repeated parameter type Int* + def m4(a: 2*) = (a*) // error } class O(a: Int*) { - val m = (a: _*) // error // error: Cannot return repeated parameter type Int* -} + val m = (a*) // error +} \ No newline at end of file diff --git a/tests/neg/i8407.scala b/tests/neg/i8407.scala deleted file mode 100644 index 34d7fa20914c..000000000000 --- a/tests/neg/i8407.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test: - val xs = List(1, 2, 3, 4, 5) - xs match { - case List(1, 2, xs1 @ xs2: _*) => println(xs2) // error // error - case _ => () - } \ No newline at end of file diff --git a/tests/neg/i8715.scala b/tests/neg/i8715.scala deleted file mode 100644 index aedb32cffdcb..000000000000 --- a/tests/neg/i8715.scala +++ /dev/null @@ -1,2 +0,0 @@ -@main -def Test = List(42) match { case List(xs @ (ys: _*)) => xs } // error diff --git a/tests/neg/i9298.scala b/tests/neg/i9298.scala index 88afe769524d..7810942dd559 100644 --- a/tests/neg/i9298.scala +++ b/tests/neg/i9298.scala @@ -1,5 +1,5 @@ object Foo { val foo = Nil object foo // error - foo(foo: _*) // error + foo(foo*) // error } diff --git a/tests/neg/i9749.scala b/tests/neg/i9749.scala index a316ec032040..3e3697da189f 100644 --- a/tests/neg/i9749.scala +++ b/tests/neg/i9749.scala @@ -2,6 +2,6 @@ class A { def f(x: Any) = 1 def foo(x: List[String]): Unit = { - f(x: _*) // error + f(x*) // error } } diff --git a/tests/neg/repeatedArgs213.scala b/tests/neg/repeatedArgs213.scala index d1b259453e9e..fdce37d66068 100644 --- a/tests/neg/repeatedArgs213.scala +++ b/tests/neg/repeatedArgs213.scala @@ -6,25 +6,25 @@ class repeatedArgs { def test(xs: immutable.Seq[String], ys: collection.Seq[String], zs: Array[String]): Unit = { bar("a", "b", "c") - bar(xs: _*) - bar(ys: _*) // error: immutable.Seq expected, found Seq - bar(zs: _*) // old-error: Remove (compiler generated) Array to Seq conversion in 2.13? + bar(xs*) + bar(ys*) // error: immutable.Seq expected, found Seq + bar(zs*) // old-error: Remove (compiler generated) Array to Seq conversion in 2.13? Paths.get("Hello", "World") - Paths.get("Hello", xs: _*) - Paths.get("Hello", ys: _*) // error: immutable.Seq expected, found Seq - Paths.get("Hello", zs: _*) + Paths.get("Hello", xs*) + Paths.get("Hello", ys*) // error: immutable.Seq expected, found Seq + Paths.get("Hello", zs*) } def test2(xs: immutable.Seq[String] | Null, ys: collection.Seq[String] | Null, zs: Array[String] | Null): Unit = { bar("a", "b", "c") - bar(xs: _*) - bar(ys: _*) // error: immutable.Seq expected, found Seq - bar(zs: _*) // old-error: Remove (compiler generated) Array to Seq conversion in 2.13? + bar(xs*) + bar(ys*) // error: immutable.Seq expected, found Seq + bar(zs*) // old-error: Remove (compiler generated) Array to Seq conversion in 2.13? Paths.get("Hello", "World") - Paths.get("Hello", xs: _*) - Paths.get("Hello", ys: _*) // error: immutable.Seq expected, found Seq - Paths.get("Hello", zs: _*) + Paths.get("Hello", xs*) + Paths.get("Hello", ys*) // error: immutable.Seq expected, found Seq + Paths.get("Hello", zs*) } } diff --git a/tests/neg/t5702-neg-bad-and-wild.scala b/tests/neg/t5702-neg-bad-and-wild.scala index d0fe356a59d8..c8e27278eca0 100644 --- a/tests/neg/t5702-neg-bad-and-wild.scala +++ b/tests/neg/t5702-neg-bad-and-wild.scala @@ -7,9 +7,9 @@ object Test { val is = List(1,2,3) is match { - case List(1, _*,) => // error // // error: bad use of _* (a sequence pattern must be the last pattern) - // illegal start of simple pattern - case List(1, _*3,) => // error // error // error: illegal start of simple pattern + case List(1, _*,) => // error: pattern expected // error + + case List(1, _*3,) => // error: pattern expected // error // error //case List(1, _*3:) => // poor recovery by parens case List(1, x*) => // ok case List(x*, 1) => // error: pattern expected @@ -20,8 +20,8 @@ object Test { // good syntax, bad semantics, detected by typer //gowild.scala:14: error: star patterns must correspond with varargs parameters val K(x @ _*) = k - val K(ns @ _*, x) = k // error: bad use of _* (a sequence pattern must be the last pattern) - val (b, _ : _* ) = (5,6) // error: bad use of _* (sequence pattern not allowed) + val K(ns @ _*, x) = k // error: pattern expected + val (b, _ * ) = (5,6) // ok // no longer complains //bad-and-wild.scala:15: error: ')' expected but '}' found. } diff --git a/tests/patmat/i6490.scala b/tests/patmat/i6490.scala index e9eb01e1cbb9..de15938a5215 100644 --- a/tests/patmat/i6490.scala +++ b/tests/patmat/i6490.scala @@ -6,5 +6,5 @@ object Foo { def foo(x: Foo): Unit = x match { - case Foo(x, _: _*) => assert(x == 3) + case Foo(x, _*) => assert(x == 3) } diff --git a/tests/patmat/i8757.scala b/tests/patmat/i8757.scala index 2056bfb74527..c824caaf25bb 100644 --- a/tests/patmat/i8757.scala +++ b/tests/patmat/i8757.scala @@ -2,9 +2,9 @@ sealed trait T case class C(xs: Int*) extends T -def f(): Unit = (C(42): T) match { case C(xs: _*) => } -def g(): Unit = (C(42): T) match { case C(_: _*) => } +def f(): Unit = (C(42): T) match { case C(xs*) => } +def g(): Unit = (C(42): T) match { case C(_*) => } def h(): Unit = (C(42): T) match - case C(5, _: _*) => - case C(x, xs: _*) => + case C(5, _*) => + case C(x, xs*) => diff --git a/tests/patmat/t8178.scala b/tests/patmat/t8178.scala index d1b5f9608ae4..b75874399642 100644 --- a/tests/patmat/t8178.scala +++ b/tests/patmat/t8178.scala @@ -4,7 +4,7 @@ case class FailsChild2(a: Seq[String]) extends Fails object FailsTest { def matchOnVarArgsFirstFails(f: Fails) = { f match { - case VarArgs1(_: _*) => ??? + case VarArgs1(_*) => ??? // BUG: Without this line we should get a non-exhaustive match compiler error. //case FailsChild2(_) => ??? } diff --git a/tests/patmat/t9232.scala b/tests/patmat/t9232.scala index 2ca677b81f52..b2e7e65c0458 100644 --- a/tests/patmat/t9232.scala +++ b/tests/patmat/t9232.scala @@ -11,14 +11,14 @@ case class Node2() extends Tree object Test { def transformTree(tree: Tree): Any = tree match { - case Node1(Foo(_: _*)) => ??? + case Node1(Foo(_*)) => ??? } def transformTree2(tree: Tree): Any = tree match { - case Node1(Foo(1, _: _*)) => ??? + case Node1(Foo(1, _*)) => ??? } def transformTree3(tree: Tree): Any = tree match { - case Node1(Foo(x, _: _*)) => ??? + case Node1(Foo(x, _*)) => ??? } } diff --git a/tests/pending/run/caseClassEquality.scala b/tests/pending/run/caseClassEquality.scala index c11d7ad0d19c..1d6b685b4a63 100644 --- a/tests/pending/run/caseClassEquality.scala +++ b/tests/pending/run/caseClassEquality.scala @@ -13,8 +13,8 @@ object Test { } case class CS1(xs: Any*) - class CS2(xs: Seq[_]*) extends CS1(xs: _*) - class CS3(xs: IndexedSeq[Int]*) extends CS2(xs: _*) + class CS2(xs: Seq[_]*) extends CS1(xs*) + class CS3(xs: IndexedSeq[Int]*) extends CS2(xs*) case class H1(x: Int, y: Double) class H2(x: Double, y: Int) extends H1(y, x) diff --git a/tests/pending/run/patmat-behavior-2.scala b/tests/pending/run/patmat-behavior-2.scala index 448dcf45037e..445e7f1383bf 100644 --- a/tests/pending/run/patmat-behavior-2.scala +++ b/tests/pending/run/patmat-behavior-2.scala @@ -17,15 +17,15 @@ object Test { case _ => false } def f1seq(x: Any) = x match { - case Foo(x, ys : _*) => true + case Foo(x, ys *) => true case _ => false } def f2seq(x: Any) = x match { - case Foo(x, y, zs : _*) => true + case Foo(x, y, zs *) => true case _ => false } def f3seq(x: Any) = x match { - case Foo(x, y, z, qs : _*) => true + case Foo(x, y, z, qs *) => true case _ => false } diff --git a/tests/pending/run/patmat-behavior.scala b/tests/pending/run/patmat-behavior.scala index 3ce9fb3a70bd..0129a23e10a9 100644 --- a/tests/pending/run/patmat-behavior.scala +++ b/tests/pending/run/patmat-behavior.scala @@ -40,51 +40,51 @@ package pos { def ga5(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } def ga6(x: Any) = x match { case C00() => 1 ; case C10(x) => 2 ; case C20(x, y) => 3 ; case C01(xs) => 4 ; case C11(x, ys) => 5 ; case C21(x, y, zs) => 6 } - def gb1[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } - def gb2[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } - def gb3[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } - def gb4[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } - def gb5[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } - def gb6[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } + def gb1[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } + def gb2[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } + def gb3[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } + def gb4[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } + def gb5[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } + def gb6[A](x: C[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } - def gc1[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gc2[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gc3[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gc4[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gc5[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gc6[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } + def gc1[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gc2[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gc3[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gc4[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gc5[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gc6[A](x: C[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } - def gd1[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gd2[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gd3[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gd4[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gd5[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gd6[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } + def gd1[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gd2[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gd3[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gd4[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gd5[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gd6[A, B <: C[A]](x: B) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } } } package neg { object Fail { - def gb1[A](x: C00[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } - def gb2[A](x: C10[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } - def gb3[A](x: C20[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } - def gb4[A](x: C01[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } - def gb5[A](x: C11[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } - def gb6[A](x: C21[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs : _*) => xs.head ; case E11(x, ys : _*) => x ; case E21(x, y, zs : _*) => x } + def gb1[A](x: C00[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } + def gb2[A](x: C10[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } + def gb3[A](x: C20[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } + def gb4[A](x: C01[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } + def gb5[A](x: C11[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } + def gb6[A](x: C21[A]) = x match { case E00() => ??? ; case E10(x) => x ; case E20(x, y) => x ; case E01(xs *) => xs.head ; case E11(x, ys *) => x ; case E21(x, y, zs *) => x } - def gc1[A](x: C00[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gc2[A](x: C10[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gc3[A](x: C20[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gc4[A](x: C01[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gc5[A](x: C11[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } - def gc6[A](x: C21[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs : _*) => xs.head ; case F11(x, ys : _*) => x ; case F21(x, y, zs : _*) => x } + def gc1[A](x: C00[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gc2[A](x: C10[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gc3[A](x: C20[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gc4[A](x: C01[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gc5[A](x: C11[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } + def gc6[A](x: C21[A]) = x match { case F00() => ??? ; case F10(x) => x ; case F20(x, y) => x ; case F01(xs *) => xs.head ; case F11(x, ys *) => x ; case F21(x, y, zs *) => x } - def gd1[A](x: C00[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs : _*) => xs.head ; case G11(x, ys : _*) => x ; case G21(x, y, zs : _*) => x } - def gd2[A](x: C10[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs : _*) => xs.head ; case G11(x, ys : _*) => x ; case G21(x, y, zs : _*) => x } - def gd3[A](x: C20[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs : _*) => xs.head ; case G11(x, ys : _*) => x ; case G21(x, y, zs : _*) => x } - def gd4[A](x: C01[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs : _*) => xs.head ; case G11(x, ys : _*) => x ; case G21(x, y, zs : _*) => x } - def gd5[A](x: C11[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs : _*) => xs.head ; case G11(x, ys : _*) => x ; case G21(x, y, zs : _*) => x } - def gd6[A](x: C21[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs : _*) => xs.head ; case G11(x, ys : _*) => x ; case G21(x, y, zs : _*) => x } + def gd1[A](x: C00[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs *) => xs.head ; case G11(x, ys *) => x ; case G21(x, y, zs *) => x } + def gd2[A](x: C10[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs *) => xs.head ; case G11(x, ys *) => x ; case G21(x, y, zs *) => x } + def gd3[A](x: C20[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs *) => xs.head ; case G11(x, ys *) => x ; case G21(x, y, zs *) => x } + def gd4[A](x: C01[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs *) => xs.head ; case G11(x, ys *) => x ; case G21(x, y, zs *) => x } + def gd5[A](x: C11[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs *) => xs.head ; case G11(x, ys *) => x ; case G21(x, y, zs *) => x } + def gd6[A](x: C21[A]) = x match { case G00() => ??? ; case G10(x) => x ; case G20(x, y) => x ; case G01(xs *) => xs.head ; case G11(x, ys *) => x ; case G21(x, y, zs *) => x } } } diff --git a/tests/pending/run/patmat-mix-case-extractor.scala b/tests/pending/run/patmat-mix-case-extractor.scala index 8c1a2c906d93..4b00143e2215 100644 --- a/tests/pending/run/patmat-mix-case-extractor.scala +++ b/tests/pending/run/patmat-mix-case-extractor.scala @@ -15,24 +15,24 @@ object Extractor4 { def unapplySeq(x: ProdCaseClass with SeqCaseClass): Option[( class A { def f1(x: Any) = x match { case CaseClass1() => -1 - case CaseClass2(xs : _*) => xs.sum + case CaseClass2(xs *) => xs.sum case CaseClass3(x) => x - case CaseClass4(x, xs : _*) => x + xs.sum - case Extractor4(x, xs : _*) => 1000 + x + xs.sum + case CaseClass4(x, xs *) => x + xs.sum + case Extractor4(x, xs *) => 1000 + x + xs.sum case Extractor3(x) => 1000 + x - case Extractor2(xs : _*) => 1000 + xs.sum + case Extractor2(xs *) => 1000 + xs.sum case Extractor1() => -3 case _ => -2 } def f2(x: Any) = x match { - case Extractor4(x, xs : _*) => 1000 + x + xs.sum + case Extractor4(x, xs *) => 1000 + x + xs.sum case Extractor3(x) => 1000 + x - case Extractor2(xs : _*) => 1000 + xs.sum + case Extractor2(xs *) => 1000 + xs.sum case Extractor1() => -3 case CaseClass1() => -1 - case CaseClass2(xs : _*) => xs.sum + case CaseClass2(xs *) => xs.sum case CaseClass3(x) => x - case CaseClass4(x, xs : _*) => x + xs.sum + case CaseClass4(x, xs *) => x + xs.sum case _ => -2 } def run(): Unit = { @@ -75,11 +75,11 @@ class B { } def f4(x: CaseSeq) = x match { case CaseSeq(x, y, z) => z :: Nil - case CaseSeq(x, y, z : _*) => z + case CaseSeq(x, y, z *) => z } def f5(x: Any) = x match { case ExtractorSeq(x, y, z) => z } - def f6(x: Any) = x match { case ExtractorSeq(x, y, z : _*) => z } + def f6(x: Any) = x match { case ExtractorSeq(x, y, z *) => z } def g1(x: CaseClass0) = x match { case CaseClass0() => true @@ -88,7 +88,7 @@ class B { case CaseClass0v() => true case CaseClass0v(5) => true case CaseClass0v(x) => true - case CaseClass0v(xs : _*) => false + case CaseClass0v(xs *) => false } } diff --git a/tests/pending/run/patmatnew.scala b/tests/pending/run/patmatnew.scala index d55773e25d59..218e60671199 100644 --- a/tests/pending/run/patmatnew.scala +++ b/tests/pending/run/patmatnew.scala @@ -617,7 +617,7 @@ object Test { case class X(p: String, ps: String*) def bar = X("a", "b") match { - case X(p, ps:_*) => foo(ps: _*) + case X(p, ps:_*) => foo(ps*) } def run(): Unit = { assertEquals("Foo", bar) } } diff --git a/tests/pending/run/sequenceComparisons.scala b/tests/pending/run/sequenceComparisons.scala index 27d995477b2c..b0564aad4d2c 100644 --- a/tests/pending/run/sequenceComparisons.scala +++ b/tests/pending/run/sequenceComparisons.scala @@ -9,25 +9,25 @@ object Test { // the commented out ones in seqMakers val seqMakers = List[List[Int] => Seq[Int]]( - // scala.Array(_: _*), - mutable.ArrayBuffer(_: _*), - // mutable.ArrayStack(_: _*), - mutable.Buffer(_: _*), - mutable.LinearSeq(_: _*), + // scala.Array(_*), + mutable.ArrayBuffer(_*), + // mutable.ArrayStack(_*), + mutable.Buffer(_*), + mutable.LinearSeq(_*), // null on Nil - // mutable.LinkedList(_: _*), - mutable.ListBuffer(_: _*), - // mutable.PriorityQueue(_: _*), - // immutable.Queue(_: _*), - // mutable.Queue(_: _*), - immutable.Seq(_: _*), - mutable.Seq(_: _*), - immutable.Stack(_: _*), - // mutable.Stack(_: _*), - immutable.IndexedSeq(_: _*), // was Vector - //mutable.Vector(_: _*), - immutable.List(_: _*), - immutable.Stream(_: _*) + // mutable.LinkedList(_*), + mutable.ListBuffer(_*), + // mutable.PriorityQueue(_*), + // immutable.Queue(_*), + // mutable.Queue(_*), + immutable.Seq(_*), + mutable.Seq(_*), + immutable.Stack(_*), + // mutable.Stack(_*), + immutable.IndexedSeq(_*), // was Vector + //mutable.Vector(_*), + immutable.List(_*), + immutable.Stream(_*) ) abstract class Data[T] { diff --git a/tests/pending/run/t2800.scala b/tests/pending/run/t2800.scala index 0d289384294a..0a2b1aaaded6 100644 --- a/tests/pending/run/t2800.scala +++ b/tests/pending/run/t2800.scala @@ -1,13 +1,13 @@ object Test { - def f1 = ("": Any) match { case List(x : _*) => x ; case _ => false } - def f2 = (5: Any) match { case List(x : _*) => x ; case _ => false } - def f3 = (Nil: Any) match { case List(x : _*) => x ; case _ => false } - def f4 = (Array(1): Any) match { case List(x : _*) => x ; case _ => false } + def f1 = ("": Any) match { case List(x *) => x ; case _ => false } + def f2 = (5: Any) match { case List(x *) => x ; case _ => false } + def f3 = (Nil: Any) match { case List(x *) => x ; case _ => false } + def f4 = (Array(1): Any) match { case List(x *) => x ; case _ => false } - def f5 = ("": Any) match { case Array(x : _*) => x ; case _ => false } - def f6 = (5: Any) match { case Array(x : _*) => x ; case _ => false } - def f7 = (Nil: Any) match { case Array(x : _*) => x ; case _ => false } - def f8 = (Array(1): Any) match { case Array(x : _*) => x ; case _ => false } + def f5 = ("": Any) match { case Array(x *) => x ; case _ => false } + def f6 = (5: Any) match { case Array(x *) => x ; case _ => false } + def f7 = (Nil: Any) match { case Array(x *) => x ; case _ => false } + def f8 = (Array(1): Any) match { case Array(x *) => x ; case _ => false } def f9 = ("": Any) match { case x @ List(_*) => x ; case _ => false } def f10 = ("": Any) match { case List(_*) => true ; case _ => false } diff --git a/tests/pending/run/t3530.scala b/tests/pending/run/t3530.scala index 7fd9fc8054e1..9cd9f641b15e 100644 --- a/tests/pending/run/t3530.scala +++ b/tests/pending/run/t3530.scala @@ -9,7 +9,7 @@ object Test { def f2[T](x: List[T]) = println(x match { case List(_, _) => "two" case List(_, _, _) => "three" - case List(xs : _*) => "list: " + xs.length + case List(xs *) => "list: " + xs.length // bug: the default case is marked unreachable // case _ => "not a list" }) diff --git a/tests/pending/run/t7039.scala b/tests/pending/run/t7039.scala index 7ca4ac497b47..5d934990755a 100644 --- a/tests/pending/run/t7039.scala +++ b/tests/pending/run/t7039.scala @@ -6,6 +6,6 @@ object Test extends App { null match { case UnapplySeqTest(5) => println("uh-oh") case UnapplySeqTest(5, 1) => println("Matched!") // compiles - case UnapplySeqTest(5, xs : _*) => println("toooo long: "+ (xs: Seq[Int])) + case UnapplySeqTest(5, xs *) => println("toooo long: "+ (xs: Seq[Int])) } } diff --git a/tests/pending/run/t9003.scala b/tests/pending/run/t9003.scala index 4f2471220196..bb4e15070f1e 100644 --- a/tests/pending/run/t9003.scala +++ b/tests/pending/run/t9003.scala @@ -62,7 +62,7 @@ object Test { case class CaseSequence(as: Int*) val buffer1 = collection.mutable.Buffer(0, 0) - CaseSequence(buffer1: _*) match { + CaseSequence(buffer1*) match { case CaseSequence(_, i) => buffer1(1) = 1 assertZero(i) // failed diff --git a/tests/pos-java-interop/i9912/Test.scala b/tests/pos-java-interop/i9912/Test.scala index 19d58b199d9d..6376c23ac996 100644 --- a/tests/pos-java-interop/i9912/Test.scala +++ b/tests/pos-java-interop/i9912/Test.scala @@ -3,7 +3,7 @@ class Test { def log(): Unit = { logger.info( "My {} String {} with multiple args {}", - Array("a", "b", "c"): _* + Array("a", "b", "c")* ) } } diff --git a/tests/pos-macros/i6253.scala b/tests/pos-macros/i6253.scala index b5875c8db25e..1409d2312127 100644 --- a/tests/pos-macros/i6253.scala +++ b/tests/pos-macros/i6253.scala @@ -4,6 +4,6 @@ object Macros { case '{ StringContext() } => '{""} case '{ StringContext($part1) } => part1 case '{ StringContext($part1, $part2) } => '{ $part1 + $part2 } - case '{ StringContext($parts: _*) } => '{ $parts.mkString } + case '{ StringContext($parts*) } => '{ $parts.mkString } } } diff --git a/tests/pos-macros/i6435.scala b/tests/pos-macros/i6435.scala index 722677cd38c0..23038c40ae5b 100644 --- a/tests/pos-macros/i6435.scala +++ b/tests/pos-macros/i6435.scala @@ -3,10 +3,10 @@ class Foo { def f(sc: quoted.Expr[StringContext])(using Quotes): Unit = { - val '{ StringContext(${parts}: _*) } = sc + val '{ StringContext(${parts}*) } = sc val ps0: Expr[Seq[String]] = parts - val '{ StringContext(${Varargs(parts2)}: _*) } = sc + val '{ StringContext(${Varargs(parts2)}*) } = sc val ps: Seq[Expr[String]] = parts2 } } \ No newline at end of file diff --git a/tests/pos-macros/i8866c/Macro_1.scala b/tests/pos-macros/i8866c/Macro_1.scala index d035bcf4babe..53118b4580ce 100644 --- a/tests/pos-macros/i8866c/Macro_1.scala +++ b/tests/pos-macros/i8866c/Macro_1.scala @@ -4,7 +4,7 @@ def f(xs: Boolean*): Unit = ??? def mcrImpl(using Quotes): Expr[Unit] = val func: Expr[Seq[Boolean] => Unit] = - '{(esx: Seq[Boolean]) => f(esx: _*)} + '{(esx: Seq[Boolean]) => f(esx*)} val trees: Expr[Seq[Boolean]] = '{Seq(true)} Expr.betaReduce('{ $func($trees) }) end mcrImpl diff --git a/tests/pos-macros/i9321/macros.scala b/tests/pos-macros/i9321/macros.scala index 05017f95d6de..96fa2663f240 100644 --- a/tests/pos-macros/i9321/macros.scala +++ b/tests/pos-macros/i9321/macros.scala @@ -10,7 +10,7 @@ def mcr1Impl(using Quotes): Expr[F[String]] = '{???} inline def mcr2: Unit = ${mcr2Impl} def mcr2Impl(using ctx: Quotes): Expr[Unit] = val func: Expr[Seq[Foo] => Unit] = - '{ (esx: Seq[Foo]) => varargsFunc(esx: _*) } + '{ (esx: Seq[Foo]) => varargsFunc(esx*) } val trees: Expr[Seq[Foo]] = '{Nil} Expr.betaReduce('{$func($trees)}) \ No newline at end of file diff --git a/tests/pos-macros/quotedPatterns-4.scala b/tests/pos-macros/quotedPatterns-4.scala index 6ca02c732a59..9ac6c1f1245a 100644 --- a/tests/pos-macros/quotedPatterns-4.scala +++ b/tests/pos-macros/quotedPatterns-4.scala @@ -3,7 +3,7 @@ object Test { def impl(receiver: Expr[StringContext])(using qctx: scala.quoted.Quotes) = { import quotes.reflect.Repeated receiver match { - case '{ StringContext(${Repeated(parts, tpt)}: _*) } => // now OK + case '{ StringContext(${Repeated(parts, tpt)}*) } => // now OK } } } diff --git a/tests/pos-scala2/i8715b.scala b/tests/pos-scala2/i8715b.scala index 18f053806496..b1eacb1b7015 100644 --- a/tests/pos-scala2/i8715b.scala +++ b/tests/pos-scala2/i8715b.scala @@ -1,4 +1,4 @@ // from stdlib class Test { - def printf(text: String, args: Any*): Unit = { System.out.print(text format (args : _*)) } + def printf(text: String, args: Any*): Unit = { System.out.print(text format (args: _ *)) } } \ No newline at end of file diff --git a/tests/pos-special/strawman-collections/CollectionStrawMan1.scala b/tests/pos-special/strawman-collections/CollectionStrawMan1.scala index c127757ad539..631e2f8e3b71 100644 --- a/tests/pos-special/strawman-collections/CollectionStrawMan1.scala +++ b/tests/pos-special/strawman-collections/CollectionStrawMan1.scala @@ -28,7 +28,7 @@ object CollectionStrawMan1 { /** Base trait for companion objects of collections */ trait IterableFactory[+C[X] <: Iterable[X]] extends FromIterator[C] { def empty[X]: C[X] = fromIterator(Iterator.empty) - def apply[A](xs: A*): C[A] = fromIterator(Iterator(xs: _*)) + def apply[A](xs: A*): C[A] = fromIterator(Iterator(xs*)) } /** Base trait for generic collections */ diff --git a/tests/pos-special/strawman-collections/CollectionStrawMan4.scala b/tests/pos-special/strawman-collections/CollectionStrawMan4.scala index a554c3e8c794..2ec8486ba2e4 100644 --- a/tests/pos-special/strawman-collections/CollectionStrawMan4.scala +++ b/tests/pos-special/strawman-collections/CollectionStrawMan4.scala @@ -32,7 +32,7 @@ object CollectionStrawMan4 { /** Base trait for companion objects of collections */ trait IterableFactory[+C[X] <: Iterable[X]] extends FromIterable[C] { def empty[X]: C[X] = fromIterable(View.Empty) - def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs: _*)) + def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs*)) } /** Base trait for generic collections */ @@ -367,7 +367,7 @@ object CollectionStrawMan4 { override def knownLength = 0 } case class Elems[A](xs: A*) extends View[A] { - def iterator = Iterator(xs: _*) + def iterator = Iterator(xs*) override def knownLength = xs.length } case class Filter[A](val underlying: Iterable[A], p: A => Boolean) extends View[A] { diff --git a/tests/pos-special/strawman-collections/CollectionStrawMan5.scala b/tests/pos-special/strawman-collections/CollectionStrawMan5.scala index ad698fec3615..4d9fa8ac533f 100644 --- a/tests/pos-special/strawman-collections/CollectionStrawMan5.scala +++ b/tests/pos-special/strawman-collections/CollectionStrawMan5.scala @@ -39,7 +39,7 @@ object CollectionStrawMan5 { /** Base trait for companion objects of collections */ trait IterableFactory[+C[X] <: Iterable[X]] extends FromIterable[C] { def empty[X]: C[X] = fromIterable(View.Empty) - def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs: _*)) + def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs*)) } /** Base trait for generic collections */ @@ -378,7 +378,7 @@ object CollectionStrawMan5 { override def knownLength = 0 } case class Elems[A](xs: A*) extends View[A] { - def iterator = Iterator(xs: _*) + def iterator = Iterator(xs*) override def knownLength = xs.length } case class Filter[A](val underlying: Iterable[A], p: A => Boolean) extends View[A] { diff --git a/tests/pos-special/strawman-collections/CollectionStrawMan6.scala b/tests/pos-special/strawman-collections/CollectionStrawMan6.scala index 37fc529bb2be..6379d7efd4c6 100644 --- a/tests/pos-special/strawman-collections/CollectionStrawMan6.scala +++ b/tests/pos-special/strawman-collections/CollectionStrawMan6.scala @@ -109,7 +109,7 @@ object CollectionStrawMan6 extends LowPriority { /** Base trait for companion objects of collections */ trait IterableFactory[+C[X] <: Iterable[X]] extends FromIterable[C] { def empty[X]: C[X] = fromIterable(View.Empty) - def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs: _*)) + def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs*)) } /** Base trait for generic collections */ @@ -803,7 +803,7 @@ object CollectionStrawMan6 extends LowPriority { /** A view with given elements */ case class Elems[A](xs: A*) extends View[A] { - def iterator = Iterator(xs: _*) + def iterator = Iterator(xs*) override def knownSize = xs.length // should be: xs.knownSize, but A*'s are not sequences in this strawman. } diff --git a/tests/pos/arrays2.scala b/tests/pos/arrays2.scala index c3812b798299..68b41da2cd16 100644 --- a/tests/pos/arrays2.scala +++ b/tests/pos/arrays2.scala @@ -12,17 +12,17 @@ object arrays2 { // #2422 object arrays4 { val args = Array[String]("World") - "Hello %1$s".format(args: _*) + "Hello %1$s".format(args*) } /* test/files/pos/arrays2.scala:15: warning: Passing an explicit array value to a Scala varargs method is deprecated (since 2.13.0) and will result in a defensive copy; Use the more efficient non-copying ArraySeq.unsafeWrapArray or an explicit toIndexedSeq call - "Hello %1$s".format(args: _*) + "Hello %1$s".format(args*) ^ one warning found */ // #2461 object arrays3 { - def apply[X <: AnyRef](xs : X*) : java.util.List[X] = java.util.Arrays.asList(xs: _*) - def apply2[X](xs : X*) : java.util.List[X] = java.util.Arrays.asList(xs: _*) + def apply[X <: AnyRef](xs : X*) : java.util.List[X] = java.util.Arrays.asList(xs*) + def apply2[X](xs : X*) : java.util.List[X] = java.util.Arrays.asList(xs*) } diff --git a/tests/pos/gadt-accumulatable.scala b/tests/pos/gadt-accumulatable.scala index ce4cf347538d..18938ee9f050 100644 --- a/tests/pos/gadt-accumulatable.scala +++ b/tests/pos/gadt-accumulatable.scala @@ -9,7 +9,7 @@ object `gadt-accumulatable` { sealed abstract class Every[+T] protected (underlying: Vector[T]) extends /*PartialFunction[Int, T] with*/ Product with Serializable final case class One[+T](loneElement: T) extends Every[T](Vector(loneElement)) - final case class Many[+T](firstElement: T, secondElement: T, otherElements: T*) extends Every[T](firstElement +: secondElement +: Vector(otherElements: _*)) + final case class Many[+T](firstElement: T, secondElement: T, otherElements: T*) extends Every[T](firstElement +: secondElement +: Vector(otherElements*)) class Accumulatable[G, ERR, EVERY[_]] { } @@ -27,7 +27,7 @@ object `gadt-accumulatable` { val tail = results.tail val second = tail.head val rest = tail.tail - Bad(Many(first, second, rest: _*)) + Bad(Many(first, second, rest*)) } case Bad(myBad) => Bad(myBad) } diff --git a/tests/pos/i1059.scala b/tests/pos/i1059.scala index 1fb89afd06fe..cf97f09550f6 100644 --- a/tests/pos/i1059.scala +++ b/tests/pos/i1059.scala @@ -2,9 +2,9 @@ object Repeated { val list = List(1, 2, 3) list match { - case List(_, _, _, _ @ _*) => 0 // error: only allowed in Scala2 mode - case List(_, _, _*) => 1 // error: only allowed in Scala2 mode - case List(_, _: _*) => 2 - case Nil => 3 + case List(_, _, _, _ @ _*) => 0 // error: only allowed in Scala2 mode + case List(_, _, _*) => 1 // error: only allowed in Scala2 mode + case List(_, _*) => 2 + case Nil => 3 } } diff --git a/tests/pos/i3248.scala b/tests/pos/i3248.scala index 2126545c471f..462b7a3d6505 100644 --- a/tests/pos/i3248.scala +++ b/tests/pos/i3248.scala @@ -5,7 +5,7 @@ object Test { } def foo(f: Foo) = f match { - case Foo(name, cs : _*) => name :: cs.reverse.toList.map(_.toString) + case Foo(name, cs *) => name :: cs.reverse.toList.map(_.toString) } def main(args: Array[String]) = { println(foo(new Foo("hi", 1, 2, 3)).mkString(" ")) diff --git a/tests/pos/i3669.scala b/tests/pos/i3669.scala index 3046027b803b..c785c4f6800e 100644 --- a/tests/pos/i3669.scala +++ b/tests/pos/i3669.scala @@ -5,6 +5,6 @@ class Test { val p1 = Paths.get("Hello") val p2 = Paths.get("Hello", "World") val p3 = Paths.get("Hello", "World", "!") - val p4 = Paths.get("Hello", xs: _*) + val p4 = Paths.get("Hello", xs*) } } diff --git a/tests/pos/i4785.scala b/tests/pos/i4785.scala index ed12c6a531e3..9067f155aa21 100644 --- a/tests/pos/i4785.scala +++ b/tests/pos/i4785.scala @@ -6,10 +6,10 @@ class i4785 { def bar(xs: String*) = xs.length def test(xs: Seq[String], ys: Array[String]) = { - Paths.get("Hello", xs: _*) - Paths.get("Hello", ys: _*) + Paths.get("Hello", xs*) + Paths.get("Hello", ys*) - bar(xs: _*) - bar(ys: _*) + bar(xs*) + bar(ys*) } } diff --git a/tests/pos/i5140/S.scala b/tests/pos/i5140/S.scala index c07874660460..09842c6ff398 100644 --- a/tests/pos/i5140/S.scala +++ b/tests/pos/i5140/S.scala @@ -4,6 +4,6 @@ class S { // Check that the java varargs for `foo` gets typed as `Array[_ <: Animal]`. // Otherwise, the call below would fail in -Ycheck:elimRepeated because arrays are invariant before erasure. // This is unsound but allowed. - j.foo(x: _*) + j.foo(x*) j.foo(new Dog, new Dog) } diff --git a/tests/pos/i5411.scala b/tests/pos/i5411.scala index 6acba113b7d2..ec80afa9c94f 100644 --- a/tests/pos/i5411.scala +++ b/tests/pos/i5411.scala @@ -1,5 +1,5 @@ trait A trait B object O { - def m(x: Seq[A & B]) = java.util.Arrays.asList(x: _*) + def m(x: Seq[A & B]) = java.util.Arrays.asList(x*) } \ No newline at end of file diff --git a/tests/pos/i6849a.scala b/tests/pos/i6849a.scala index 4f52695f9685..b1f692ae8662 100644 --- a/tests/pos/i6849a.scala +++ b/tests/pos/i6849a.scala @@ -7,7 +7,7 @@ object Foo { object Test { def main(args: Array[String]): Unit = { (new Foo(3)) match { - case Foo(x, _: _*) => + case Foo(x, _*) => assert(x == 3) } } diff --git a/tests/pos/i8056.scala b/tests/pos/i8056.scala index f105b021c764..cf38633b5402 100644 --- a/tests/pos/i8056.scala +++ b/tests/pos/i8056.scala @@ -1,5 +1,5 @@ object O{ def m(x: Any*) = () - def n(l: List[Int] | List[String]): Unit = m(l: _*) - def n2(l: List[Int] & List[String]): Unit = m(l: _*) + def n(l: List[Int] | List[String]): Unit = m(l*) + def n2(l: List[Int] & List[String]): Unit = m(l*) } \ No newline at end of file diff --git a/tests/pos/i8715.scala b/tests/pos/i8715.scala new file mode 100644 index 000000000000..0490ce53c8cf --- /dev/null +++ b/tests/pos/i8715.scala @@ -0,0 +1,2 @@ +@main +def Test = List(42) match { case List(xs @ (ys*)) => xs } diff --git a/tests/pos/i9749.scala b/tests/pos/i9749.scala index 612ac1d40a73..575b3043c6af 100644 --- a/tests/pos/i9749.scala +++ b/tests/pos/i9749.scala @@ -3,6 +3,6 @@ class A { def f(x: String*) = 1 def foo(x: List[String]): Unit = { - f(x: _*) + f(x*) } } diff --git a/tests/pos/opaque-immutable-array.scala b/tests/pos/opaque-immutable-array.scala index 711a8e0a61e8..4b0a08c73fda 100644 --- a/tests/pos/opaque-immutable-array.scala +++ b/tests/pos/opaque-immutable-array.scala @@ -5,7 +5,7 @@ object ia { opaque type IArray[A1] = Array[A1] object IArray { - def apply[A: ClassTag](xs: A*) = initialize(Array(xs: _*)) + def apply[A: ClassTag](xs: A*) = initialize(Array(xs*)) def initialize[A](body: => Array[A]): IArray[A] = body def size[A](ia: IArray[A]): Int = ia.length diff --git a/tests/pos/patmatSeq.scala b/tests/pos/patmatSeq.scala index 449ed0821aee..cbad3739c945 100644 --- a/tests/pos/patmatSeq.scala +++ b/tests/pos/patmatSeq.scala @@ -4,7 +4,7 @@ object Test { (xs: Any) match { case Seq(x, y) => println(s"$x, $y") - case Seq(x: _*) => println(s"other sequence") + case Seq(x*) => println(s"other sequence") case _ => println("None") } diff --git a/tests/pos/reference/extension-methods.scala b/tests/pos/reference/extension-methods.scala index daa187cafa50..cf075b7f3cda 100644 --- a/tests/pos/reference/extension-methods.scala +++ b/tests/pos/reference/extension-methods.scala @@ -76,7 +76,7 @@ object ExtMethods: class Lst[T](xs: T*): private val elems = xs.toList def foldLeft[U](x: U)(op: (U, T) => U): U = elems.foldLeft(x)(op) - def ++ (other: Lst[T]): Lst[T] = Lst(elems ++ other.elems: _*) + def ++ (other: Lst[T]): Lst[T] = Lst((elems ++ other.elems)*) trait Ord[T]: extension (x: T) def less (y: T): Boolean diff --git a/tests/pos/reference/vararg-patterns.scala b/tests/pos/reference/vararg-patterns.scala index 3a2cf96a7175..aa49e0062553 100644 --- a/tests/pos/reference/vararg-patterns.scala +++ b/tests/pos/reference/vararg-patterns.scala @@ -1,6 +1,6 @@ package varargPatterns object t1 extends App { - val List(1, 2, xs : _*) = List(1, 2, 3) + val List(1, 2, xs *) = List(1, 2, 3) println(xs) - val List(1, 2, _ : _*) = List(1, 2, 3) + val List(1, 2, _ *) = List(1, 2, 3) } diff --git a/tests/pos/repeatedArgs213.scala b/tests/pos/repeatedArgs213.scala index 73a9eb90c496..b1be56cf65f8 100644 --- a/tests/pos/repeatedArgs213.scala +++ b/tests/pos/repeatedArgs213.scala @@ -7,23 +7,23 @@ class repeatedArgs { def test(xs: immutable.Seq[String]): Unit = { bar("a", "b", "c") - bar(xs: _*) + bar(xs*) Paths.get("Hello", "World") - Paths.get("Hello", xs: _*) + Paths.get("Hello", xs*) - val List(_, others: _*) = xs.toList // toList should not be needed, see #4790 + val List(_, others*) = xs.toList // toList should not be needed, see #4790 val x: immutable.Seq[String] = others } def test2(xs: immutable.Seq[String] | Null): Unit = { bar("a", "b", "c") - bar(xs: _*) + bar(xs*) Paths.get("Hello", "World") - Paths.get("Hello", xs: _*) + Paths.get("Hello", xs*) - val List(_, others: _*) = xs.toList // toList should not be needed, see #4790 + val List(_, others*) = xs.toList // toList should not be needed, see #4790 val x: immutable.Seq[String] = others } } diff --git a/tests/pos/sequence-argument/B_2.scala b/tests/pos/sequence-argument/B_2.scala index 97c1817dade1..bd9a3485cf49 100644 --- a/tests/pos/sequence-argument/B_2.scala +++ b/tests/pos/sequence-argument/B_2.scala @@ -9,20 +9,20 @@ object B { def widen(args: Long*): Unit = {} def conv(args: Y*): Unit = {} - box(doubleSeq(1): _*) - box(doubleArray(1): _*) - Java_2.box(doubleSeq(1): _*) - Java_2.box(doubleArray(1): _*) + box(doubleSeq(1)*) + box(doubleArray(1)*) + Java_2.box(doubleSeq(1)*) + Java_2.box(doubleArray(1)*) - widen(doubleSeq(1): _*) - widen(doubleArray(1): _*) - Java_2.widen(doubleSeq(1): _*) - Java_2.widen(doubleArray(1): _*) + widen(doubleSeq(1)*) + widen(doubleArray(1)*) + Java_2.widen(doubleSeq(1)*) + Java_2.widen(doubleArray(1)*) implicit def xToY(x: X): Y = new Y val x: X = new X - conv(doubleSeq(x): _*) - conv(doubleArray(x): _*) - Java_2.conv(doubleSeq(x): _*) - Java_2.conv(doubleArray(x): _*) + conv(doubleSeq(x)*) + conv(doubleArray(x)*) + Java_2.conv(doubleSeq(x)*) + Java_2.conv(doubleArray(x)*) } diff --git a/tests/pos/t1136.scala b/tests/pos/t1136.scala index 92d603e69070..bcf3ad036c23 100644 --- a/tests/pos/t1136.scala +++ b/tests/pos/t1136.scala @@ -1,7 +1,7 @@ object test { def foo(s: Int*): Unit = { s.toList match { - case t: List[Int] => foo(t: _*) + case t: List[Int] => foo(t*) //case _ => // unreachable code } } diff --git a/tests/pos/t2698.scala b/tests/pos/t2698.scala index bce02e48b3d6..b97bdeeb136d 100644 --- a/tests/pos/t2698.scala +++ b/tests/pos/t2698.scala @@ -10,5 +10,5 @@ abstract class S2 { type __labelT = lang._labelT var deltaq: Array[__labelT] = _ - def delta1 = immutable.Map(deltaq.zipWithIndex: _*) + def delta1 = immutable.Map(deltaq.zipWithIndex*) } diff --git a/tests/pos/t2945.scala b/tests/pos/t2945.scala index 54f0a7724b8b..7bfa4558a0c4 100644 --- a/tests/pos/t2945.scala +++ b/tests/pos/t2945.scala @@ -1,9 +1,9 @@ object Foo { def test(s: String) = { (s: Seq[Char]) match { - case Seq('f', 'o', 'o', ' ', rest1: _*) => + case Seq('f', 'o', 'o', ' ', rest1*) => rest1 - case Seq('b', 'a', 'r', ' ', ' ', rest2: _*) => + case Seq('b', 'a', 'r', ' ', ' ', rest2*) => rest2 case _ => s diff --git a/tests/pos/t3859.scala b/tests/pos/t3859.scala index 486c1d4b2b36..ba47ae6d8f7b 100644 --- a/tests/pos/t3859.scala +++ b/tests/pos/t3859.scala @@ -1,4 +1,4 @@ class Test { - def foo: Unit = bar(Array[AnyRef](): _*) + def foo: Unit = bar(Array[AnyRef]()*) def bar(values: AnyRef*): Unit = () } diff --git a/tests/pos/t3972.scala b/tests/pos/t3972.scala index 65ef43f84dec..73aa3961dbf6 100644 --- a/tests/pos/t3972.scala +++ b/tests/pos/t3972.scala @@ -1,7 +1,7 @@ object CompilerCrash { def main(args: Array[String]): Unit = { args match { - case Array("a", a : _*) => { } // The code compiles fine if this line is commented out or "@ _*" is deleted or this line is swapped for the next line + case Array("a", a *) => { } // The code compiles fine if this line is commented out or "@ _*" is deleted or this line is swapped for the next line case Array("b") => { } // The code compiles fine if this line is commented out case Array("c", c) => { 0 // The code compiles fine if this line is commented out diff --git a/tests/pos/t4173.scala b/tests/pos/t4173.scala index 33a713191a48..bea0305d1000 100644 --- a/tests/pos/t4173.scala +++ b/tests/pos/t4173.scala @@ -1,4 +1,4 @@ object t4173 { def bar(a: Int = 0, b: Int = 0)(cs: Any*) = () - bar(b = 1)(Nil: _*) + bar(b = 1)(Nil*) } diff --git a/tests/pos/t4269.scala b/tests/pos/t4269.scala index fe0c20103c19..99a30785b4d1 100644 --- a/tests/pos/t4269.scala +++ b/tests/pos/t4269.scala @@ -1,5 +1,5 @@ class A { PartialFunction.condOpt(Nil) { - case items@List(_: _*) if true => + case items@List(_*) if true => } } diff --git a/tests/pos/t5859.scala b/tests/pos/t5859.scala index 60ec8b4cba35..9d1fb4ef4677 100644 --- a/tests/pos/t5859.scala +++ b/tests/pos/t5859.scala @@ -4,12 +4,12 @@ class A { def f(xs: AnyRef*) = () f() - f(List[AnyRef](): _*) - f(List(): _*) - f(Nil: _*) - // f(Array(): _*) // undetermined ClassTag - f(Array[AnyRef](): _*) + f(List[AnyRef]()*) + f(List()*) + f(Nil*) + // f(Array()*) // undetermined ClassTag + f(Array[AnyRef]()*) f(List(1)) - f(List(1), Nil: _*) - // f(List(1), Array(): _*) // undetermined ClassTag + f(List(1), Nil*) + // f(List(1), Array()*) // undetermined ClassTag } diff --git a/tests/pos/test-desugar.scala b/tests/pos/test-desugar.scala index 3b9b9719d36f..a1e7c7e2c9af 100644 --- a/tests/pos/test-desugar.scala +++ b/tests/pos/test-desugar.scala @@ -75,7 +75,7 @@ object desugar { type ~[X, Y] = Tuple2[X, Y] val pair: Int ~ String = 1 -> "abc" def foo(xs: Int*) = xs.length - foo(list: _*) + foo(list*) (list length) - desugar.x def bar(x: => Int) = x diff --git a/tests/pos/trailingCommas/trailingCommas.scala b/tests/pos/trailingCommas/trailingCommas.scala index 6170fda0fe9b..1e83edfab8f6 100644 --- a/tests/pos/trailingCommas/trailingCommas.scala +++ b/tests/pos/trailingCommas/trailingCommas.scala @@ -14,7 +14,7 @@ trait ArgumentExprs1 { def g(x: Int, y: Int*) = 1 g(1,2, ) - g(1,List(2, 3): _*, + g(1,List(2, 3)*, ) } @@ -118,14 +118,14 @@ trait SimplePattern { ) => x } - // test ': _*' syntax in patterns + // test '*' syntax in patterns List(1, 2, 3) match { - case List(1, 2, x : _*, + case List(1, 2, x *, ) => 1 } // test varargs in patterns - val List(x, y, z: _*, + val List(x, y, z*, ) = 42 :: 17 :: Nil } diff --git a/tests/pos/vararg-pattern.scala b/tests/pos/vararg-pattern.scala index 430973a28538..3b40cd19501b 100644 --- a/tests/pos/vararg-pattern.scala +++ b/tests/pos/vararg-pattern.scala @@ -1,9 +1,9 @@ object Test { List(1, 2, 3, 4) match { - case List(1, 2, xs: _*) => + case List(1, 2, xs*) => val ys: Seq[Int] = xs println(ys) } - val List(1, 2, x: _*) = List(1, 2, 3, 4) + val List(1, 2, x*) = List(1, 2, 3, 4) } diff --git a/tests/pos/varargs-position.scala b/tests/pos/varargs-position.scala index e0b1abc43e55..df9264fd304c 100644 --- a/tests/pos/varargs-position.scala +++ b/tests/pos/varargs-position.scala @@ -4,9 +4,9 @@ object varargspos { val xs = 1 :: 2 :: Nil val a = 8 val b = 7 - g(5, xs: _*) - g(3, Nil: _*) - g(a, xs: _*) + g(5, xs*) + g(3, Nil*) + g(a, xs*) g(a, b, 2, 3) g(1) } diff --git a/tests/pos/varargs.scala b/tests/pos/varargs.scala index bbfcac841a71..41165d4c96b6 100644 --- a/tests/pos/varargs.scala +++ b/tests/pos/varargs.scala @@ -6,8 +6,8 @@ object varargs { def foo[T](x: T, y: T): T = x foo(1, 2) val xs = 1 :: 2 :: Nil - g(xs: _*) - g(Nil: _*) + g(xs*) + g(Nil*) g(1) g() diff --git a/tests/run-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala b/tests/run-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala index a01c3396c7e1..fa5508b78c51 100644 --- a/tests/run-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala +++ b/tests/run-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala @@ -37,7 +37,7 @@ class Interpreter[Q <: Quotes & Singleton](using q0: Q) extends TreeInterpreter[ } else { assert(method.getClass == classOf[Object]) - method.invoke(this, args: _*) + method.invoke(this, args*) } } } diff --git a/tests/run-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala b/tests/run-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala index ff506553884b..d3fc7feb2e21 100644 --- a/tests/run-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala +++ b/tests/run-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala @@ -56,22 +56,22 @@ class JVMReflection[Q <: Quotes & Singleton](using val q: Q) { // TODO can we use interpretMethodCall instead? val inst = loadModule(moduleClass) val method = getMethod(inst.getClass, fn.name, paramsSig(fn)) - method.invoke(inst, args: _*) + method.invoke(inst, args*) } def interpretMethodCall(inst: Object, fn: Symbol, args: List[Object]): Object = { val method = getMethod(inst.getClass, fn.name, paramsSig(fn)) - method.invoke(inst, args: _*) + method.invoke(inst, args*) } def interpretNew(fn: Symbol, args: List[Object]): Object = { val clazz = getClassOf(fn.owner) - val constr = clazz.getConstructor(paramsSig(fn): _*) - constr.newInstance(args: _*).asInstanceOf[Object] + val constr = clazz.getConstructor(paramsSig(fn)*) + constr.newInstance(args*).asInstanceOf[Object] } def getMethod(clazz: Class[_], name: String, paramClasses: List[Class[_]]): Method = { - try clazz.getMethod(name, paramClasses: _*) + try clazz.getMethod(name, paramClasses*) catch { case _: NoSuchMethodException => val msg = s"Could not find method ${clazz.getCanonicalName}.$name with parameters ($paramClasses%, %)$extraMsg" diff --git a/tests/run-deep-subtype/colltest4/CollectionStrawMan4_1.scala b/tests/run-deep-subtype/colltest4/CollectionStrawMan4_1.scala index 1284a00bc6fc..d5cb8a940eb2 100644 --- a/tests/run-deep-subtype/colltest4/CollectionStrawMan4_1.scala +++ b/tests/run-deep-subtype/colltest4/CollectionStrawMan4_1.scala @@ -31,7 +31,7 @@ object CollectionStrawMan4 { /** Base trait for companion objects of collections */ trait IterableFactory[+C[X] <: Iterable[X]] extends FromIterable[C] { def empty[X]: C[X] = fromIterable(View.Empty) - def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs: _*)) + def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs*)) } /** Base trait for generic collections */ @@ -366,7 +366,7 @@ object CollectionStrawMan4 { override def knownLength = 0 } case class Elems[A](xs: A*) extends View[A] { - def iterator = Iterator(xs: _*) + def iterator = Iterator(xs*) override def knownLength = xs.length } case class Filter[A](val underlying: Iterable[A], p: A => Boolean) extends View[A] { diff --git a/tests/run-macros/f-interpolation-1/FQuote_1.scala b/tests/run-macros/f-interpolation-1/FQuote_1.scala index 4d61240c982a..7d9127025adb 100644 --- a/tests/run-macros/f-interpolation-1/FQuote_1.scala +++ b/tests/run-macros/f-interpolation-1/FQuote_1.scala @@ -53,6 +53,6 @@ object FQuote { } val string = parts.mkString("") - '{ new collection.immutable.StringOps(${Expr(string)}).format($args: _*) } + '{ new collection.immutable.StringOps(${Expr(string)}).format($args*) } } } diff --git a/tests/run-macros/i6253-b/quoted_1.scala b/tests/run-macros/i6253-b/quoted_1.scala index 039e798155cb..8e01b3f719db 100644 --- a/tests/run-macros/i6253-b/quoted_1.scala +++ b/tests/run-macros/i6253-b/quoted_1.scala @@ -7,7 +7,7 @@ object Macros { private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using Quotes): Expr[String] = { self match { - case '{ StringContext($parts: _*) } => + case '{ StringContext($parts*) } => '{ val p: Seq[String] = $parts val a: Seq[Any] = $args ++ Seq("") diff --git a/tests/run-macros/i6253-c/quoted_1.scala b/tests/run-macros/i6253-c/quoted_1.scala index 49525f6c3069..39281b9cd79c 100644 --- a/tests/run-macros/i6253-c/quoted_1.scala +++ b/tests/run-macros/i6253-c/quoted_1.scala @@ -8,7 +8,7 @@ object Macros { private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using Quotes): Expr[String] = { self match { - case '{ StringContext($parts: _*) } => // Should not match as the parameter is not marked as inlined + case '{ StringContext($parts*) } => // Should not match as the parameter is not marked as inlined '{ ??? } case _ => '{ "Ok" } diff --git a/tests/run-macros/i6253/quoted_1.scala b/tests/run-macros/i6253/quoted_1.scala index 5956386e1d17..2e05cc17f625 100644 --- a/tests/run-macros/i6253/quoted_1.scala +++ b/tests/run-macros/i6253/quoted_1.scala @@ -7,8 +7,8 @@ object Macros { private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using Quotes): Expr[String] = { self match { - case '{ StringContext($parts: _*) } => - '{ StringContext($parts: _*).s($args: _*) } + case '{ StringContext($parts*) } => + '{ StringContext($parts*).s($args*) } case _ => '{ "ERROR" } } diff --git a/tests/run-macros/quote-matcher-runtime/quoted_2.scala b/tests/run-macros/quote-matcher-runtime/quoted_2.scala index eef4e106f529..a2a1e37b183b 100644 --- a/tests/run-macros/quote-matcher-runtime/quoted_2.scala +++ b/tests/run-macros/quote-matcher-runtime/quoted_2.scala @@ -64,10 +64,10 @@ object Test { // matches({(); 1}, 1) // matches(1, {(); 1}) matches(fs(), fs()) - matches(fs(), fs(patternHole[Seq[Int]]: _*)) + matches(fs(), fs(patternHole[Seq[Int]]*)) matches(fs(1, 2, 3), fs(1, 2, 3)) matches(fs(1, 2, 3), fs(patternHole[Int], patternHole[Int], 3)) - matches(fs(1, 2, 3), fs(patternHole[Seq[Int]]: _*)) + matches(fs(1, 2, 3), fs(patternHole[Seq[Int]]*)) matches(f2(1, 2), f2(1, 2)) matches(f2(a = 1, b = 2), f2(a = 1, b = 2)) matches(f2(a = 1, b = 2), f2(a = patternHole[Int], b = patternHole[Int])) @@ -82,7 +82,7 @@ object Test { matches((x: Int) => "abc", (x: Int) => patternHole[String]) matches(StringContext("abc", "xyz"), StringContext("abc", "xyz")) matches(StringContext("abc", "xyz"), StringContext(patternHole, patternHole)) - matches(StringContext("abc", "xyz"), StringContext(patternHole[Seq[String]]: _*)) + matches(StringContext("abc", "xyz"), StringContext(patternHole[Seq[String]]*)) matches({ val a: Int = 45 }, { val a: Int = 45 }) matches({ val a: Int = 45 }, { val a: Int = patternHole }) matches({ val a: Int = 45 }, { lazy val a: Int = 45 }) diff --git a/tests/run-macros/quote-matcher-string-interpolator-2/quoted_1.scala b/tests/run-macros/quote-matcher-string-interpolator-2/quoted_1.scala index 8660cdc7575b..2aff8705ce06 100644 --- a/tests/run-macros/quote-matcher-string-interpolator-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-string-interpolator-2/quoted_1.scala @@ -8,10 +8,10 @@ object Macros { private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using Quotes): Expr[String] = { (self, args) match { - case ('{ StringContext(${Varargs(parts)}: _*) }, Varargs(args1)) => + case ('{ StringContext(${Varargs(parts)}*) }, Varargs(args1)) => val strParts = parts.map(_.valueOrError.reverse) val strArgs = args1.map(_.valueOrError) - Expr(StringContext(strParts: _*).s(strArgs: _*)) + Expr(StringContext(strParts*).s(strArgs*)) case _ => ??? } diff --git a/tests/run-macros/quote-matcher-string-interpolator-3/quoted_1.scala b/tests/run-macros/quote-matcher-string-interpolator-3/quoted_1.scala index 9ba5ea61c69c..c1dfd083e41a 100644 --- a/tests/run-macros/quote-matcher-string-interpolator-3/quoted_1.scala +++ b/tests/run-macros/quote-matcher-string-interpolator-3/quoted_1.scala @@ -8,15 +8,15 @@ object Macros { private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using Quotes): Expr[String] = { self match { - case '{ StringContext(${Varargs(Exprs(parts))}: _*) } => + case '{ StringContext(${Varargs(Exprs(parts))}*) } => val upprerParts: List[String] = parts.toList.map(_.toUpperCase) val upprerPartsExpr: Expr[List[String]] = Expr.ofList(upprerParts.map(Expr(_))) - '{ StringContext($upprerPartsExpr: _*).s($args: _*) } + '{ StringContext($upprerPartsExpr*).s($args*) } case _ => '{ val parts: Seq[String] = $self.parts val upprerParts = parts.map(_.toUpperCase) - StringContext(upprerParts: _*).s($args: _*) + StringContext(upprerParts*).s($args*) } } diff --git a/tests/run-macros/quote-matcher-string-interpolator/quoted_1.scala b/tests/run-macros/quote-matcher-string-interpolator/quoted_1.scala index a14f05fbcf26..187ee69565d3 100644 --- a/tests/run-macros/quote-matcher-string-interpolator/quoted_1.scala +++ b/tests/run-macros/quote-matcher-string-interpolator/quoted_1.scala @@ -8,9 +8,9 @@ object Macros { private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using Quotes): Expr[String] = { self match { - case '{ StringContext(${Varargs(parts)}: _*) } => + case '{ StringContext(${Varargs(parts)}*) } => val parts2 = Expr.ofList(parts.map(x => '{ $x.reverse })) - '{ StringContext($parts2: _*).s($args: _*) } + '{ StringContext($parts2*).s($args*) } case _ => '{ "ERROR" } } diff --git a/tests/run-macros/quote-toExprOfSeq/Test_2.scala b/tests/run-macros/quote-toExprOfSeq/Test_2.scala index e45e19af1776..8c9e43ea4431 100644 --- a/tests/run-macros/quote-toExprOfSeq/Test_2.scala +++ b/tests/run-macros/quote-toExprOfSeq/Test_2.scala @@ -3,7 +3,7 @@ object Test { println(seq) val s: Seq[Int] = seq println(s) - println(List(seq: _*)) + println(List(seq*)) println(seq(1)) } } diff --git a/tests/run-macros/quoted-matching-docs-2/Macro_1.scala b/tests/run-macros/quoted-matching-docs-2/Macro_1.scala index cb8ceb59fe66..9f0edee63294 100644 --- a/tests/run-macros/quoted-matching-docs-2/Macro_1.scala +++ b/tests/run-macros/quoted-matching-docs-2/Macro_1.scala @@ -15,13 +15,13 @@ private def optimizeExpr(body: Expr[Int])(using Quotes): Expr[Int] = body match // Match a call to sum with an argument $n of type Int. n will be the Expr[Int] representing the argument. case '{ sum($n) } => n // Match a call to sum and extracts all its args in an `Expr[Seq[Int]]` - case '{ sum(${Varargs(args)}: _*) } => sumExpr(args) + case '{ sum(${Varargs(args)}*) } => sumExpr(args) case body => body } private def sumExpr(args1: Seq[Expr[Int]])(using Quotes): Expr[Int] = { def flatSumArgs(arg: Expr[Int]): Seq[Expr[Int]] = arg match { - case '{ sum(${Varargs(subArgs)}: _*) } => subArgs.flatMap(flatSumArgs) + case '{ sum(${Varargs(subArgs)}*) } => subArgs.flatMap(flatSumArgs) case arg => Seq(arg) } val args2 = args1.flatMap(flatSumArgs) diff --git a/tests/run-macros/quoted-matching-docs-2/Test_2.scala b/tests/run-macros/quoted-matching-docs-2/Test_2.scala index 784cdd12ae86..c29d8345964d 100644 --- a/tests/run-macros/quoted-matching-docs-2/Test_2.scala +++ b/tests/run-macros/quoted-matching-docs-2/Test_2.scala @@ -5,6 +5,6 @@ object Test extends App { println(showOptimize(sum(1, a, sum(1, 2, 3), 5))) println(optimize(sum(1, a, sum(1, 2, 3), 5))) val seq: Seq[Int] = Seq(1, 3, 5) - println(showOptimize(sum(1, sum(seq: _*), 3))) - println(optimize(sum(1, sum(seq: _*), 3))) + println(showOptimize(sum(1, sum(seq*), 3))) + println(optimize(sum(1, sum(seq*), 3))) } diff --git a/tests/run-macros/quoted-matching-docs/Test_2.scala b/tests/run-macros/quoted-matching-docs/Test_2.scala index d196181591b7..36a378d48d58 100644 --- a/tests/run-macros/quoted-matching-docs/Test_2.scala +++ b/tests/run-macros/quoted-matching-docs/Test_2.scala @@ -5,6 +5,6 @@ object Test extends App { println(sumShow(1, a, 4, 5)) println(sum(1, a, 4, 5)) val seq: Seq[Int] = Seq(1, 3, 5) - println(sumShow(seq: _*)) - println(sum(seq: _*)) + println(sumShow(seq*)) + println(sum(seq*)) } diff --git a/tests/run-macros/refined-selectable-macro/Macro_1.scala b/tests/run-macros/refined-selectable-macro/Macro_1.scala index 27dcbaa01082..a648dc3a4a43 100644 --- a/tests/run-macros/refined-selectable-macro/Macro_1.scala +++ b/tests/run-macros/refined-selectable-macro/Macro_1.scala @@ -11,7 +11,7 @@ object Macro { trait SelectableRecordCompanion[T] { protected def fromUntypedTuple(elems: (String, Any)*): T - transparent inline def fromTuple[T <: Tuple](inline s: T): Any = ${ fromTupleImpl('s, '{ (x: Array[(String, Any)]) => fromUntypedTuple(x: _*) } ) } + transparent inline def fromTuple[T <: Tuple](inline s: T): Any = ${ fromTupleImpl('s, '{ (x: Array[(String, Any)]) => fromUntypedTuple(x*) } ) } } private def toTupleImpl(s: Expr[Selectable])(using qctx:Quotes) : Expr[Tuple] = { diff --git a/tests/run-macros/refined-selectable-macro/Macro_2.scala b/tests/run-macros/refined-selectable-macro/Macro_2.scala index d01708d32ad3..7d686a0e065a 100644 --- a/tests/run-macros/refined-selectable-macro/Macro_2.scala +++ b/tests/run-macros/refined-selectable-macro/Macro_2.scala @@ -20,7 +20,7 @@ object Macro2 { '{ new Record($elems:_*).asInstanceOf[R] } } - def fromUntypedTuple(elems: (String, Any)*): Record = new Record(elems: _*) + def fromUntypedTuple(elems: (String, Any)*): Record = new Record(elems*) // `new` is needed since resolving the two `apply`s is ambiguous; this was hidden by old scheme for creator applications } } \ No newline at end of file diff --git a/tests/run-macros/string-context-implicits/Macro_1.scala b/tests/run-macros/string-context-implicits/Macro_1.scala index a3a5af631b6e..b0049f9049d3 100644 --- a/tests/run-macros/string-context-implicits/Macro_1.scala +++ b/tests/run-macros/string-context-implicits/Macro_1.scala @@ -16,9 +16,9 @@ private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using report.error(s"could not find implicit for ${Type.show[Show[tp]]}", arg); '{???} } val newArgsExpr = Varargs(argShowedExprs) - '{ $sc.s($newArgsExpr: _*) } + '{ $sc.s($newArgsExpr*) } case _ => - // `new StringContext(...).showMeExpr(args: _*)` not an explicit `showMeExpr"..."` + // `new StringContext(...).showMeExpr(args*)` not an explicit `showMeExpr"..."` report.error(s"Args must be explicit", argsExpr) '{ ??? } diff --git a/tests/run-macros/tasty-interpolation-1/Macro.scala b/tests/run-macros/tasty-interpolation-1/Macro.scala index 56e1e588bf64..bf5ab7091f1c 100644 --- a/tests/run-macros/tasty-interpolation-1/Macro.scala +++ b/tests/run-macros/tasty-interpolation-1/Macro.scala @@ -14,17 +14,17 @@ object Macro { object SIntepolator extends MacroStringInterpolator[String] { protected def interpolate(strCtx: StringContext, args: List[Expr[Any]]) (using Quotes): Expr[String] = - '{(${Expr(strCtx)}).s(${Expr.ofList(args)}: _*)} + '{(${Expr(strCtx)}).s(${Expr.ofList(args)}*)} } object RawIntepolator extends MacroStringInterpolator[String] { protected def interpolate(strCtx: StringContext, args: List[Expr[Any]]) (using Quotes): Expr[String] = - '{(${Expr(strCtx)}).raw(${Expr.ofList(args)}: _*)} + '{(${Expr(strCtx)}).raw(${Expr.ofList(args)}*)} } object FooIntepolator extends MacroStringInterpolator[String] { protected def interpolate(strCtx: StringContext, args: List[Expr[Any]]) (using Quotes): Expr[String] = - '{(${Expr(strCtx)}).s(${Expr.ofList(args.map(_ => '{"foo"}))}: _*)} + '{(${Expr(strCtx)}).s(${Expr.ofList(args.map(_ => '{"foo"}))}*)} } // TODO put this class in the stdlib or separate project? @@ -62,7 +62,7 @@ abstract class MacroStringInterpolator[T] { case Literal(StringConstant(str)) => str case tree => throw new NotStaticlyKnownError("Expected statically known StringContext", tree.asExpr) } - StringContext(strCtxArgs: _*) + StringContext(strCtxArgs*) case tree => throw new NotStaticlyKnownError("Expected statically known StringContext", tree.asExpr) } @@ -77,7 +77,7 @@ abstract class MacroStringInterpolator[T] { } protected implicit def StringContextIsToExpr: ToExpr[StringContext] = new ToExpr[StringContext] { - def apply(strCtx: StringContext)(using Quotes) = '{StringContext(${Expr(strCtx.parts.toSeq)}: _*)} + def apply(strCtx: StringContext)(using Quotes) = '{StringContext(${Expr(strCtx.parts.toSeq)}*)} } protected class NotStaticlyKnownError(msg: String, expr: Expr[Any]) extends Exception(msg) diff --git a/tests/run-macros/tasty-string-interpolation-reporter-test/Macros_1.scala b/tests/run-macros/tasty-string-interpolation-reporter-test/Macros_1.scala index 1c5d392b1e41..23cca5a1ba7a 100644 --- a/tests/run-macros/tasty-string-interpolation-reporter-test/Macros_1.scala +++ b/tests/run-macros/tasty-string-interpolation-reporter-test/Macros_1.scala @@ -20,7 +20,7 @@ object Macro { def foo(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using Quotes): Expr[String] = { (sc, argsExpr) match { - case ('{ StringContext(${Varargs(parts)}: _*) }, Varargs(args)) => + case ('{ StringContext(${Varargs(parts)}*) }, Varargs(args)) => val reporter = new Reporter { def errorOnPart(msg: String, partIdx: Int): Unit = { import quotes.reflect._ @@ -33,7 +33,7 @@ object Macro { def fooErrors(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using Quotes): Expr[List[(Int, Int, Int, String)]] = { (sc, argsExpr) match { - case ('{ StringContext(${Varargs(parts)}: _*) }, Varargs(args)) => + case ('{ StringContext(${Varargs(parts)}*) }, Varargs(args)) => val errors = List.newBuilder[Expr[(Int, Int, Int, String)]] val reporter = new Reporter { def errorOnPart(msg: String, partIdx: Int): Unit = { @@ -57,7 +57,7 @@ object Macro { reporter.errorOnPart("Cannot use #", idx) } - '{ StringContext(${Expr.ofList(parts)}: _*).s(${Expr.ofList(args)}: _*) } + '{ StringContext(${Expr.ofList(parts)}*).s(${Expr.ofList(args)}*) } } diff --git a/tests/run-macros/xml-interpolation-2/Test_2.scala b/tests/run-macros/xml-interpolation-2/Test_2.scala index 2223052ee24a..ef060d87e864 100644 --- a/tests/run-macros/xml-interpolation-2/Test_2.scala +++ b/tests/run-macros/xml-interpolation-2/Test_2.scala @@ -22,6 +22,6 @@ object Test { assert(new SCOps(ctx2).xml(name) == Xml("Hello ??!", List(name))) val args = Seq(name) - assert(new SCOps(ctx2).xml(args: _*) == Xml("Hello ??!", List(name))) + assert(new SCOps(ctx2).xml(args*) == Xml("Hello ??!", List(name))) } } diff --git a/tests/run-macros/xml-interpolation-4/Macros_1.scala b/tests/run-macros/xml-interpolation-4/Macros_1.scala index 6eba65baba00..ef0416817acd 100644 --- a/tests/run-macros/xml-interpolation-4/Macros_1.scala +++ b/tests/run-macros/xml-interpolation-4/Macros_1.scala @@ -10,7 +10,7 @@ object XmlQuote { } private def impl(receiver: Expr[StringContext], args: Expr[Seq[Scope ?=> Any]], scope: Expr[Scope])(using Quotes): Expr[String] = '{ - $receiver.s($args.map(_(using $scope.inner)): _*) + $receiver.s($args.map(_(using $scope.inner))*) } } diff --git a/tests/run/CollectionTests.scala b/tests/run/CollectionTests.scala index c451b350d354..4478c4160265 100644 --- a/tests/run/CollectionTests.scala +++ b/tests/run/CollectionTests.scala @@ -38,7 +38,7 @@ object CollectionStrawMan5 { /** Base trait for companion objects of collections */ trait IterableFactory[+C[X] <: Iterable[X]] extends FromIterable[C] { def empty[X]: C[X] = fromIterable(View.Empty) - def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs: _*)) + def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs*)) } /** Base trait for generic collections */ @@ -377,7 +377,7 @@ object CollectionStrawMan5 { override def knownLength = 0 } case class Elems[A](xs: A*) extends View[A] { - def iterator = Iterator(xs: _*) + def iterator = Iterator(xs*) override def knownLength = xs.length } case class Filter[A](val underlying: Iterable[A], p: A => Boolean) extends View[A] { diff --git a/tests/run/adding-growing-set.scala b/tests/run/adding-growing-set.scala index ab94b893b20a..4eaaeba37f2c 100644 --- a/tests/run/adding-growing-set.scala +++ b/tests/run/adding-growing-set.scala @@ -5,7 +5,7 @@ object Test { def main(args: Array[String]): Unit = { val a = new Array[Long](1000000) (1 to 10000) foreach (i => a(i) = i) - val s = collection.mutable.Set(a: _*) + val s = collection.mutable.Set(a*) assert(s.sum > 0) } } diff --git a/tests/run/applydynamic_sip.scala b/tests/run/applydynamic_sip.scala index 49af333336ec..b4ed94f42641 100644 --- a/tests/run/applydynamic_sip.scala +++ b/tests/run/applydynamic_sip.scala @@ -25,7 +25,7 @@ object Test extends App { // qual.applyDynamic(“sel”)(arg1, …, argn) qual.sel() qual.sel(a) - // qual.sel(a, a2: _*) -- should not accept varargs? + // qual.sel(a, a2*) -- should not accept varargs? qual.sel(a)(a2) qual.sel[T](a) qual.sel[T](a)(a2) @@ -38,8 +38,8 @@ object Test extends App { qual.sel(a, arg2 = "a2") // qual.sel(a)(a2, arg2 = "a2") // qual.sel[T](a)(a2, arg2 = "a2") - // qual.sel(arg = a, a2: _*) - // qual.sel(arg, arg2 = "a2", a2: _*) + // qual.sel(arg = a, a2*) + // qual.sel(arg, arg2 = "a2", a2*) // If qual.sel appears immediately on the left-hand side of an assigment // qual.updateDynamic(“sel”)(expr) diff --git a/tests/run/array-charSeq.scala b/tests/run/array-charSeq.scala index e2f019274820..514fb54d64c3 100644 --- a/tests/run/array-charSeq.scala +++ b/tests/run/array-charSeq.scala @@ -1,7 +1,7 @@ import runtime.ArrayCharSequence object Test { - val arr = Array[Char]('a' to 'i': _*) + val arr = Array[Char]('a' to 'i'*) var xs: CharSequence = new runtime.ArrayCharSequence(arr, 0, arr.length) val hash = xs.hashCode diff --git a/tests/run/bitsets.scala b/tests/run/bitsets.scala index b6843d1fa9c2..2e5a13e76a18 100644 --- a/tests/run/bitsets.scala +++ b/tests/run/bitsets.scala @@ -42,7 +42,7 @@ object TestMutable { val N = 257 val gen = 3 - val bs = BitSet((1 until N): _*) + val bs = BitSet((1 until N)*) (1 until N).foldLeft(gen) { case (acc, i) => assert(bs.size == N-i, s"Bad size for $bs, expected ${N-i} actual ${bs.size}") @@ -62,14 +62,14 @@ object TestMutable2 { val l1 = (190 to 255 toList) reverse val l2 = (0 to 256 toList) val l3 = (1 to 200 by 2 toList) reverse - val t0 = TreeSet(l0: _*) - val t1 = TreeSet(l1: _*) - val t2 = TreeSet(l2: _*) - val t3 = TreeSet(l3: _*) - val b0 = BitSet(l0: _*) - val b1 = BitSet(l1: _*) - val b2 = BitSet(l2: _*) - val b3 = BitSet(l3: _*) + val t0 = TreeSet(l0*) + val t1 = TreeSet(l1*) + val t2 = TreeSet(l2*) + val t3 = TreeSet(l3*) + val b0 = BitSet(l0*) + val b1 = BitSet(l1*) + val b2 = BitSet(l2*) + val b3 = BitSet(l3*) println("m2_m0 = " + b0.toBitMask.toList.map(_.toBinaryString)) println("m2_m2 = " + b2.toBitMask.toList.map(_.toHexString)) @@ -172,14 +172,14 @@ object TestImmutable2 { val l1 = (190 to 255 toList) reverse val l2 = (0 to 256 toList) val l3 = (1 to 200 by 2 toList) reverse - val t0 = TreeSet(l0: _*) - val t1 = TreeSet(l1: _*) - val t2 = TreeSet(l2: _*) - val t3 = TreeSet(l3: _*) - val b0 = BitSet(l0: _*) - val b1 = BitSet(l1: _*) - val b2 = BitSet(l2: _*) - val b3 = BitSet(l3: _*) + val t0 = TreeSet(l0*) + val t1 = TreeSet(l1*) + val t2 = TreeSet(l2*) + val t3 = TreeSet(l3*) + val b0 = BitSet(l0*) + val b1 = BitSet(l1*) + val b2 = BitSet(l2*) + val b3 = BitSet(l3*) println("i2_m0 = " + b0.toBitMask.toList.map(_.toBinaryString)) println("i2_m2 = " + b2.toBitMask.toList.map(_.toHexString)) diff --git a/tests/run/byNameVarargs/i499.scala b/tests/run/byNameVarargs/i499.scala index cd96a3df58fa..5aa44662c5fb 100644 --- a/tests/run/byNameVarargs/i499.scala +++ b/tests/run/byNameVarargs/i499.scala @@ -1,7 +1,7 @@ object Test extends App{ def foo(a: => Any*) = () - def bar(a: => Any*) = foo(a : _*) - def baz(a: => Seq[Any]) = foo(a : _*) + def bar(a: => Any*) = foo(a *) + def baz(a: => Seq[Any]) = foo(a *) bar(???, ???) baz(Seq(???, ???)) @@ -10,7 +10,7 @@ object Test extends App{ foo1(???, ???, ???) def assertFails(a: => Any) = { - var failed = false + var failed = false try { a } catch { diff --git a/tests/run/colltest5/CollectionStrawMan5_1.scala b/tests/run/colltest5/CollectionStrawMan5_1.scala index 1e29969e3927..3be18817b597 100644 --- a/tests/run/colltest5/CollectionStrawMan5_1.scala +++ b/tests/run/colltest5/CollectionStrawMan5_1.scala @@ -31,7 +31,7 @@ object CollectionStrawMan5 { /** Base trait for companion objects of collections */ trait IterableFactory[+C[X] <: Iterable[X]] extends FromIterable[C] { def empty[X]: C[X] = fromIterable(View.Empty) - def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs: _*)) + def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs*)) } /** Base trait for generic collections */ @@ -370,7 +370,7 @@ object CollectionStrawMan5 { override def knownLength = 0 } case class Elems[A](xs: A*) extends View[A] { - def iterator = Iterator(xs: _*) + def iterator = Iterator(xs*) override def knownLength = xs.length } case class Filter[A](val underlying: Iterable[A], p: A => Boolean) extends View[A] { diff --git a/tests/run/colltest6/CollectionStrawMan6_1.scala b/tests/run/colltest6/CollectionStrawMan6_1.scala index 3e045c8cd722..16e404d3941b 100644 --- a/tests/run/colltest6/CollectionStrawMan6_1.scala +++ b/tests/run/colltest6/CollectionStrawMan6_1.scala @@ -110,7 +110,7 @@ object CollectionStrawMan6 extends LowPriority { /** Base trait for companion objects of collections */ trait IterableFactory[+C[X] <: Iterable[X]] extends FromIterable[C] { def empty[X]: C[X] = fromIterable(View.Empty) - def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs: _*)) + def apply[A](xs: A*): C[A] = fromIterable(View.Elems(xs*)) } /** Base trait for generic collections */ @@ -804,7 +804,7 @@ object CollectionStrawMan6 extends LowPriority { /** A view with given elements */ case class Elems[A](xs: A*) extends View[A] { - def iterator = Iterator(xs: _*) + def iterator = Iterator(xs*) override def knownSize = xs.length // should be: xs.knownSize, but A*'s are not sequences in this strawman. } diff --git a/tests/run/correct-bind.scala b/tests/run/correct-bind.scala index db625a544d18..d0ece2021a14 100644 --- a/tests/run/correct-bind.scala +++ b/tests/run/correct-bind.scala @@ -1,4 +1,4 @@ object Test extends App { - val Array(who, what: _*) = "first second third" split (" ") + val Array(who, what*) = "first second third" split (" ") println(what) } diff --git a/tests/run/decorators/sample-program.scala b/tests/run/decorators/sample-program.scala index 1f58f4cd3260..a6d96349939f 100644 --- a/tests/run/decorators/sample-program.scala +++ b/tests/run/decorators/sample-program.scala @@ -44,7 +44,7 @@ object addAll: $split$wrapper.adapt { (args: Array[String]) => val cll = $main$wrapper.call(args) val arg1 = cll.finalArgsGetter[Int]("nums", summon[$main.ArgumentParser[Int]]) - cll.run(myProgram.addAll(arg1(): _*)) + cll.run(myProgram.addAll(arg1()*)) } (args) } (args) } (args) diff --git a/tests/run/dynamicDynamicTests.scala b/tests/run/dynamicDynamicTests.scala index b2bbb529937b..61bd3356f5bf 100644 --- a/tests/run/dynamicDynamicTests.scala +++ b/tests/run/dynamicDynamicTests.scala @@ -66,7 +66,7 @@ object Test { assertEquals("applyDynamic(bazApply)(1)", foo.bazApply(1)) assertEquals("applyDynamic(bazApply)(1, 2, 3)", foo.bazApply(1, 2, 3)) assertEquals("applyDynamic(bazApply)(1, 2, a)", foo.bazApply(1, 2, "a")) - assertEquals("applyDynamic(bazApply)(1, 2, a)", foo.bazApply(List(1, 2, "a"): _*)) + assertEquals("applyDynamic(bazApply)(1, 2, a)", foo.bazApply(List(1, 2, "a")*)) assertEquals("applyDynamicNamed(bazApply)((a,1))", foo.bazApply(a = 1)) assertEquals("applyDynamicNamed(bazApply)((a,1), (b,2))", foo.bazApply(a = 1, b = 2)) @@ -111,7 +111,7 @@ object Test { assertEquals("applyDynamic(apply)(1)", foo(1)) assertEquals("applyDynamic(apply)(1, 2, 3)", foo(1, 2, 3)) assertEquals("applyDynamic(apply)(1, 2, a)", foo(1, 2, "a")) - assertEquals("applyDynamic(apply)(1, 2, a)", foo(List(1, 2, "a"): _*)) + assertEquals("applyDynamic(apply)(1, 2, a)", foo(List(1, 2, "a")*)) assertEquals("applyDynamicNamed(apply)((a,1))", foo(a = 1)) assertEquals("applyDynamicNamed(apply)((a,1), (b,2))", foo(a = 1, b = 2)) @@ -123,7 +123,7 @@ object Test { assertEquals("applyDynamic(apply)(1)", foo.apply(1)) assertEquals("applyDynamic(apply)(1, 2, 3)", foo.apply(1, 2, 3)) assertEquals("applyDynamic(apply)(1, 2, a)", foo.apply(1, 2, "a")) - assertEquals("applyDynamic(apply)(1, 2, a)", foo.apply(List(1, 2, "a"): _*)) + assertEquals("applyDynamic(apply)(1, 2, a)", foo.apply(List(1, 2, "a")*)) assertEquals("applyDynamicNamed(apply)((a,1))", foo.apply(a = 1)) assertEquals("applyDynamicNamed(apply)((a,1), (b,2))", foo.apply(a = 1, b = 2)) @@ -139,7 +139,7 @@ object Test { assertEquals("applyDynamic(apply)(1)", bar.foo(1)) assertEquals("applyDynamic(apply)(1, 2, 3)", bar.foo(1, 2, 3)) assertEquals("applyDynamic(apply)(1, 2, a)", bar.foo(1, 2, "a")) - assertEquals("applyDynamic(apply)(1, 2, a)", bar.foo(List(1, 2, "a"): _*)) + assertEquals("applyDynamic(apply)(1, 2, a)", bar.foo(List(1, 2, "a")*)) assertEquals("applyDynamicNamed(apply)((a,1))", bar.foo(a = 1)) assertEquals("applyDynamicNamed(apply)((a,1), (b,2))", bar.foo(a = 1, b = 2)) @@ -151,7 +151,7 @@ object Test { assertEquals("applyDynamic(apply)(1)", bar.foo.apply(1)) assertEquals("applyDynamic(apply)(1, 2, 3)", bar.foo.apply(1, 2, 3)) assertEquals("applyDynamic(apply)(1, 2, a)", bar.foo.apply(1, 2, "a")) - assertEquals("applyDynamic(apply)(1, 2, a)", bar.foo.apply(List(1, 2, "a"): _*)) + assertEquals("applyDynamic(apply)(1, 2, a)", bar.foo.apply(List(1, 2, "a")*)) assertEquals("applyDynamicNamed(apply)((a,1))", bar.foo.apply(a = 1)) assertEquals("applyDynamicNamed(apply)((a,1), (b,2))", bar.foo.apply(a = 1, b = 2)) diff --git a/tests/run/i3207.scala b/tests/run/i3207.scala index 267c39c11fe7..1524fa035489 100644 --- a/tests/run/i3207.scala +++ b/tests/run/i3207.scala @@ -1,6 +1,6 @@ object Test extends App { def foo(ff: String*) = ff - def bar(bb: String*) = foo(ff = bb: _*) + def bar(bb: String*) = foo(ff = bb*) println(bar()) println(bar("A", "B")) } diff --git a/tests/run/i3248.scala b/tests/run/i3248.scala index 5e6e0c05d94c..5db0b56f6e8f 100644 --- a/tests/run/i3248.scala +++ b/tests/run/i3248.scala @@ -5,14 +5,14 @@ object Test { } def foo(f: Foo) = f match { - case Foo(name, ns : _*) => + case Foo(name, ns *) => assert(name == "hello") assert(ns(0) == 3) assert(ns(1) == 5) } def bar(f: Foo) = f match { - case Foo(name, x, y, ns : _*) => + case Foo(name, x, y, ns *) => assert(name == "hello") assert(x == 3) assert(y == 5) diff --git a/tests/run/i3248b.scala b/tests/run/i3248b.scala index 31984780e9f6..9ab511b39099 100644 --- a/tests/run/i3248b.scala +++ b/tests/run/i3248b.scala @@ -5,14 +5,14 @@ object Test { } def foo(f: Foo) = f match { - case Foo(name, ns: _*) => + case Foo(name, ns*) => assert(name == "hello") assert(ns(0) == 3) assert(ns(1) == 5) } def bar(f: Foo) = f match { - case Foo(name, x, y, ns : _*) => + case Foo(name, x, y, ns *) => assert(name == "hello") assert(x == 3) assert(y == 5) diff --git a/tests/run/i3248c.scala b/tests/run/i3248c.scala index 138973251b45..3221f33cbef7 100644 --- a/tests/run/i3248c.scala +++ b/tests/run/i3248c.scala @@ -2,14 +2,14 @@ object Test { case class Foo(name: String, children: Int *) def foo(f: Foo) = f match { - case Foo(name, ns: _*) => + case Foo(name, ns*) => assert(name == "hello") assert(ns(0) == 3) assert(ns(1) == 5) } def bar(f: Foo) = f match { - case Foo(name, x, y, ns : _*) => + case Foo(name, x, y, ns *) => assert(name == "hello") assert(x == 3) assert(y == 5) diff --git a/tests/run/i3248d.scala b/tests/run/i3248d.scala index 1d7aef0742f7..bfb2b707e6ed 100644 --- a/tests/run/i3248d.scala +++ b/tests/run/i3248d.scala @@ -6,14 +6,14 @@ object Test { } def foo(f: Foo) = f match { - case Foo(name, ns: _*) => + case Foo(name, ns*) => assert(name == "hello") assert(ns(0) == 3) assert(ns(1) == 5) } def bar(f: Foo) = f match { - case Foo(name, x, y, ns : _*) => + case Foo(name, x, y, ns *) => assert(name == "hello") assert(x == 3) assert(y == 5) @@ -23,7 +23,7 @@ object Test { def qux(f: Foo) = f match { case Foo(name) => 1 case Foo(name, x, y) => 2 - case Foo(name, xs: _*) => 0 + case Foo(name, xs*) => 0 } diff --git a/tests/run/i533/Test.scala b/tests/run/i533/Test.scala index a8420450dc4e..a05a438c81a0 100644 --- a/tests/run/i533/Test.scala +++ b/tests/run/i533/Test.scala @@ -3,6 +3,6 @@ object Test { val x = new Array[Integer](1) x(0) = 10 println(JA.get(x)) - println(JA.getVarargs(x: _*)) + println(JA.getVarargs(x*)) } } diff --git a/tests/run/i6490.scala b/tests/run/i6490.scala index 4f52695f9685..b1f692ae8662 100644 --- a/tests/run/i6490.scala +++ b/tests/run/i6490.scala @@ -7,7 +7,7 @@ object Foo { object Test { def main(args: Array[String]): Unit = { (new Foo(3)) match { - case Foo(x, _: _*) => + case Foo(x, _*) => assert(x == 3) } } diff --git a/tests/run/i6490b.scala b/tests/run/i6490b.scala index b0ba19eefc15..1a5368e13ae8 100644 --- a/tests/run/i6490b.scala +++ b/tests/run/i6490b.scala @@ -7,7 +7,7 @@ object Foo { object Test { def main(args: Array[String]): Unit = { (new Foo(3)) match { - case Foo(x, _: _*) => + case Foo(x, _*) => assert(x == 3) } } diff --git a/tests/run/i6858.scala b/tests/run/i6858.scala index d849e91733f1..7f379a078456 100644 --- a/tests/run/i6858.scala +++ b/tests/run/i6858.scala @@ -1,10 +1,10 @@ object Test extends App { - inline def foo(ys: Int*): Unit = bar(ys: _*) + inline def foo(ys: Int*): Unit = bar(ys*) def bar(ys: Int*) = () val xs: Array[Int] = new Array[Int](3) - foo(xs: _*) + foo(xs*) val ys: Seq[Int] = new Array[Int](3) - foo(ys: _*) + foo(ys*) } diff --git a/tests/run/i7212/CompatVargs.scala b/tests/run/i7212/CompatVargs.scala index 0269d27c5841..1ad60229b8d8 100644 --- a/tests/run/i7212/CompatVargs.scala +++ b/tests/run/i7212/CompatVargs.scala @@ -7,5 +7,5 @@ class CompatVargs { def vargsFromScala(): Unit = vargs("single") vargs("a", "b") - vargs(Seq("a", "b"): _*) + vargs(Seq("a", "b")*) } diff --git a/tests/run/iarrays.scala b/tests/run/iarrays.scala index 2892b53e6b08..a2e11ef4c387 100644 --- a/tests/run/iarrays.scala +++ b/tests/run/iarrays.scala @@ -43,7 +43,7 @@ object Test extends App { k += 1 } } - IArray(flat: _*) + IArray(flat*) } val ys = IArray.concat(xs, xs, xs) diff --git a/tests/run/indexedSeq.scala b/tests/run/indexedSeq.scala index b1a2b1bc6060..1059df325eec 100644 --- a/tests/run/indexedSeq.scala +++ b/tests/run/indexedSeq.scala @@ -5,7 +5,7 @@ object Test { def main(args: Array[String]): Unit = { def r = 1 to 10 - checkIdentity(immutable.Vector(r: _*)) + checkIdentity(immutable.Vector(r*)) checkIdentity(r.toIndexedSeq) } } diff --git a/tests/run/java-varargs-2/Test.scala b/tests/run/java-varargs-2/Test.scala index 1a3d165188bd..21087f82eb77 100644 --- a/tests/run/java-varargs-2/Test.scala +++ b/tests/run/java-varargs-2/Test.scala @@ -1,13 +1,13 @@ object Test { def main(args: Array[String]): Unit = { A.foo(1) - A.foo(Array(1): _*) - A.foo(Seq(1): _*) + A.foo(Array(1)*) + A.foo(Seq(1)*) A.gen(1) - A.gen(Array(1): _*) - A.gen(Seq(1): _*) + A.gen(Array(1)*) + A.gen(Seq(1)*) A.gen2("") - A.gen2(Array(""): _*) - A.gen2(Seq(""): _*) + A.gen2(Array("")*) + A.gen2(Seq("")*) } } diff --git a/tests/run/java-varargs/Test_2.scala b/tests/run/java-varargs/Test_2.scala index 4b5c5749fa7a..11bab5b39ac7 100644 --- a/tests/run/java-varargs/Test_2.scala +++ b/tests/run/java-varargs/Test_2.scala @@ -1,13 +1,13 @@ object Test { def main(args: Array[String]): Unit = { A_1.foo(1) - A_1.foo(Array(1): _*) - A_1.foo(Seq(1): _*) + A_1.foo(Array(1)*) + A_1.foo(Seq(1)*) A_1.gen(1) - A_1.gen(Array(1): _*) - A_1.gen(Seq(1): _*) + A_1.gen(Array(1)*) + A_1.gen(Seq(1)*) A_1.gen2("") - A_1.gen2(Array(""): _*) - A_1.gen2(Seq(""): _*) + A_1.gen2(Array("")*) + A_1.gen2(Seq("")*) } } diff --git a/tests/run/mutable-treeset.scala b/tests/run/mutable-treeset.scala index 28b233836649..7af243482322 100644 --- a/tests/run/mutable-treeset.scala +++ b/tests/run/mutable-treeset.scala @@ -124,7 +124,7 @@ object Test extends App { val it = set.iterator.toList assert(it == list, s"$it did not equal $list") } - val set = TreeSet(list: _*) + val set = TreeSet(list*) check(set, sorted) check(set.clone, sorted) diff --git a/tests/run/opaque-immutable-array-xm.scala b/tests/run/opaque-immutable-array-xm.scala index bca0b050806e..4137cd88bf5b 100644 --- a/tests/run/opaque-immutable-array-xm.scala +++ b/tests/run/opaque-immutable-array-xm.scala @@ -7,7 +7,7 @@ object Test extends App { implicit object IArray { def initialize[A](body: => Array[A]): IArray[A] = body - def apply[A: ClassTag](xs: A*): IArray[A] = initialize(Array(xs: _*)) + def apply[A: ClassTag](xs: A*): IArray[A] = initialize(Array(xs*)) // These should be inline but that does not work currently. Try again // once inliner is moved to PickleQuotes diff --git a/tests/run/string-context-implicits-with-conversion.scala b/tests/run/string-context-implicits-with-conversion.scala index a8899d4232a4..832c22af7241 100644 --- a/tests/run/string-context-implicits-with-conversion.scala +++ b/tests/run/string-context-implicits-with-conversion.scala @@ -1,6 +1,6 @@ object Lib { - extension (sc: StringContext) def showMe(args: Showed*): String = sc.s(args: _*) + extension (sc: StringContext) def showMe(args: Showed*): String = sc.s(args*) opaque type Showed = String diff --git a/tests/run/string-extractor.scala b/tests/run/string-extractor.scala index d2b4641691f1..bca9aaab0c84 100644 --- a/tests/run/string-extractor.scala +++ b/tests/run/string-extractor.scala @@ -37,14 +37,14 @@ object TripleBippy { object Test { def f(x: Any) = x match { - case Bippy('B' | 'b', 'O' | 'o', 'B' | 'b', xs : _*) => xs + case Bippy('B' | 'b', 'O' | 'o', 'B' | 'b', xs *) => xs case _ => "nope" } def g(x: Any): String = x match { - case TripleBippy(3 :: Nil, 3.0, 'b', chars : _*) => "1: " + chars - case TripleBippy(5 :: Nil, 5.0, 'b' | 'B', chars : _*) => "2: " + chars - case TripleBippy(_, _, chars : _*) => "3: " + chars + case TripleBippy(3 :: Nil, 3.0, 'b', chars *) => "1: " + chars + case TripleBippy(5 :: Nil, 5.0, 'b' | 'B', chars *) => "2: " + chars + case TripleBippy(_, _, chars *) => "3: " + chars case _ => "nope" } diff --git a/tests/run/t1360.scala b/tests/run/t1360.scala index 959c1cd2ff01..7ec8b9ad325b 100644 --- a/tests/run/t1360.scala +++ b/tests/run/t1360.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { val seq: Seq[String] = List("one", "two") - println(java.util.Arrays.asList(seq: _*)) - println(java.util.Arrays.asList(Seq(1,2,3): _*)) + println(java.util.Arrays.asList(seq*)) + println(java.util.Arrays.asList(Seq(1,2,3)*)) } } diff --git a/tests/run/t3488.scala b/tests/run/t3488.scala index 913752125549..a8cfa9b808d8 100644 --- a/tests/run/t3488.scala +++ b/tests/run/t3488.scala @@ -1,6 +1,6 @@ object Test extends App { def foo(p: => Unit)(x:Int = 0) = x - println(foo { val List(_: _*)=List(0); 1 } ()) - println(foo { val List(_: _*)=List(0); 1 } (1)) + println(foo { val List(_*)=List(0); 1 } ()) + println(foo { val List(_*)=List(0); 1 } (1)) } diff --git a/tests/run/t4024.scala b/tests/run/t4024.scala index f48410915d84..227be345f85a 100644 --- a/tests/run/t4024.scala +++ b/tests/run/t4024.scala @@ -4,7 +4,7 @@ object Test extends App { val m = x.getClass.getMethod("toString") - assert(m.invoke(x, (Nil: List[AnyRef]): _*) == "abc") + assert(m.invoke(x, (Nil: List[AnyRef])*) == "abc") Test2.main(Array()) } @@ -14,7 +14,7 @@ object Test2 { def main(args: Array[String]): Unit = { val x = "abc" val m = x.getClass.getMethod("toString") - m.invoke(x, Nil: _*) - m.invoke(x, Seq(): _*) + m.invoke(x, Nil*) + m.invoke(x, Seq()*) } } diff --git a/tests/run/t4288.scala b/tests/run/t4288.scala index 5b6fcbe3dd12..7c5ea35ceb21 100644 --- a/tests/run/t4288.scala +++ b/tests/run/t4288.scala @@ -1,8 +1,8 @@ object Test { - def f1 = scala.collection.mutable.ListBuffer(1 to 9: _*).slice(-5, -1) - def f2 = List(1 to 9: _*).slice(-5, -1) - def f3 = Vector(1 to 9: _*).slice(-5, -1) - def f4 = Iterable(1 to 9: _*).slice(-5, -1) + def f1 = scala.collection.mutable.ListBuffer(1 to 9*).slice(-5, -1) + def f2 = List(1 to 9*).slice(-5, -1) + def f3 = Vector(1 to 9*).slice(-5, -1) + def f4 = Iterable(1 to 9*).slice(-5, -1) def f5 = (1 to 9).toArray.slice(-5, -1) def f6 = LazyList.from(1 to 9).slice(-5, -1) def f7 = (1 to 9).slice(-5, -1) diff --git a/tests/run/t5867.scala b/tests/run/t5867.scala index c7f5d0a41a39..773ba7a0e24d 100644 --- a/tests/run/t5867.scala +++ b/tests/run/t5867.scala @@ -5,7 +5,7 @@ import collection.mutable.UnrolledBuffer object Test { def main(args: Array[String]): Unit = { - val buf = UnrolledBuffer(1 to 50: _*) + val buf = UnrolledBuffer(1 to 50*) val dub = buf ++ buf println(dub) diff --git a/tests/run/t5879.scala b/tests/run/t5879.scala index f96a1741007e..bb0125429f6b 100644 --- a/tests/run/t5879.scala +++ b/tests/run/t5879.scala @@ -46,8 +46,8 @@ object Test { } def resolveMany(): Unit = { - val a = HashMap((0 until 100) zip (0 until 100): _*) - val b = HashMap((0 until 100) zip (100 until 200): _*) + val a = HashMap((0 until 100) zip (0 until 100)*) + val b = HashMap((0 until 100) zip (100 until 200)*) def collision(a: (Int, Int), b: (Int, Int)) = { (a._1, a._2 + b._2) } diff --git a/tests/run/t6443-varargs.scala b/tests/run/t6443-varargs.scala index 4a68801a958a..21b03324742a 100644 --- a/tests/run/t6443-varargs.scala +++ b/tests/run/t6443-varargs.scala @@ -11,6 +11,6 @@ object Test { object X extends T { type U = Int } def lazyDep(t: T)(us: t.U*): Unit = { - List(us: _*) + List(us*) } } diff --git a/tests/run/t6611.scala b/tests/run/t6611.scala index c295368aeae3..ae77eceac9be 100644 --- a/tests/run/t6611.scala +++ b/tests/run/t6611.scala @@ -1,61 +1,61 @@ object Test extends App { locally { val a = Array("1") - val a2 = Array(a: _*) + val a2 = Array(a*) assert(a ne a2) } locally { val a = Array("1": Object) - val a2 = Array(a: _*) + val a2 = Array(a*) assert(a ne a2) } locally { val a = Array(true) - val a2 = Array(a: _*) + val a2 = Array(a*) assert(a ne a2) } locally { val a = Array(1: Short) - val a2 = Array(a: _*) + val a2 = Array(a*) assert(a ne a2) } locally { val a = Array(1: Byte) - val a2 = Array(a: _*) + val a2 = Array(a*) assert(a ne a2) } locally { val a = Array(1) - val a2 = Array(a: _*) + val a2 = Array(a*) assert(a ne a2) } locally { val a = Array(1L) - val a2 = Array(a: _*) + val a2 = Array(a*) assert(a ne a2) } locally { val a = Array(1f) - val a2 = Array(a: _*) + val a2 = Array(a*) assert(a ne a2) } locally { val a = Array(1d) - val a2 = Array(a: _*) + val a2 = Array(a*) assert(a ne a2) } locally { val a = Array(()) - val a2 = Array(a: _*) + val a2 = Array(a*) assert(a ne a2) } } diff --git a/tests/run/t6611b.scala b/tests/run/t6611b.scala index 1c3cdf8d9742..ef7ac4377c05 100644 --- a/tests/run/t6611b.scala +++ b/tests/run/t6611b.scala @@ -1,6 +1,6 @@ object Test extends App { val a = Array("1") - val a2 = Array(a: _*) + val a2 = Array(a*) a2(0) = "2" assert(a(0) == "1") } diff --git a/tests/run/t889.scala b/tests/run/t889.scala index f32048819690..e00f8d8a8275 100644 --- a/tests/run/t889.scala +++ b/tests/run/t889.scala @@ -3,7 +3,7 @@ object Test extends App { val a = List("a") a match { - case Seq("a", "b", rest : _*) => println("a, b, " + rest) - case Seq(first, rest : _*) => println("first: " + first + ", rest: " + rest) + case Seq("a", "b", rest *) => println("a, b, " + rest) + case Seq(first, rest *) => println("first: " + first + ", rest: " + rest) } } diff --git a/tests/run/value-class-extractor-seq.check b/tests/run/value-class-extractor-seq.check index 9efcde120dda..1309b148230d 100644 --- a/tests/run/value-class-extractor-seq.check +++ b/tests/run/value-class-extractor-seq.check @@ -1,3 +1,3 @@ Bip(1, 2, 3) -Bip(1, 2, c : ArraySeq(3, 4, 5): _*) +Bip(1, 2, c : ArraySeq(3, 4, 5)*) class [I diff --git a/tests/run/value-class-extractor-seq.scala b/tests/run/value-class-extractor-seq.scala index 4aa246b249eb..c20e2f064121 100644 --- a/tests/run/value-class-extractor-seq.scala +++ b/tests/run/value-class-extractor-seq.scala @@ -44,7 +44,7 @@ object Bip { object Test { def f(x: Any) = x match { case Bip(a, b, c) => s"Bip($a, $b, $c)" - case Bip(a, b, c : _*) => s"Bip($a, $b, c : ${stringOf(c)}: _*)" + case Bip(a, b, c *) => s"Bip($a, $b, c : ${stringOf(c)}*)" case _ => "" + x.getClass } @@ -54,6 +54,6 @@ object Test { println(f(Array[Int](1))) } // Bip(1, 2, 3) - // Bip(1, 2, c @ [I@782be20e: _*) + // Bip(1, 2, c @ [I@782be20e*) // class [I } diff --git a/tests/run/view-iterator-stream.scala b/tests/run/view-iterator-stream.scala index 0f61f8e61fe3..3a1a00c87628 100644 --- a/tests/run/view-iterator-stream.scala +++ b/tests/run/view-iterator-stream.scala @@ -49,7 +49,7 @@ object Test { def sdt(n: Int): Perturber = p(slice(n, n * 2), drop(n / 2), take(n / 4)) def std(n: Int): Perturber = p(slice(n, n * 2), take(n / 2), drop(n / 4)) - val transforms = (fns.permutations map (xs => p(xs take 3: _*))).toList.distinct + val transforms = (fns.permutations map (xs => p(xs take 3*))).toList.distinct def mkOps(n: Int) = List[Perturber](tds(n), dts(n), sdt(n), std(n)) def runOps(n: Int) = { val xs: List[(String, List[String])] = mkOps(n) map { op => From cb470749bb1cb6906c20169faa09f0b295eaa966 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 28 Jan 2021 17:15:29 +0100 Subject: [PATCH 4/7] Allow rewriting `x: _*` to `x*` --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 12 +++++++----- tests/rewrites/rewrites.scala | 4 ++++ tests/rewrites/rewrites3x.scala | 7 +++++++ 3 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 tests/rewrites/rewrites3x.scala diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index f60ef3c9ced9..fb827bf3802b 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -376,13 +376,13 @@ object Parsers { in.nextToken() // needed to ensure progress; otherwise we might cycle forever accept(SEMI) - def rewriteNotice(additionalOption: String = "") = { + def rewriteNotice(version: String = "3.0", additionalOption: String = "") = { val optionStr = if (additionalOption.isEmpty) "" else " " ++ additionalOption - i"\nThis construct can be rewritten automatically under$optionStr -rewrite -source 3.0-migration." + i"\nThis construct can be rewritten automatically under$optionStr -rewrite -source $version-migration." } def syntaxVersionError(option: String, span: Span) = - syntaxError(em"""This construct is not allowed under $option.${rewriteNotice(option)}""", span) + syntaxError(em"""This construct is not allowed under $option.${rewriteNotice("3.0", option)}""", span) def rewriteToNewSyntax(span: Span = Span(in.offset)): Boolean = { if (in.newSyntax) { @@ -2082,8 +2082,10 @@ object Parsers { if isVarargSplice then if sourceVersion.isAtLeast(`3.1`) then report.errorOrMigrationWarning( - em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead", + em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead${rewriteNotice("3.1")}", in.sourcePos(uscoreStart)) + if sourceVersion == `3.1-migration` then + patch(source, Span(t.span.end, in.lastOffset), " *") else if opStack.nonEmpty then report.errorOrMigrationWarning( em"""`_*` can be used only for last argument of method application. @@ -2160,7 +2162,7 @@ object Parsers { // Don't error in non-strict mode, as the alternative syntax "implicit (x: T) => ... " // is not supported by Scala2.x report.errorOrMigrationWarning( - s"This syntax is no longer supported; parameter needs to be enclosed in (...)${rewriteNotice()}", + s"This syntax is no longer supported; parameter needs to be enclosed in (...)${rewriteNotice("3.1")}", source.atSpan(Span(start, in.lastOffset))) in.nextToken() val t = infixType() diff --git a/tests/rewrites/rewrites.scala b/tests/rewrites/rewrites.scala index 4630ef0cb572..6e2e4c2c8d9f 100644 --- a/tests/rewrites/rewrites.scala +++ b/tests/rewrites/rewrites.scala @@ -56,4 +56,8 @@ object test3 { } } } + def g = { x: Int => + x + 1 + } } + diff --git a/tests/rewrites/rewrites3x.scala b/tests/rewrites/rewrites3x.scala new file mode 100644 index 000000000000..d8f9f680d614 --- /dev/null +++ b/tests/rewrites/rewrites3x.scala @@ -0,0 +1,7 @@ +def f(xs: Int*) = xs.sum +def test = + f(List(1, 2, 3) *) + +def g = { implicit x: Int => + x + 1 +} \ No newline at end of file From f78be3dc47ec53edb0d49331342d7ca052622fcd Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 28 Jan 2021 18:35:23 +0100 Subject: [PATCH 5/7] Update docs --- .../changed-features/vararg-patterns.md | 42 ------------------- .../changed-features/vararg-splices.md | 42 +++++++++++++++++++ docs/sidebar.yml | 4 +- 3 files changed, 44 insertions(+), 44 deletions(-) delete mode 100644 docs/docs/reference/changed-features/vararg-patterns.md create mode 100644 docs/docs/reference/changed-features/vararg-splices.md diff --git a/docs/docs/reference/changed-features/vararg-patterns.md b/docs/docs/reference/changed-features/vararg-patterns.md deleted file mode 100644 index 6d467e69233c..000000000000 --- a/docs/docs/reference/changed-features/vararg-patterns.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -layout: doc-page -title: "Vararg Patterns" ---- - -The syntax of vararg patterns has changed. In the new syntax one writes varargs in patterns exactly -like one writes them in expressions, using a `: _*` type annotation: - -```scala -xs match - case List(1, 2, xs: _*) => println(xs) // binds xs - case List(1, _ : _*) => // wildcard pattern -``` - -The old syntax, which is shorter but less regular, is no longer supported. - -```scala -/*!*/ case List(1, 2, xs @ _*) // syntax error -/*!*/ case List(1, 2, _*) => ... // syntax error -``` - -The change to the grammar is: - -```diff - SimplePattern ::= ‘_’ - | varid - | Literal - | StableId - | StableId ‘(’ [Patterns ‘)’ -- | StableId ‘(’ [Patterns ‘,’] [varid ‘@’] ‘_’ ‘*’ ‘)’ -+ | StableId ‘(’ [Patterns ‘,’] (varid | ‘_’) ‘:’ ‘_’ ‘*’ ‘)’ - | ‘(’ [Patterns] ‘)’ - | XmlPattern -``` - -## Compatibility considerations - -To enable smooth cross compilation between Scala 2 and Scala 3, the compiler will -accept both the old and the new syntax. Under the `-source 3.1` setting, an error -will be emitted when the old syntax is encountered. They will be enabled by -default in version 3.1 of the language. - diff --git a/docs/docs/reference/changed-features/vararg-splices.md b/docs/docs/reference/changed-features/vararg-splices.md new file mode 100644 index 000000000000..d49ff1175d3f --- /dev/null +++ b/docs/docs/reference/changed-features/vararg-splices.md @@ -0,0 +1,42 @@ +--- +layout: doc-page +title: "Vararg Splices" +--- + +The syntax of vararg splices in patterns and function arguments has changed. The new syntax uses a postfix `*`, analogously to how a vararg parameter is declared. + +```scala +val arr = Array(1, 2, 3) +val lst = List(0, arr*) // vararg splice argument +lst match + case List(0, 1, xs*) => println(xs) // binds xs to Seq(2, 3) + case List(1, _*) => // wildcard pattern +``` + +The old syntax for splice arguments will be phased out. + +```scala +/*!*/ val lst = List(0, arr: _*) // syntax error + lst match + case List(1, 2, xs @ _*) // ok, equivalent to `xs*` +``` + +## Syntax + +``` +ArgumentPatterns ::= ‘(’ [Patterns] ‘)’ + | ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’ + +ParArgumentExprs ::= ‘(’ [‘using’] ExprsInParens ‘)’ + | ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘*’ ‘)’ +``` + +## Compatibility considerations + +To enable cross compilation between Scala 2 and Scala 3, the compiler will +accept both the old and the new syntax. Under the `-source 3.1` setting, an error +will be emitted when the old syntax is encountered. An automatic rewrite from old +to new syntax is offered under `-source 3.1-migration`. + + + diff --git a/docs/sidebar.yml b/docs/sidebar.yml index eac1368cfdd4..c48e8e46ee79 100644 --- a/docs/sidebar.yml +++ b/docs/sidebar.yml @@ -141,8 +141,8 @@ sidebar: url: docs/reference/changed-features/overload-resolution.html - title: Match Expressions url: docs/reference/changed-features/match-syntax.html - - title: Vararg Patterns - url: docs/reference/changed-features/vararg-patterns.html + - title: Vararg Splices + url: docs/reference/changed-features/vararg-splices.html - title: Pattern Bindings url: docs/reference/changed-features/pattern-bindings.html - title: Pattern Matching From 94166406da1d8cb8b6508bd855a5fd6cb42a59c9 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 28 Jan 2021 20:15:44 +0100 Subject: [PATCH 6/7] Update check file --- tests/neg-custom-args/fatal-warnings/i9266.check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/neg-custom-args/fatal-warnings/i9266.check b/tests/neg-custom-args/fatal-warnings/i9266.check index 4062b29a94c1..00f0973a160c 100644 --- a/tests/neg-custom-args/fatal-warnings/i9266.check +++ b/tests/neg-custom-args/fatal-warnings/i9266.check @@ -2,4 +2,4 @@ 3 |def test = { implicit x: Int => x + x } // error | ^ | This syntax is no longer supported; parameter needs to be enclosed in (...) - | This construct can be rewritten automatically under -rewrite -source 3.0-migration. + | This construct can be rewritten automatically under -rewrite -source 3.1-migration. From ac51c1125ea8a254238103ea8c40d5fc92d66004 Mon Sep 17 00:00:00 2001 From: odersky Date: Wed, 3 Feb 2021 18:02:29 +0100 Subject: [PATCH 7/7] Update compiler/src/dotty/tools/dotc/parsing/Parsers.scala Co-authored-by: Fengyun Liu --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index fb827bf3802b..20d801f7f4c9 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -2628,7 +2628,7 @@ object Parsers { ascription(p, location) else p - /** Pattern2 ::= InfixPattern [‘*’] + /** Pattern3 ::= InfixPattern [‘*’] */ def pattern3(): Tree = val p = infixPattern()