diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index f78dfed8ba14..90671c410113 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -601,6 +601,7 @@ object StdNames { val universe: N = "universe" val update: N = "update" val updateDynamic: N = "updateDynamic" + val using: N = "using" val value: N = "value" val valueOf : N = "valueOf" val values: N = "values" diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 1c8bedc8ed7b..166d44ecb4ff 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -911,11 +911,14 @@ object Parsers { /** Are the next tokens a prefix of a formal parameter or given type? * @pre: current token is LPAREN + * TODO: Drop once syntax has stabilized */ def followingIsParamOrGivenType() = val lookahead = in.LookaheadScanner() lookahead.nextToken() - if startParamOrGivenTypeTokens.contains(lookahead.token) then true + if startParamOrGivenTypeTokens.contains(lookahead.token) + || lookahead.isIdent(nme.using) + then true else if lookahead.token == IDENTIFIER then if lookahead.name == nme.inline then lookahead.nextToken() @@ -944,7 +947,6 @@ object Parsers { else lookahead.token == SUBTYPE // TODO: remove || lookahead.isIdent(nme.as) - || lookahead.token == WITH && lookahead.ch != Chars.LF // TODO: remove LF test def followingIsExtension() = val lookahead = in.LookaheadScanner() @@ -1344,8 +1346,8 @@ object Parsers { * MonoFunType ::= FunArgTypes (‘=>’ | ‘?=>’) Type * PolyFunType ::= HKTypeParamClause '=>' Type * FunArgTypes ::= InfixType - * | `(' [ [ ‘['erased'] FunArgType {`,' FunArgType } ] `)' - * | '(' [ ‘['erased'] TypedFunParam {',' TypedFunParam } ')' + * | `(' [ [ ‘[using]’ ‘['erased'] FunArgType {`,' FunArgType } ] `)' + * | '(' [ ‘[using]’ ‘['erased'] TypedFunParam {',' TypedFunParam } ')' */ def typ(): Tree = { val start = in.offset @@ -2184,7 +2186,6 @@ object Parsers { * | SimpleExpr `.' MatchClause * | SimpleExpr (TypeArgs | NamedTypeArgs) * | SimpleExpr1 ArgumentExprs - * | SimpleExpr ContextArguments * Quoted ::= ‘'’ ‘{’ Block ‘}’ * | ‘'’ ‘[’ Type ‘]’ */ @@ -2253,8 +2254,6 @@ object Parsers { case DOT => in.nextToken() simpleExprRest(selector(t), canApply = true) - case DOTWITH => - simpleExprRest(contextArguments(t), canApply = true) case LBRACKET => val tapp = atSpan(startOffset(t), in.offset) { TypeApply(t, typeArgs(namedOK = true, wildOK = false)) } simpleExprRest(tapp, canApply = true) @@ -2294,13 +2293,13 @@ object Parsers { def exprsInParensOpt(): List[Tree] = if (in.token == RPAREN) Nil else commaSeparated(exprInParens) - /** ParArgumentExprs ::= `(' [‘given’] [ExprsInParens] `)' + /** ParArgumentExprs ::= `(' [‘using’] [ExprsInParens] `)' * | `(' [ExprsInParens `,'] PostfixExpr `:' `_' `*' ')' */ def parArgumentExprs(): (List[Tree], Boolean) = inParens { if in.token == RPAREN then (Nil, false) - else if in.token == GIVEN then + else if in.token == GIVEN || isIdent(nme.using) then in.nextToken() (commaSeparated(argumentExpr), true) else @@ -2331,7 +2330,7 @@ object Parsers { else fn } - /** ParArgumentExprss ::= {ParArgumentExprs | ContextArguments} + /** ParArgumentExprss ::= {ParArgumentExprs} * * Special treatment for arguments to primary constructor annotations. * (...) is considered an argument only if it does not look like a formal @@ -2356,8 +2355,6 @@ object Parsers { parArgumentExprss( atSpan(startOffset(fn)) { mkApply(fn, parArgumentExprs()) } ) - else if in.token == DOTWITH then - parArgumentExprss(contextArguments(fn)) else fn } @@ -2387,14 +2384,6 @@ object Parsers { else Block(stats, EmptyTree) } - /** ContextArguments ::= ‘.’ ‘with’ ArgumentExprs */ - def contextArguments(t: Tree): Tree = - if in.token == DOTWITH then - atSpan(t.span.start, in.skipToken()) { - Apply(t, argumentExprs()._1).setGivenApply() - } - else t - /** Guard ::= if PostfixExpr */ def guard(): Tree = @@ -2886,23 +2875,22 @@ object Parsers { def typeParamClauseOpt(ownerKind: ParamOwner.Value): List[TypeDef] = if (in.token == LBRACKET) typeParamClause(ownerKind) else Nil - /** AnnotTypes ::= AnnotType {‘,’ AnnotType} - * Types ::= Type {‘,’ Type} + /** ContextTypes ::= Type {‘,’ Type} */ - def givenTypes(parseType: () => Tree, nparams: Int, ofClass: Boolean): List[ValDef] = - val tps = commaSeparated(parseType) + def contextTypes(ofClass: Boolean, nparams: Int): List[ValDef] = + val tps = commaSeparated(typ) var counter = nparams def nextIdx = { counter += 1; counter } val paramFlags = if ofClass then Private | Local | ParamAccessor else Param tps.map(makeSyntheticParameter(nextIdx, _, paramFlags | Synthetic | Given)) - /** ClsParamClause ::= ‘(’ [‘erased’] ClsParams ‘)’ - * GivenClsParamClause::= 'with' (‘(’ (ClsParams | Types) ‘)’ | AnnotTypes) + /** ClsParamClause ::= ‘(’ [‘erased’] ClsParams ‘)’ | UsingClsParamClause + * UsingClsParamClause::= ‘(’ ‘using’ [‘erased’] (ClsParams | ContextTypes) ‘)’ * ClsParams ::= ClsParam {‘,’ ClsParam} * ClsParam ::= {Annotation} * - * DefParamClause ::= ‘(’ [‘erased’] DefParams ‘)’ - * GivenParamClause ::= ‘with’ (‘(’ (DefParams | Types) ‘)’ | AnnotTypes) + * DefParamClause ::= ‘(’ [‘erased’] DefParams ‘)’ | UsingParamClause + * UsingParamClause ::= ‘(’ ‘using’ [‘erased’] (DefParams | ContextTypes) ‘)’ * DefParams ::= DefParam {‘,’ DefParam} * DefParam ::= {Annotation} [‘inline’] Param * @@ -2915,17 +2903,17 @@ object Parsers { ofCaseClass: Boolean = false, // owner is a case class prefix: Boolean = false, // clause precedes name of an extension method givenOnly: Boolean = false, // only given parameters allowed - firstClause: Boolean = false, // clause is the first in regular list of clauses - prefixMods: Modifiers = EmptyModifiers // is `Given` if this is a with clause + firstClause: Boolean = false // clause is the first in regular list of clauses ): List[ValDef] = { - var impliedMods: Modifiers = prefixMods + var impliedMods: Modifiers = EmptyModifiers - def impliedModOpt(token: Token, mod: () => Mod): Boolean = - if in.token == token then - impliedMods = addMod(impliedMods, atSpan(in.skipToken()) { mod() }) - true + def addParamMod(mod: () => Mod) = impliedMods = addMod(impliedMods, atSpan(in.skipToken()) { mod() }) + + def paramMods() = + if in.token == IMPLICIT then addParamMod(() => Mod.Implicit()) else - false + if in.token == GIVEN || isIdent(nme.using) then addParamMod(() => Mod.Given()) + if in.token == ERASED then addParamMod(() => Mod.Erased()) def param(): ValDef = { val start = in.offset @@ -2984,32 +2972,22 @@ object Parsers { val clause = if prefix then param() :: Nil else - if !impliedModOpt(IMPLICIT, () => Mod.Implicit()) then - impliedModOpt(GIVEN, () => Mod.Given()) - impliedModOpt(ERASED, () => Mod.Erased()) + paramMods() if givenOnly && !impliedMods.is(Given) then - syntaxError("Normal parameter clause cannot follow context parameter clause") + syntaxError("`using` expected") val isParams = !impliedMods.is(Given) || startParamTokens.contains(in.token) || isIdent && (in.name == nme.inline || in.lookaheadIn(BitSet(COLON))) if isParams then commaSeparated(() => param()) - else givenTypes(typ, nparams, ofClass) + else contextTypes(ofClass, nparams) checkVarArgsRules(clause) clause } } /** ClsParamClauses ::= {ClsParamClause} [[nl] ‘(’ [‘implicit’] ClsParams ‘)’] - * | ClsParamClause ClsParamClauses - * | ClsParamClauses1 - * ClsParamClauses1 ::= WithClsParamClause ClsParamClauses - * | AnnotTypes ClsParamClauses1ClsParamClauses * DefParamClauses ::= {DefParamClause} [[nl] ‘(’ [‘implicit’] DefParams ‘)’] - * | DefParamClause DefParamClauses - * | DefParamClauses1 - * DefParamClauses1 ::= WithCaramClause DefParamClauses - * | AnnotTypes DeParamClauses1 * * @return The parameter definitions */ @@ -3019,12 +2997,6 @@ object Parsers { def recur(firstClause: Boolean, nparams: Int): List[List[ValDef]] = newLineOptWhenFollowedBy(LPAREN) - val prefixMods = - if in.token == WITH && in.ch != Chars.LF then // TODO: remove LF test - in.nextToken() - Modifiers(Given) - else - EmptyModifiers if in.token == LPAREN then val paramsStart = in.offset val params = paramClause( @@ -3032,20 +3004,11 @@ object Parsers { ofClass = ofClass, ofCaseClass = ofCaseClass, givenOnly = givenOnly, - firstClause = firstClause, - prefixMods = prefixMods) + firstClause = firstClause) val lastClause = params.nonEmpty && params.head.mods.flags.is(Implicit) - val isGivenClause = prefixMods.is(Given) - || params.nonEmpty && params.head.mods.flags.is(Given) params :: ( if lastClause then Nil else recur(firstClause = false, nparams + params.length)) - else if prefixMods.is(Given) then - val params = givenTypes(annotType, nparams, ofClass) - params :: ( - if in.token == WITH then recur(firstClause = false, nparams + params.length) - else Nil - ) else Nil end recur @@ -3090,8 +3053,8 @@ object Parsers { /** ImportSelectors ::= id [‘=>’ id | ‘=>’ ‘_’] [‘,’ ImportSelectors] * | WildCardSelector {‘,’ WildCardSelector} - * WildCardSelector ::= ‘given’ [InfixType] - * | ‘_' [‘:’ InfixType] + * WildCardSelector ::= ‘given’ (‘_' | InfixType) + * | ‘_' */ def importSelectors(idOK: Boolean): List[ImportSelector] = val selToken = in.token @@ -3543,10 +3506,7 @@ object Parsers { /** GivenDef ::= [GivenSig] [‘_’ ‘<:’] Type ‘=’ Expr * | [GivenSig] ConstrApps [TemplateBody] - * GivenSig ::= [id] [DefTypeParamClause] {WithParamsOrTypes} ‘as’ - * ExtParamClause ::= [DefTypeParamClause] DefParamClause - * ExtMethods ::= [nl] ‘{’ ‘def’ DefDef {semi ‘def’ DefDef} ‘}’ - * WithParamsOrTypes ::= WithParamClause | AnnotTypes + * GivenSig ::= [id] [DefTypeParamClause] {UsingParamClauses} ‘as’ */ def givenDef(start: Offset, mods: Modifiers, instanceMod: Mod) = atSpan(start, nameStart) { var mods1 = addMod(mods, instanceMod) @@ -3571,18 +3531,17 @@ object Parsers { templ.body.foreach(checkExtensionMethod(tparams, _)) ModuleDef(name, templ) else - val hasLabel = !name.isEmpty && in.token == COLON || in.isIdent(nme.as) + val hasLabel = !name.isEmpty && in.token == COLON || isIdent(nme.as) if hasLabel then in.nextToken() val tparams = typeParamClauseOpt(ParamOwner.Def) val paramsStart = in.offset val vparamss = - if in.token == WITH && in.ch != Chars.LF // TODO: remove LF test - || in.token == LPAREN && followingIsParamOrGivenType() + if in.token == LPAREN && followingIsParamOrGivenType() then paramClauses() else Nil def checkAllGivens(vparamss: List[List[ValDef]], what: String) = vparamss.foreach(_.foreach(vparam => - if !vparam.mods.is(Given) then syntaxError(em"$what must be `given`", vparam.span))) + if !vparam.mods.is(Given) then syntaxError(em"$what must be preceded by `using`", vparam.span))) checkAllGivens(vparamss, "parameter of given instance") val parents = if in.token == SUBTYPE && !hasLabel then @@ -3620,7 +3579,7 @@ object Parsers { finalizeDef(gdef, mods1, start) } - /** ExtensionDef ::= [id] ‘on’ ExtParamClause GivenParamClauses ExtMethods + /** ExtensionDef ::= [id] ‘on’ ExtParamClause {UsingParamClause} ExtMethods */ def extensionDef(start: Offset, mods: Modifiers): ModuleDef = in.nextToken() @@ -3644,8 +3603,7 @@ object Parsers { val constrApp: () => Tree = () => { val t = rejectWildcardType(annotType(), fallbackTree = Ident(nme.ERROR)) // Using Ident(nme.ERROR) to avoid causing cascade errors on non-user-written code - if in.token == LPAREN || in.token == DOTWITH then parArgumentExprss(wrapNew(t)) - else t + if in.token == LPAREN then parArgumentExprss(wrapNew(t)) else t } /** ConstrApps ::= ConstrApp {(‘,’ | ‘with’) ConstrApp} diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index e5f51362eb3f..5bedbb06375b 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -593,11 +593,7 @@ object Scanners { this.copyFrom(prev) } - /** - Join CASE + CLASS => CASECLASS, - * CASE + OBJECT => CASEOBJECT, - * SEMI + ELSE => ELSE, - * COLON + => COLONEOL - * DOT + WITH => DOTWITH + /** - Join CASE + CLASS => CASECLASS, CASE + OBJECT => CASEOBJECT, SEMI + ELSE => ELSE, COLON + => COLONEOL * - Insert missing OUTDENTs at EOF */ def postProcessToken(): Unit = { @@ -623,10 +619,6 @@ object Scanners { } else if (token == EOF) { // e.g. when the REPL is parsing "val List(x, y, _*," /* skip the trailing comma */ } else reset() - case DOT => - lookahead() - if token == WITH then fuse(DOTWITH) - else reset() case COLON => if colonSyntax then observeColonEOL() case EOF | RBRACE => diff --git a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala index 68144f780e3d..8b86aa078796 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala @@ -204,7 +204,6 @@ object Tokens extends TokensCommon { final val QUOTE = 87; enter(QUOTE, "'") final val COLONEOL = 88; enter(COLONEOL, ":", ": at eol") - final val DOTWITH = 89; enter(DOTWITH, ".with") /** XML mode */ final val XMLSTART = 98; enter(XMLSTART, "$XMLSTART$<") // TODO: deprecate diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 1f4a2dbc9be3..9ebebd8c19ea 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -244,7 +244,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case _ => toTextGlobal(args, ", ") } "[applied to (" - ~ keywordText("given ").provided(tp.isContextualMethod) + ~ keywordText("using ").provided(tp.isContextualMethod) ~ keywordText("erased ").provided(tp.isErasedMethod) ~ argsText ~ ") returning " @@ -389,8 +389,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { keywordStr("${") ~ toTextGlobal(args, ", ") ~ keywordStr("}") else toTextLocal(fun) - ~ ("." ~ keywordText("with")).provided(app.isGivenApply && !homogenizedView) ~ "(" + ~ Str("using ").provided(app.isGivenApply && !homogenizedView) ~ toTextGlobal(args, ", ") ~ ")" case tree: TypeApply => diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index d74d54c70a81..256aad382939 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2663,9 +2663,9 @@ class Typer extends Namer // coming from context bounds. Issue a warning instead and offer a patch. ctx.migrationWarning( em"""Context bounds will map to context parameters. - |A `with` clause is needed to pass explicit arguments to them. + |A `using` clause is needed to pass explicit arguments to them. |This code can be rewritten automatically using -rewrite""", tree.sourcePos) - patch(Span(tree.span.end), ".with") + patch(Span(pt.args.head.span.start), "using ") tree else adaptNoArgs(wtp) // insert arguments implicitly diff --git a/docs/docs/internals/syntax.md b/docs/docs/internals/syntax.md index a36301998a21..612ae34fe9e0 100644 --- a/docs/docs/internals/syntax.md +++ b/docs/docs/internals/syntax.md @@ -104,7 +104,7 @@ yield ### Soft keywords ``` -as derives extension inline on opaque open +as derives extension inline on opaque open using ~ * | & + - ``` @@ -175,7 +175,6 @@ Refinement ::= ‘{’ [RefineDcl] {semi [RefineDcl]} ‘}’ SubtypeBounds ::= [‘>:’ Type] [‘<:’ Type] | INT TypeBoundsTree(lo, hi) TypeParamBounds ::= SubtypeBounds {‘:’ Type} ContextBounds(typeBounds, tps) Types ::= Type {‘,’ Type} -AnnotTypes ::= AnnotType {‘,’ AnnotType} ``` ### Expressions @@ -222,7 +221,6 @@ SimpleExpr ::= Path | ‘(’ ExprsInParens ‘)’ Parens(exprs) | SimpleExpr ‘.’ id Select(expr, id) | SimpleExpr ‘.’ MatchClause - | SimpleExpr ‘.’ ContextArguments | SimpleExpr TypeArgs TypeApply(expr, args) | SimpleExpr ArgumentExprs Apply(expr, args) | SimpleExpr ‘_’ PostfixOp(expr, _) @@ -232,12 +230,10 @@ Quoted ::= ‘'’ ‘{’ Block ‘}’ ExprsInParens ::= ExprInParens {‘,’ ExprInParens} ExprInParens ::= PostfixExpr ‘:’ Type -- normal Expr allows only RefinedType here | Expr -ParArgumentExprs ::= ‘(’ ExprsInParens ‘)’ exprs +ParArgumentExprs ::= ‘(’ [‘using’] ExprsInParens ‘)’ exprs | ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘:’ ‘_’ ‘*’ ‘)’ exprs :+ Typed(expr, Ident(wildcardStar)) -ParArgumentExprss ::= {ParArgumentExprs | ContextArguments} ArgumentExprs ::= ParArgumentExprs | [nl] BlockExpr -ContextArguments ::= ‘.’ ‘with’ ArgumentExprs BlockExpr ::= ‘{’ (CaseClauses | Block) ‘}’ Block ::= {BlockStat semi} [BlockResult] Block(stats, expr?) BlockStat ::= Import @@ -300,12 +296,8 @@ HkTypeParam ::= {Annotation} [‘+’ | ‘-’] (id [HkTypeParamClause] SubtypeBounds ClsParamClauses ::= {ClsParamClause} [[nl] ‘(’ [‘implicit’] ClsParams ‘)’] - | ClsParamClause ClsParamClauses - | ClsParamClauses1 -ClsParamClauses1 ::= WithClsParamClause ClsParamClauses - | AnnotTypes ClsParamClauses1 -ClsParamClause ::= [nl] ‘(’ ClsParams ‘)’ -WithClsParamClause::= ‘with’ ‘(’ (ClsParams | Types) ‘)’ +ClsParamClause ::= [nl] ‘(’ ClsParams ‘)’ + | [nl] ‘(’ ‘using’ (ClsParams | Types) ‘)’ ClsParams ::= ClsParam {‘,’ ClsParam} ClsParam ::= {Annotation} ValDef(mods, id, tpe, expr) -- point of mods on val/var [{Modifier} (‘val’ | ‘var’) | ‘inline’] Param @@ -313,13 +305,8 @@ Param ::= id ‘:’ ParamType [‘=’ Expr] | INT DefParamClauses ::= {DefParamClause} [[nl] ‘(’ [‘implicit’] DefParams ‘)’] - | DefParamClause DefParamClauses - | DefParamClauses1 -DefParamClauses1 ::= WithParamClause DefParamClauses - | AnnotTypes DefParamClauses1 -DefParamClause ::= [nl] ‘(’ DefParams ‘)’ -WithParamClause ::= ‘with’ (‘(’ (DefParams | Types) ‘)’ -WithParamsOrTypes ::= WithParamClause | AnnotTypes +DefParamClause ::= [nl] ‘(’ DefParams ‘)’ | UsingParamClause +UsingParamClause ::= [nl] ‘(’ ‘using’ (DefParams | Types) ‘)’ DefParams ::= DefParam {‘,’ DefParam} DefParam ::= {Annotation} [‘inline’] Param ValDef(mods, id, tpe, expr) -- point of mods at id. ClosureMods ::= { ‘implicit’ | ‘given’} @@ -344,7 +331,7 @@ LocalModifier ::= ‘abstract’ AccessModifier ::= (‘private’ | ‘protected’) [AccessQualifier] AccessQualifier ::= ‘[’ id ‘]’ -Annotation ::= ‘@’ SimpleType ParArgumentExprss Apply(tpe, args) +Annotation ::= ‘@’ SimpleType {ParArgumentExprs} Apply(tpe, args) Import ::= ‘import’ ImportExpr {‘,’ ImportExpr} ImportExpr ::= StableId ‘.’ ImportSpec Import(expr, sels) @@ -398,14 +385,14 @@ ObjectDef ::= id [Template] EnumDef ::= id ClassConstr InheritClauses EnumBody EnumDef(mods, name, tparams, template) GivenDef ::= [GivenSig] [‘_’ ‘<:’] Type ‘=’ Expr | [GivenSig] ConstrApps [TemplateBody] -GivenSig ::= [id] [DefTypeParamClause] {WithParamsOrTypes} ‘as’ +GivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘as’ ExtensionDef ::= [id] ‘on’ ExtParamClause {WithParamsOrTypes} ExtMethods ExtMethods ::= [nl] ‘{’ ‘def’ DefDef {semi ‘def’ DefDef} ‘}’ ExtParamClause ::= [DefTypeParamClause] ‘(’ DefParam ‘)’ Template ::= InheritClauses [TemplateBody] Template(constr, parents, self, stats) InheritClauses ::= [‘extends’ ConstrApps] [‘derives’ QualId {‘,’ QualId}] ConstrApps ::= ConstrApp {(‘,’ | ‘with’) ConstrApp} -ConstrApp ::= AnnotType ParArgumentExprss Apply(tp, args) +ConstrApp ::= AnnotType {ParArgumentExprs} Apply(tp, args) ConstrExpr ::= SelfInvocation | ‘{’ SelfInvocation {semi BlockStat} ‘}’ SelfInvocation ::= ‘this’ ArgumentExprs {ArgumentExprs} diff --git a/docs/docs/reference/contextual/by-name-context-parameters.md b/docs/docs/reference/contextual/by-name-context-parameters.md index c2c96f10351e..a259cea88ae5 100644 --- a/docs/docs/reference/contextual/by-name-context-parameters.md +++ b/docs/docs/reference/contextual/by-name-context-parameters.md @@ -12,7 +12,7 @@ trait Codec[T] { given intCodec as Codec[Int] = ??? -given optionCodec[T] with (ev: => Codec[T]) as Codec[Option[T]] { +given optionCodec[T](using ev: => Codec[T]) as Codec[Option[T]] { def write(xo: Option[T]) = xo match { case Some(x) => ev.write(x) case None => @@ -55,7 +55,7 @@ In the example above, the definition of `s` would be expanded as follows. ```scala val s = summon[Test.Codec[Option[Int]]]( - optionCodec[Int].with(intCodec) + optionCodec[Int](using intCodec) ) ``` diff --git a/docs/docs/reference/contextual/context-bounds-new.md b/docs/docs/reference/contextual/context-bounds-new.md index fa8f92a3b9a9..2ae0e932c7b8 100644 --- a/docs/docs/reference/contextual/context-bounds-new.md +++ b/docs/docs/reference/contextual/context-bounds-new.md @@ -11,11 +11,11 @@ def maximum[T: Ord](xs: List[T]): T = xs.reduceLeft(max) ``` A bound like `: Ord` on a type parameter `T` of a method or class indicates a context parameter `with Ord[T]`. The context parameter(s) generated from context bounds come last in the definition of the containing method or class. E.g., ```scala -def f[T: C1 : C2, U: C3](x: T) with (y: U, z: V) : R +def f[T: C1 : C2, U: C3](x: T)(using y: U, z: V): R ``` would expand to ```scala -def f[T, U](x: T) with (y: U, z: V) with C1[T], C2[T], C3[U]) : R +def f[T, U](x: T)(using y: U, z: V)(using C1[T], C2[T], C3[U]): R ``` Context bounds can be combined with subtype bounds. If both are present, subtype bounds come first, e.g. ```scala @@ -25,12 +25,11 @@ def g[T <: B : C](x: T): R = ... ### Migration To ease migration, context bounds in Dotty map in Scala 3.0 to old-style implicit parameters -for which arguments can be passed either using `.with(...)` or using a normal application. -From Scala 3.1 on, they will map to context parameters instead, as is described above. +for which arguments can be passed either with a `(using ...)` clause or with a normal application. From Scala 3.1 on, they will map to context parameters instead, as is described above. If the source version is `3.1` and the `-migration` command-line option is set, any pairing of an evidence context parameter stemming from a context bound with a normal argument will give a migration -warning. The warning indicates that a `.with(...)` clause should be used instead. The rewrite can be +warning. The warning indicates that a `(using ...)` clause is needed instead. The rewrite can be done automatically under `-rewrite`. ### Syntax diff --git a/docs/docs/reference/contextual/context-functions-spec.md b/docs/docs/reference/contextual/context-functions-spec.md index 265548f06783..fa5156bc4baf 100644 --- a/docs/docs/reference/contextual/context-functions-spec.md +++ b/docs/docs/reference/contextual/context-functions-spec.md @@ -22,7 +22,7 @@ methods with context parameters. Specifically, the `N`-ary function type ```scala package scala trait ContextFunctionN[-T1 , ... , -TN, +R] { - def apply with (x1: T1 , ... , xN: TN) : R + def apply(using x1: T1 , ... , xN: TN): R } ``` Context function types erase to normal function types, so these classes are @@ -45,7 +45,7 @@ The context function literal is evaluated as the instance creation expression ```scala new scala.ContextFunctionN[T1, ..., Tn, T] { - def apply with (x1: T1, ..., xn: Tn) : T = e + def apply(using x1: T1, ..., xn: Tn): T = e } ``` A context parameter may also be a wildcard represented by an underscore `_`. In that case, a fresh name for the parameter is chosen arbitrarily. diff --git a/docs/docs/reference/contextual/context-functions.md b/docs/docs/reference/contextual/context-functions.md index bf25d88e989b..332f1ecfafed 100644 --- a/docs/docs/reference/contextual/context-functions.md +++ b/docs/docs/reference/contextual/context-functions.md @@ -17,7 +17,7 @@ the same way methods with context parameters is applied. For instance: def f(x: Int): Executable[Int] = ... - f(2).with(ec) // explicit argument + f(2)(using ec) // explicit argument f(2) // argument is inferred ``` Conversely, if the expected type of an expression `E` is a context function type @@ -38,9 +38,9 @@ For example, continuing with the previous definitions, g(22) // is expanded to g((ev: ExecutionContext) ?=> 22) - g(f(2)) // is expanded to g((ev: ExecutionContext) ?=> f(2).with(ev)) + g(f(2)) // is expanded to g((ev: ExecutionContext) ?=> f(2)(using ev)) - g((ctx: ExecutionContext) ?=> f(22).with(ctx)) // is left as it is + g((ctx: ExecutionContext) ?=> f(22)(using ctx)) // is left as it is ``` ### Example: Builder Pattern @@ -86,13 +86,13 @@ that would otherwise be necessary. t } - def row(init: Row ?=> Unit) with (t: Table) = { + def row(init: Row ?=> Unit)(using t: Table) = { given r as Row init t.add(r) } - def cell(str: String) with (r: Row) = + def cell(str: String)(using r: Row) = r.add(new Cell(str)) ``` With that setup, the table construction code above compiles and expands to: @@ -100,14 +100,14 @@ With that setup, the table construction code above compiles and expands to: table { ($t: Table) ?=> row { ($r: Row) ?=> - cell("top left").with($r) - cell("top right").with($r) - }.with($t) + cell("top left")(using $r) + cell("top right")(using $r) + }(using $t) row { ($r: Row) ?=> - cell("bottom left").with($r) - cell("bottom right").with($r) - }.with($t) + cell("bottom left")(using $r) + cell("bottom right")(using $r) + }(using $t) } ``` ### Example: Postconditions @@ -118,10 +118,10 @@ As a larger example, here is a way to define constructs for checking arbitrary p object PostConditions { opaque type WrappedResult[T] = T - def result[T] with (r: WrappedResult[T]) : T = r + def result[T](using r: WrappedResult[T]): T = r - def (x: T) ensuring[T](condition: WrappedResult[T] ?=> Boolean): T = { - assert(condition.with(x)) + def (x: T).ensuring[T](condition: WrappedResult[T] ?=> Boolean): T = { + assert(condition(using x)) x } } diff --git a/docs/docs/reference/contextual/context-parameters.md b/docs/docs/reference/contextual/context-parameters.md index b6184ea9645a..7f494f7b5845 100644 --- a/docs/docs/reference/contextual/context-parameters.md +++ b/docs/docs/reference/contextual/context-parameters.md @@ -1,6 +1,6 @@ --- layout: doc-page -title: "Context Parameters" +title: "Using Clauses" --- Functional programming tends to express most dependencies as simple function parameterization. @@ -11,22 +11,19 @@ repetitive arguments instead of the programmer having to write them explicitly. For example, with the [given instances](./givens.md) defined previously, a maximum function that works for any arguments for which an ordering exists can be defined as follows: ```scala -def max[T](x: T, y: T) with (ord: Ord[T]) : T = +def max[T](x: T, y: T)(using ord: Ord[T]): T = if ord.compare(x, y) < 0 then y else x ``` -Here, `ord` is a _context parameter_ introduced with a `with` clause. +Here, `ord` is a _context parameter_ introduced with a `using` clause. The `max` method can be applied as follows: ```scala -max(2, 3).with(intOrd) +max(2, 3)(using intOrd) ``` -The `.with(intOrd)` part passes `intOrd` as an argument for the `ord` parameter. But the point of -context parameters is that this argument can also be left out (and it usually is). So the following -applications are equally valid: +The `(using intOrd)` part passes `intOrd` as an argument for the `ord` parameter. But the point of context parameters is that this argument can also be left out (and it usually is). So the following applications are equally valid: ```scala max(2, 3) max(List(1, 2, 3), Nil) ``` -Formatting hint: For legibility it is recommended to always leave one space after a `with` clause before following it with another lexeme. ## Anonymous Context Parameters @@ -35,45 +32,41 @@ mentioned explicitly at all, since it is used only in synthesized arguments for other context parameters. In that case one can avoid defining a parameter name and just provide its type. Example: ```scala -def maximum[T](xs: List[T]) with Ord[T] : T = +def maximum[T](xs: List[T])(using Ord[T]): T = xs.reduceLeft(max) ``` `maximum` takes a context parameter of type `Ord` only to pass it on as an inferred argument to `max`. The name of the parameter is left out. -Generally, context parameters may be defined either as a full parameter list `(p_1: T_1, ..., p_n: T_n)` or just as a sequence of types `T_1, ..., T_n`. Vararg parameters are not supported in with clauses. - -**Note:** According to the rules above, a `with` clause like `(A, B)` consisting of types in parentheses defines a context parameter of tuple type. But by analogy with `(a: A, b: B)` one might assume that it defines two context parameters -of type `A` and `B` instead. To avoid confusion, the compiler could issue a warning in this case that clarifies the meaning. If a context parameter of tuple type is in fact intended, the warning can be avoided by switching to a named context parameter, -e.g. `(ab: (A, B))` or enclosing the tuple in an extra set of parentheses, e.g. `((A, B))`. +Generally, context parameters may be defined either as a full parameter list `(p_1: T_1, ..., p_n: T_n)` or just as a sequence of types `T_1, ..., T_n`. Vararg parameters are not supported in using clauses. ## Inferring Complex Arguments Here are two other methods that have a context parameter of type `Ord[T]`: ```scala -def descending[T] with (asc: Ord[T]) : Ord[T] = new Ord[T] { +def descending[T](using asc: Ord[T]): Ord[T] = new Ord[T] { def compare(x: T, y: T) = asc.compare(y, x) } -def minimum[T](xs: List[T]) with Ord[T] = - maximum(xs).with(descending) +def minimum[T](xs: List[T])(using Ord[T]) = + maximum(xs)(using descending) ``` The `minimum` method's right hand side passes `descending` as an explicit argument to `maximum(xs)`. With this setup, the following calls are all well-formed, and they all normalize to the last one: ```scala minimum(xs) -maximum(xs).with(descending) -maximum(xs).with(descending.with(listOrd)) -maximum(xs).with(descending.with(listOrd.with(intOrd))) +maximum(xs)(using descending) +maximum(xs)(using descending(using listOrd)) +maximum(xs)(using descending(using listOrd(using intOrd))) ``` -## Multiple With Clauses +## Multiple Using Clauses -There can be several `with` clauses in a definition. Example: +There can be several using clauses in a definition and using clauses can be freely mixed with normal parameter clauses. Example: ```scala -def f(u: Universe) with (ctx: u.Context) with (s: ctx.Symbol, k: ctx.Kind) = ... +def f(u: Universe)(using ctx: u.Context)(using s: ctx.Symbol, k: ctx.Kind) = ... ``` -Multiple with clauses are matched left-to-right in applications. Example: +Multiple using clauses are matched left-to-right in applications. Example: ```scala object global extends Universe { type Context = ... } given ctx as global.Context { type Symbol = ...; type Kind = ... } @@ -83,56 +76,31 @@ given kind as ctx.Kind Then the following calls are all valid (and normalize to the last one) ```scala f(global) -f(global).with(ctx) -f(global).with(ctx).with(sym, kind) +f(global)(using ctx) +f(global)(using ctx)(using sym, kind) ``` -But `f(global).with(sym, kind)` would give a type error. +But `f(global)(using sym, kind)` would give a type error. -`with` clauses can be freely interspersed with normal parameters, but a normal parameter clause cannot -directly follow a `with` clause consisting only of types outside parentheses. So the following is illegal: -```scala -def f with A, B (x: C) = ... -``` -But the following variants are valid: -```scala -def g with A, B with (x: C) = ... -def h with (A, B) (x: C) = ... -``` ## Summoning Instances The method `summon` in `Predef` returns the given of a specific type. For example, the given instance for `Ord[List[Int]]` is produced by ```scala -summon[Ord[List[Int]]] // reduces to listOrd.with(intOrd) +summon[Ord[List[Int]]] // reduces to listOrd(using intOrd) ``` The `summon` method is simply defined as the (non-widening) identity function over a context parameter. ```scala -def summon[T] with (x: T): x.type = x +def summon[T](using x: T): x.type = x ``` ## Syntax -Here is the new syntax of parameters and arguments seen as a delta from the [standard context free syntax of Scala 3](../../internals/syntax.md). +Here is the new syntax of parameters and arguments seen as a delta from the [standard context free syntax of Scala 3](../../internals/syntax.md). `using` is a soft keyword, recognized only at the start of a parameter or argument list. It can be used as a normal identifier everywhere else. ``` -ClsParamClauses ::= ... - | ClsParamClause ClsParamClauses - | ClsParamClauses1 -ClsParamClauses1 ::= WithClsParamClause ClsParamClauses - | AnnotTypes ClsParamClauses1 -DefParamClauses ::= ... - | DefParamClause DefParamClauses - | DefParamClauses1 -DefParamClauses1 ::= WithParamClause DefParamClauses - | AnnotTypes DefParamClauses1 -WithClsParamClause ::= ‘with’ (‘(’ (ClsParams | Types) ‘)’ | AnnotTypes) -WithParamClause ::= ‘with’ (‘(’ (DefParams | Types) ‘)’ | AnnotTypes) -Types ::= Type {‘,’ Type} -AnnotTypes ::= AnnotType {‘,’ AnnotType} - -SimpleExpr ::= ... - | SimpleExpr ContextArguments -ParArgumentExprss ::= {ParArgumentExprs | ContextArguments} -ContextArguments ::= ‘.’ ‘with’ ArgumentExprs - +ClsParamClause ::= ... | UsingClsParamClause +DefParamClauses ::= ... | UsingParamClause +UsingClsParamClause ::= ‘(’ ‘using’ (ClsParams | Types) ‘)’ +UsingParamClause ::= ‘(’ ‘using’ (DefParams | Types) ‘)’ +ParArgumentExprs ::= ... | ‘(’ ‘using’ ExprsInParens ‘)’ ``` diff --git a/docs/docs/reference/contextual/derivation-new.md b/docs/docs/reference/contextual/derivation-new.md index 467c9cbecdf9..47a09a690e25 100644 --- a/docs/docs/reference/contextual/derivation-new.md +++ b/docs/docs/reference/contextual/derivation-new.md @@ -139,15 +139,15 @@ signature and implementation of a `derived` method for a type class `TC[_]` are following form, ```scala -def derived[T] with Mirror.Of[T] : TC[T] = ... +def derived[T](using Mirror.Of[T]): TC[T] = ... ``` That is, the `derived` method takes a context parameter of (some subtype of) type `Mirror` which defines the shape of the deriving type `T`, and computes the type class implementation according to that shape. This is all that the provider of an ADT with a `derives` clause has to know about the derivation of a type class instance. -Note that `derived` methods may have given `Mirror` arguments indirectly (e.g. by having a context argument which in turn -has a context `Mirror`, or not at all (e.g. they might use some completely different user-provided mechanism, for +Note that `derived` methods may have context `Mirror` parameters indirectly (e.g. by having a context argument which in turn +has a context `Mirror` parameter, or not at all (e.g. they might use some completely different user-provided mechanism, for instance using Dotty macros or runtime reflection). We expect that (direct or indirect) `Mirror` based implementations will be the most common and that is what this document emphasises. @@ -175,7 +175,7 @@ we need to implement a method `Eq.derived` on the companion object of `Eq` that a `Mirror[T]`. Here is a possible implementation, ```scala -inline given derived[T] with (m: Mirror.Of[T]) as Eq[T] = { +inline given derived[T](using m: Mirror.Of[T]) as Eq[T] = { val elemInstances = summonAll[m.MirroredElemTypes] // (1) inline m match { // (2) case s: Mirror.SumOf[T] => eqSum(s, elemInstances) @@ -281,7 +281,7 @@ object Eq { } } - inline given derived[T] with (m: Mirror.Of[T]) as Eq[T] = { + inline given derived[T](using m: Mirror.Of[T]) as Eq[T] = { val elemInstances = summonAll[m.MirroredElemTypes] inline m match { case s: Mirror.SumOf[T] => eqSum(s, elemInstances) @@ -312,7 +312,7 @@ In this case the code that is generated by the inline expansion for the derived following, after a little polishing, ```scala -given derived$Eq[T] with (eqT: Eq[T]) as Eq[Opt[T]] = +given derived$Eq[T](using eqT: Eq[T]) as Eq[Opt[T]] = eqSum(summon[Mirror[Opt[T]]], List( eqProduct(summon[Mirror[Sm[T]]], List(summon[Eq[T]])) @@ -329,24 +329,27 @@ As a third example, using a higher level library such as shapeless the type clas `derived` method as, ```scala -given eqSum[A] with (inst: => K0.CoproductInstances[Eq, A]) as Eq[A] { +given eqSum[A](using inst: => K0.CoproductInstances[Eq, A]) as Eq[A] { def eqv(x: A, y: A): Boolean = inst.fold2(x, y)(false)( [t] => (eqt: Eq[t], t0: t, t1: t) => eqt.eqv(t0, t1) ) } -given eqProduct[A] with (inst: K0.ProductInstances[Eq, A]) as Eq[A] { +given eqProduct[A](using inst: K0.ProductInstances[Eq, A]) as Eq[A] { def eqv(x: A, y: A): Boolean = inst.foldLeft2(x, y)(true: Boolean)( [t] => (acc: Boolean, eqt: Eq[t], t0: t, t1: t) => Complete(!eqt.eqv(t0, t1))(false)(true) ) } - -inline def derived[A] with (gen: K0.Generic[A]) as Eq[A] = gen.derive(eqSum, eqProduct) +inline def derived[A](using gen: K0.Generic[A]) as Eq[A] = gen.derive(eqSum, eqProduct) ``` The framework described here enables all three of these approaches without mandating any of them. +For a brief discussion on how to use macros to write a type class `derived` +method please read more at [How to write a type class `derived` method using +macros](./derivation-macro.md). + ### Deriving instances elsewhere Sometimes one would like to derive a type class instance for an ADT after the ADT is defined, without being able to diff --git a/docs/docs/reference/contextual/extension-methods-new.md b/docs/docs/reference/contextual/extension-methods-new.md index bdca8071881c..6cbedce4cebd 100644 --- a/docs/docs/reference/contextual/extension-methods-new.md +++ b/docs/docs/reference/contextual/extension-methods-new.md @@ -50,7 +50,7 @@ trait StringSeqOps { ``` We can make the extension method available by defining a given `StringSeqOps` instance, like this: ```scala -given ops1: StringSeqOps +given ops1 as StringSeqOps ``` Then ```scala @@ -69,9 +69,9 @@ Assume a selection `e.m[Ts]` where `m` is not a member of `e`, where the type ar and where `T` is the expected type. The following two rewritings are tried in order: 1. The selection is rewritten to `m[Ts](e)`. - 2. If the first rewriting does not typecheck with expected type `T`, and there is a given instance `i` - in either the current scope or in the implicit scope of `T`, and `i` defines an extension - method named `m`, then selection is expanded to `i.m[Ts](e)`. + 2. If the first rewriting does not typecheck with expected type `T`, and there is a given instance `g` + in either the current scope or in the context scope of `T`, and `g` defines an extension + method named `m`, then selection is expanded to `g.m[Ts](e)`. This second rewriting is attempted at the time where the compiler also tries an implicit conversion from `T` to a type containing `m`. If there is more than one way of rewriting, an ambiguity error results. @@ -140,35 +140,33 @@ extension listOps on [T](xs: List[T]) { def third: T = xs.tail.tail.head } -extension on [T](xs: List[T])(given Ordering[T]) { +extension on [T](xs: List[T])(using Ordering[T]) { def largest(n: Int) = xs.sorted.takeRight(n) } ``` -If a given extension is anonymous (as in the last clause), its name is synthesized from the name of the first defined extension method. +If an extension is anonymous (as in the last clause), its name is synthesized from the name of the first defined extension method. -The extensions above are equivalent to the following regular given instances where the implemented parent is `AnyRef` and the parameters in the `extension` clause are repeated in each extension method definition: +The extensions above are equivalent to the following regular given instances where the implemented parent is `AnyRef` and the leading parameters are repeated in each extension method definition: ```scala -given stringOps: AnyRef { +given stringOps as AnyRef { def (xs: Seq[String]).longestStrings: Seq[String] = { val maxLength = xs.map(_.length).max xs.filter(_.length == maxLength) } } -given listOps: AnyRef { - def [T](xs: List[T]) second = xs.tail.head - def [T](xs: List[T]) third: T = xs.tail.tail.head +given listOps as AnyRef { + def [T](xs: List[T]).second = xs.tail.head + def [T](xs: List[T]).third: T = xs.tail.tail.head } -given extension_largest_List_T: AnyRef { - def [T](xs: List[T]) largest (given Ordering[T])(n: Int) = +given extension_largest_List_T as AnyRef { + def [T](xs: List[T]).largest(using Ordering[T])(n: Int) = xs.sorted.takeRight(n) } ``` -`extension` and `on` are soft keywords. They can also be used as a regular identifiers. - ### Syntax -Here are the syntax changes for extension methods and given extensions relative +Here are the syntax changes for extension methods and collective extensions relative to the [current syntax](../../internals/syntax.md). `extension` is a soft keyword, recognized only in tandem with `on`. It can be used as an identifier everywhere else. ``` diff --git a/docs/docs/reference/contextual/extension-methods.md b/docs/docs/reference/contextual/extension-methods.md index f852073659a5..3df3ca573978 100644 --- a/docs/docs/reference/contextual/extension-methods.md +++ b/docs/docs/reference/contextual/extension-methods.md @@ -143,7 +143,7 @@ extension listOps on [T](xs: List[T]) { def third: T = xs.tail.tail.head } -extension on [T](xs: List[T]) with Ordering[T] { +extension on [T](xs: List[T])(using Ordering[T]) { def largest(n: Int) = xs.sorted.takeRight(n) } ``` @@ -158,11 +158,11 @@ given stringOps as AnyRef { } } given listOps as AnyRef { - def [T](xs: List[T]) second = xs.tail.head - def [T](xs: List[T]) third: T = xs.tail.tail.head + def [T](xs: List[T]).second = xs.tail.head + def [T](xs: List[T]).third: T = xs.tail.tail.head } given extension_largest_List_T as AnyRef { - def [T](xs: List[T]) largest with (Ordering[T]) (n: Int) = + def [T](xs: List[T]).largest(using Ordering[T])(n: Int) = xs.sorted.takeRight(n) } ``` @@ -171,7 +171,7 @@ given extension_largest_List_T as AnyRef { Here are the syntax changes for extension methods and collective extensions relative to the [current syntax](../../internals/syntax.md). `extension` is a soft keyword, recognized only -in tandem with `of`. It can be used as an identifier everywhere else. +in tandem with `on`. It can be used as an identifier everywhere else. ``` DefSig ::= ... | ExtParamClause [nl] [‘.’] id DefParamClauses diff --git a/docs/docs/reference/contextual/given-imports.md b/docs/docs/reference/contextual/given-imports.md index 8471ade65a93..723f01159b3a 100644 --- a/docs/docs/reference/contextual/given-imports.md +++ b/docs/docs/reference/contextual/given-imports.md @@ -3,12 +3,12 @@ layout: doc-page title: "Importing Givens" --- -A special form of import wildcard selector is used to import givens. Example: +A special form of import wildcard selector is used to import given instances. Example: ```scala object A { class TC given tc as TC - def f with TC = ??? + def f(using TC) = ??? } object B { import A._ @@ -47,7 +47,7 @@ is expressed by multiple `given` selectors. ``` import A.{given T1, ..., given Tn} ``` -Importing all givens of a parameterized type is expressed by wildcard arguments. +Importing all given instances of a parameterized type is expressed by wildcard arguments. For instance, assuming the object ```scala object Instances { diff --git a/docs/docs/reference/contextual/givens.md b/docs/docs/reference/contextual/givens.md index fc84de72ef57..939d91e6c2ce 100644 --- a/docs/docs/reference/contextual/givens.md +++ b/docs/docs/reference/contextual/givens.md @@ -18,7 +18,7 @@ given intOrd as Ord[Int] { if (x < y) -1 else if (x > y) +1 else 0 } -given listOrd[T] with (ord: Ord[T]) as Ord[List[T]] { +given listOrd[T](using ord: Ord[T]) as Ord[List[T]] { def compare(xs: List[T], ys: List[T]): Int = (xs, ys) match case (Nil, Nil) => 0 @@ -29,10 +29,10 @@ given listOrd[T] with (ord: Ord[T]) as Ord[List[T]] { if (fst != 0) fst else compare(xs1, ys1) } ``` -This code defines a trait `Ord` with two given declarations. `intOrd` defines +This code defines a trait `Ord` with two given instances. `intOrd` defines a given for the type `Ord[Int]` whereas `listOrd[T]` defines givens -for `Ord[List[T]]` for all types `T` that come with a given for `Ord[T]` -themselves. The `with` clause in `listOrd` defines a condition: There must be a +for `Ord[List[T]]` for all types `T` that come with a given instance for `Ord[T]` +themselves. The `using` clause in `listOrd` defines a condition: There must be a given of type `Ord[T]` for a given of type `List[Ord[T]]` to exist. Such conditions are expanded by the compiler to context parameters, which are explained in the [next section](./context-parameters.md). @@ -43,14 +43,14 @@ The name of a given can be left out. So the definitions of the last section can also be expressed like this: ```scala given Ord[Int] { ... } -given [T] with Ord[T] as Ord[List[T]] { ... } +given [T](using Ord[T]) as Ord[List[T]] { ... } ``` If the name of a given is missing, the compiler will synthesize a name from the implemented type(s). ## Alias Givens -An alias can be used to define a given that is equal to some expression. E.g.: +An alias can be used to define a given instance that is equal to some expression. E.g.: ```scala given global as ExecutionContext = new ForkJoinPool() ``` @@ -61,8 +61,8 @@ returned for this and all subsequent accesses to `global`. Alias givens can be anonymous, e.g. ```scala -given as Position = enclosingTree.position -given with (outer: Context) as Context = outer.withOwner(currentOwner) +given Position = enclosingTree.position +given (using outer: Context) as Context = outer.withOwner(currentOwner) ``` An alias given can have type parameters and implicit parameters just like any other given, but it can only implement a single type. @@ -81,19 +81,18 @@ which can be a proper subtype of the declared result type `Annotations[A, T]`. ## Given Instance Initialization -A given without type or context parameters is initialized on-demand, the first +A given instance without type or context parameters is initialized on-demand, the first time it is accessed. If a given has type or context parameters, a fresh instance is created for each reference. ## Syntax -Here is the new syntax for givens, seen as a delta from the [standard context free syntax of Scala 3](../../internals/syntax.md). +Here is the new syntax for given instances, seen as a delta from the [standard context free syntax of Scala 3](../../internals/syntax.md). ``` TmplDef ::= ... | ‘given’ GivenDef GivenDef ::= [GivenSig] [‘_’ ‘<:’] Type ‘=’ Expr | [GivenSig] ConstrApp {‘,’ ConstrApp } [TemplateBody] -GivenSig ::= [id] [DefTypeParamClause] {WithParamsOrTypes} ‘as’ -WithParamsOrTypes ::= WithParamClause | AnnotTypes +GivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘as’ ``` diff --git a/docs/docs/reference/contextual/motivation-new.md b/docs/docs/reference/contextual/motivation-new.md index ed2402e6cd98..50add4815613 100644 --- a/docs/docs/reference/contextual/motivation-new.md +++ b/docs/docs/reference/contextual/motivation-new.md @@ -49,7 +49,7 @@ The following pages introduce a redesign of contextual abstractions in Scala. Th 1. [Given Instances](./givens.md) are a new way to define basic terms that can be synthesized. They replace implicit definitions. The core principle of the proposal is that, rather than mixing the `implicit` modifier with a large number of features, we have a single way to define terms that can be synthesized for types. - 2. [With Clauses](./context-parameters.md) define are a new syntax for implicit _parameters_ and their _arguments_. It unambiguously aligns parameters and arguments, solving a number of language warts. It also allows us to have several with clauses in a definition. + 2. [Using Clauses](./context-parameters.md) define are a new syntax for implicit _parameters_ and their _arguments_. It unambiguously aligns parameters and arguments, solving a number of language warts. It also allows us to have several with clauses in a definition. 3. ["Given" Imports](./given-imports.md) are a new class of import selectors that specifically import givens and nothing else. diff --git a/docs/docs/reference/contextual/multiversal-equality-new.md b/docs/docs/reference/contextual/multiversal-equality-new.md index 3ea0a7c6a816..39ffac6de5e0 100644 --- a/docs/docs/reference/contextual/multiversal-equality-new.md +++ b/docs/docs/reference/contextual/multiversal-equality-new.md @@ -33,7 +33,7 @@ class T derives Eql ``` Alternatively, one can also provide an `Eql` given instance directly, like this: ```scala -given as Eql[T, T] = Eql.derived +given Eql[T, T] = Eql.derived ``` This definition effectively says that values of type `T` can (only) be compared to other values of type `T` when using `==` or `!=`. The definition @@ -59,10 +59,10 @@ definitions below make values of type `A` and type `B` comparable with each other, but not comparable to anything else: ```scala -given as Eql[A, A] = Eql.derived -given as Eql[B, B] = Eql.derived -given as Eql[A, B] = Eql.derived -given as Eql[B, A] = Eql.derived +given Eql[A, A] = Eql.derived +given Eql[B, B] = Eql.derived +given Eql[A, B] = Eql.derived +given Eql[B, A] = Eql.derived ``` The `scala.Eql` object defines a number of `Eql` given instances that together define a rule book for what standard types can be compared (more details below). @@ -95,9 +95,9 @@ Instead of defining `Eql` instances directly, it is often more convenient to der class Box[T](x: T) derives Eql ``` By the usual rules of [typeclass derivation](./derivation.md), -this generates the following `Eql` given in the companion object of `Box`: +this generates the following `Eql` instance in the companion object of `Box`: ```scala -given [T, U] with Eql[T, U]) as Eql[Box[T], Box[U]] = Eql.derived +given [T, U](using Eql[T, U]) as Eql[Box[T], Box[U]] = Eql.derived ``` That is, two boxes are comparable with `==` or `!=` if their elements are. Examples: ```scala @@ -175,7 +175,7 @@ This generic version of `contains` is the one used in the current (Scala 2.13) v It looks different but it admits exactly the same applications as the `contains(x: Any)` definition we started with. However, we can make it more useful (i.e. restrictive) by adding an `Eql` parameter: ```scala - def contains[U >: T](x: U) with Eql[T, U] : Boolean // (1) + def contains[U >: T](x: U)(using Eql[T, U]): Boolean // (1) ``` This version of `contains` is equality-safe! More precisely, given `x: T`, `xs: List[T]` and `y: U`, then `xs.contains(y)` is type-correct if and only if @@ -183,7 +183,7 @@ This version of `contains` is equality-safe! More precisely, given Unfortunately, the crucial ability to "lift" equality type checking from simple equality and pattern matching to arbitrary user-defined operations gets lost if we restrict ourselves to an equality class with a single type parameter. Consider the following signature of `contains` with a hypothetical `Eql1[T]` type class: ```scala - def contains[U >: T](x: U) with Eql1[U] : Boolean // (2) + def contains[U >: T](x: U)(using Eql1[U]): Boolean // (2) ``` This version could be applied just as widely as the original `contains(x: Any)` method, since the `Eql1[Any]` fallback is always available! So we have gained nothing. What got lost in the transition to a single parameter type class was the original rule that `Eql[A, B]` is available only if neither `A` nor `B` have a reflexive `Eql` instance. That rule simply cannot be expressed if there is a single type parameter for `Eql`. diff --git a/docs/docs/reference/contextual/relationship-implicits-new.md b/docs/docs/reference/contextual/relationship-implicits-new.md index d0d06d3cfb8c..16b0a010de28 100644 --- a/docs/docs/reference/contextual/relationship-implicits-new.md +++ b/docs/docs/reference/contextual/relationship-implicits-new.md @@ -21,14 +21,14 @@ Given instances can be mapped to combinations of implicit objects, classes and i ``` 2. Parameterized givens are mapped to combinations of classes and implicit methods. E.g., ```scala - given listOrd[T] with (ord: Ord[T]) as Ord[List[T]] { ... } + given listOrd[T](using ord: Ord[T]) as Ord[List[T]] { ... } ``` maps to ```scala class ListOrd[T](implicit ord: Ord[T]) extends Ord[List[T]] { ... } final implicit def ListOrd[T](implicit ord: Ord[T]): ListOrd[T] = new ListOrd[T] ``` - 3. Alias givens map to implicit methods or implicit lazy vals. If an alias has neither type nor implicit parameters, + 3. Alias givens map to implicit methods or implicit lazy vals. If an alias has neither type nor context parameters, it is treated as a lazy val, unless the right hand side is a simple reference, in which case we can use a forwarder to that reference without caching it. @@ -37,7 +37,7 @@ Examples: given global as ExecutionContext = new ForkJoinContext() val ctx: Context -given as Context = ctx +given Context = ctx ``` would map to ```scala @@ -82,15 +82,15 @@ gets the synthesized name `extension_second_List_T`. Given clauses correspond largely to Scala-2's implicit parameter clauses. E.g. ```scala -def max[T](x: T, y: T) with (ord: Ord[T]) : T +def max[T](x: T, y: T)(using ord: Ord[T]): T ``` would be written ```scala def max[T](x: T, y: T)(implicit ord: Ord[T]): T ``` in Scala 2. The main difference concerns applications of such parameters. -Explicit arguments to parameters of with clauses _must_ be written using `.with(...)`, -mirroring the definition syntax. E.g, `max(2, 3).with(IntOrd)`. +Explicit arguments to parameters of using clauses _must_ be written using `(using ...)`, +mirroring the definition syntax. E.g, `max(2, 3)(using IntOrd)`. Scala 2 uses normal applications `max(2, 3)(IntOrd)` instead. The Scala 2 syntax has some inherent ambiguities and restrictions which are overcome by the new syntax. For instance, multiple implicit parameter lists are not available in the old syntax, even though they can be simulated using auxiliary objects in the "Aux" pattern. The `summon` method corresponds to `implicitly` in Scala 2. @@ -103,8 +103,8 @@ asked for. Context bounds are the same in both language versions. They expand to the respective forms of implicit parameters. -**Note:** To ease migration, context bounds in Dotty map for a limited time to old-style implicit parameters for which arguments can be passed either followin `.with(...)` or -with a normal application. Once old-style implicits are deprecated, context bounds +**Note:** To ease migration, context bounds in Dotty map for a limited time to old-style implicit parameters for which arguments can be passed either in a using clause or +in a normal argument list. Once old-style implicits are deprecated, context bounds will map to with clauses instead. ### Extension Methods @@ -154,7 +154,7 @@ given stringToToken as Conversion[String, Token] = KeyWord(_) ### Implicit Classes -Implicit classes in Scala 2 are often used to define extension methods, which are directly supported in Dotty. Other uses of implicit classes can be simulated by a pair of a regular class and a given as `Conversion` type. +Implicit classes in Scala 2 are often used to define extension methods, which are directly supported in Dotty. Other uses of implicit classes can be simulated by a pair of a regular class and a given `Conversion` instance. ### Implicit Values @@ -166,7 +166,7 @@ lazy implicit val pos: Position = tree.sourcePos can be expressed in Dotty as ```scala lazy val pos: Position = tree.sourcePos -given as Position = pos +given Position = pos ``` ### Abstract Implicits @@ -178,7 +178,7 @@ implicit def symDecorator: SymDecorator can be expressed in Dotty as ```scala def symDecorator: SymDecorator -given as SymDecorator = symDecorator +given SymDecorator = symDecorator ``` ## Implementation Status and Timeline diff --git a/docs/docs/reference/contextual/typeclasses-new.md b/docs/docs/reference/contextual/typeclasses-new.md index ee2c20226d0b..8175cea64e93 100644 --- a/docs/docs/reference/contextual/typeclasses-new.md +++ b/docs/docs/reference/contextual/typeclasses-new.md @@ -19,15 +19,15 @@ trait Monoid[T] extends SemiGroup[T] { } object Monoid { - def apply[T] with (m: Monoid[T]) = m + def apply[T](using m: Monoid[T]) = m } -given as Monoid[String] { +given Monoid[String] { def (x: String) combine (y: String): String = x.concat(y) def unit: String = "" } -given as Monoid[Int] { +given Monoid[Int] { def (x: Int) combine (y: Int): Int = x + y def unit: Int = 0 } diff --git a/tests/disabled/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala b/tests/disabled/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala index fe5efaebc587..545da384ed84 100644 --- a/tests/disabled/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala +++ b/tests/disabled/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala @@ -4,7 +4,7 @@ import scala.quoted.autolift.{given _} object Macros { inline def foo(i: => Int): Int = ${ fooImpl('i) } - def fooImpl(i: Expr[Int]) with QuoteContext : Expr[Int] = { + def fooImpl(i: Expr[Int])(given QuoteContext): Expr[Int] = { given Toolbox = Toolbox.make(getClass.getClassLoader) val y: Int = run(i) y diff --git a/tests/disabled/reflect/run/t3425b/Base_1.scala b/tests/disabled/reflect/run/t3425b/Base_1.scala index e09a30eed2b1..bdbc124d2913 100644 --- a/tests/disabled/reflect/run/t3425b/Base_1.scala +++ b/tests/disabled/reflect/run/t3425b/Base_1.scala @@ -26,7 +26,7 @@ object Gen { } case class Pair(tp1: Tp, tp2: Tp) { def expr = s"((new ABC): $tp)" - def tp = s"($tp1) with $tp2" + def tp = s"($tp1) with ($tp2)" } val traits = Vector("Any", "A", "B", "C") map ("%6s" format _) val types = Vector("P", "Q", "R forSome { type R <: P with Q }") @@ -39,7 +39,7 @@ object Gen { import p._ List( s"type R1_$idx = $tp", - s"type R2_$idx = R1_$idx { val y: (${tp1.elem}) with ${tp2.elem} }" + s"type R2_$idx = R1_$idx { val y: (${tp1.elem}) with (${tp2.elem}) }" ) } diff --git a/tests/generic-java-signatures/i3653.scala b/tests/generic-java-signatures/i3653.scala index 42a3a727543a..2fef47e4fbe3 100644 --- a/tests/generic-java-signatures/i3653.scala +++ b/tests/generic-java-signatures/i3653.scala @@ -5,7 +5,7 @@ class Foo { c0: T, c1: T, c2: T, c3: T, c4: T, c5: T, c6: T, c7: T, c8: T, c9: T) => 0 // #6946 - def baz = (x: String ?=> Unit) => x.with("") + def baz = (x: String ?=> Unit) => x(using "") } object Test { diff --git a/tests/neg-custom-args/erased/i2642.scala b/tests/neg-custom-args/erased/i2642.scala index e3527d3f522c..fdb73e215d52 100644 --- a/tests/neg-custom-args/erased/i2642.scala +++ b/tests/neg-custom-args/erased/i2642.scala @@ -1,5 +1,5 @@ object Foo { - type X = (given) => Int // error: an identifier expected, but ')' found + type X = (using ) => Int // error: an identifier expected, but ')' found def ff: X = () // error: found: Unit, expected: Int type Y = (erased) => Int // error: empty function may not be erased diff --git a/tests/neg-custom-args/fatal-warnings/quote-simple-hole.scala b/tests/neg-custom-args/fatal-warnings/quote-simple-hole.scala index 047c9d6c30f4..626b4d76787f 100644 --- a/tests/neg-custom-args/fatal-warnings/quote-simple-hole.scala +++ b/tests/neg-custom-args/fatal-warnings/quote-simple-hole.scala @@ -1,6 +1,6 @@ import scala.quoted.QuoteContext -def test with QuoteContext = { +def test(using QuoteContext) = { val x = '{0} val y = '{ // error: Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ. $x diff --git a/tests/neg-macros/GenericNumLits/Even_1.scala b/tests/neg-macros/GenericNumLits/Even_1.scala index ecfa97a35262..c3087600865b 100644 --- a/tests/neg-macros/GenericNumLits/Even_1.scala +++ b/tests/neg-macros/GenericNumLits/Even_1.scala @@ -11,7 +11,7 @@ object Even { else throw FromDigits.MalformedNumber(s"$digits is odd") } - private def evenFromDigitsImpl(digits: Expr[String]) with (ctx: QuoteContext) : Expr[Even] = digits match { + private def evenFromDigitsImpl(digits: Expr[String])(using ctx: QuoteContext): Expr[Even] = digits match { case Const(ds) => val ev = try evenFromDigits(ds) diff --git a/tests/neg-macros/delegate-match-1/Macro_1.scala b/tests/neg-macros/delegate-match-1/Macro_1.scala index 3af85f3ffbc6..b0e3f0c83185 100644 --- a/tests/neg-macros/delegate-match-1/Macro_1.scala +++ b/tests/neg-macros/delegate-match-1/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted.matching._ inline def f: Any = ${ fImpl } -private def fImpl with (qctx: QuoteContext) : Expr[Unit] = { +private def fImpl(using qctx: QuoteContext): Expr[Unit] = { import qctx.tasty.{_, given _} searchImplicit(('[A]).unseal.tpe) match { case x: ImplicitSearchSuccess => diff --git a/tests/neg-macros/delegate-match-2/Macro_1.scala b/tests/neg-macros/delegate-match-2/Macro_1.scala index 3af85f3ffbc6..62973a0b015f 100644 --- a/tests/neg-macros/delegate-match-2/Macro_1.scala +++ b/tests/neg-macros/delegate-match-2/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted.matching._ inline def f: Any = ${ fImpl } -private def fImpl with (qctx: QuoteContext) : Expr[Unit] = { +private def fImpl (using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} searchImplicit(('[A]).unseal.tpe) match { case x: ImplicitSearchSuccess => diff --git a/tests/neg-macros/delegate-match-3/Macro_1.scala b/tests/neg-macros/delegate-match-3/Macro_1.scala index 3af85f3ffbc6..9d98e3c52307 100644 --- a/tests/neg-macros/delegate-match-3/Macro_1.scala +++ b/tests/neg-macros/delegate-match-3/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted.matching._ inline def f: Any = ${ fImpl } -private def fImpl with (qctx: QuoteContext) : Expr[Unit] = { +private def fImpl(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} searchImplicit(('[A]).unseal.tpe) match { case x: ImplicitSearchSuccess => diff --git a/tests/neg-macros/i6432/Macro_1.scala b/tests/neg-macros/i6432/Macro_1.scala index 1daffcc70935..14bc791cab46 100644 --- a/tests/neg-macros/i6432/Macro_1.scala +++ b/tests/neg-macros/i6432/Macro_1.scala @@ -6,7 +6,7 @@ import scala.quoted.matching._ object Macro { inline def (sc: => StringContext).foo(args: String*): Unit = ${ impl('sc) } - def impl(sc: Expr[StringContext]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl(sc: Expr[StringContext])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} sc match { case '{ StringContext(${ExprSeq(parts)}: _*) } => diff --git a/tests/neg-macros/i6432b/Macro_1.scala b/tests/neg-macros/i6432b/Macro_1.scala index 1daffcc70935..14bc791cab46 100644 --- a/tests/neg-macros/i6432b/Macro_1.scala +++ b/tests/neg-macros/i6432b/Macro_1.scala @@ -6,7 +6,7 @@ import scala.quoted.matching._ object Macro { inline def (sc: => StringContext).foo(args: String*): Unit = ${ impl('sc) } - def impl(sc: Expr[StringContext]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl(sc: Expr[StringContext])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} sc match { case '{ StringContext(${ExprSeq(parts)}: _*) } => diff --git a/tests/neg-macros/i6976/Macro_1.scala b/tests/neg-macros/i6976/Macro_1.scala index 3279852bef76..c54c7be7d188 100644 --- a/tests/neg-macros/i6976/Macro_1.scala +++ b/tests/neg-macros/i6976/Macro_1.scala @@ -7,7 +7,7 @@ import scala.tasty._ object macros { inline def mcr(x: => Any) = ${mcrImpl('x)} - def mcrImpl(body: Expr[Any]) with (ctx: QuoteContext) : Expr[Any] = { + def mcrImpl(body: Expr[Any])(using ctx: QuoteContext) : Expr[Any] = { import ctx.tasty.{_, given _} body.unseal match { case Block(_, _) => '{2} } } diff --git a/tests/neg-macros/i7142/Macro_1.scala b/tests/neg-macros/i7142/Macro_1.scala index ebdf818baa54..6791ad1ed7d3 100644 --- a/tests/neg-macros/i7142/Macro_1.scala +++ b/tests/neg-macros/i7142/Macro_1.scala @@ -1,7 +1,7 @@ package macros import scala.quoted._ -def oops(given QuoteContext) = { +def oops(using QuoteContext) = { var v = '{0}; val q = '{ (x: Int) => ${ v = '{x}; v } } '{$q($v)} diff --git a/tests/neg-macros/i7142b/Macro_1.scala b/tests/neg-macros/i7142b/Macro_1.scala index 0da378b536d2..c7bde0e7a030 100644 --- a/tests/neg-macros/i7142b/Macro_1.scala +++ b/tests/neg-macros/i7142b/Macro_1.scala @@ -2,7 +2,7 @@ package macros import scala.quoted._ import scala.util.control.NonLocalReturns._ -def oops(given QuoteContext): Expr[Int] = +def oops(using QuoteContext): Expr[Int] = returning('{ { (x: Int) => ${ throwReturn('x) }} apply 0 }) inline def test = ${oops} diff --git a/tests/neg-macros/i7142c/Macro_1.scala b/tests/neg-macros/i7142c/Macro_1.scala index 3b6638b9036d..b2d5cc1b413c 100644 --- a/tests/neg-macros/i7142c/Macro_1.scala +++ b/tests/neg-macros/i7142c/Macro_1.scala @@ -1,7 +1,7 @@ package macros import scala.quoted._ -def oops(given QuoteContext) = { +def oops(using QuoteContext) = { var v = '{0}; val q = '{ val x: Int = 8; ${ v = '{x}; v } } v diff --git a/tests/neg-macros/i7142d/Macro_1.scala b/tests/neg-macros/i7142d/Macro_1.scala index 3322ff93b514..f4be5eeba997 100644 --- a/tests/neg-macros/i7142d/Macro_1.scala +++ b/tests/neg-macros/i7142d/Macro_1.scala @@ -1,7 +1,7 @@ package macros import scala.quoted._ -def oops(given QuoteContext) = { +def oops(using QuoteContext) = { var v = '{0}; val q = '{ ??? match { case x => ${ v = '{x}; v } } } v diff --git a/tests/neg-macros/i7142e/Macro_1.scala b/tests/neg-macros/i7142e/Macro_1.scala index 7ba07db645e8..ee0aa824fb93 100644 --- a/tests/neg-macros/i7142e/Macro_1.scala +++ b/tests/neg-macros/i7142e/Macro_1.scala @@ -1,7 +1,7 @@ package macros import scala.quoted._ -def oops(given QuoteContext) = { +def oops(using QuoteContext) = { var v = '{0}; val q = '{ def x: Int = 8; ${ v = '{x}; v } } v diff --git a/tests/neg-macros/i7142f/Macro_1.scala b/tests/neg-macros/i7142f/Macro_1.scala index e1fdb0ed83a9..2fd075e04741 100644 --- a/tests/neg-macros/i7142f/Macro_1.scala +++ b/tests/neg-macros/i7142f/Macro_1.scala @@ -1,7 +1,7 @@ package macros import scala.quoted._ -def oops(given QuoteContext) = { +def oops(using QuoteContext) = { var v = '{0}; val q = '{ def f(x: Int): Int = ${ v = '{x}; v } } v diff --git a/tests/neg-macros/i7142g/Macro_1.scala b/tests/neg-macros/i7142g/Macro_1.scala index ea6f966cf420..33d67d35b527 100644 --- a/tests/neg-macros/i7142g/Macro_1.scala +++ b/tests/neg-macros/i7142g/Macro_1.scala @@ -1,7 +1,7 @@ package macros import scala.quoted._ -def oops(given QuoteContext) = { +def oops(using QuoteContext) = { var v = '{}; val q = '{ var x: Int = 8; ${ v = '{x = 9}; v } } v diff --git a/tests/neg-macros/inline-macro-staged-interpreter/Macro_1.scala b/tests/neg-macros/inline-macro-staged-interpreter/Macro_1.scala index 26d8d4ae15b3..2af0b4d287fb 100644 --- a/tests/neg-macros/inline-macro-staged-interpreter/Macro_1.scala +++ b/tests/neg-macros/inline-macro-staged-interpreter/Macro_1.scala @@ -7,40 +7,40 @@ object E { inline def eval[T](inline x: E[T]): T = ${ impl('x) } - def impl[T: Type](x: Expr[E[T]]) with QuoteContext : Expr[T] = x.value.lift + def impl[T: Type](x: Expr[E[T]]) (using QuoteContext): Expr[T] = x.value.lift implicit def ev1[T: Type]: ValueOfExpr[E[T]] = new ValueOfExpr { - def apply(x: Expr[E[T]]) with QuoteContext : Option[E[T]] = x match { + def apply(x: Expr[E[T]]) (using QuoteContext): Option[E[T]] = x match { case '{ I(${Const(n)}) } => Some(I(n).asInstanceOf[E[T]]) - case '{ Plus[T](${Value(x)}, ${Value(y)})(given $op) } if op.matches('{Plus2.IPlus}) => Some(Plus(x, y)(given Plus2.IPlus.asInstanceOf[Plus2[T]]).asInstanceOf[E[T]]) + case '{ Plus[T](${Value(x)}, ${Value(y)})(using $op) } if op.matches('{Plus2.IPlus}) => Some(Plus(x, y)(using Plus2.IPlus.asInstanceOf[Plus2[T]]).asInstanceOf[E[T]]) case _ => None } } object Value { - def unapply[T, U >: T](expr: Expr[T])(given ValueOfExpr[U], QuoteContext): Option[U] = expr.getValue + def unapply[T, U >: T](expr: Expr[T])(using ValueOfExpr[U], QuoteContext): Option[U] = expr.getValue } } trait E[T] { - def lift with QuoteContext : Expr[T] + def lift (using QuoteContext): Expr[T] } case class I(n: Int) extends E[Int] { - def lift with QuoteContext : Expr[Int] = n + def lift (using QuoteContext): Expr[Int] = n } case class Plus[T](x: E[T], y: E[T])(implicit op: Plus2[T]) extends E[T] { - def lift with QuoteContext : Expr[T] = op(x.lift, y.lift) + def lift (using QuoteContext): Expr[T] = op(x.lift, y.lift) } trait Op2[T] { - def apply(x: Expr[T], y: Expr[T]) with QuoteContext : Expr[T] + def apply(x: Expr[T], y: Expr[T]) (using QuoteContext): Expr[T] } trait Plus2[T] extends Op2[T] object Plus2 { implicit case object IPlus extends Plus2[Int] { - def apply(x: Expr[Int], y: Expr[Int]) with QuoteContext : Expr[Int] = '{$x + $y} + def apply(x: Expr[Int], y: Expr[Int]) (using QuoteContext): Expr[Int] = '{$x + $y} } } diff --git a/tests/neg-macros/inline-option/Macro_1.scala b/tests/neg-macros/inline-option/Macro_1.scala index 1662011dcb3e..39cf1c5d3301 100644 --- a/tests/neg-macros/inline-option/Macro_1.scala +++ b/tests/neg-macros/inline-option/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macro { - def impl(opt: Expr[Option[Int]]) with QuoteContext : Expr[Int] = opt.value match { + def impl(opt: Expr[Option[Int]]) (using QuoteContext): Expr[Int] = opt.value match { case Some(i) => Expr(i) case None => '{-1} } diff --git a/tests/neg-macros/inline-tuples-1/Macro_1.scala b/tests/neg-macros/inline-tuples-1/Macro_1.scala index bdf0bdf0f63d..44a92b1dc08d 100644 --- a/tests/neg-macros/inline-tuples-1/Macro_1.scala +++ b/tests/neg-macros/inline-tuples-1/Macro_1.scala @@ -3,26 +3,26 @@ import scala.quoted._ import scala.quoted.autolift.{given _} object Macros { - def tup1(tup: Expr[Tuple1[Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup2(tup: Expr[Tuple2[Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup3(tup: Expr[Tuple3[Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup8(tup: Expr[Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup9(tup: Expr[Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup10(tup: Expr[Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup11(tup: Expr[Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup12(tup: Expr[Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup13(tup: Expr[Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup14(tup: Expr[Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup15(tup: Expr[Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup16(tup: Expr[Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup17(tup: Expr[Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup18(tup: Expr[Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup19(tup: Expr[Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup20(tup: Expr[Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup21(tup: Expr[Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup22(tup: Expr[Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup1(tup: Expr[Tuple1[Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup2(tup: Expr[Tuple2[Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup3(tup: Expr[Tuple3[Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup8(tup: Expr[Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup9(tup: Expr[Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup10(tup: Expr[Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup11(tup: Expr[Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup12(tup: Expr[Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup13(tup: Expr[Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup14(tup: Expr[Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup15(tup: Expr[Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup16(tup: Expr[Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup17(tup: Expr[Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup18(tup: Expr[Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup19(tup: Expr[Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup20(tup: Expr[Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup21(tup: Expr[Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup22(tup: Expr[Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum } diff --git a/tests/neg-macros/macro-class-not-found-1/Foo.scala b/tests/neg-macros/macro-class-not-found-1/Foo.scala index a4ba3ad2c583..3c1c9d650e07 100644 --- a/tests/neg-macros/macro-class-not-found-1/Foo.scala +++ b/tests/neg-macros/macro-class-not-found-1/Foo.scala @@ -4,7 +4,7 @@ object Foo { inline def myMacro(): Unit = ${ aMacroImplementation } - def aMacroImplementation with QuoteContext : Expr[Unit] = + def aMacroImplementation(using QuoteContext): Expr[Unit] = throw new NoClassDefFoundError() } diff --git a/tests/neg-macros/macro-class-not-found-2/Foo.scala b/tests/neg-macros/macro-class-not-found-2/Foo.scala index 08c16f5d4b3a..0ff06e4372dd 100644 --- a/tests/neg-macros/macro-class-not-found-2/Foo.scala +++ b/tests/neg-macros/macro-class-not-found-2/Foo.scala @@ -4,7 +4,7 @@ object Foo { inline def myMacro(): Unit = ${ aMacroImplementation } - def aMacroImplementation with QuoteContext : Expr[Unit] = + def aMacroImplementation(using QuoteContext): Expr[Unit] = throw new NoClassDefFoundError("this.is.not.a.Class") } diff --git a/tests/neg-macros/macros-in-same-project-1.scala b/tests/neg-macros/macros-in-same-project-1.scala index b500e9c8a25b..ed0e6558e2a5 100644 --- a/tests/neg-macros/macros-in-same-project-1.scala +++ b/tests/neg-macros/macros-in-same-project-1.scala @@ -7,6 +7,6 @@ object Bar { inline def myMacro(): Unit = ${ aMacroImplementation } - def aMacroImplementation with QuoteContext : Expr[Unit] = '{} + def aMacroImplementation(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/neg-macros/macros-in-same-project-2.scala b/tests/neg-macros/macros-in-same-project-2.scala index b176777c5e35..ff9cd1e89e6e 100644 --- a/tests/neg-macros/macros-in-same-project-2.scala +++ b/tests/neg-macros/macros-in-same-project-2.scala @@ -8,6 +8,6 @@ object Bar { inline def myMacro(): Unit = myMacro2() inline def myMacro2(): Unit = ${ aMacroImplementation } - def aMacroImplementation with QuoteContext : Expr[Unit] = '{} + def aMacroImplementation(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/neg-macros/macros-in-same-project-4/Bar.scala b/tests/neg-macros/macros-in-same-project-4/Bar.scala index b90bc0b6d492..373fa488989e 100644 --- a/tests/neg-macros/macros-in-same-project-4/Bar.scala +++ b/tests/neg-macros/macros-in-same-project-4/Bar.scala @@ -5,5 +5,5 @@ object Bar { Foo.myMacro() - def hello() with QuoteContext : Expr[Unit] = '{ println("Hello") } + def hello()(using QuoteContext): Expr[Unit] = '{ println("Hello") } } diff --git a/tests/neg-macros/macros-in-same-project-4/Foo.scala b/tests/neg-macros/macros-in-same-project-4/Foo.scala index c3c72d51ee6e..7993b3a428b6 100644 --- a/tests/neg-macros/macros-in-same-project-4/Foo.scala +++ b/tests/neg-macros/macros-in-same-project-4/Foo.scala @@ -4,6 +4,6 @@ object Foo { inline def myMacro(): Unit = ${ aMacroImplementation } - def aMacroImplementation with QuoteContext : Expr[Unit] = Bar.hello() + def aMacroImplementation(using QuoteContext): Expr[Unit] = Bar.hello() } diff --git a/tests/neg-macros/macros-in-same-project-5/Bar.scala b/tests/neg-macros/macros-in-same-project-5/Bar.scala index 57cde71ef537..f955f6c82f17 100644 --- a/tests/neg-macros/macros-in-same-project-5/Bar.scala +++ b/tests/neg-macros/macros-in-same-project-5/Bar.scala @@ -4,7 +4,7 @@ object Bar { Foo.myMacro() // error - def aMacroImplementation with QuoteContext : Expr[Unit] = Bar.hello() + def aMacroImplementation(using QuoteContext): Expr[Unit] = Bar.hello() - def hello() with QuoteContext : Expr[Unit] = '{ println("Hello") } + def hello()(using QuoteContext): Expr[Unit] = '{ println("Hello") } } diff --git a/tests/neg-macros/macros-in-same-project-6/Foo.scala b/tests/neg-macros/macros-in-same-project-6/Foo.scala index f6b18d49bfb5..e877c774a5fa 100644 --- a/tests/neg-macros/macros-in-same-project-6/Foo.scala +++ b/tests/neg-macros/macros-in-same-project-6/Foo.scala @@ -4,7 +4,7 @@ object Foo { inline def myMacro(): Unit = ${ aMacroImplementation } - def aMacroImplementation with (qctx: QuoteContext) : Expr[Unit] = { + def aMacroImplementation(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{given, _} error("some error", rootPosition) throw new NoClassDefFoundError("Bar$") diff --git a/tests/neg-macros/quote-complex-top-splice.scala b/tests/neg-macros/quote-complex-top-splice.scala index d82fab0a9940..34abedb796ec 100644 --- a/tests/neg-macros/quote-complex-top-splice.scala +++ b/tests/neg-macros/quote-complex-top-splice.scala @@ -28,6 +28,6 @@ object Test { impl(1) } - def impl(i: Int) with QuoteContext : Expr[Unit] = '{} + def impl(i: Int)(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/neg-macros/quote-error-2/Macro_1.scala b/tests/neg-macros/quote-error-2/Macro_1.scala index 5d1414736086..d19000d56055 100644 --- a/tests/neg-macros/quote-error-2/Macro_1.scala +++ b/tests/neg-macros/quote-error-2/Macro_1.scala @@ -2,10 +2,10 @@ import quoted._ object Macro_1 { inline def foo(inline b: Boolean): Unit = ${ fooImpl('b) } - def fooImpl(b: Expr[Boolean]) with QuoteContext: Expr[Unit] = + def fooImpl(b: Expr[Boolean])(using QuoteContext): Expr[Unit] = '{println(${msg(b.value)})} - def msg(b: Boolean) with (qctx: QuoteContext) : Expr[String] = + def msg(b: Boolean)(using qctx: QuoteContext): Expr[String] = if (b) '{"foo(true)"} else { qctx.error("foo cannot be called with false"); '{ ??? } } diff --git a/tests/neg-macros/quote-error/Macro_1.scala b/tests/neg-macros/quote-error/Macro_1.scala index fdce182d6e95..4f1e00971e61 100644 --- a/tests/neg-macros/quote-error/Macro_1.scala +++ b/tests/neg-macros/quote-error/Macro_1.scala @@ -2,7 +2,7 @@ import quoted._ object Macro_1 { inline def foo(inline b: Boolean): Unit = ${fooImpl('b)} - def fooImpl(b: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] = + def fooImpl(b: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = if (b.value) '{println("foo(true)")} else { qctx.error("foo cannot be called with false"); '{ ??? } } } diff --git a/tests/neg-macros/quote-exception/Macro_1.scala b/tests/neg-macros/quote-exception/Macro_1.scala index c5345a0bdfd8..8dea32b01f80 100644 --- a/tests/neg-macros/quote-exception/Macro_1.scala +++ b/tests/neg-macros/quote-exception/Macro_1.scala @@ -2,7 +2,7 @@ import quoted._ object Macro_1 { inline def foo(inline b: Boolean): Unit = ${fooImpl('b)} - def fooImpl(b: Expr[Boolean]) with QuoteContext : Expr[Unit] = + def fooImpl(b: Expr[Boolean]) (using QuoteContext): Expr[Unit] = if (b.value) '{println("foo(true)")} else ??? } diff --git a/tests/neg-macros/quote-interpolator-core-old.scala b/tests/neg-macros/quote-interpolator-core-old.scala index e4dc9ca1a49e..40b8eed6a757 100644 --- a/tests/neg-macros/quote-interpolator-core-old.scala +++ b/tests/neg-macros/quote-interpolator-core-old.scala @@ -12,12 +12,12 @@ object FInterpolation { // ... } - private def liftSeq(args: Seq[Expr[Any]]) with QuoteContext : Expr[Seq[Any]] = args match { + private def liftSeq(args: Seq[Expr[Any]])(using QuoteContext): Expr[Seq[Any]] = args match { case x :: xs => '{ ($x) +: ${liftSeq(xs)} } case Nil => '{Seq(): Seq[Any]} } - def fInterpolation(sc: StringContext, args: Seq[Expr[Any]]) with QuoteContext : Expr[String] = { + def fInterpolation(sc: StringContext, args: Seq[Expr[Any]])(using QuoteContext): Expr[String] = { val str: Expr[String] = sc.parts.mkString("") val args1: Expr[Seq[Any]] = liftSeq(args) '{ $str.format($args1: _*) } diff --git a/tests/neg-macros/quote-macro-complex-arg-0.scala b/tests/neg-macros/quote-macro-complex-arg-0.scala index c0aa0e9ff498..a1079aab4b39 100644 --- a/tests/neg-macros/quote-macro-complex-arg-0.scala +++ b/tests/neg-macros/quote-macro-complex-arg-0.scala @@ -2,5 +2,5 @@ import scala.quoted._ object Macros { inline def foo(inline i: Int, dummy: Int, j: Int): Int = ${ bar(i + 1, 'j) } // error: i + 1 is not a parameter or field reference - def bar(x: Int, y: Expr[Int]) with QuoteContext : Expr[Int] = '{ ${Expr(x)} + $y } + def bar(x: Int, y: Expr[Int])(using QuoteContext): Expr[Int] = '{ ${Expr(x)} + $y } } diff --git a/tests/neg-macros/quote-this-b.scala b/tests/neg-macros/quote-this-b.scala index 9908ce966d18..cb066b5adb0d 100644 --- a/tests/neg-macros/quote-this-b.scala +++ b/tests/neg-macros/quote-this-b.scala @@ -6,5 +6,5 @@ class Foo { } object Foo { - def impl[T](x: Any) with QuoteContext : Expr[Unit] = '{} + def impl[T](x: Any)(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/neg-macros/quote-this.scala b/tests/neg-macros/quote-this.scala index de860b9047e1..ff3245f35858 100644 --- a/tests/neg-macros/quote-this.scala +++ b/tests/neg-macros/quote-this.scala @@ -2,7 +2,7 @@ import scala.quoted._ class Foo { - def f with QuoteContext : Unit = '{ + def f(using QuoteContext): Unit = '{ def bar[T](x: T): T = x bar[ this.type // error @@ -24,5 +24,5 @@ class Foo { } object Foo { - def impl[T](x: Any) with QuoteContext : Expr[Unit] = '{} + def impl[T](x: Any)(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/neg-macros/quote-whitebox/Macro_1.scala b/tests/neg-macros/quote-whitebox/Macro_1.scala index 7ea1a14b76a3..50ab2371b8c6 100644 --- a/tests/neg-macros/quote-whitebox/Macro_1.scala +++ b/tests/neg-macros/quote-whitebox/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macros { inline def defaultOf(inline str: String) <: Any = ${ defaultOfImpl('str) } - def defaultOfImpl(str: Expr[String]) with QuoteContext : Expr[Any] = str.value match { + def defaultOfImpl(str: Expr[String]) (using QuoteContext): Expr[Any] = str.value match { case "int" => '{1} case "string" => '{"a"} } diff --git a/tests/neg-macros/reflect-inline/assert_1.scala b/tests/neg-macros/reflect-inline/assert_1.scala index 02730342f870..5d5bb55cac08 100644 --- a/tests/neg-macros/reflect-inline/assert_1.scala +++ b/tests/neg-macros/reflect-inline/assert_1.scala @@ -4,7 +4,7 @@ object api { inline def (inline x: String).stripMargin2: String = ${ stripImpl('x) } - private def stripImpl(x: Expr[String]) with (qctx: QuoteContext) : Expr[String] = + private def stripImpl(x: Expr[String])(using qctx: QuoteContext): Expr[String] = Expr(x.value.stripMargin) } diff --git a/tests/neg-macros/splice-in-top-level-splice-1.scala b/tests/neg-macros/splice-in-top-level-splice-1.scala index 4114fe5134e1..0e21dbbfd174 100644 --- a/tests/neg-macros/splice-in-top-level-splice-1.scala +++ b/tests/neg-macros/splice-in-top-level-splice-1.scala @@ -3,6 +3,6 @@ import scala.quoted.autolift.{given _} object Foo { inline def foo(): Int = ${bar(${x})} // error - def x with QuoteContext : Expr[Int] = '{1} - def bar(i: Int) with QuoteContext : Expr[Int] = i + def x(using QuoteContext): Expr[Int] = '{1} + def bar(i: Int)(using QuoteContext): Expr[Int] = i } diff --git a/tests/neg-macros/splice-in-top-level-splice-2.scala b/tests/neg-macros/splice-in-top-level-splice-2.scala index c836b126bbe2..21e38ed219ac 100644 --- a/tests/neg-macros/splice-in-top-level-splice-2.scala +++ b/tests/neg-macros/splice-in-top-level-splice-2.scala @@ -2,5 +2,5 @@ import scala.quoted._ object Foo { inline def foo(): Int = ${$x} // error - def x with QuoteContext : Expr[Expr[Int]] = '{ '{1} } + def x(using QuoteContext): Expr[Expr[Int]] = '{ '{1} } } diff --git a/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala b/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala index 66a3bc96e2cd..88677113c598 100644 --- a/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala @@ -12,7 +12,7 @@ object Asserts { inline def macroAssert(inline cond: Boolean): Unit = ${impl('cond)} - def impl(cond: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl(cond: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = cond.unseal diff --git a/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala b/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala index 1c2996a71307..b15878b3060a 100644 --- a/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala @@ -12,7 +12,7 @@ object Asserts { inline def macroAssert(inline cond: Boolean): Unit = ${ impl('cond) } - def impl(cond: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl(cond: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = cond.unseal diff --git a/tests/neg-macros/tasty-macro-error/quoted_1.scala b/tests/neg-macros/tasty-macro-error/quoted_1.scala index 68950e1a0cf3..94dc0daa015d 100644 --- a/tests/neg-macros/tasty-macro-error/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-error/quoted_1.scala @@ -4,7 +4,7 @@ object Macros { inline def fun(x: Any): Unit = ${ impl('x) } - def impl(x: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl(x: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} error("here is the the argument is " + x.unseal.underlyingArgument.show, x.unseal.underlyingArgument.pos) '{} diff --git a/tests/neg-macros/tasty-macro-positions/quoted_1.scala b/tests/neg-macros/tasty-macro-positions/quoted_1.scala index 01e0f64d1d20..96275657266d 100644 --- a/tests/neg-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-positions/quoted_1.scala @@ -4,7 +4,7 @@ object Macros { inline def fun(x: Any): Unit = ${ impl('x) } - def impl(x: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl(x: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val pos = x.unseal.underlyingArgument.pos error("here is the the argument is " + x.unseal.underlyingArgument.show, pos) 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 fe212e1745f5..21cfae08f55d 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 @@ -9,7 +9,7 @@ object Macro { object FIntepolator { - def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]]) with (qctx: QuoteContext) : Expr[String] = { + def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} error("there are no parts", strCtxExpr.unseal.underlyingArgument.pos) '{ ($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 73b6ea28a4a4..918fb6e632ab 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 @@ -8,7 +8,7 @@ object Macro { } object FIntepolator { - def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]]) with (qctx: QuoteContext) : Expr[String] = { + def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} error("there are no args", argsExpr.unseal.underlyingArgument.pos) '{ ($strCtxExpr).s($argsExpr: _*) } diff --git a/tests/neg-staging/i5941/macro_1.scala b/tests/neg-staging/i5941/macro_1.scala index 58188dde86f3..a58333b7bcb7 100644 --- a/tests/neg-staging/i5941/macro_1.scala +++ b/tests/neg-staging/i5941/macro_1.scala @@ -11,7 +11,7 @@ object Lens { def set(t: T, s: S): S = _set(t)(s) } - def impl[S: Type, T: Type](getter: Expr[S => T]) with (qctx: QuoteContext) : Expr[Lens[S, T]] = { + def impl[S: Type, T: Type](getter: Expr[S => T])(using qctx: QuoteContext): Expr[Lens[S, T]] = { implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(this.getClass.getClassLoader) import qctx.tasty.{_, given _} import util._ diff --git a/tests/neg-staging/quote-run-in-macro-1/quoted_1.scala b/tests/neg-staging/quote-run-in-macro-1/quoted_1.scala index 15c9d1b675a9..1913b4538e35 100644 --- a/tests/neg-staging/quote-run-in-macro-1/quoted_1.scala +++ b/tests/neg-staging/quote-run-in-macro-1/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { given Toolbox = Toolbox.make(getClass.getClassLoader) inline def foo(i: => Int): Int = ${ fooImpl('i) } - def fooImpl(i: Expr[Int]) with QuoteContext : Expr[Int] = { + def fooImpl(i: Expr[Int])(using QuoteContext): Expr[Int] = { val y: Int = run(i) y } diff --git a/tests/neg-with-compiler/GenericNumLits/Even_1.scala b/tests/neg-with-compiler/GenericNumLits/Even_1.scala index ecfa97a35262..c3087600865b 100644 --- a/tests/neg-with-compiler/GenericNumLits/Even_1.scala +++ b/tests/neg-with-compiler/GenericNumLits/Even_1.scala @@ -11,7 +11,7 @@ object Even { else throw FromDigits.MalformedNumber(s"$digits is odd") } - private def evenFromDigitsImpl(digits: Expr[String]) with (ctx: QuoteContext) : Expr[Even] = digits match { + private def evenFromDigitsImpl(digits: Expr[String])(using ctx: QuoteContext): Expr[Even] = digits match { case Const(ds) => val ev = try evenFromDigits(ds) diff --git a/tests/neg/BigFloat/BigFloat_1.scala b/tests/neg/BigFloat/BigFloat_1.scala index b4c790579038..480e9a78e145 100644 --- a/tests/neg/BigFloat/BigFloat_1.scala +++ b/tests/neg/BigFloat/BigFloat_1.scala @@ -30,7 +30,7 @@ object BigFloat extends App { BigFloat(BigInt(intPart), exponent) } - private def fromDigitsImpl(digits: Expr[String]) with (ctx: QuoteContext) : Expr[BigFloat] = + private def fromDigitsImpl(digits: Expr[String])(using ctx: QuoteContext): Expr[BigFloat] = digits match { case Const(ds) => try { diff --git a/tests/neg/given-eta.scala b/tests/neg/given-eta.scala index a6012ce61061..c2969d4149e9 100644 --- a/tests/neg/given-eta.scala +++ b/tests/neg/given-eta.scala @@ -3,9 +3,8 @@ trait D type T def trans(other: T): T -def h(d: D) with (x: d.T) (y: d.T) = (d.trans(x), d.trans(y)) +def h(d: D)(using x: d.T)(y: d.T) = (d.trans(x), d.trans(y)) val z = h // error: no implicit argument of type d.T was found for parameter x of method h -def f with (D) (x: Int) = x // OK -def g with D (x: Int) = x // error // error \ No newline at end of file +def f(using D)(x: Int) = x // OK diff --git a/tests/neg/i2514.scala b/tests/neg/i2514.scala index a5f69f1bade9..b8cb196530d2 100644 --- a/tests/neg/i2514.scala +++ b/tests/neg/i2514.scala @@ -4,7 +4,7 @@ object Foo { // ^^^^^^^^ // an identifier expected, but 'implicit' found - f.with(2) + f(using 2) } val f = (implicit x: Int) => x // error // error diff --git a/tests/neg/i2514a.scala b/tests/neg/i2514a.scala index f412711e10ad..5b88b22d9aba 100644 --- a/tests/neg/i2514a.scala +++ b/tests/neg/i2514a.scala @@ -1,7 +1,7 @@ object Foo { def foo(): Int = { val f: Int ?=> Int = (x: Int) ?=> 2 * x - f.with(2) + f(using 2) } val f = implicit (x: Int) => x diff --git a/tests/neg/i2960.scala b/tests/neg/i2960.scala index 018af938b302..435d9f5cbed1 100644 --- a/tests/neg/i2960.scala +++ b/tests/neg/i2960.scala @@ -24,7 +24,7 @@ class Tag(val name: String, def apply[U](f: Tag ?=> U)(implicit t: Tag = null): this.type = { if(t != null) t.children += this - f.with(this) + f(using this) this } } diff --git a/tests/neg/i4044a.scala b/tests/neg/i4044a.scala index 4c04a174a35d..591ef79f1549 100644 --- a/tests/neg/i4044a.scala +++ b/tests/neg/i4044a.scala @@ -1,6 +1,6 @@ import scala.quoted._ -def test with QuoteContext = { +def test(using QuoteContext) = { val a = '{1} '{ diff --git a/tests/neg/i4044b.scala b/tests/neg/i4044b.scala index 9b57cf99eca6..87b07bc1cb45 100644 --- a/tests/neg/i4044b.scala +++ b/tests/neg/i4044b.scala @@ -1,6 +1,6 @@ import scala.quoted._ -def test with QuoteContext = { +def test(using QuoteContext) = { '{ given QuoteContext = ??? diff --git a/tests/neg/i5954b.scala b/tests/neg/i5954b.scala index 4fee54809f5a..c6cd22f7c261 100644 --- a/tests/neg/i5954b.scala +++ b/tests/neg/i5954b.scala @@ -5,7 +5,7 @@ abstract class MatcherFactory1[A] { object MatcherFactory1 { import scala.quoted._ - def impl[T](self: Expr[MatcherFactory1[T]#AndNotWord]) with QuoteContext = + def impl[T](self: Expr[MatcherFactory1[T]#AndNotWord])(using QuoteContext) = '{ val a: Any = $self } // error: access to type T from wrong staging level } diff --git a/tests/neg/i5954c.scala b/tests/neg/i5954c.scala index 75a8bee943fa..8941701f8c06 100644 --- a/tests/neg/i5954c.scala +++ b/tests/neg/i5954c.scala @@ -5,7 +5,7 @@ abstract class MatcherFactory1 { object MatcherFactory1 { import scala.quoted._ - def impl[T](self: Expr[MatcherFactory1#AndNotWord[T]]) with QuoteContext = + def impl[T](self: Expr[MatcherFactory1#AndNotWord[T]])(using QuoteContext) = '{ val a: Any = $self } // error: access to type T from wrong staging level } diff --git a/tests/neg/i5978.scala b/tests/neg/i5978.scala index 19c523c1e101..bf67dbb7eda6 100644 --- a/tests/neg/i5978.scala +++ b/tests/neg/i5978.scala @@ -7,7 +7,7 @@ trait TokenParser[Token, R] object TextParser { given TP as TokenParser[Char, Position[CharSequence]] {} - given FromCharToken with (T: TokenParser[Char, Position[CharSequence]]) + given FromCharToken(using T: TokenParser[Char, Position[CharSequence]]) : Conversion[Char, Position[CharSequence]] = ??? } diff --git a/tests/neg/i6324.scala b/tests/neg/i6324.scala index 3481e1e28a60..cab1df5a3c0a 100644 --- a/tests/neg/i6324.scala +++ b/tests/neg/i6324.scala @@ -1,5 +1,5 @@ class Test { - def res(x: quoted.Expr[Int]) with tasty.Reflection : quoted.Expr[Int] = x match { + def res(x: quoted.Expr[Int])(using tasty.Reflection): quoted.Expr[Int] = x match { case '{ 1 + $b } => // error: Type must be fully defined. Consider annotating the splice using a type ascription: (${b}: XYZ). b // error: Not found: b } diff --git a/tests/neg/i6325.scala b/tests/neg/i6325.scala index 639494137d32..2e134d1c1478 100644 --- a/tests/neg/i6325.scala +++ b/tests/neg/i6325.scala @@ -1,6 +1,6 @@ //import scala.quoted.matching.Bind object Test { - def res(x: quoted.Expr[Int]) with tasty.Reflection : quoted.Expr[Int] = x match { + def res(x: quoted.Expr[Int])(using tasty.Reflection): quoted.Expr[Int] = x match { case '{ 1 + (${Bind(b)}: Int) } => ??? // error: Not found: Bind case _ => ??? } diff --git a/tests/neg/i6530b.scala b/tests/neg/i6530b.scala index f37b7148bb90..9a36fa93c3dc 100644 --- a/tests/neg/i6530b.scala +++ b/tests/neg/i6530b.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Foo { - def program with QuoteContext = '{ + def program(using QuoteContext) = '{ val tpe: quoted.Type[Int] = ??? val expr: quoted.Expr[Int] = ??? diff --git a/tests/neg/i6739.scala b/tests/neg/i6739.scala index 2daae22d5c07..177f701d4e76 100644 --- a/tests/neg/i6739.scala +++ b/tests/neg/i6739.scala @@ -3,4 +3,4 @@ import scala.quoted._ inline def assert(expr: => Boolean): Unit = ${ assertImpl('expr) } // error: Macro cannot be implemented with an `inline` method -inline def assertImpl(expr: Expr[Boolean]) with QuoteContext : Expr[Unit] = '{ println("Hello World") } +inline def assertImpl(expr: Expr[Boolean])(using QuoteContext): Expr[Unit] = '{ println("Hello World") } diff --git a/tests/neg/i6762.scala b/tests/neg/i6762.scala index e6c64820f53f..c653c454f06c 100644 --- a/tests/neg/i6762.scala +++ b/tests/neg/i6762.scala @@ -2,4 +2,4 @@ import scala.quoted.{_, given _} type G[X] case class Foo[T](x: T) -def f(word: String) with QuoteContext : Expr[Foo[G[String]]] = '{Foo(${Expr(word)})} // error // error +def f(word: String)(using QuoteContext): Expr[Foo[G[String]]] = '{Foo(${Expr(word)})} // error // error diff --git a/tests/neg/i6762b.scala b/tests/neg/i6762b.scala index 3cbb4091f97f..187313380eb5 100644 --- a/tests/neg/i6762b.scala +++ b/tests/neg/i6762b.scala @@ -9,5 +9,5 @@ type Liftable given Liftable = ??? implicit object ExprOps { - def (x: T).toExpr[T] with Liftable : Expr[T] = ??? + def (x: T).toExpr[T](using Liftable): Expr[T] = ??? } diff --git a/tests/neg/i6779.check b/tests/neg/i6779.check index 91e2313fa5c7..396e3f829d6a 100644 --- a/tests/neg/i6779.check +++ b/tests/neg/i6779.check @@ -1,6 +1,6 @@ -- [E007] Type Mismatch Error: tests/neg/i6779.scala:9:30 -------------------------------------------------------------- -9 |def g1[T](x: T): F[G[T]] = x.f.with(summon[Stuff]) // error - | ^^^^^^^^^^^^^^^^^^^^^^^ +9 |def g1[T](x: T): F[G[T]] = x.f(using summon[Stuff]) // error + | ^^^^^^^^^^^^^^^^^^^^^^^^ | Found: F[T] | Required: F[G[T]] -- [E007] Type Mismatch Error: tests/neg/i6779.scala:11:27 ------------------------------------------------------------- @@ -9,7 +9,7 @@ | Found: F[T] | Required: F[G[T]] -- [E007] Type Mismatch Error: tests/neg/i6779.scala:13:31 ------------------------------------------------------------- -13 |def g3[T](x: T): F[G[T]] = f(x).with(summon[Stuff]) // error - | ^^^^^^^^^^^^^^^^^^^^^^^^ +13 |def g3[T](x: T): F[G[T]] = f(x)(using summon[Stuff]) // error + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | Found: F[T] | Required: F[G[T]] diff --git a/tests/neg/i6779.scala b/tests/neg/i6779.scala index 780f889e76a2..28d11ae43ac8 100644 --- a/tests/neg/i6779.scala +++ b/tests/neg/i6779.scala @@ -3,11 +3,11 @@ type G[T] type Stuff given Stuff = ??? -def (x: T).f[T] with Stuff : F[T] = ??? +def (x: T).f[T](using Stuff): F[T] = ??? -def g1[T](x: T): F[G[T]] = x.f.with(summon[Stuff]) // error +def g1[T](x: T): F[G[T]] = x.f(using summon[Stuff]) // error def g2[T](x: T): F[G[T]] = x.f // error -def g3[T](x: T): F[G[T]] = f(x).with(summon[Stuff]) // error +def g3[T](x: T): F[G[T]] = f(x)(using summon[Stuff]) // error diff --git a/tests/neg/i6801.scala b/tests/neg/i6801.scala index ad8845a06cec..b2a968cc7893 100644 --- a/tests/neg/i6801.scala +++ b/tests/neg/i6801.scala @@ -1,5 +1,5 @@ extension myNumericOps on [T](x: T) { - def + (y: T) with (n: Numeric[T]) : T = n.plus(x,y) + def + (y: T)(using n: Numeric[T]): T = n.plus(x,y) } def foo[T: Numeric](x: T) = 1f + x // error: no implicit argument of type Numeric[Any] def bar[T: Numeric](x: T) = x + 1f // error: no implicit argument of type Numeric[Any] \ No newline at end of file diff --git a/tests/neg/i6997b.scala b/tests/neg/i6997b.scala index a67885f3a159..a3a861fce5b9 100644 --- a/tests/neg/i6997b.scala +++ b/tests/neg/i6997b.scala @@ -4,7 +4,7 @@ import scala.quoted.{_, given _}, scala.quoted.matching._ inline def mcr(x: => Any): Any = ${mcrImpl('x)} -def mcrImpl(body: Expr[Any]) with (ctx: QuoteContext) : Expr[Any] = { +def mcrImpl(body: Expr[Any])(using ctx: QuoteContext): Expr[Any] = { val '{$x: $t} = body // error '{ val tmp: $t = $x.asInstanceOf[$t] // error // error diff --git a/tests/neg/i7013.scala b/tests/neg/i7013.scala index eb5c261feeb5..07232e453ba4 100644 --- a/tests/neg/i7013.scala +++ b/tests/neg/i7013.scala @@ -1,6 +1,6 @@ import quoted._ -def foo() with QuoteContext = { +def foo()(using QuoteContext) = { class C '[C] // error } diff --git a/tests/neg/i7013b.scala b/tests/neg/i7013b.scala index 0d696246e47f..f144e254b2d1 100644 --- a/tests/neg/i7013b.scala +++ b/tests/neg/i7013b.scala @@ -2,7 +2,7 @@ import quoted._ class Foo { class Bar - def foo() with QuoteContext = { + def foo()(using QuoteContext) = { '[Bar] // error } } diff --git a/tests/neg/i7013c.scala b/tests/neg/i7013c.scala index ac1995b4e0ce..1a69c8c077f1 100644 --- a/tests/neg/i7013c.scala +++ b/tests/neg/i7013c.scala @@ -1,6 +1,6 @@ import quoted._ -def foo() with QuoteContext = { +def foo()(using QuoteContext) = { type C '[C] // error } diff --git a/tests/neg/i7048e.scala b/tests/neg/i7048e.scala index be1953a41291..6a5a4debae46 100644 --- a/tests/neg/i7048e.scala +++ b/tests/neg/i7048e.scala @@ -7,7 +7,7 @@ abstract class Test { val getT: Type[T] = T // need this to avoid getting `null` given Type[T] = getT - def foo with QuoteContext: Expr[Any] = { + def foo(using QuoteContext): Expr[Any] = { val r = '{Option.empty[T]} // error diff --git a/tests/neg/i7052.scala b/tests/neg/i7052.scala index 2439769f3f29..83cce3f13748 100644 --- a/tests/neg/i7052.scala +++ b/tests/neg/i7052.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Test { - def foo(str: String) with QuoteContext = '{ + def foo(str: String)(using QuoteContext) = '{ @deprecated(str, "") // error def bar = ??? } diff --git a/tests/neg/i7052b.scala b/tests/neg/i7052b.scala index 87898107f61c..d1bc1422297d 100644 --- a/tests/neg/i7052b.scala +++ b/tests/neg/i7052b.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Test { - def foo(str: String) with QuoteContext = '{ + def foo(str: String)(using QuoteContext) = '{ given QuoteContext = ??? '{ @deprecated(str, "") // error diff --git a/tests/neg/i7060.scala b/tests/neg/i7060.scala index 6dfde89434e4..38ab44d584a4 100644 --- a/tests/neg/i7060.scala +++ b/tests/neg/i7060.scala @@ -10,10 +10,10 @@ object PostConditions { class Box[T](val t: T) - def res[T] with (b: Box[T]) : T = b.t + def res[T](using b: Box[T]): T = b.t def [T](e: T) ensure (cond: Box[T] ?=> Boolean): T = { - if (cond.with(Box(e))) e + if (cond(using Box(e))) e else throw new AssertionError("condition not fulfilled") } } \ No newline at end of file diff --git a/tests/neg/i7121.scala b/tests/neg/i7121.scala index 905873ab3960..467fdd54be83 100644 --- a/tests/neg/i7121.scala +++ b/tests/neg/i7121.scala @@ -7,7 +7,7 @@ class Test()(implicit qtx: QuoteContext) { @annot1('{4}) // error def foo(str: String) = () - @annot2(4).with('[Int]) // error + @annot2(4)(using '[Int]) // error def foo2(str: String) = () } diff --git a/tests/neg/i7248.scala b/tests/neg/i7248.scala index 04d84992e903..e3d8f3115333 100644 --- a/tests/neg/i7248.scala +++ b/tests/neg/i7248.scala @@ -1,4 +1,4 @@ object Test extends App { - given f[H] with (h: H) as H = h + given f[H](using h: H) as H = h summon[Int] // error } \ No newline at end of file diff --git a/tests/neg/i7249.scala b/tests/neg/i7249.scala index 7f627b38e76f..472918278354 100644 --- a/tests/neg/i7249.scala +++ b/tests/neg/i7249.scala @@ -4,6 +4,6 @@ trait F[H, T] object Test extends App { - given f[H, T] with (h: H, t: T) as F[H, T] = ??? + given f[H, T](using h: H, t: T) as F[H, T] = ??? summon[F[Int, Unit]] // error } \ No newline at end of file diff --git a/tests/neg/i7264d.scala b/tests/neg/i7264d.scala index 718131746576..010538b8ee77 100644 --- a/tests/neg/i7264d.scala +++ b/tests/neg/i7264d.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Foo { - def f[T2: Type](e: Expr[T2]) with QuoteContext = e match { + def f[T2: Type](e: Expr[T2])(using QuoteContext) = e match { case '{ $x: *:[Int, Any] } => // error: Type argument Any does not conform to upper bound Tuple } diff --git a/tests/neg/i7323.scala b/tests/neg/i7323.scala index 3d5d92858909..49d365ff8bc8 100644 --- a/tests/neg/i7323.scala +++ b/tests/neg/i7323.scala @@ -1,3 +1,3 @@ trait Foo { type X } -def f[T] with scala.quoted.Type[T] = ??? +def f[T](using scala.quoted.Type[T]) = ??? def g(m: Foo) = f[m.X] // error \ No newline at end of file diff --git a/tests/neg/i7407.scala b/tests/neg/i7407.scala index 1a31f290b3f7..8aebb7e38b53 100644 --- a/tests/neg/i7407.scala +++ b/tests/neg/i7407.scala @@ -1,2 +1,2 @@ -def qc with (ctx: scala.quoted.QuoteContext) = println(ctx) +def qc(using ctx: scala.quoted.QuoteContext) = println(ctx) inline def g = qc // error: no implicit argument diff --git a/tests/neg/i7425.scala b/tests/neg/i7425.scala index 06e2a6cfcda4..24481ea375f4 100644 --- a/tests/neg/i7425.scala +++ b/tests/neg/i7425.scala @@ -2,7 +2,7 @@ class C { def f: Int = 0 } trait D { def f(): Int = 0 } -def foo1(x: C & D) = x.f // error: method f must be called with argument +def foo1(x: C & D) = x.f // error: method f must be called with argument def foo2(x: C | D) = x.f // error: value f is not a member of C | D def foo3(x: D & C) = x.f // ok def foo4(x: D | C) = x.f // error: value f is not a member of D | C diff --git a/tests/neg/i7459.scala b/tests/neg/i7459.scala index 8b8d6cef9477..1c0c6fc4873b 100644 --- a/tests/neg/i7459.scala +++ b/tests/neg/i7459.scala @@ -8,7 +8,7 @@ object Foo { import scala.deriving._ import scala.compiletime.erasedValue -inline def summon[T] with (t:T) : T = t match { +inline def summon[T](using t:T): T = t match { case t: T => t } @@ -47,7 +47,7 @@ object Eq { } } - inline given derived[T] with (m: Mirror.Of[T]) : Eq[T] = { + inline given derived[T](using m: Mirror.Of[T]): Eq[T] = { val elemInstances = summonAll[m.MirroredElemTypes] inline m match { case s: Mirror.SumOf[T] => eqSum(s, elemInstances) diff --git a/tests/neg/i7603.scala b/tests/neg/i7603.scala index f96755f762b4..dd543ebfdbcd 100644 --- a/tests/neg/i7603.scala +++ b/tests/neg/i7603.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Foo { - def f[T2: Type](e: Expr[T2]) with QuoteContext = e match { + def f[T2: Type](e: Expr[T2])(using QuoteContext) = e match { case '{ $x: ${'[List[$t]]} } => // error case '{ $x: ${y @ '[List[$t]]} } => // error // error } diff --git a/tests/neg/i7618.scala b/tests/neg/i7618.scala index 56ab3ddec5dd..c8122ea007c9 100644 --- a/tests/neg/i7618.scala +++ b/tests/neg/i7618.scala @@ -12,7 +12,7 @@ enum Exp { object Compiler { import Exp._ - inline def compile(e: Exp, env: Map[String, Expr[Int]]) with (ctx: QuoteContext) : Expr[Int] = inline e match { + inline def compile(e: Exp, env: Map[String, Expr[Int]])(using ctx: QuoteContext): Expr[Int] = inline e match { case Num(n) => Expr(n) case Plus(e1, e2) => @@ -31,6 +31,6 @@ object Example { val exp = Plus(Plus(Num(2), Var("x")), Num(4)) val letExp = Let("x", Num(3), exp) - Compiler.compile(letExp, Map.empty).with(QuoteContext.macroContext) // error // error + Compiler.compile(letExp, Map.empty)(using QuoteContext.macroContext) // error // error } } diff --git a/tests/neg/i7618b.scala b/tests/neg/i7618b.scala index 18d04a1de1d2..5467aa91d32c 100644 --- a/tests/neg/i7618b.scala +++ b/tests/neg/i7618b.scala @@ -12,7 +12,7 @@ enum Exp { object Compiler { import Exp._ - inline def compile(e: Exp, env: Map[String, Expr[Int]]) with (ctx: QuoteContext) : Expr[Int] = inline e match { + inline def compile(e: Exp, env: Map[String, Expr[Int]])(using ctx: QuoteContext): Expr[Int] = inline e match { case Num(n) => Expr(n) case Plus(e1, e2) => @@ -31,6 +31,6 @@ object Example { val exp = Plus(Plus(Num(2), Var("x")), Num(4)) val letExp = Let("x", Num(3), exp) - Compiler.compile(letExp, Map.empty).with((??? : QuoteContext)) // error + Compiler.compile(letExp, Map.empty)(using (??? : QuoteContext)) // error } } diff --git a/tests/neg/i7919.scala b/tests/neg/i7919.scala index 09a9de6eddc6..bc0607ad6d38 100644 --- a/tests/neg/i7919.scala +++ b/tests/neg/i7919.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Test { - def staged[T] with (qctx: QuoteContext) = { + def staged[T](using qctx: QuoteContext) = { import qctx.tasty.{_, given _} given typeT as quoted.Type[T] // error val tTypeTree = typeT.unseal diff --git a/tests/neg/implicit-funs.scala b/tests/neg/implicit-funs.scala index e3718268f1c5..7941f7b40a3e 100644 --- a/tests/neg/implicit-funs.scala +++ b/tests/neg/implicit-funs.scala @@ -1,11 +1,11 @@ trait IF1 extends (Int ?=> Unit) // error abstract class IF2 extends ((Int, String) ?=> Unit) // error class IF3 extends (ImplicitFunction3[Int, String, Boolean, Unit]) { // error - def apply with (Int, String, Boolean) = () + def apply(using Int, String, Boolean) = () } -trait IFXXL extends ((given // error - Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) => Unit) +trait IFXXL extends (( // error + Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) ?=> Unit) -val IFOK: (given // OK - Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) => Unit = () \ No newline at end of file +val IFOK: ( // OK + Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) ?=> Unit = () \ No newline at end of file diff --git a/tests/neg/implicit-params.scala b/tests/neg/implicit-params.scala index e68ef8503ddf..1d41ef966ce9 100644 --- a/tests/neg/implicit-params.scala +++ b/tests/neg/implicit-params.scala @@ -3,11 +3,11 @@ object Test { case class C(x: Int) case class D(x: Int) - def f(x: Int) with (c: C) = x + c.x + def f(x: Int)(using c: C) = x + c.x - def g0(x: Int) with (c: C) (y: Int) = x + c.x + y + def g0(x: Int)(using c: C) (y: Int) = x + c.x + y - def g(x: Int) with (c: C) with D = x + c.x + summon[D].x // OK + def g(x: Int)(using c: C)(using D) = x + c.x + summon[D].x // OK def h(x: Int) given () = x // error: missing return type @@ -15,14 +15,14 @@ object Test { given D as D(11) f(1) - f(1).with(C) - f.with(2) // error + f(1)(using C) + f(using 2) // error f(1)(C) // error g(1) // OK - g(1).with(C) // OK - g(1).with(C).with(D(0)) // OK - g(1).with(D) // error + g(1)(using C) // OK + g(1)(using C)(using D(0)) // OK + g(1)(using D) // error g(1)(D) // error g(1)(C)(D) // error } \ No newline at end of file diff --git a/tests/neg/import-implied.scala b/tests/neg/import-implied.scala index d5fbaafed39f..0262960bf7e5 100644 --- a/tests/neg/import-implied.scala +++ b/tests/neg/import-implied.scala @@ -1,27 +1,27 @@ class TC object A { given tc as TC - def foo with TC = () + def foo(using TC) = () } object B { import A._ foo // error: no implicit argument was found - foo.with(tc) // error: not found: tc - foo.with(A.tc) // ok + foo(using tc) // error: not found: tc + foo(using A.tc) // ok } object C { import A._ import A.tc foo // ok - foo.with(tc) // ok + foo(using tc) // ok } object D { import A.{foo, given _} foo // ok - foo.with(tc) // ok + foo(using tc) // ok } object E { import A.{_, given _} foo // ok - foo.with(tc) // ok + foo(using tc) // ok } diff --git a/tests/neg/inline-quote.scala b/tests/neg/inline-quote.scala index a5ceac662303..1a94609d4c9c 100644 --- a/tests/neg/inline-quote.scala +++ b/tests/neg/inline-quote.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Test { - inline def foo(x: Expr[Int]) with QuoteContext : Expr[Int] = '{ // error + inline def foo(x: Expr[Int])(using QuoteContext): Expr[Int] = '{ // error println("foo") ${ ${??? : Expr[Int]} diff --git a/tests/neg/machine-state-encoding-with-implicit-match.scala b/tests/neg/machine-state-encoding-with-implicit-match.scala index 661f26370a74..9aaae7d1cf4f 100644 --- a/tests/neg/machine-state-encoding-with-implicit-match.scala +++ b/tests/neg/machine-state-encoding-with-implicit-match.scala @@ -18,10 +18,10 @@ object IsOn { } class Machine[S <: State] { - inline def turnOn() with (s: IsOff[S]) <: Machine[On] = summonFrom { + inline def turnOn()(using s: IsOff[S]) <: Machine[On] = summonFrom { case _: IsOff[Off] => new Machine[On] } - inline def turnOff() with (s: IsOn[S]) <: Machine[Off] = summonFrom { + inline def turnOff()(using s: IsOn[S]) <: Machine[Off] = summonFrom { case _: IsOn[On] => new Machine[Off] } } diff --git a/tests/neg/macro-cycle1.scala b/tests/neg/macro-cycle1.scala index 65e7b16494b2..008187fe6db8 100644 --- a/tests/neg/macro-cycle1.scala +++ b/tests/neg/macro-cycle1.scala @@ -1,6 +1,6 @@ import scala.quoted.{Expr, QuoteContext} object Test { - def fooImpl with QuoteContext : Expr[Unit] = '{println("hi")} + def fooImpl(using QuoteContext): Expr[Unit] = '{println("hi")} inline def foo: Unit = ${fooImpl} diff --git a/tests/neg/main-functions2.scala b/tests/neg/main-functions2.scala index 30cc89c1d688..7831df56560b 100644 --- a/tests/neg/main-functions2.scala +++ b/tests/neg/main-functions2.scala @@ -10,4 +10,4 @@ class Foo { @main def h[T: util.FromString](x: T) = () // error: @main method cannot have type parameters -@main def i(x: Int) with Foo = () // error: @main method cannot have implicit parameters +@main def i(x: Int)(using Foo) = () // error: @main method cannot have implicit parameters diff --git a/tests/neg/missing-implicit1.scala b/tests/neg/missing-implicit1.scala index 4128b4ce5f6a..e6c2d867d6f6 100644 --- a/tests/neg/missing-implicit1.scala +++ b/tests/neg/missing-implicit1.scala @@ -12,7 +12,7 @@ object testObjectInstance: def [T](xs: List[T]) first: T = xs.head } - def ff with (xs: Zip[Option]) = ??? + def ff(using xs: Zip[Option]) = ??? ff // error @@ -39,7 +39,7 @@ def testLocalInstance = given traverseList as Traverse[List] = ??? } - def ff with (xs: Zip[Option]) = ??? + def ff(using xs: Zip[Option]) = ??? ff // error diff --git a/tests/neg/missing-implicit2.check b/tests/neg/missing-implicit2.check index e4ab5970457b..7b04dbc33a30 100644 --- a/tests/neg/missing-implicit2.check +++ b/tests/neg/missing-implicit2.check @@ -1,12 +1,12 @@ --- Error: tests/neg/missing-implicit2.scala:10:17 ---------------------------------------------------------------------- -10 | f.with(xFromY) // error - | ^ - | no implicit argument of type Y was found for parameter y of method xFromY +-- Error: tests/neg/missing-implicit2.scala:10:18 ---------------------------------------------------------------------- +10 | f(using xFromY) // error + | ^ + | no implicit argument of type Y was found for parameter y of method xFromY | - | The following import might fix the problem: + | The following import might fix the problem: | - | import test.instances.y - | + | import test.instances.y + | -- Error: tests/neg/missing-implicit2.scala:16:5 ----------------------------------------------------------------------- 16 | f // error | ^ diff --git a/tests/neg/missing-implicit2.scala b/tests/neg/missing-implicit2.scala index 8c4ccfe36786..7edcd1d37b0e 100644 --- a/tests/neg/missing-implicit2.scala +++ b/tests/neg/missing-implicit2.scala @@ -1,17 +1,17 @@ trait X trait Y object test: - def f with (x: X) = ??? + def f(using x: X) = ??? object instances { given y as Y = ??? } locally { - given xFromY with (y: Y) as X = ??? - f.with(xFromY) // error + given xFromY(using y: Y) as X = ??? + f(using xFromY) // error } locally { object instances2 { - given xFromY with Y as X = ??? + given xFromY(using Y) as X = ??? } f // error } diff --git a/tests/neg/multi-param-derives.scala b/tests/neg/multi-param-derives.scala index 221b7eb54f2a..2dbaaa5d22d9 100644 --- a/tests/neg/multi-param-derives.scala +++ b/tests/neg/multi-param-derives.scala @@ -5,11 +5,11 @@ object Test extends App { trait Show[T] object Show { given Show[Int] {} - given [T] with (st: Show[T]) as Show[Tuple1[T]] {} - given t2[T, U] with (st: Show[T], su: Show[U]) as Show[(T, U)] {} - given t3[T, U, V] with (st: Show[T], su: Show[U], sv: Show[V]) as Show[(T, U, V)] {} + given [T](using st: Show[T]) as Show[Tuple1[T]] {} + given t2[T, U](using st: Show[T], su: Show[U]) as Show[(T, U)] {} + given t3[T, U, V](using st: Show[T], su: Show[U], sv: Show[V]) as Show[(T, U, V)] {} - def derived[T] with (m: Mirror.Of[T], r: Show[m.MirroredElemTypes]) : Show[T] = new Show[T] {} + def derived[T](using m: Mirror.Of[T], r: Show[m.MirroredElemTypes]): Show[T] = new Show[T] {} } case class Mono(i: Int) derives Show @@ -27,7 +27,7 @@ object Test extends App { given t2 [T] as Functor[[U] =>> (T, U)] {} given t3 [T, U] as Functor[[V] =>> (T, U, V)] {} - def derived[F[_]] with (m: Mirror { type MirroredType = F ; type MirroredElemTypes[_] }, r: Functor[m.MirroredElemTypes]) : Functor[F] = new Functor[F] {} + def derived[F[_]](using m: Mirror { type MirroredType = F ; type MirroredElemTypes[_] }, r: Functor[m.MirroredElemTypes]): Functor[F] = new Functor[F] {} } case class Mono(i: Int) derives Functor @@ -43,7 +43,7 @@ object Test extends App { given [C] as FunctorK[[F[_]] =>> C] {} given [T] as FunctorK[[F[_]] =>> Tuple1[F[T]]] - def derived[F[_[_]]] with (m: Mirror { type MirroredType = F ; type MirroredElemTypes[_[_]] }, r: FunctorK[m.MirroredElemTypes]) : FunctorK[F] = new FunctorK[F] {} + def derived[F[_[_]]](using m: Mirror { type MirroredType = F ; type MirroredElemTypes[_[_]] }, r: FunctorK[m.MirroredElemTypes]): FunctorK[F] = new FunctorK[F] {} } case class Mono(i: Int) derives FunctorK @@ -61,7 +61,7 @@ object Test extends App { given t2 as Bifunctor[[T, U] =>> (T, U)] {} given t3 [T] as Bifunctor[[U, V] =>> (T, U, V)] {} - def derived[F[_, _]] with (m: Mirror { type MirroredType = F ; type MirroredElemTypes[_, _] }, r: Bifunctor[m.MirroredElemTypes]) : Bifunctor[F] = ??? + def derived[F[_, _]](using m: Mirror { type MirroredType = F ; type MirroredElemTypes[_, _] }, r: Bifunctor[m.MirroredElemTypes]): Bifunctor[F] = ??? } case class Mono(i: Int) derives Bifunctor diff --git a/tests/neg/quote-0.scala b/tests/neg/quote-0.scala index e56ccf55d45c..3e08935b908f 100644 --- a/tests/neg/quote-0.scala +++ b/tests/neg/quote-0.scala @@ -1,6 +1,6 @@ import scala.quoted._ -def test with QuoteContext = { +def test(using QuoteContext) = { val x: Int = 0 diff --git a/tests/neg/quote-1.scala b/tests/neg/quote-1.scala index 03738df74854..0409266f1194 100644 --- a/tests/neg/quote-1.scala +++ b/tests/neg/quote-1.scala @@ -2,7 +2,7 @@ import scala.quoted._ class Test { - def f[T](t: Type[T], x: Expr[T]) with QuoteContext = '{ + def f[T](t: Type[T], x: Expr[T])(using QuoteContext) = '{ val z2 = $x // error // error: wrong staging level } diff --git a/tests/neg/quote-macro-2-splices.scala b/tests/neg/quote-macro-2-splices.scala index e137c3f9fe97..f297ed154644 100644 --- a/tests/neg/quote-macro-2-splices.scala +++ b/tests/neg/quote-macro-2-splices.scala @@ -7,5 +7,5 @@ object Macro { else ${ bar(false) } } - def bar(b: Boolean) with QuoteContext : Expr[Int] = if (b) '{1} else '{0} + def bar(b: Boolean)(using QuoteContext): Expr[Int] = if (b) '{1} else '{0} } diff --git a/tests/neg/quote-spliceNonStaged.scala b/tests/neg/quote-spliceNonStaged.scala index f6d0bd6f1049..f1df505f31c5 100644 --- a/tests/neg/quote-spliceNonStaged.scala +++ b/tests/neg/quote-spliceNonStaged.scala @@ -2,6 +2,6 @@ package quotes import scala.quoted._ object Quotes_1 { - def printHello with QuoteContext : Expr[Unit] = '{ println("Hello") } + def printHello(using QuoteContext): Expr[Unit] = '{ println("Hello") } $printHello // error } diff --git a/tests/neg/quotedPatterns-1.scala b/tests/neg/quotedPatterns-1.scala index ae5a7a690597..42181a663381 100644 --- a/tests/neg/quotedPatterns-1.scala +++ b/tests/neg/quotedPatterns-1.scala @@ -1,5 +1,5 @@ object Test { - def test(x: quoted.Expr[Int]) with scala.quoted.QuoteContext = x match { + def test(x: quoted.Expr[Int])(using scala.quoted.QuoteContext) = x match { case '{ val a = '{ println($y) }; 0 } => ??? // error: Not found: y case _ => } diff --git a/tests/neg/quotedPatterns-2.scala b/tests/neg/quotedPatterns-2.scala index 01ce35cf8925..9ef43d58ab2d 100644 --- a/tests/neg/quotedPatterns-2.scala +++ b/tests/neg/quotedPatterns-2.scala @@ -1,5 +1,5 @@ object Test { - def test(x: quoted.Expr[Int]) with scala.quoted.QuoteContext = x match { + def test(x: quoted.Expr[Int])(using scala.quoted.QuoteContext) = x match { case '{ val a = 4; '{ a }; $y } => y // error // error: access to value a from wrong staging level case _ => } diff --git a/tests/neg/quotedPatterns-3.scala b/tests/neg/quotedPatterns-3.scala index 7968fa576842..81ea1226dc10 100644 --- a/tests/neg/quotedPatterns-3.scala +++ b/tests/neg/quotedPatterns-3.scala @@ -1,5 +1,5 @@ object Test { - def test(x: quoted.Expr[Int]) with scala.quoted.QuoteContext = x match { + def test(x: quoted.Expr[Int])(using scala.quoted.QuoteContext) = x match { case '{ val `$y`: Int = 2; 1 } => y // error: Not found: y case '{ ((`$y`: Int) => 3); 2 } => diff --git a/tests/neg/quotedPatterns-4.scala b/tests/neg/quotedPatterns-4.scala index 2bc5f4273560..6321c9630e9b 100644 --- a/tests/neg/quotedPatterns-4.scala +++ b/tests/neg/quotedPatterns-4.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Test { - def impl(receiver: Expr[StringContext]) with (qctx: scala.quoted.QuoteContext) = { + def impl(receiver: Expr[StringContext])(using qctx: scala.quoted.QuoteContext) = { import qctx.tasty.Repeated receiver match { case '{ StringContext(${Repeated(parts)}: _*) } => // error diff --git a/tests/neg/quotedPatterns-5.scala b/tests/neg/quotedPatterns-5.scala index 9c03ef5040c9..abdb2edc5670 100644 --- a/tests/neg/quotedPatterns-5.scala +++ b/tests/neg/quotedPatterns-5.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Test { - def test(x: quoted.Expr[Int]) with QuoteContext = x match { + def test(x: quoted.Expr[Int])(using QuoteContext) = x match { case '{ type $t; poly[$t]($x); 4 } => ??? // error: duplicate pattern variable: $t case '{ type `$t`; poly[`$t`]($x); 4 } => val tt: quoted.Type[_] = t // error diff --git a/tests/neg/quotedPatterns-6.scala b/tests/neg/quotedPatterns-6.scala index 87344a707223..249763b0461d 100644 --- a/tests/neg/quotedPatterns-6.scala +++ b/tests/neg/quotedPatterns-6.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Test { - def test(x: quoted.Expr[Int]) with QuoteContext = x match { + def test(x: quoted.Expr[Int])(using QuoteContext) = x match { case '{ poly[${Foo(t)}]($x); 4 } => ??? // error case '{ type $t; poly[${Foo(y: quoted.Type[`$t`])}]($x); 4 } => ??? // error case _ => diff --git a/tests/neg/scoped-quoted-expr-proto.scala b/tests/neg/scoped-quoted-expr-proto.scala index 143b4a977b31..11cf5ee5665c 100644 --- a/tests/neg/scoped-quoted-expr-proto.scala +++ b/tests/neg/scoped-quoted-expr-proto.scala @@ -3,14 +3,14 @@ package a { trait Expr[+T] trait QCtx - /*Quote*/ def q[T](x: T)(given QCtx): Expr[T] = ??? - /*Splice*/ def s[T](x: (given QCtx) => Expr[T]): T = ??? - /*run*/ def r[T](x: (given QCtx) => Expr[T]): T = ??? + /*Quote*/ def q[T](x: T)(using QCtx): Expr[T] = ??? + /*Splice*/ def s[T](x: QCtx ?=> Expr[T]): T = ??? + /*run*/ def r[T](x: QCtx ?=> Expr[T]): T = ??? val test: Any = { - def pow(x: Expr[Double], n: Int)(given QCtx): Expr[Double] = + def pow(x: Expr[Double], n: Int)(using QCtx): Expr[Double] = if n == 0 then q{1.0} else q{ s{x} * s{pow(x, n - 1)} } r { @@ -46,14 +46,14 @@ package b { type Expr[+T] } - /*Quote*/ def q[T](x: T)(given qctx: QCtx): qctx.Expr[T] = ??? - /*Splice*/ def s[T](given qctx0: QCtx)(x: (given qctx: QCtx { type Expr[+T] >: qctx0.Expr[T] }) => qctx.Expr[T]): T = ??? - /*run*/ def r[T](x: (given qctx: QCtx) => qctx.Expr[T]): T = ??? + /*Quote*/ def q[T](x: T)(using qctx: QCtx): qctx.Expr[T] = ??? + /*Splice*/ def s[T](using qctx0: QCtx)(x: (qctx: QCtx { type Expr[+T] >: qctx0.Expr[T] }) ?=> qctx.Expr[T]): T = ??? + /*run*/ def r[T](x: (qctx: QCtx) ?=> qctx.Expr[T]): T = ??? val test: Any = { - def pow(given qctx: QCtx)(x: qctx.Expr[Double], n: Int): qctx.Expr[Double] = + def pow(using qctx: QCtx)(x: qctx.Expr[Double], n: Int): qctx.Expr[Double] = if n == 0 then q{1.0} else q{ s{x} * s{pow(x, n - 1)} } r { @@ -69,7 +69,7 @@ package b { } } - r { (given qctx) => + r { qctx ?=> var escaped: qctx.Expr[Double] = ??? q{ (x: Double) => s{ diff --git a/tests/neg/splice-non-expr.scala b/tests/neg/splice-non-expr.scala index 97ac5929418c..758fb129bcd6 100644 --- a/tests/neg/splice-non-expr.scala +++ b/tests/neg/splice-non-expr.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Foo { - def test with QuoteContext = '{ + def test(using QuoteContext) = '{ ${3} // error ${new Object} // error ${"abc"} // error diff --git a/tests/neg/toexproftuple.scala b/tests/neg/toexproftuple.scala index 0406fbb85541..42ce624f2205 100644 --- a/tests/neg/toexproftuple.scala +++ b/tests/neg/toexproftuple.scala @@ -2,7 +2,7 @@ import scala.quoted._, scala.deriving._ import scala.quoted.{given _} inline def mcr: Any = ${mcrImpl} -def mcrImpl with (ctx: QuoteContext) : Expr[Any] = { +def mcrImpl(using ctx: QuoteContext): Expr[Any] = { val tpl: (Expr[1], Expr[2], Expr[3]) = ('{1}, '{2}, '{3}) '{val res: (1, 3, 3) = ${Expr.ofTuple(tpl)}; res} // error diff --git a/tests/patmat/i6255.scala b/tests/patmat/i6255.scala index dafbb8fb47b6..5c515e988694 100644 --- a/tests/patmat/i6255.scala +++ b/tests/patmat/i6255.scala @@ -1,5 +1,5 @@ class Foo { - def foo(x: quoted.Expr[Int]) with scala.quoted.QuoteContext : Unit = x match { + def foo(x: quoted.Expr[Int])(using scala.quoted.QuoteContext): Unit = x match { case '{ 1 } => case '{ 2 } => case _ => diff --git a/tests/patmat/i6255b.scala b/tests/patmat/i6255b.scala index ffdc38629b94..25bc213b56b5 100644 --- a/tests/patmat/i6255b.scala +++ b/tests/patmat/i6255b.scala @@ -1,5 +1,5 @@ class Foo { - def foo(x: quoted.Expr[Int]) with scala.quoted.QuoteContext : Unit = x match { + def foo(x: quoted.Expr[Int])(using scala.quoted.QuoteContext): Unit = x match { case '{ 1 } => case '{ 2 } => } diff --git a/tests/pending/pos/i4987.scala b/tests/pending/pos/i4987.scala index 5744f580856c..f00e67585c6b 100644 --- a/tests/pending/pos/i4987.scala +++ b/tests/pending/pos/i4987.scala @@ -12,6 +12,6 @@ object Foo { implicit def NilIsLiftable: Liftable[Nil.type] = ??? - Expr(Nil) with NilIsLiftable + Expr(Nil)(using NilIsLiftable) Expr(Nil) } \ No newline at end of file diff --git a/tests/pending/run/tasty-comments/quoted_1.scala b/tests/pending/run/tasty-comments/quoted_1.scala index 7a2f00971d95..fc8faec97624 100644 --- a/tests/pending/run/tasty-comments/quoted_1.scala +++ b/tests/pending/run/tasty-comments/quoted_1.scala @@ -7,7 +7,7 @@ object Macros { inline def printComment[T](t: => T): Unit = ${ impl('t) } - def impl[T](x: Expr[T]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl[T](x: Expr[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = x.unseal diff --git a/tests/pos-custom-args/erased/i7868.scala b/tests/pos-custom-args/erased/i7868.scala index 6072dc5592e4..f4ffe3a7d83c 100644 --- a/tests/pos-custom-args/erased/i7868.scala +++ b/tests/pos-custom-args/erased/i7868.scala @@ -15,17 +15,17 @@ object Coproduct { def cast: Head <:< Head +: Tail = summon[Head <:< Head +: Tail] } - given atTail[Head, Tail, Value, NextIndex <: Int] with (atNext: At[Tail, Value, NextIndex]) : At[Head +: Tail, Value, S[NextIndex]] { + given atTail[Head, Tail, Value, NextIndex <: Int](using atNext: At[Tail, Value, NextIndex]) as At[Head +: Tail, Value, S[NextIndex]] { val cast: Value <:< Head +: Tail = atNext.cast } - given [A] with A as (() => A)= { () => summon[A]} + given [A](using A) as (() => A)= { () => summon[A]} } - def upCast[A, B](a: A) with (erased evidence: (A <:< B) ): B = a.asInstanceOf[B] + def upCast[A, B](a: A)(using erased evidence: (A <:< B) ): B = a.asInstanceOf[B] - def from[Set, Value, Index <: Int](value: Value) with (erased at: At[Set, Value, Index]) : ValueOf[Index] ?=> Coproduct[Set, Value, Index] = { - Coproduct[Set, Value, Index](upCast(value: Value).with(at.cast.liftCo[[X] =>> Value & X]), valueOf[Index]) + def from[Set, Value, Index <: Int](value: Value)(using erased at: At[Set, Value, Index]) : ValueOf[Index] ?=> Coproduct[Set, Value, Index] = { + Coproduct[Set, Value, Index](upCast(value: Value)(using at.cast.liftCo[[X] =>> Value & X]), valueOf[Index]) } } diff --git a/tests/pos-custom-args/i4509.scala b/tests/pos-custom-args/i4509.scala index afb15a5486bb..2e394ef296ed 100644 --- a/tests/pos-custom-args/i4509.scala +++ b/tests/pos-custom-args/i4509.scala @@ -1,4 +1,4 @@ object Main { - def fun[T](op: (erased Int) ?=> T) = op.with(0) + def fun[T](op: (erased Int) ?=> T) = op(using 0) fun { } } diff --git a/tests/pos-custom-args/phantom-Eq.scala b/tests/pos-custom-args/phantom-Eq.scala index 9547720d9ca5..d3c94503bbd1 100644 --- a/tests/pos-custom-args/phantom-Eq.scala +++ b/tests/pos-custom-args/phantom-Eq.scala @@ -18,7 +18,7 @@ object EqUtil { type PhantomEqEq[T] = PhantomEq[T, T] implicit class EqualsDeco[T](val x: T) extends AnyVal { - def ===[U] (y: U) with (erased ce: PhantomEq[T, U]) = x.equals(y) + def ===[U] (y: U) (using erased ce: PhantomEq[T, U]) = x.equals(y) } implicit erased def eqString: PhantomEqEq[String] = ??? @@ -28,5 +28,5 @@ object EqUtil { implicit erased def eqByteNum: PhantomEq[Byte, Number] = ??? implicit erased def eqNumByte: PhantomEq[Number, Byte] = ??? - implicit erased def eqSeq[T, U] with (erased eq: PhantomEq[T, U]) : PhantomEq[Seq[T], Seq[U]] = ??? + implicit erased def eqSeq[T, U] (using erased eq: PhantomEq[T, U]): PhantomEq[Seq[T], Seq[U]] = ??? } diff --git a/tests/pos-custom-args/phantom-Eq2/Phantom-Eq_1.scala b/tests/pos-custom-args/phantom-Eq2/Phantom-Eq_1.scala index afabcaeb7d40..9c12aefebece 100644 --- a/tests/pos-custom-args/phantom-Eq2/Phantom-Eq_1.scala +++ b/tests/pos-custom-args/phantom-Eq2/Phantom-Eq_1.scala @@ -6,7 +6,7 @@ object EqUtil { type PhantomEqEq[T] = PhantomEq[T, T] implicit class EqualsDeco[T](val x: T) extends AnyVal { - def ===[U] (y: U) with (erased ce: PhantomEq[T, U]) = x.equals(y) + def ===[U] (y: U) (using erased ce: PhantomEq[T, U]) = x.equals(y) } implicit erased def eqString: PhantomEqEq[String] = new PhantomEq[String, String] @@ -16,6 +16,6 @@ object EqUtil { implicit erased def eqByteNum: PhantomEq[Byte, Number] = new PhantomEq[Byte, Number] implicit erased def eqNumByte: PhantomEq[Number, Byte] = new PhantomEq[Number, Byte] - implicit erased def eqSeq[T, U] with (erased eq: PhantomEq[T, U]) : PhantomEq[Seq[T], Seq[U]] = + implicit erased def eqSeq[T, U] (using erased eq: PhantomEq[T, U]): PhantomEq[Seq[T], Seq[U]] = new PhantomEq[Seq[T], Seq[U]] } diff --git a/tests/pos-custom-args/phantom-Evidence.scala b/tests/pos-custom-args/phantom-Evidence.scala index db0bac9fe295..6ad6f927591b 100644 --- a/tests/pos-custom-args/phantom-Evidence.scala +++ b/tests/pos-custom-args/phantom-Evidence.scala @@ -10,8 +10,8 @@ object WithNormalState { def newInstance(): Instance[Off] = new Instance[Off] } class Instance[S <: State] private { - def getOnInstance with (erased ev: S =::= Off) : Instance[On] = new Instance[On] // phantom parameter ev is erased - def getOffInstance with (erased ev: S =::= On) : Instance[Off] = new Instance[Off] // phantom parameter ev is erased + def getOnInstance (using erased ev: S =::= Off): Instance[On] = new Instance[On] // phantom parameter ev is erased + def getOffInstance (using erased ev: S =::= On): Instance[Off] = new Instance[Off] // phantom parameter ev is erased } def run() = { diff --git a/tests/pos-macros/i3898/quoted_1.scala b/tests/pos-macros/i3898/quoted_1.scala index 6e68a77b8aeb..c30e7b099ed7 100644 --- a/tests/pos-macros/i3898/quoted_1.scala +++ b/tests/pos-macros/i3898/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def ff(args: Any*): String = ${impl('args)} - def impl(args: Expr[Seq[Any]]) with QuoteContext : Expr[String] = '{""} + def impl(args: Expr[Seq[Any]])(using QuoteContext): Expr[String] = '{""} } diff --git a/tests/pos-macros/i3898b/quoted_1.scala b/tests/pos-macros/i3898b/quoted_1.scala index 41a41e99782a..a09baa5e9f6b 100644 --- a/tests/pos-macros/i3898b/quoted_1.scala +++ b/tests/pos-macros/i3898b/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def ff(x: Int, inline y: Int): String = ${impl('x)} - def impl(x: Expr[Int]) with QuoteContext : Expr[String] = '{""} + def impl(x: Expr[Int])(using QuoteContext): Expr[String] = '{""} } diff --git a/tests/pos-macros/i3898c/quoted_1.scala b/tests/pos-macros/i3898c/quoted_1.scala index 41a41e99782a..a09baa5e9f6b 100644 --- a/tests/pos-macros/i3898c/quoted_1.scala +++ b/tests/pos-macros/i3898c/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def ff(x: Int, inline y: Int): String = ${impl('x)} - def impl(x: Expr[Int]) with QuoteContext : Expr[String] = '{""} + def impl(x: Expr[Int])(using QuoteContext): Expr[String] = '{""} } diff --git a/tests/pos-macros/i3898c/quoted_2.scala b/tests/pos-macros/i3898c/quoted_2.scala index 1b1947f65e16..b52af983c1d7 100644 --- a/tests/pos-macros/i3898c/quoted_2.scala +++ b/tests/pos-macros/i3898c/quoted_2.scala @@ -1,5 +1,5 @@ import scala.quoted._ -def test with QuoteContext = { +def test(using QuoteContext) = { val a = '{ def z: Int = 5 Macro.ff(z, 5) diff --git a/tests/pos-macros/i3912-1/i3912_1.scala b/tests/pos-macros/i3912-1/i3912_1.scala index 7bed91812477..f8b4331b1423 100644 --- a/tests/pos-macros/i3912-1/i3912_1.scala +++ b/tests/pos-macros/i3912-1/i3912_1.scala @@ -3,5 +3,5 @@ import scala.quoted._ object Macros { inline def foo(): Int = { ${ impl() } } - def impl() with QuoteContext : Expr[Int] = '{1} + def impl()(using QuoteContext): Expr[Int] = '{1} } \ No newline at end of file diff --git a/tests/pos-macros/i3912-2/i3912_1.scala b/tests/pos-macros/i3912-2/i3912_1.scala index bc44f30dec6a..aae33694311f 100644 --- a/tests/pos-macros/i3912-2/i3912_1.scala +++ b/tests/pos-macros/i3912-2/i3912_1.scala @@ -3,5 +3,5 @@ import scala.quoted._ object Macros { inline def foo2(): Unit = ${ impl() } - def impl() with QuoteContext : Expr[Int] = '{1} + def impl()(using QuoteContext): Expr[Int] = '{1} } \ No newline at end of file diff --git a/tests/pos-macros/i4023b/Macro_1.scala b/tests/pos-macros/i4023b/Macro_1.scala index 9ebbeae837c8..3c4cf7774a54 100644 --- a/tests/pos-macros/i4023b/Macro_1.scala +++ b/tests/pos-macros/i4023b/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def ff[T](implicit t: Type[T]): Int = ${ impl[T] } - def impl[T] with QuoteContext : Expr[Int] = '{4} + def impl[T](using QuoteContext): Expr[Int] = '{4} } diff --git a/tests/pos-macros/i4734/Macro_1.scala b/tests/pos-macros/i4734/Macro_1.scala index 26f2d67322c2..cffa353a0975 100644 --- a/tests/pos-macros/i4734/Macro_1.scala +++ b/tests/pos-macros/i4734/Macro_1.scala @@ -5,7 +5,7 @@ object Macros { inline def unrolledForeach(f: Int => Int): Int = ${unrolledForeachImpl('f)} - def unrolledForeachImpl(f: Expr[Int => Int]) with QuoteContext : Expr[Int] = '{ + def unrolledForeachImpl(f: Expr[Int => Int])(using QuoteContext): Expr[Int] = '{ val size: Int = 5 ($f)(3) } diff --git a/tests/pos-macros/i6171/Macro_1.scala b/tests/pos-macros/i6171/Macro_1.scala index 95968d1d619f..aff1bfafbfe2 100644 --- a/tests/pos-macros/i6171/Macro_1.scala +++ b/tests/pos-macros/i6171/Macro_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(x: => Any): Unit = ${ assertImpl('x) } - def assertImpl(x: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(x: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} x.unseal.underlyingArgument '{ () } diff --git a/tests/pos-macros/i6210/Macros_1.scala b/tests/pos-macros/i6210/Macros_1.scala index 571c13bd1a14..24c4fb839c7b 100644 --- a/tests/pos-macros/i6210/Macros_1.scala +++ b/tests/pos-macros/i6210/Macros_1.scala @@ -4,7 +4,7 @@ object Macro { inline def test[A, B]: Any = ${ impl[A, B] } - def impl[A : Type, B : Type] with QuoteContext : Expr[Any] = { + def impl[A : Type, B : Type](using QuoteContext): Expr[Any] = { val t = '[Map[A, B]] '{ new Object().asInstanceOf[$t] diff --git a/tests/pos-macros/i6535/Macro_1.scala b/tests/pos-macros/i6535/Macro_1.scala index e12b3040c095..a97a09bb4649 100644 --- a/tests/pos-macros/i6535/Macro_1.scala +++ b/tests/pos-macros/i6535/Macro_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition) } - def assertImpl(cond: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} import util._ diff --git a/tests/pos-macros/i6803b/Macro_1.scala b/tests/pos-macros/i6803b/Macro_1.scala index e3f207e3f5c6..14cf25e6fab1 100644 --- a/tests/pos-macros/i6803b/Macro_1.scala +++ b/tests/pos-macros/i6803b/Macro_1.scala @@ -9,7 +9,7 @@ object AsObject { object LineNo { def unsafe(i: Int): LineNo = new LineNo(i) inline given x : LineNo = ${impl} - private def impl with (qctx: QuoteContext) : Expr[LineNo] = { + private def impl(using qctx: QuoteContext) : Expr[LineNo] = { import qctx.tasty.{_, given _} '{unsafe(${rootPosition.startLine})} } diff --git a/tests/pos-macros/i6803b/Test_2.scala b/tests/pos-macros/i6803b/Test_2.scala index cb22fb35a077..562d780d9162 100644 --- a/tests/pos-macros/i6803b/Test_2.scala +++ b/tests/pos-macros/i6803b/Test_2.scala @@ -5,7 +5,7 @@ object Test { def testO(): Unit = { import AsObject.LineNo - summon[LineNo].with(LineNo.x) + summon[LineNo](using LineNo.x) } } } diff --git a/tests/pos-macros/i7011/Macros_1.scala b/tests/pos-macros/i7011/Macros_1.scala index a70e8d1ef3ae..d5221b664283 100644 --- a/tests/pos-macros/i7011/Macros_1.scala +++ b/tests/pos-macros/i7011/Macros_1.scala @@ -3,7 +3,7 @@ import scala.quoted.{given _} inline def mcr(body: => Any): Unit = ${mcrImpl('body)} -def mcrImpl[T](body: Expr[Any]) with (ctx: QuoteContext) : Expr[Any] = { +def mcrImpl[T](body: Expr[Any])(using ctx: QuoteContext) : Expr[Any] = { import ctx.tasty.{_, given _} val bTree = body.unseal diff --git a/tests/pos-macros/i7513/Macro_1.scala b/tests/pos-macros/i7513/Macro_1.scala index 6ebab19b09df..4752c85df4e4 100644 --- a/tests/pos-macros/i7513/Macro_1.scala +++ b/tests/pos-macros/i7513/Macro_1.scala @@ -5,7 +5,7 @@ trait Quoted { } inline def quote: Quoted = ${ quoteImpl } -def quoteImpl with (qctx: QuoteContext) : Expr[Quoted] = '{ +def quoteImpl(using qctx: QuoteContext): Expr[Quoted] = '{ new Quoted { def foo = ??? } diff --git a/tests/pos-macros/i7513b/Macro_1.scala b/tests/pos-macros/i7513b/Macro_1.scala index 85faf7748496..c338f27b6f81 100644 --- a/tests/pos-macros/i7513b/Macro_1.scala +++ b/tests/pos-macros/i7513b/Macro_1.scala @@ -5,7 +5,7 @@ trait Quoted { } inline def quote: Quoted = ${ quoteImpl } -def quoteImpl with (qctx: QuoteContext) : Expr[Quoted] = '{ +def quoteImpl(using qctx: QuoteContext): Expr[Quoted] = '{ new Quoted { val foo = ??? } diff --git a/tests/pos-macros/i7513c/Macro_1.scala b/tests/pos-macros/i7513c/Macro_1.scala index 486a5624ba3c..a0f99886c276 100644 --- a/tests/pos-macros/i7513c/Macro_1.scala +++ b/tests/pos-macros/i7513c/Macro_1.scala @@ -6,7 +6,7 @@ object Macros { } inline def quote: Quoted = ${ quoteImpl } - def quoteImpl with (qctx: QuoteContext) : Expr[Quoted] = '{ + def quoteImpl(using qctx: QuoteContext): Expr[Quoted] = '{ new Quoted { def foo = ??? } diff --git a/tests/pos-macros/i7853/JsonEncoder_1.scala b/tests/pos-macros/i7853/JsonEncoder_1.scala index 48c18a7a938c..b0bb1afa6536 100644 --- a/tests/pos-macros/i7853/JsonEncoder_1.scala +++ b/tests/pos-macros/i7853/JsonEncoder_1.scala @@ -36,7 +36,7 @@ object JsonEncoder { } } - given listEncoder[T] with (encoder: JsonEncoder[T]) as JsonEncoder[List[T]] { + given listEncoder[T](using encoder: JsonEncoder[T]) as JsonEncoder[List[T]] { def encode(list: List[T]) = s"[${ list.map(v => encoder.encode(v)).mkString(", ") }]" } diff --git a/tests/pos-macros/i7853/SummonJsonEncoderTest_2.scala b/tests/pos-macros/i7853/SummonJsonEncoderTest_2.scala index d991df71e263..6bcfa59463c7 100644 --- a/tests/pos-macros/i7853/SummonJsonEncoderTest_2.scala +++ b/tests/pos-macros/i7853/SummonJsonEncoderTest_2.scala @@ -8,7 +8,7 @@ object SummonJsonEncoderTest { inline def encodeAndMessAroundType[T](value: =>T): String = ${ encodeAndMessAroundTypeImpl('value) } - def encodeAndMessAroundTypeImpl[T: Type](value: Expr[T]) with (qctx: QuoteContext) : Expr[String] = { + def encodeAndMessAroundTypeImpl[T: Type](value: Expr[T])(using qctx: QuoteContext): Expr[String] = { import qctx.tasty._ val mirrorExpr = summonExpr[Mirror.Of[T]] match { diff --git a/tests/pos-macros/macro-with-type/Macro_1.scala b/tests/pos-macros/macro-with-type/Macro_1.scala index b82ade598d5d..3a00191873d5 100644 --- a/tests/pos-macros/macro-with-type/Macro_1.scala +++ b/tests/pos-macros/macro-with-type/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def ff: Unit = ${impl('[Int])} - def impl(t: Type[Int]) with QuoteContext : Expr[Unit] = '{} + def impl(t: Type[Int])(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/pos-macros/macros-in-same-project-1/Foo.scala b/tests/pos-macros/macros-in-same-project-1/Foo.scala index 686d234276da..d45bda5775d7 100644 --- a/tests/pos-macros/macros-in-same-project-1/Foo.scala +++ b/tests/pos-macros/macros-in-same-project-1/Foo.scala @@ -4,6 +4,6 @@ object Foo { inline def myMacro(): Unit = ${ aMacroImplementation } - def aMacroImplementation with QuoteContext : Expr[Unit] = '{ println("Hello") } + def aMacroImplementation(using QuoteContext): Expr[Unit] = '{ println("Hello") } } diff --git a/tests/pos-macros/macros-in-same-project-2/Foo.scala b/tests/pos-macros/macros-in-same-project-2/Foo.scala index 80c4a210c03c..25e1a530cd12 100644 --- a/tests/pos-macros/macros-in-same-project-2/Foo.scala +++ b/tests/pos-macros/macros-in-same-project-2/Foo.scala @@ -2,6 +2,6 @@ import scala.quoted._ object Foo { - def aMacroImplementation with QuoteContext : Expr[Unit] = '{ println("Hello") } + def aMacroImplementation(using QuoteContext): Expr[Unit] = '{ println("Hello") } } diff --git a/tests/pos-macros/macros-in-same-project-3/Bar.scala b/tests/pos-macros/macros-in-same-project-3/Bar.scala index cbbd514eed83..11d8aa44511b 100644 --- a/tests/pos-macros/macros-in-same-project-3/Bar.scala +++ b/tests/pos-macros/macros-in-same-project-3/Bar.scala @@ -4,6 +4,6 @@ object Bar { inline def myMacro(): Unit = ${ aMacroImplementation } - def aMacroImplementation with QuoteContext : Expr[Unit] = Foo.hello() + def aMacroImplementation(using QuoteContext): Expr[Unit] = Foo.hello() } diff --git a/tests/pos-macros/macros-in-same-project-3/Foo.scala b/tests/pos-macros/macros-in-same-project-3/Foo.scala index 3557f5bdb2c1..17cb639647fb 100644 --- a/tests/pos-macros/macros-in-same-project-3/Foo.scala +++ b/tests/pos-macros/macros-in-same-project-3/Foo.scala @@ -2,6 +2,6 @@ import scala.quoted._ object Foo { - def hello() with QuoteContext : Expr[Unit] = '{ println("Hello") } + def hello()(using QuoteContext): Expr[Unit] = '{ println("Hello") } } diff --git a/tests/pos-macros/macros-in-same-project-4/Bar.scala b/tests/pos-macros/macros-in-same-project-4/Bar.scala index 2dfed7cc1ce8..22f46fdc84e9 100644 --- a/tests/pos-macros/macros-in-same-project-4/Bar.scala +++ b/tests/pos-macros/macros-in-same-project-4/Bar.scala @@ -3,9 +3,9 @@ import scala.quoted._ object Bar { inline def eqMacro(x: Foo, y: Foo): Boolean = ${ eqMacroExpr('x, 'y) } - def eqMacroExpr(x: Expr[Foo], y: Expr[Foo]) with QuoteContext : Expr[Boolean] = '{ $x == $y } + def eqMacroExpr(x: Expr[Foo], y: Expr[Foo])(using QuoteContext): Expr[Boolean] = '{ $x == $y } inline def plusMacro(x: Foo, y: Foo): Foo = ${ eqPlusExpr('x, 'y) } - def eqPlusExpr(x: Expr[Foo], y: Expr[Foo]) with QuoteContext : Expr[Foo] = '{ new Foo($x.value + $y.value) } + def eqPlusExpr(x: Expr[Foo], y: Expr[Foo])(using QuoteContext): Expr[Foo] = '{ new Foo($x.value + $y.value) } } diff --git a/tests/pos-macros/power-macro/Macro_1.scala b/tests/pos-macros/power-macro/Macro_1.scala index 57bc2a1acbd0..e3ff02f224b5 100644 --- a/tests/pos-macros/power-macro/Macro_1.scala +++ b/tests/pos-macros/power-macro/Macro_1.scala @@ -5,10 +5,10 @@ object PowerMacro { inline def power(inline n: Long, x: Double) = ${powerCode('n, 'x)} - def powerCode(n: Expr[Long], x: Expr[Double]) with QuoteContext : Expr[Double] = + def powerCode(n: Expr[Long], x: Expr[Double]) (using QuoteContext): Expr[Double] = powerCode(n.value, x) - def powerCode(n: Long, x: Expr[Double]) with QuoteContext : Expr[Double] = + def powerCode(n: Long, x: Expr[Double])(using QuoteContext): Expr[Double] = if (n == 0) '{1.0} else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, 'y)} } } else '{ $x * ${powerCode(n - 1, x)} } diff --git a/tests/pos-macros/quote-nested-object/Macro_1.scala b/tests/pos-macros/quote-nested-object/Macro_1.scala index c1007d2965bd..688eb8c26b3e 100644 --- a/tests/pos-macros/quote-nested-object/Macro_1.scala +++ b/tests/pos-macros/quote-nested-object/Macro_1.scala @@ -9,7 +9,7 @@ object Macro { inline def plus(inline n: Int, m: Int): Int = ${ plus('n, 'm) } - def plus(n: Expr[Int], m: Expr[Int]) with QuoteContext : Expr[Int] = + def plus(n: Expr[Int], m: Expr[Int]) (using QuoteContext): Expr[Int] = if (n.value == 0) m else '{ ${n} + $m } @@ -17,7 +17,7 @@ object Macro { inline def plus(inline n: Int, m: Int): Int = ${ plus('n, 'm) } - def plus(n: Expr[Int], m: Expr[Int]) with QuoteContext : Expr[Int] = + def plus(n: Expr[Int], m: Expr[Int]) (using QuoteContext): Expr[Int] = if (n.value == 0) m else '{ ${n} + $m } } diff --git a/tests/pos-macros/quote-whitebox-2/Macro_1.scala b/tests/pos-macros/quote-whitebox-2/Macro_1.scala index 640fae98878c..a025b3089038 100644 --- a/tests/pos-macros/quote-whitebox-2/Macro_1.scala +++ b/tests/pos-macros/quote-whitebox-2/Macro_1.scala @@ -5,7 +5,7 @@ object Macro { inline def charOrString(inline str: String) <: Any = ${ impl('str) } - def impl(strExpr: Expr[String]) with QuoteContext = + def impl(strExpr: Expr[String]) (using QuoteContext)= val str = strExpr.value if (str.length == 1) Expr(str.charAt(0)) else Expr(str) diff --git a/tests/pos-macros/tasty-constant-type/Macro_1.scala b/tests/pos-macros/tasty-constant-type/Macro_1.scala index 252c4e363dcf..61dde1cfc63d 100644 --- a/tests/pos-macros/tasty-constant-type/Macro_1.scala +++ b/tests/pos-macros/tasty-constant-type/Macro_1.scala @@ -6,7 +6,7 @@ object Macro { inline def ff[A <: Int, B <: Int]() <: AddInt[A, B] = ${ impl('[A], '[B]) } - def impl[A <: Int : Type, B <: Int : Type](a: Type[A], b: Type[B]) with (qctx: QuoteContext) : Expr[AddInt[A, B]] = { + def impl[A <: Int : Type, B <: Int : Type](a: Type[A], b: Type[B])(using qctx: QuoteContext) : Expr[AddInt[A, B]] = { import qctx.tasty.{_, given _} val ConstantType(Constant(v1: Int)) = a.unseal.tpe diff --git a/tests/pos-macros/treemap-unapply/Macro.scala b/tests/pos-macros/treemap-unapply/Macro.scala index 661bb548197f..9e38b1c5cff4 100644 --- a/tests/pos-macros/treemap-unapply/Macro.scala +++ b/tests/pos-macros/treemap-unapply/Macro.scala @@ -1,7 +1,7 @@ import scala.quoted.{ given _, _ } inline def mcr(x: => Unit): Unit = ${mcrImpl('x)} -def mcrImpl(x: Expr[Unit]) with (ctx: QuoteContext) : Expr[Unit] = +def mcrImpl(x: Expr[Unit])(using ctx: QuoteContext) : Expr[Unit] = import ctx.tasty.{ given _, _ } val tr: Term = x.unseal object m extends TreeMap diff --git a/tests/pos-special/fatal-warnings/i6290.scala b/tests/pos-special/fatal-warnings/i6290.scala index d8b410224269..b5694dfa296a 100644 --- a/tests/pos-special/fatal-warnings/i6290.scala +++ b/tests/pos-special/fatal-warnings/i6290.scala @@ -1,15 +1,15 @@ class TC { type T } -class C with (TC { type T = Int }) - -def f1 with (x: TC) = ??? -def f2 with (@unchecked x: TC) = ??? -inline def f3 with (inline x: TC) = ??? - -class C1 with (x: TC) -class C2 with (@unchecked x: TC) -class C3 with (val x: TC) -class C4 with (var x: TC) -class C5 with (private val x: TC) -class C6 with (private[this] val x: TC) +class C(using TC { type T = Int }) + +def f1(using x: TC) = ??? +def f2(using @unchecked x: TC) = ??? +inline def f3(using inline x: TC) = ??? + +class C1(using x: TC) +class C2(using @unchecked x: TC) +class C3(using val x: TC) +class C4(using var x: TC) +class C5(using private val x: TC) +class C6(using private[this] val x: TC) diff --git a/tests/pos-staging/quote-0.scala b/tests/pos-staging/quote-0.scala index 3624b4961e8f..b0988ef8be38 100644 --- a/tests/pos-staging/quote-0.scala +++ b/tests/pos-staging/quote-0.scala @@ -8,18 +8,18 @@ object Macros { inline def assert(expr: => Boolean): Unit = ${ assertImpl('expr) } - def assertImpl(expr: Expr[Boolean]) with QuoteContext = + def assertImpl(expr: Expr[Boolean])(using QuoteContext) = '{ if !($expr) then throw new AssertionError(s"failed assertion: ${${showExpr(expr)}}") } - def showExpr[T](expr: Expr[T]) with QuoteContext : Expr[String] = expr.toString + def showExpr[T](expr: Expr[T])(using QuoteContext): Expr[String] = expr.toString inline def power(inline n: Int, x: Double) = ${ powerCode('n, 'x) } - def powerCode(n: Expr[Int], x: Expr[Double]) with QuoteContext : Expr[Double] = + def powerCode(n: Expr[Int], x: Expr[Double]) (using QuoteContext): Expr[Double] = powerCode(n.value, x) - def powerCode(n: Int, x: Expr[Double]) with QuoteContext : Expr[Double] = + def powerCode(n: Int, x: Expr[Double])(using QuoteContext): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x else if (n % 2 == 0) '{ { val y = $x * $x; ${ powerCode(n / 2, 'y) } } } diff --git a/tests/pos-staging/quote-assert/quoted_1.scala b/tests/pos-staging/quote-assert/quoted_1.scala index 2eb5269b15fc..b298b97f963f 100644 --- a/tests/pos-staging/quote-assert/quoted_1.scala +++ b/tests/pos-staging/quote-assert/quoted_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Macros { - def assertImpl(expr: Expr[Boolean]) with QuoteContext = + def assertImpl(expr: Expr[Boolean])(using QuoteContext) = '{ if !($expr) then throw new AssertionError(s"failed assertion: ${$expr}") } } diff --git a/tests/pos-staging/quote-assert/quoted_2.scala b/tests/pos-staging/quote-assert/quoted_2.scala index 97dcd6976692..57af0f4d8bfc 100644 --- a/tests/pos-staging/quote-assert/quoted_2.scala +++ b/tests/pos-staging/quote-assert/quoted_2.scala @@ -10,7 +10,7 @@ object Test { ${ assertImpl('expr) } - def program with QuoteContext = '{ + def program(using QuoteContext) = '{ val x = 1 assert(x != 0) diff --git a/tests/pos/case-getters.scala b/tests/pos/case-getters.scala index b49806ce07ee..391700aafb71 100644 --- a/tests/pos/case-getters.scala +++ b/tests/pos/case-getters.scala @@ -3,6 +3,6 @@ object Test { val f = Foo(1, (i: Int) ?=> i) val fx1: 1 = f.x val fx2: 1 = f._1 - val fy1: Int = f.y.with(1) - val fy2: Int = f._2.with(1) + val fy1: Int = f.y(using 1) + val fy2: Int = f._2(using 1) } diff --git a/tests/pos/combine.scala b/tests/pos/combine.scala index 5a978b461d4c..179ec36fb193 100644 --- a/tests/pos/combine.scala +++ b/tests/pos/combine.scala @@ -2,7 +2,7 @@ trait Semigroup[A] { def (x: A).combine(y: A): A } given Semigroup[Int] = ??? -given [A, B] with (Semigroup[A], Semigroup[B]) : Semigroup[(A, B)] = ??? +given [A, B](using Semigroup[A], Semigroup[B]): Semigroup[(A, B)] = ??? object Test extends App { ((1, 1)) combine ((2, 2)) // doesn't compile ((1, 1): (Int, Int)) combine (2, 2) // compiles diff --git a/tests/pos/depfuntype.scala b/tests/pos/depfuntype.scala index a8cbd454d08a..929cb7d657e3 100644 --- a/tests/pos/depfuntype.scala +++ b/tests/pos/depfuntype.scala @@ -25,9 +25,9 @@ object Test { val ifun: IDF = implicitly[C].m - val u = ifun.with(c) + val u = ifun(using c) val u1: Int = u - val v = ifun.with(d) + val v = ifun(using d) val v1: d.M = v } diff --git a/tests/pos/eff-compose.scala b/tests/pos/eff-compose.scala index 300c994e43da..40174590f707 100644 --- a/tests/pos/eff-compose.scala +++ b/tests/pos/eff-compose.scala @@ -36,7 +36,7 @@ object Test { } } - implicit def combine[E1 <: Effect, E2 <: Effect] with (x: E1, y: E2) : E1 & E2 = ??? + implicit def combine[E1 <: Effect, E2 <: Effect](using x: E1, y: E2): E1 & E2 = ??? // def compose(f: A => B)(g: B => C)(x: A): C def compose[A, B, C, E1 <: Effect, E2 <: Effect] diff --git a/tests/pos/given-constrapps.scala b/tests/pos/given-constrapps.scala index feccbc1dd777..f92653542861 100644 --- a/tests/pos/given-constrapps.scala +++ b/tests/pos/given-constrapps.scala @@ -1,29 +1,29 @@ class TC val tc = TC() -class C with (x: TC) { +class C(using x: TC) { assert(x eq tc) } -class C2(n: Int) with (x: TC) with List[TC] { +class C2(n: Int)(using x: TC)(using List[TC]) { assert(x eq tc) summon[List[TC]].foreach(t => assert(t eq tc)) - def this() with TC with List[TC] = this(1) + def this()(using TC)(using List[TC]) = this(1) } -class D extends C.with(tc) -class D2 extends C2(1).with(tc).with(Nil) +class D extends C(using tc) +class D2 extends C2(1)(using tc)(using Nil) -class Foo with TC { +class Foo(using TC) { assert(summon[TC] != null) } object Test extends App { - new C.with(tc) - new C().with(tc) - new C.with(tc) {} - new C2(1).with(tc).with(List(tc)) - new C2(1).with(tc).with(List(tc)) {} - new C2().with(tc).with(List(tc)) - def foo with TC = () - foo.with(tc) + new C(using tc) + new C()(using tc) + new C(using tc) {} + new C2(1)(using tc)(using List(tc)) + new C2(1)(using tc)(using List(tc)) {} + new C2()(using tc)(using List(tc)) + def foo(using TC) = () + foo(using tc) } \ No newline at end of file diff --git a/tests/pos/givenIn.scala b/tests/pos/givenIn.scala index 6e22c66f0f7e..fedd42b11d83 100644 --- a/tests/pos/givenIn.scala +++ b/tests/pos/givenIn.scala @@ -9,7 +9,7 @@ object Test { } def ctx: Context = new Context - def g with Context = () + def g(using Context) = () ctx.givenIn(g) /* The last three statements should generate the following code: diff --git a/tests/pos/i2723.scala b/tests/pos/i2723.scala index f1d05581467a..3c21b34d0f51 100644 --- a/tests/pos/i2723.scala +++ b/tests/pos/i2723.scala @@ -1,3 +1,3 @@ trait App(init: Array[String] ?=> Unit) { - inline def main(args: Array[String]): Unit = init.with(args) + inline def main(args: Array[String]): Unit = init(using args) } diff --git a/tests/pos/i2774.scala b/tests/pos/i2774.scala index 30473eea6b4f..bd83b3327ae6 100644 --- a/tests/pos/i2774.scala +++ b/tests/pos/i2774.scala @@ -3,11 +3,11 @@ object Test { val a: T ?=> Q ?=> Int = 1 given Q = new Q {} - val i1: Int = a.with(new T{}) + val i1: Int = a(using new T{}) given T = new T {} val i2: Int = a val i3: Int = a2 - def a2 with (t: T) with (q: Q) : Int = 1 + def a2(using t: T)(using q: Q): Int = 1 } diff --git a/tests/pos/i3692.scala b/tests/pos/i3692.scala index 3681bfb7b642..aae0b72aa7eb 100644 --- a/tests/pos/i3692.scala +++ b/tests/pos/i3692.scala @@ -7,8 +7,8 @@ object Main { def main(args: Array[String]): Unit = { val choose: (c: C) ?=> Set[Int] = Set.empty - val b0: (C) => Set[Int] = choose.with(_) - val b1: (c: C) => Set[Int] = choose.with(_) + val b0: (C) => Set[Int] = choose(using _) + val b1: (c: C) => Set[Int] = choose(using _) def applyF(f: (c: C) => Set[Int]) = f(new C{type T=Int}) //applyF(choose) } diff --git a/tests/pos/i3912-3/i3912_1.scala b/tests/pos/i3912-3/i3912_1.scala index 4fafe0f87459..31637ec31b91 100644 --- a/tests/pos/i3912-3/i3912_1.scala +++ b/tests/pos/i3912-3/i3912_1.scala @@ -7,5 +7,5 @@ object Macros { } } - def impl() with QuoteContext : Expr[Int] = '{1} + def impl()(using QuoteContext): Expr[Int] = '{1} } \ No newline at end of file diff --git a/tests/pos/i4350.scala b/tests/pos/i4350.scala index e114cad275ad..0e3e1648e366 100644 --- a/tests/pos/i4350.scala +++ b/tests/pos/i4350.scala @@ -1,5 +1,5 @@ import scala.quoted._ -class Foo[T: Type] with QuoteContext { +class Foo[T: Type](using QuoteContext) { '{null.asInstanceOf[T]} } diff --git a/tests/pos/i4380a.scala b/tests/pos/i4380a.scala index 6c131923dd6b..442e3b5e7481 100644 --- a/tests/pos/i4380a.scala +++ b/tests/pos/i4380a.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { trait Producer[A] { self => - def step(k: (A => Expr[Unit])) with QuoteContext : Expr[Unit] + def step(k: (A => Expr[Unit]))(using QuoteContext): Expr[Unit] } trait Foo[A] @@ -13,7 +13,7 @@ object Test { stream match { case Bar(producer, nestedf) => { new Producer[Expr[A]] { - def step(k: Expr[A] => Expr[Unit]) with QuoteContext : Expr[Unit] = '{ + def step(k: Expr[A] => Expr[Unit])(using QuoteContext): Expr[Unit] = '{ val adv: Unit => Unit = { _ => ${producer.step((el) => nestedf(el))} } } } diff --git a/tests/pos/i4396a.scala b/tests/pos/i4396a.scala index fb54511a6102..c1b8004e8e66 100644 --- a/tests/pos/i4396a.scala +++ b/tests/pos/i4396a.scala @@ -1,4 +1,4 @@ import scala.quoted._ -def test with QuoteContext = { +def test(using QuoteContext) = { '{ Option(4) match { case Some(a) => a; case None => 1 }} } diff --git a/tests/pos/i4396b.scala b/tests/pos/i4396b.scala index 1240b7577781..d6d886e93df7 100644 --- a/tests/pos/i4396b.scala +++ b/tests/pos/i4396b.scala @@ -1,4 +1,4 @@ import scala.quoted._ -def test with QuoteContext = { +def test(using QuoteContext) = { '{ case class Foo() } } \ No newline at end of file diff --git a/tests/pos/i4514.scala b/tests/pos/i4514.scala index 7e2b8f07c81b..904683b1e0f6 100644 --- a/tests/pos/i4514.scala +++ b/tests/pos/i4514.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Foo { inline def foo[X](x: X): Unit = ${fooImpl('x)} - def fooImpl[X: Type](x: X) with QuoteContext : Expr[Unit] = '{} + def fooImpl[X: Type](x: X)(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/pos/i4539.scala b/tests/pos/i4539.scala index f11b0344cb49..eda10e5dc926 100644 --- a/tests/pos/i4539.scala +++ b/tests/pos/i4539.scala @@ -1,5 +1,5 @@ import scala.quoted._ -def test with QuoteContext = { +def test(using QuoteContext) = { val q = '[String] '[String] } diff --git a/tests/pos/i4539b.scala b/tests/pos/i4539b.scala index b3bd3f57a598..d1eb6ce4fa4b 100644 --- a/tests/pos/i4539b.scala +++ b/tests/pos/i4539b.scala @@ -1,5 +1,5 @@ import scala.quoted._ -def test with QuoteContext = { +def test(using QuoteContext) = { def f = { { '[String] diff --git a/tests/pos/i4725.scala b/tests/pos/i4725.scala index 0e214a242cb4..e32462fe4289 100644 --- a/tests/pos/i4725.scala +++ b/tests/pos/i4725.scala @@ -1,8 +1,8 @@ object Test1 { trait T[A] - def foo[S[_], A] with (ev: (given T[A]) => T[S[A]]): Unit = () - implicit def bar[A] with (ev: T[A]) : T[List[A]] = ??? + def foo[S[_], A](using ev: T[A] ?=> T[S[A]]): Unit = () + implicit def bar[A](using ev: T[A]): T[List[A]] = ??? foo[List, Int] } @@ -11,8 +11,8 @@ object Test2 { trait T trait S - def foo with (ev: T ?=> S) : Unit = () - implicit def bar with (ev: T) : S = ??? + def foo(using ev: T ?=> S): Unit = () + implicit def bar(using ev: T): S = ??? foo } diff --git a/tests/pos/i4773.scala b/tests/pos/i4773.scala index 01b4e2058ff7..2445a291a4db 100644 --- a/tests/pos/i4773.scala +++ b/tests/pos/i4773.scala @@ -2,6 +2,6 @@ import scala.quoted._ object Foo { inline def foo2(): Unit = ${foo2Impl()} - def foo2Impl() with QuoteContext : Expr[Unit] = '{} + def foo2Impl()(using QuoteContext): Expr[Unit] = '{} inline def foo(): Unit = foo2() } diff --git a/tests/pos/i4891.scala b/tests/pos/i4891.scala index 5c2229108775..4063f067e2c1 100644 --- a/tests/pos/i4891.scala +++ b/tests/pos/i4891.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Test { - def foo with QuoteContext : Expr[Option[String]] = '{None} + def foo(using QuoteContext): Expr[Option[String]] = '{None} } diff --git a/tests/pos/i5295.scala b/tests/pos/i5295.scala index 0cbe0b2fe1a2..a9cd8e3e0306 100644 --- a/tests/pos/i5295.scala +++ b/tests/pos/i5295.scala @@ -1,2 +1,2 @@ -inline def foo: String = bar.with(4) +inline def foo: String = bar(using 4) private def bar: Int ?=> String = "baz" diff --git a/tests/pos/i5547.scala b/tests/pos/i5547.scala index 95ac2c55ebde..b6b167021a81 100644 --- a/tests/pos/i5547.scala +++ b/tests/pos/i5547.scala @@ -7,6 +7,6 @@ object scalatest { inline def assert2(condition: => Boolean): Unit = ${ assertImpl('condition, Expr("")) } - def assertImpl(condition: Expr[Boolean], clue: Expr[Any]) with QuoteContext : Expr[Unit] = + def assertImpl(condition: Expr[Boolean], clue: Expr[Any])(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/pos/i5954.scala b/tests/pos/i5954.scala index b55bb44413f6..9cde97ca02cc 100644 --- a/tests/pos/i5954.scala +++ b/tests/pos/i5954.scala @@ -5,7 +5,7 @@ abstract class MatcherFactory1 { object MatcherFactory1 { import scala.quoted._ - def impl(self: Expr[MatcherFactory1#AndNotWord]) with QuoteContext = + def impl(self: Expr[MatcherFactory1#AndNotWord])(using QuoteContext) = '{ val a: Any = $self } diff --git a/tests/pos/i5954b.scala b/tests/pos/i5954b.scala index 26ccea1c6746..8ebb4b28aaa4 100644 --- a/tests/pos/i5954b.scala +++ b/tests/pos/i5954b.scala @@ -5,11 +5,11 @@ abstract class MatcherFactory1 { object MatcherFactory1 { import scala.quoted._ - def impl(self: Expr[MatcherFactory1#AndNotWord[Int]]) with QuoteContext = + def impl(self: Expr[MatcherFactory1#AndNotWord[Int]])(using QuoteContext) = '{ val a: Any = $self } - def impl[T: Type](self: Expr[MatcherFactory1#AndNotWord[T]]) with QuoteContext = + def impl[T: Type](self: Expr[MatcherFactory1#AndNotWord[T]])(using QuoteContext) = '{ val a: Any = $self } } diff --git a/tests/pos/i5954c.scala b/tests/pos/i5954c.scala index 83877b66783a..5b936144bdd7 100644 --- a/tests/pos/i5954c.scala +++ b/tests/pos/i5954c.scala @@ -5,11 +5,11 @@ abstract class MatcherFactory1[A] { object MatcherFactory1 { import scala.quoted._ - def impl(self: Expr[MatcherFactory1[Int]#AndNotWord]) with QuoteContext = + def impl(self: Expr[MatcherFactory1[Int]#AndNotWord])(using QuoteContext) = '{ val a: Any = $self } - def impl[T: Type](self: Expr[MatcherFactory1[T]#AndNotWord]) with QuoteContext = + def impl[T: Type](self: Expr[MatcherFactory1[T]#AndNotWord])(using QuoteContext) = '{ val a: Any = $self } } diff --git a/tests/pos/i5954d.scala b/tests/pos/i5954d.scala index 9c7e343e7263..1ffde4481d41 100644 --- a/tests/pos/i5954d.scala +++ b/tests/pos/i5954d.scala @@ -5,7 +5,7 @@ abstract class MatcherFactory1 { object MatcherFactory1 { import scala.quoted._ - def impl(self: Expr[MatcherFactory1#AndNotWord]) with QuoteContext = + def impl(self: Expr[MatcherFactory1#AndNotWord])(using QuoteContext) = '{ val a: Any = $self } diff --git a/tests/pos/i5966.scala b/tests/pos/i5966.scala index 9e80f9387f22..88a0c9a9beb5 100644 --- a/tests/pos/i5966.scala +++ b/tests/pos/i5966.scala @@ -3,6 +3,6 @@ object Test { given myInt as Int = 4 foo.apply(1) - foo.with(2) + foo(using 2) foo(3) } diff --git a/tests/pos/i5978.scala b/tests/pos/i5978.scala index 8fef8c97def4..f8bb5ca71573 100644 --- a/tests/pos/i5978.scala +++ b/tests/pos/i5978.scala @@ -10,9 +10,9 @@ package p1 { given TP as TokenParser[Char, Position[CharSequence]] {} def f - with (TokenParser[Char, Position[CharSequence]]) = ??? + (using TokenParser[Char, Position[CharSequence]]) = ??? - given FromCharToken with (T: TokenParser[Char, Position[CharSequence]]) + given FromCharToken(using T: TokenParser[Char, Position[CharSequence]]) : Conversion[Char, Position[CharSequence]] = ??? } @@ -85,5 +85,5 @@ package p4 { given B[X[_], Y] as TC - given C with TC as TC + given C(using TC) as TC } \ No newline at end of file diff --git a/tests/pos/i6008.scala b/tests/pos/i6008.scala index 793770fc9093..12c7b94b9c37 100644 --- a/tests/pos/i6008.scala +++ b/tests/pos/i6008.scala @@ -2,5 +2,5 @@ import scala.quoted._ class C { type T = Int - def fn(e : Expr[T]) with QuoteContext : Expr[T] = '{ println(); $e } + def fn(e : Expr[T])(using QuoteContext): Expr[T] = '{ println(); $e } } diff --git a/tests/pos/i6142.scala b/tests/pos/i6142.scala index f6e8bd2f0a37..fc726dd4b025 100644 --- a/tests/pos/i6142.scala +++ b/tests/pos/i6142.scala @@ -1,7 +1,7 @@ import scala.quoted._ object O { - def foo with QuoteContext = { + def foo(using QuoteContext) = { type T implicit val _: scala.quoted.Type[T] = ??? '[List[T]] diff --git a/tests/pos/i6214.scala b/tests/pos/i6214.scala index a98cebee62e8..3da36f7821b1 100644 --- a/tests/pos/i6214.scala +++ b/tests/pos/i6214.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Test { - def res(x: quoted.Expr[Int]) with QuoteContext : quoted.Expr[Int] = x match { + def res(x: quoted.Expr[Int])(using QuoteContext): quoted.Expr[Int] = x match { case '{ val a: Int = $y; 1} => y // owner of `y` is `res` case _ => '{ val b: Int = ${val c = 2; Expr(c)}; 1} // owner of `c` is `b`, but that seems to be OK } diff --git a/tests/pos/i6214b.scala b/tests/pos/i6214b.scala index 807c98d873d4..0d54d689b13d 100644 --- a/tests/pos/i6214b.scala +++ b/tests/pos/i6214b.scala @@ -1,5 +1,5 @@ object Test { - def res(x: quoted.Expr[Int]) with scala.quoted.QuoteContext : quoted.Expr[Int] = x match { + def res(x: quoted.Expr[Int])(using scala.quoted.QuoteContext): quoted.Expr[Int] = x match { case '{ val a: Int = ${ Foo('{ val b: Int = $y; b }) }; a } => y // owner of y is res } object Foo { diff --git a/tests/pos/i6253.scala b/tests/pos/i6253.scala index 5d3ab6fe1014..1720e62f1416 100644 --- a/tests/pos/i6253.scala +++ b/tests/pos/i6253.scala @@ -1,6 +1,6 @@ import scala.quoted._ object Macros { - def impl(self: Expr[StringContext]) with QuoteContext : Expr[String] = self match { + def impl(self: Expr[StringContext])(using QuoteContext): Expr[String] = self match { case '{ StringContext() } => '{""} case '{ StringContext($part1) } => part1 case '{ StringContext($part1, $part2) } => '{ $part1 + $part2 } diff --git a/tests/pos/i6435.scala b/tests/pos/i6435.scala index 56f0dd2bbb61..25246b260f1b 100644 --- a/tests/pos/i6435.scala +++ b/tests/pos/i6435.scala @@ -1,7 +1,7 @@ class Foo { import scala.quoted._ import scala.quoted.matching._ - def f(sc: quoted.Expr[StringContext]) with QuoteContext : Unit = { + def f(sc: quoted.Expr[StringContext])(using QuoteContext): Unit = { val '{ StringContext(${parts}: _*) } = sc val ps0: Expr[Seq[String]] = parts diff --git a/tests/pos/i6783.scala b/tests/pos/i6783.scala index 86c6cc7d92e8..7b6dd43c7458 100644 --- a/tests/pos/i6783.scala +++ b/tests/pos/i6783.scala @@ -1,6 +1,6 @@ import scala.quoted._ -def testImpl(f: Expr[(Int, Int) => Int]) with QuoteContext : Expr[Int] = Expr.betaReduce(f)('{1}, '{2}) +def testImpl(f: Expr[(Int, Int) => Int])(using QuoteContext): Expr[Int] = Expr.betaReduce(f)('{1}, '{2}) inline def test(f: (Int, Int) => Int) = ${ testImpl('f) diff --git a/tests/pos/i6862b/lib.scala b/tests/pos/i6862b/lib.scala index 63de744aa592..f7fea7ccd871 100644 --- a/tests/pos/i6862b/lib.scala +++ b/tests/pos/i6862b/lib.scala @@ -4,5 +4,5 @@ trait Expr[+T] trait Ctx inline def foo(): Int = splice( bar() ) -def bar() with Ctx : Expr[Int] = ??? +def bar()(using Ctx): Expr[Int] = ??? def splice[T](f: Ctx ?=> Expr[T]): T = ??? diff --git a/tests/pos/i6914.scala b/tests/pos/i6914.scala index b1ba069803c5..14ee61dc5c4a 100644 --- a/tests/pos/i6914.scala +++ b/tests/pos/i6914.scala @@ -2,10 +2,10 @@ trait Expr[T] trait Liftable[T] object test1 { - class ToExpr[T] with Liftable[T] extends Conversion[T, Expr[T]] { + class ToExpr[T](using Liftable[T]) extends Conversion[T, Expr[T]] { def apply(x: T): Expr[T] = ??? } - given toExpr[T] with Liftable[T] as ToExpr[T] + given toExpr[T](using Liftable[T]) as ToExpr[T] given Liftable[Int] = ??? given Liftable[String] = ??? @@ -18,7 +18,7 @@ object test1 { object test2 { - given autoToExpr[T] with Liftable[T] as Conversion[T, Expr[T]] { + given autoToExpr[T](using Liftable[T]) as Conversion[T, Expr[T]] { def apply(x: T): Expr[T] = ??? } diff --git a/tests/pos/i6997.scala b/tests/pos/i6997.scala index 0be55ea66c22..fb8f8e6d1aa4 100644 --- a/tests/pos/i6997.scala +++ b/tests/pos/i6997.scala @@ -1,7 +1,7 @@ import scala.quoted._ class Foo { - def mcrImpl(body: Expr[Any]) with (t: Type[_ <: Any]) with (ctx: QuoteContext) : Expr[Any] = '{ + def mcrImpl(body: Expr[Any])(using t: Type[_ <: Any])(using ctx: QuoteContext): Expr[Any] = '{ val tmp = ???.asInstanceOf[$t] tmp } diff --git a/tests/pos/i6997c.scala b/tests/pos/i6997c.scala index c16272d26c74..bdf2f361aa0a 100644 --- a/tests/pos/i6997c.scala +++ b/tests/pos/i6997c.scala @@ -4,7 +4,7 @@ import scala.quoted.{_, given _}, scala.quoted.matching._ inline def mcr(x: => Any): Any = ${mcrImpl('x)} -def mcrImpl(body: Expr[Any]) with (ctx: QuoteContext) : Expr[Any] = +def mcrImpl(body: Expr[Any])(using ctx: QuoteContext): Expr[Any] = body match case '{$x: $t} => '{ diff --git a/tests/pos/i6998.scala b/tests/pos/i6998.scala index 19f13f55dc6a..e87f45166368 100644 --- a/tests/pos/i6998.scala +++ b/tests/pos/i6998.scala @@ -1,5 +1,5 @@ import scala.quoted._ -def foo with QuoteContext : Unit = { +def foo(using QuoteContext) : Unit = { val '{ $f : (Int => Double) } = ??? } diff --git a/tests/pos/i7046.scala b/tests/pos/i7046.scala index e6cc43039b8c..ed25c29120fd 100644 --- a/tests/pos/i7046.scala +++ b/tests/pos/i7046.scala @@ -1,7 +1,7 @@ import scala.quoted._ inline def mcr: Any = ${mcrImpl} -def mcrImpl with (ctx: QuoteContext) : Expr[Any] = { +def mcrImpl(using ctx: QuoteContext): Expr[Any] = { val tpl: Expr[1] = '{1} '{()} } diff --git a/tests/pos/i7048.scala b/tests/pos/i7048.scala index a4a8fae5ccc9..fba9ed619821 100644 --- a/tests/pos/i7048.scala +++ b/tests/pos/i7048.scala @@ -7,7 +7,7 @@ trait IsExpr[T] { def f(x: Any): String = x.toString -def g[T] with (e: IsExpr[T], tu: Type[e.Underlying]) : QuoteContext ?=> Expr[String] = { +def g[T](using e: IsExpr[T], tu: Type[e.Underlying]): QuoteContext ?=> Expr[String] = { val underlying: Expr[e.Underlying] = e.expr '{f($underlying)} } diff --git a/tests/pos/i7048b.scala b/tests/pos/i7048b.scala index 92183d266817..f81077c0ef6c 100644 --- a/tests/pos/i7048b.scala +++ b/tests/pos/i7048b.scala @@ -6,7 +6,7 @@ trait IsExpr { val foo: IsExpr = ??? -def g() with QuoteContext : Unit = { +def g()(using QuoteContext): Unit = { val a = '[foo.Underlying] () } diff --git a/tests/pos/i7048c.scala b/tests/pos/i7048c.scala index 5d765aac7228..0a81a7aa853a 100644 --- a/tests/pos/i7048c.scala +++ b/tests/pos/i7048c.scala @@ -6,8 +6,8 @@ trait IsExpr { val foo: IsExpr = ??? -def g(e: IsExpr) with (tu: Type[e.Underlying]) : Unit = ??? +def g(e: IsExpr)(using tu: Type[e.Underlying]): Unit = ??? -def mcrImpl with QuoteContext : Unit = { +def mcrImpl(using QuoteContext): Unit = { g(foo) } diff --git a/tests/pos/i7048d.scala b/tests/pos/i7048d.scala index 444e83330c1f..ad3577dc68f3 100644 --- a/tests/pos/i7048d.scala +++ b/tests/pos/i7048d.scala @@ -6,8 +6,8 @@ trait IsExpr { val foo: IsExpr = ??? -def g(e: IsExpr) with (tu: Type[e.Underlying]) : Unit = ??? +def g(e: IsExpr)(using tu: Type[e.Underlying]): Unit = ??? -def mcrImpl with QuoteContext : Unit = { +def mcrImpl(using QuoteContext): Unit = { g(foo) } diff --git a/tests/pos/i7048e.scala b/tests/pos/i7048e.scala index fc69af1e5a63..3234edfeb9c5 100644 --- a/tests/pos/i7048e.scala +++ b/tests/pos/i7048e.scala @@ -7,7 +7,7 @@ abstract class Test { val getT: Type[T] = T // need this to avoid getting `null` given getT.type = getT - def foo with QuoteContext: Expr[Any] = { + def foo(using QuoteContext): Expr[Any] = { val r = '{Option.empty[T]} diff --git a/tests/pos/i7052.scala b/tests/pos/i7052.scala index 106c19d2aaf7..a06885ef7bc0 100644 --- a/tests/pos/i7052.scala +++ b/tests/pos/i7052.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Test { - def foo(str: Expr[String]) with QuoteContext = '{ + def foo(str: Expr[String])(using QuoteContext) = '{ @deprecated($str, "") def bar = ??? } diff --git a/tests/pos/i7084.scala b/tests/pos/i7084.scala index 2eb82e124b2c..0eb5c5920570 100644 --- a/tests/pos/i7084.scala +++ b/tests/pos/i7084.scala @@ -3,10 +3,10 @@ object Test { type Foo extension on (y: Any) { - def g with Foo : Any = ??? + def g(using Foo): Any = ??? } - def f(x: Any) with Foo : Any = { + def f(x: Any)(using Foo): Any = { val y = x.g y.g diff --git a/tests/pos/i7087.scala b/tests/pos/i7087.scala index 7fc487e8ad92..f66a75ca4976 100644 --- a/tests/pos/i7087.scala +++ b/tests/pos/i7087.scala @@ -7,7 +7,7 @@ type F[T] = T match { } extension on [T](tup: T) { - def g with (Foo: F[T]) = ??? + def g(using Foo: F[T]) = ??? } -def f(x: G[Int]) with (Foo: String) = x.g \ No newline at end of file +def f(x: G[Int])(using Foo: String) = x.g \ No newline at end of file diff --git a/tests/pos/i7119.scala b/tests/pos/i7119.scala index ab087c1a2210..50da06cba682 100644 --- a/tests/pos/i7119.scala +++ b/tests/pos/i7119.scala @@ -1,9 +1,9 @@ class Impl -def (impl: Impl).prop with Int = ???//summon[Int] +def (impl: Impl).prop(using Int) = ???//summon[Int] def main(args: Array[String]): Unit = { given Int = 3 - println(new Impl().prop.with(3)) + println(new Impl().prop(using 3)) } \ No newline at end of file diff --git a/tests/pos/i7204.scala b/tests/pos/i7204.scala index 01cc89f3fcf8..e10734e39054 100644 --- a/tests/pos/i7204.scala +++ b/tests/pos/i7204.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Foo { - def impl with (qctx: QuoteContext) : Unit = { + def impl(using qctx: QuoteContext) : Unit = { import qctx.tasty.{_, given _} val Select(_, _) = (??? : Term) } diff --git a/tests/pos/i7264.scala b/tests/pos/i7264.scala index 25a75daf533e..0467b0714dea 100644 --- a/tests/pos/i7264.scala +++ b/tests/pos/i7264.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Foo { - def f[T2](t: Type[T2]) with QuoteContext = t match { + def f[T2](t: Type[T2])(using QuoteContext) = t match { case '[ *:[Int, $t] ] => '[ *:[Int, $t] ] } diff --git a/tests/pos/i7264b.scala b/tests/pos/i7264b.scala index 10603967c8a0..3c4f0b0a9945 100644 --- a/tests/pos/i7264b.scala +++ b/tests/pos/i7264b.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Foo { - def f[T2: Type](e: Expr[T2]) with QuoteContext = e match { + def f[T2: Type](e: Expr[T2])(using QuoteContext) = e match { case '{ $x: *:[Int, $t] } => '[ *:[Int, $t] ] } diff --git a/tests/pos/i7264c.scala b/tests/pos/i7264c.scala index ef60e2afee94..d246bbb23027 100644 --- a/tests/pos/i7264c.scala +++ b/tests/pos/i7264c.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Foo { - def f[T2: Type](e: Expr[T2]) with QuoteContext = e match { + def f[T2: Type](e: Expr[T2])(using QuoteContext) = e match { case '{ $x: $t0 } => t0 match case '[ *:[Int, $t] ] => diff --git a/tests/pos/i7358.scala b/tests/pos/i7358.scala index 27ad8a27013b..a8f6e3aaf99c 100644 --- a/tests/pos/i7358.scala +++ b/tests/pos/i7358.scala @@ -3,7 +3,7 @@ package test import scala.quoted._ import scala.compiletime._ -inline def summonT[Tp <: Tuple] with QuoteContext <: Tuple = inline erasedValue[Tp] match { +inline def summonT[Tp <: Tuple](using QuoteContext) <: Tuple = inline erasedValue[Tp] match { case _ : Unit => () case _ : (hd *: tl) => { type H = hd @@ -13,4 +13,4 @@ inline def summonT[Tp <: Tuple] with QuoteContext <: Tuple = inline erasedValue[ } } -def test[T : Type] with QuoteContext = summonT[Tuple1[List[T]]] +def test[T : Type](using QuoteContext) = summonT[Tuple1[List[T]]] diff --git a/tests/pos/i7405.scala b/tests/pos/i7405.scala index 2f7d94d06151..4526758501d8 100644 --- a/tests/pos/i7405.scala +++ b/tests/pos/i7405.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Foo { - def f(given QuoteContext): Expr[Any] = { + def f(using QuoteContext): Expr[Any] = { '{ type X = Int // Level 1 val x: X = ??? diff --git a/tests/pos/i7405b.scala b/tests/pos/i7405b.scala index c90895bce3b4..f2fb52b02d60 100644 --- a/tests/pos/i7405b.scala +++ b/tests/pos/i7405b.scala @@ -1,7 +1,7 @@ import scala.quoted._ class Foo { - def f(given QuoteContext): Expr[Any] = { + def f(using QuoteContext): Expr[Any] = { '{ trait X { type Y diff --git a/tests/pos/i7477.scala b/tests/pos/i7477.scala index ccb3d53846ea..67d802dfa277 100644 --- a/tests/pos/i7477.scala +++ b/tests/pos/i7477.scala @@ -14,9 +14,9 @@ package X { class Test1 { - def spawn[T](f: => T) with (ec:ExecutionContext, naming: Int = 3) : Future[T] = ??? + def spawn[T](f: => T)(using ec:ExecutionContext, naming: Int = 3): Future[T] = ??? - def await[T](f:Future[T], atMost: Duration = Duration.Inf) with (ec: ExecutionContext) :T = ??? + def await[T](f:Future[T], atMost: Duration = Duration.Inf)(using ec: ExecutionContext):T = ??? def test(): Unit = { val promiseToWait = Promise[Int]() diff --git a/tests/pos/i7519.scala b/tests/pos/i7519.scala index ca37d884ffb1..7e6c6322e5cb 100644 --- a/tests/pos/i7519.scala +++ b/tests/pos/i7519.scala @@ -7,7 +7,7 @@ object Test { class Quoted[T] inline def quote[T]: Quoted[T] = ${ quoteImpl[T] } - def quoteImpl[T: Type] with (qctx: QuoteContext) : Expr[Quoted[T]] = '{ + def quoteImpl[T: Type](using qctx: QuoteContext): Expr[Quoted[T]] = '{ new Quoted[T @Annot] } } diff --git a/tests/pos/i7519b.scala b/tests/pos/i7519b.scala index 9e2e77e7ad71..63ac578b5a83 100644 --- a/tests/pos/i7519b.scala +++ b/tests/pos/i7519b.scala @@ -7,7 +7,7 @@ class Quoted[T] inline def quote[T]: Quoted[T] = ${ quoteImpl[T] } -def quoteImpl[T: Type] with (qctx: QuoteContext) : Expr[Quoted[T]] = { +def quoteImpl[T: Type](using qctx: QuoteContext): Expr[Quoted[T]] = { val value: Expr[Int] = '{ 42 } '{ new Quoted[T @Annot($value)] } } diff --git a/tests/pos/i7532.scala b/tests/pos/i7532.scala index 0753a547fe2c..128c639fe723 100644 --- a/tests/pos/i7532.scala +++ b/tests/pos/i7532.scala @@ -11,7 +11,7 @@ class Tasty { } object Foo { - def impl with (tasty: Tasty) : Unit = { + def impl(using tasty: Tasty) : Unit = { import tasty.{_, given _} val Select() = (??? : Term) } diff --git a/tests/pos/i7700.scala b/tests/pos/i7700.scala index 5403fceec9d7..f058acc5153b 100644 --- a/tests/pos/i7700.scala +++ b/tests/pos/i7700.scala @@ -7,6 +7,6 @@ object Macros: inline def (sc: StringContext).show(args: =>Any*): String = ??? object Show: - def[A] (a: A) show with (S: Show[A]) : String = S.show(a) + def[A] (a: A) show(using S: Show[A]): String = S.show(a) export Macros.show \ No newline at end of file diff --git a/tests/pos/i7851.scala b/tests/pos/i7851.scala index 19910acdd83c..92bc34ed184f 100644 --- a/tests/pos/i7851.scala +++ b/tests/pos/i7851.scala @@ -10,7 +10,7 @@ given Wrapper[Unit] { type WrappedT = Unit } given [T: Wrappable]: Wrapper[T] { type WrappedT = Wrapped[T] } -given [H: Wrappable, T <: Tuple, WrappedT0 <: Tuple] with (Wrapper.Aux[T, WrappedT0]) : Wrapper[H *: T] { +given [H: Wrappable, T <: Tuple, WrappedT0 <: Tuple](using Wrapper.Aux[T, WrappedT0]): Wrapper[H *: T] { type WrappedT = Wrapped[H] *: WrappedT0 } diff --git a/tests/pos/i7887.scala b/tests/pos/i7887.scala index daeac328c5c5..e505aa02fb6c 100644 --- a/tests/pos/i7887.scala +++ b/tests/pos/i7887.scala @@ -1,4 +1,4 @@ -def typed[A](given t: quoted.Type[A], qctx: quoted.QuoteContext): Unit = { +def typed[A](using t: quoted.Type[A], qctx: quoted.QuoteContext): Unit = { import qctx.tasty.{given, _} '{ type T = $t diff --git a/tests/pos/inline-apply.scala b/tests/pos/inline-apply.scala index 9b8598f10523..f70975d609b2 100644 --- a/tests/pos/inline-apply.scala +++ b/tests/pos/inline-apply.scala @@ -3,7 +3,7 @@ class Context object Test { def transform()(implicit ctx: Context) = { - inline def withLocalOwner[T](op: Context ?=> T) = op.with(ctx) + inline def withLocalOwner[T](op: Context ?=> T) = op(using ctx) withLocalOwner { ctx ?=> } diff --git a/tests/pos/macro-docs.scala b/tests/pos/macro-docs.scala index f9bb4f9399ab..bebe01cc3d66 100644 --- a/tests/pos/macro-docs.scala +++ b/tests/pos/macro-docs.scala @@ -24,7 +24,7 @@ object MacrosMD_Liftable { } } - def showExpr[T](expr: Expr[T]) with QuoteContext : Expr[String] = { + def showExpr[T](expr: Expr[T])(using QuoteContext): Expr[String] = { val code: String = expr.show Expr(code) } diff --git a/tests/pos/multi-given.scala b/tests/pos/multi-given.scala index ef2cb4ad8680..c5d8c54ffdf1 100644 --- a/tests/pos/multi-given.scala +++ b/tests/pos/multi-given.scala @@ -2,7 +2,7 @@ trait A trait B trait C -def fancy with (a: A, b: B, c: C) = "Fancy!" +def fancy(using a: A, b: B, c: C) = "Fancy!" def foo(implicit a: A, b: B, c: C) = "foo" given A, B {} diff --git a/tests/pos/multiversal.scala b/tests/pos/multiversal.scala index a206b99db070..012f761a092a 100644 --- a/tests/pos/multiversal.scala +++ b/tests/pos/multiversal.scala @@ -1,7 +1,7 @@ object Test { import scala.Eql - given [X, Y] with (Eql[X, Y]) as Eql[List[X], List[Y]] = Eql.derived + given [X, Y](using Eql[X, Y]) as Eql[List[X], List[Y]] = Eql.derived val b: Byte = 1 val c: Char = 2 diff --git a/tests/pos/postconditions.scala b/tests/pos/postconditions.scala index 243540b0bcee..ce0611d558c2 100644 --- a/tests/pos/postconditions.scala +++ b/tests/pos/postconditions.scala @@ -1,7 +1,7 @@ object PostConditions: opaque type WrappedResult[T] = T - def result[T] with (r: WrappedResult[T]) : T = r + def result[T](using r: WrappedResult[T]): T = r def [T](x: T) ensuring (condition: WrappedResult[T] ?=> Boolean): T = given WrappedResult[T] = x diff --git a/tests/pos/quote-bind-T.scala b/tests/pos/quote-bind-T.scala index 7a0c787564b8..eea1f0d901b5 100644 --- a/tests/pos/quote-bind-T.scala +++ b/tests/pos/quote-bind-T.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Test { - def matchX[T](x: Expr[T]) with (Type[T], QuoteContext) : Expr[T] = '{ + def matchX[T](x: Expr[T])(using Type[T], QuoteContext): Expr[T] = '{ $x match { case y: T => y } diff --git a/tests/pos/quote-liftable.scala b/tests/pos/quote-liftable.scala index 1e55c12bee0b..eb71ffb5647e 100644 --- a/tests/pos/quote-liftable.scala +++ b/tests/pos/quote-liftable.scala @@ -1,6 +1,6 @@ import scala.quoted._ -def test with QuoteContext = { +def test(using QuoteContext) = { given QuoteContext = ??? diff --git a/tests/pos/quote-matching-implicit-types.scala b/tests/pos/quote-matching-implicit-types.scala index 10ee78d0cf13..f7c2edf88c4d 100644 --- a/tests/pos/quote-matching-implicit-types.scala +++ b/tests/pos/quote-matching-implicit-types.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Foo { - def f(e: Expr[Any]) with QuoteContext : Unit = e match { + def f(e: Expr[Any])(using QuoteContext): Unit = e match { case '{ foo[$t]($x) } => bar(x) case '{ foo[$t]($x) } if bar(x) => () case '{ foo[$t]($x) } => '{ foo($x) } diff --git a/tests/pos/quote-nested.scala b/tests/pos/quote-nested.scala index aec2ebc4cc4e..e01404ab6d0a 100644 --- a/tests/pos/quote-nested.scala +++ b/tests/pos/quote-nested.scala @@ -5,7 +5,7 @@ object Macro { inline def foo: Unit = ${ nested() } - private def nested() with QuoteContext : Expr[Unit] = '{ + private def nested()(using QuoteContext): Expr[Unit] = '{ var i = 0 ${ val x: Expr[Double] = '{ diff --git a/tests/pos/quote-no-splices.scala b/tests/pos/quote-no-splices.scala index 2a2a0a2aded4..de7ae9a49bb2 100644 --- a/tests/pos/quote-no-splices.scala +++ b/tests/pos/quote-no-splices.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Foo { - def foo with QuoteContext : Unit = { + def foo(using QuoteContext): Unit = { val expr ='{ val a = 3 println("foo") diff --git a/tests/pos/quote-non-static-macro.scala b/tests/pos/quote-non-static-macro.scala index 655016075c26..bc37f4e490d4 100644 --- a/tests/pos/quote-non-static-macro.scala +++ b/tests/pos/quote-non-static-macro.scala @@ -14,5 +14,5 @@ object Foo { object Quox { inline def foo: Unit = ${Foo.impl} } - def impl with QuoteContext : Expr[Unit] = '{} + def impl(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/pos/quote-this.scala b/tests/pos/quote-this.scala index 04e7bff75546..aaf7f807e2fa 100644 --- a/tests/pos/quote-this.scala +++ b/tests/pos/quote-this.scala @@ -1,16 +1,16 @@ import scala.quoted._ class Foo { - def a with QuoteContext : Expr[Int] = '{1} - def b with QuoteContext : Expr[Int] = '{ + def a(using QuoteContext): Expr[Int] = '{1} + def b(using QuoteContext): Expr[Int] = '{ ${ this.a } } - def d with QuoteContext : Expr[QuoteContext ?=> Expr[Int]] = '{ '{1} } + def d(using QuoteContext): Expr[QuoteContext ?=> Expr[Int]] = '{ '{1} } def foo[T](x: T): T = x - def f with QuoteContext = '{ + def f(using QuoteContext) = '{ ${ foo[this.type](this).a } } @@ -22,5 +22,5 @@ class Foo { } object Foo { - def impl[T](x: Any) with QuoteContext : Expr[Unit] = '{} + def impl[T](x: Any)(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/pos/quoted-inline-quote.scala b/tests/pos/quoted-inline-quote.scala index 464da08d3c6e..5427738a1baf 100644 --- a/tests/pos/quoted-inline-quote.scala +++ b/tests/pos/quoted-inline-quote.scala @@ -1,6 +1,6 @@ import scala.quoted._ class Foo { - inline def foo(x: Expr[String]) with QuoteContext = '{ println(${x}) } + inline def foo(x: Expr[String])(using QuoteContext) = '{ println(${x}) } given QuoteContext = ??? foo('{"abc"}) diff --git a/tests/pos/quoted-pattern-type.scala b/tests/pos/quoted-pattern-type.scala index d2b0372ff01d..144d3f68b0ed 100644 --- a/tests/pos/quoted-pattern-type.scala +++ b/tests/pos/quoted-pattern-type.scala @@ -3,7 +3,7 @@ import scala.tasty.Reflection object Lib { - def impl[T: Type](arg: Expr[T]) with QuoteContext : Expr[T] = { + def impl[T: Type](arg: Expr[T])(using QuoteContext): Expr[T] = { arg match { case e @ '{ $x: Boolean } => e: Expr[T & Boolean] diff --git a/tests/pos/quotedPatterns.scala b/tests/pos/quotedPatterns.scala index 48e4380f855a..e6e4630f62fe 100644 --- a/tests/pos/quotedPatterns.scala +++ b/tests/pos/quotedPatterns.scala @@ -1,12 +1,12 @@ import scala.quoted._ object Test { - def x with QuoteContext = '{1 + 2} + def x(using QuoteContext) = '{1 + 2} def f(x: Int) = x def g(x: Int, y: Int) = x * y - def res with QuoteContext : quoted.Expr[Int] = x match { + def res(using QuoteContext): quoted.Expr[Int] = x match { case '{1 + 2} => '{0} case '{f($y)} => y case '{g($y, $z)} => '{$y * $z} diff --git a/tests/pos/reference/delegates.scala b/tests/pos/reference/delegates.scala index 24bdcf287950..c624afecfcee 100644 --- a/tests/pos/reference/delegates.scala +++ b/tests/pos/reference/delegates.scala @@ -30,7 +30,7 @@ object Instances extends Common: def (x: Int).compareTo(y: Int) = if (x < y) -1 else if (x > y) +1 else 0 - given listOrd[T] with Ord[T] as Ord[List[T]]: + given listOrd[T](using Ord[T]) as Ord[List[T]]: def (xs: List[T]).compareTo(ys: List[T]): Int = (xs, ys) match case (Nil, Nil) => 0 case (Nil, _) => -1 @@ -61,20 +61,20 @@ object Instances extends Common: def pure[A](x: A): Ctx => A = ctx => x - def maximum[T](xs: List[T]) with Ord[T] : T = + def maximum[T](xs: List[T])(using Ord[T]): T = xs.reduceLeft((x, y) => if (x < y) y else x) - def descending[T] with (asc: Ord[T]) : Ord[T] = new Ord[T]: + def descending[T](using asc: Ord[T]): Ord[T] = new Ord[T]: def (x: T).compareTo(y: T) = asc.compareTo(y)(x) - def minimum[T](xs: List[T]) with Ord[T] = - maximum(xs).with(descending) + def minimum[T](xs: List[T])(using Ord[T]) = + maximum(xs)(using descending) def test(): Unit = val xs = List(1, 2, 3) println(maximum(xs)) - println(maximum(xs).with(descending)) - println(maximum(xs).with(descending.with(intOrd))) + println(maximum(xs)(using descending)) + println(maximum(xs)(using descending(using intOrd))) println(minimum(xs)) case class Context(value: String) @@ -99,7 +99,7 @@ object Instances extends Common: class D[T] - class C with (ctx: Context) : + class C(using ctx: Context): def f() = locally { given Context = this.ctx @@ -115,7 +115,7 @@ object Instances extends Common: println(summon[D[Int]]) } locally { - given with Context as D[Int] + given (using Context) as D[Int] println(summon[D[Int]]) } end C @@ -132,11 +132,11 @@ end Instances object PostConditions: opaque type WrappedResult[T] = T - def result[T] with (x: WrappedResult[T]) : T = x + def result[T](using x: WrappedResult[T]): T = x extension on [T](x: T): def ensuring(condition: WrappedResult[T] ?=> Boolean): T = - assert(condition.with(x)) + assert(condition(using x)) x end PostConditions @@ -162,7 +162,7 @@ object AnonymousInstances extends Common: extension on [T](xs: List[T]): def second = xs.tail.head - given [From, To] with (c: Convertible[From, To]) as Convertible[List[From], List[To]]: + given [From, To](using c: Convertible[From, To]) as Convertible[List[From], List[To]]: def (x: List[From]).convert: List[To] = x.map(c.convert) given Monoid[String]: diff --git a/tests/pos/reference/extension-methods.scala b/tests/pos/reference/extension-methods.scala index 5aa2c88ba713..8fe07d523e7a 100644 --- a/tests/pos/reference/extension-methods.scala +++ b/tests/pos/reference/extension-methods.scala @@ -53,7 +53,7 @@ object ExtMethods: def third: T = xs.tail.tail.head - extension on [T](xs: List[T]) with Ordering[T] : + extension on [T](xs: List[T])(using Ordering[T]): def largest(n: Int) = xs.sorted.takeRight(n) given stringOps1 as AnyRef { @@ -69,7 +69,7 @@ object ExtMethods: } given AnyRef { - def [T](xs: List[T]) largest (n: Int) with Ordering[T] = + def [T](xs: List[T]) largest (using Ordering[T])(n: Int) = xs.sorted.takeRight(n) } diff --git a/tests/pos/toexproftuple.scala b/tests/pos/toexproftuple.scala index 40d8be189a10..1d72473e11a2 100644 --- a/tests/pos/toexproftuple.scala +++ b/tests/pos/toexproftuple.scala @@ -2,7 +2,7 @@ import scala.quoted._, scala.deriving._ import scala.quoted.{given _} inline def mcr: Any = ${mcrImpl} -def mcrImpl with (ctx: QuoteContext) : Expr[Any] = { +def mcrImpl(using ctx: QuoteContext): Expr[Any] = { val tpl: (Expr[1], Expr[2], Expr[3]) = ('{1}, '{2}, '{3}) '{val res: (1, 2, 3) = ${Expr.ofTuple(tpl)}; res} } diff --git a/tests/pos/typetags.scala b/tests/pos/typetags.scala index e73e79647a1f..c3dc50fceb89 100644 --- a/tests/pos/typetags.scala +++ b/tests/pos/typetags.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Test { - def f[T: Type] with QuoteContext = { + def f[T: Type](using QuoteContext) = { implicitly[Type[Int]] implicitly[Type[List[Int]]] implicitly[Type[T]] diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala index b8571a9e454b..e1b185d93366 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala @@ -6,7 +6,7 @@ object Foo { inline def inspectBody(inline i: Int): String = ${ inspectBodyImpl('i) } - def inspectBodyImpl(x: Expr[Int]) with (qctx: QuoteContext) : Expr[String] = { + def inspectBodyImpl(x: Expr[Int])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} x.unseal match { case Inlined(None, Nil, arg) => arg.symbol.tree.showExtractors diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala index 07a55cadda58..fc315b943b49 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala @@ -6,7 +6,7 @@ object Foo { inline def inspectBody(inline i: Int): String = ${ inspectBodyImpl('i) } - def inspectBodyImpl(x: Expr[Int]) with (qctx: QuoteContext) : Expr[String] = { + def inspectBodyImpl(x: Expr[Int])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} x.unseal match { case Inlined(None, Nil, arg) => arg.symbol.tree.showExtractors diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala index 3d94c09f539e..a9dae76a6511 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { implicit inline def printOwners[T](inline x: T): Unit = ${ impl('x) } - def impl[T](x: Expr[T]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl[T](x: Expr[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val buff = new StringBuilder diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala index fd1b2baf44a9..de8d3deca4eb 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala @@ -6,7 +6,7 @@ object Foo { inline def inspectBody(inline i: Int): String = ${ inspectBodyImpl('i) } - def inspectBodyImpl(x: Expr[Int]) with (qctx: QuoteContext) : Expr[String] = { + def inspectBodyImpl(x: Expr[Int])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} def definitionString(sym: Symbol): Expr[String] = diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala index 3efa8fe98648..ec0e8880352b 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala @@ -5,7 +5,7 @@ object Foo { inline def inspectBody(inline i: Int): String = ${ inspectBodyImpl('i) } - def inspectBodyImpl(x: Expr[Int]) with (qctx: QuoteContext) : Expr[String] = { + def inspectBodyImpl(x: Expr[Int])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} def definitionString(sym: Symbol): Expr[String] = diff --git a/tests/run-custom-args/erased/erased-22.scala b/tests/run-custom-args/erased/erased-22.scala index 628bba4de504..954b67604eb6 100644 --- a/tests/run-custom-args/erased/erased-22.scala +++ b/tests/run-custom-args/erased/erased-22.scala @@ -10,7 +10,7 @@ object Test { println("foo") 42 } - def fun1 with (erased boo: Int) : Int = { + def fun1 (using erased boo: Int): Int = { println("fun1") 43 } diff --git a/tests/run-custom-args/erased/erased-frameless.scala b/tests/run-custom-args/erased/erased-frameless.scala index 1b146519bd01..989faf22ddb7 100644 --- a/tests/run-custom-args/erased/erased-frameless.scala +++ b/tests/run-custom-args/erased/erased-frameless.scala @@ -26,7 +26,7 @@ trait Dataset[T] { // Use c.label to do an untyped select on actual Spark Dataset, and // cast the result to TypedDataset[A] - def col[S <: String, A](s: S) with (erased ev: Exists[T, s.type, A]) = + def col[S <: String, A](s: S) (using erased ev: Exists[T, s.type, A]) = new Column[T, A](s) // ev is only here to check than this is safe, it's never used at runtime! def collect(): Vector[T] diff --git a/tests/run-custom-args/erased/erased-machine-state.scala b/tests/run-custom-args/erased/erased-machine-state.scala index 71c4844467e2..d4f6eff6f39b 100644 --- a/tests/run-custom-args/erased/erased-machine-state.scala +++ b/tests/run-custom-args/erased/erased-machine-state.scala @@ -23,11 +23,11 @@ object IsOn { } class Machine[S <: State] private { - def turnedOn with (erased s: IsOff[S]) : Machine[On] = { + def turnedOn (using erased s: IsOff[S]): Machine[On] = { println("turnedOn") new Machine[On] } - def turnedOff with (erased s: IsOn[S]) : Machine[Off] = { + def turnedOff (using erased s: IsOn[S]): Machine[Off] = { println("turnedOff") new Machine[Off] } diff --git a/tests/run-custom-args/phantom-OnHList.scala b/tests/run-custom-args/phantom-OnHList.scala index e61fa32dd88a..7c1ba18bbec4 100644 --- a/tests/run-custom-args/phantom-OnHList.scala +++ b/tests/run-custom-args/phantom-OnHList.scala @@ -77,7 +77,7 @@ trait Appender[L1 <: HList, L2 <: HList] { } object Appender { - implicit def lowLevelAppender[L1 <: HList, L2 <: HList, O <: HList] with (erased p: PhantomAppender.Aux[L1, L2, O]) : Appender[L1, L2] { type Out = O } = + implicit def lowLevelAppender[L1 <: HList, L2 <: HList, O <: HList] (using erased p: PhantomAppender.Aux[L1, L2, O]): Appender[L1, L2] { type Out = O } = new Appender[L1, L2] { type Out = O def apply(l1: L1, l2: L2): Out = HListN(Array.concat(l1.underlying, l2.underlying)).asInstanceOf[O] @@ -89,5 +89,5 @@ object Appender { object PhantomAppender { type Aux[L1 <: HList, L2 <: HList, O <: HList] implicit erased def caseHNil[L <: HList]: Aux[HNil, L, L] = ??? - implicit erased def caseHCons[H, T <: HList, L <: HList, O <: HList] with (erased p: Aux[T, L, O]) : Aux[H :: T, L, H :: O] = ??? + implicit erased def caseHCons[H, T <: HList, L <: HList, O <: HList] (using erased p: Aux[T, L, O]): Aux[H :: T, L, H :: O] = ??? } diff --git a/tests/run-custom-args/run-macros-erased/macro-erased/1.scala b/tests/run-custom-args/run-macros-erased/macro-erased/1.scala index 4f40794a0503..7492c9e04ed6 100644 --- a/tests/run-custom-args/run-macros-erased/macro-erased/1.scala +++ b/tests/run-custom-args/run-macros-erased/macro-erased/1.scala @@ -10,12 +10,12 @@ object Macro { inline def foo7(i: Int) = $ { case7('{ i })(1)('{ i }) } inline def foo8(i: Int) = $ { case8('{ i })('{ i })(1) } - def case1(erased i: Expr[Int]) with QuoteContext : Expr[Int] = '{ 0 } - def case2 (i: Int)(erased j: Expr[Int]) with QuoteContext : Expr[Int] = '{ 0 } - def case3(erased i: Expr[Int]) (j: Int) with QuoteContext : Expr[Int] = '{ 0 } - def case4 (h: Int)(erased i: Expr[Int], j: Expr[Int]) with QuoteContext : Expr[Int] = '{ 0 } - def case5(erased i: Expr[Int], j: Expr[Int]) (h: Int) with QuoteContext : Expr[Int] = '{ 0 } - def case6 (h: Int)(erased i: Expr[Int])(erased j: Expr[Int]) with QuoteContext : Expr[Int] = '{ 0 } - def case7(erased i: Expr[Int]) (h: Int)(erased j: Expr[Int]) with QuoteContext : Expr[Int] = '{ 0 } - def case8(erased i: Expr[Int])(erased j: Expr[Int]) (h: Int) with QuoteContext : Expr[Int] = '{ 0 } + def case1(erased i: Expr[Int])(using QuoteContext): Expr[Int] = '{ 0 } + def case2 (i: Int)(erased j: Expr[Int])(using QuoteContext): Expr[Int] = '{ 0 } + def case3(erased i: Expr[Int]) (j: Int)(using QuoteContext): Expr[Int] = '{ 0 } + def case4 (h: Int)(erased i: Expr[Int], j: Expr[Int])(using QuoteContext): Expr[Int] = '{ 0 } + def case5(erased i: Expr[Int], j: Expr[Int]) (h: Int)(using QuoteContext): Expr[Int] = '{ 0 } + def case6 (h: Int)(erased i: Expr[Int])(erased j: Expr[Int])(using QuoteContext): Expr[Int] = '{ 0 } + def case7(erased i: Expr[Int]) (h: Int)(erased j: Expr[Int])(using QuoteContext): Expr[Int] = '{ 0 } + def case8(erased i: Expr[Int])(erased j: Expr[Int]) (h: Int)(using QuoteContext): Expr[Int] = '{ 0 } } diff --git a/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala b/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala index cd1719e8c21a..b96ebac4b87c 100644 --- a/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala +++ b/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ inline def isFunctionType[T:Type]: Boolean = ${ isFunctionTypeImpl('[T]) } -def isFunctionTypeImpl[T](tp: Type[T]) with (qctx: QuoteContext) : Expr[Boolean] = { +def isFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} Expr(tp.unseal.tpe.isFunctionType) } @@ -11,7 +11,7 @@ def isFunctionTypeImpl[T](tp: Type[T]) with (qctx: QuoteContext) : Expr[Boolean] inline def isImplicitFunctionType[T:Type]: Boolean = ${ isImplicitFunctionTypeImpl('[T]) } -def isImplicitFunctionTypeImpl[T](tp: Type[T]) with (qctx: QuoteContext) : Expr[Boolean] = { +def isImplicitFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} Expr(tp.unseal.tpe.isImplicitFunctionType) } @@ -19,14 +19,14 @@ def isImplicitFunctionTypeImpl[T](tp: Type[T]) with (qctx: QuoteContext) : Expr[ inline def isErasedFunctionType[T:Type]: Boolean = ${ isErasedFunctionTypeImpl('[T]) } -def isErasedFunctionTypeImpl[T](tp: Type[T]) with (qctx: QuoteContext) : Expr[Boolean] = { +def isErasedFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} Expr(tp.unseal.tpe.isErasedFunctionType) } inline def isDependentFunctionType[T:Type]: Boolean = ${ isDependentFunctionTypeImpl('[T]) } -def isDependentFunctionTypeImpl[T](tp: Type[T]) with (qctx: QuoteContext) : Expr[Boolean] = { +def isDependentFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} Expr(tp.unseal.tpe.isDependentFunctionType) } diff --git a/tests/run-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala b/tests/run-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala index 7c627eba989a..d443c274dfa6 100644 --- a/tests/run-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala +++ b/tests/run-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala @@ -14,7 +14,7 @@ class TastyInterpreter extends TastyInspector { case DefDef("main", _, _, _, Some(rhs)) => val interpreter = new jvm.Interpreter(reflect) - interpreter.eval(rhs).with(Map.empty) + interpreter.eval(rhs)(using Map.empty) // TODO: recurse only for PackageDef, ClassDef case tree => super.traverseTree(tree) diff --git a/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala b/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala index eab43e09e177..6965bd3b2f83 100644 --- a/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala +++ b/tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala @@ -18,10 +18,10 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { def localValue(sym: Symbol)(implicit env: Env): LocalValue = env(sym) def withLocalValue[T](sym: Symbol, value: LocalValue)(in: Env ?=> T)(implicit env: Env): T = - in.with(env.updated(sym, value)) + in(using env.updated(sym, value)) def withLocalValues[T](syms: List[Symbol], values: List[LocalValue])(in: Env ?=> T)(implicit env: Env): T = - in.with(env ++ syms.zip(values)) + in(using env ++ syms.zip(values)) def interpretCall(inst: AbstractAny, sym: Symbol, args: List[AbstractAny]): Result = { // TODO @@ -68,7 +68,7 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { def interpretBlock(stats: List[Statement], expr: Term): Result = { val newEnv = stats.foldLeft(implicitly[Env])((accEnv, stat) => stat match { case ValDef(name, tpt, Some(rhs)) => - def evalRhs = eval(rhs).with(accEnv) + def evalRhs = eval(rhs)(using accEnv) val evalRef: LocalValue = if (stat.symbol.flags.is(Flags.Lazy)) LocalValue.lazyValFrom(evalRhs) else if (stat.symbol.flags.is(Flags.Mutable)) LocalValue.varFrom(evalRhs) @@ -79,10 +79,10 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { // TODO: record the environment for closure purposes accEnv case stat => - eval(stat).with(accEnv) + eval(stat)(using accEnv) accEnv }) - eval(expr).with(newEnv) + eval(expr)(using newEnv) } def interpretUnit(): AbstractAny diff --git a/tests/run-macros/BigFloat/BigFloat_1.scala b/tests/run-macros/BigFloat/BigFloat_1.scala index b4c790579038..480e9a78e145 100644 --- a/tests/run-macros/BigFloat/BigFloat_1.scala +++ b/tests/run-macros/BigFloat/BigFloat_1.scala @@ -30,7 +30,7 @@ object BigFloat extends App { BigFloat(BigInt(intPart), exponent) } - private def fromDigitsImpl(digits: Expr[String]) with (ctx: QuoteContext) : Expr[BigFloat] = + private def fromDigitsImpl(digits: Expr[String])(using ctx: QuoteContext): Expr[BigFloat] = digits match { case Const(ds) => try { diff --git a/tests/run-macros/expr-map-1/Macro_1.scala b/tests/run-macros/expr-map-1/Macro_1.scala index 5353992b9892..303e4b2d60c0 100644 --- a/tests/run-macros/expr-map-1/Macro_1.scala +++ b/tests/run-macros/expr-map-1/Macro_1.scala @@ -3,12 +3,12 @@ import scala.quoted.matching._ inline def rewrite[T](inline x: Any): Any = ${ stringRewriter('x) } -private def stringRewriter(e: Expr[Any]) with QuoteContext : Expr[Any] = +private def stringRewriter(e: Expr[Any])(using QuoteContext): Expr[Any] = StringRewriter.transform(e) private object StringRewriter extends util.ExprMap { - def transform[T](e: Expr[T]) with (QuoteContext, Type[T]) : Expr[T] = e match + def transform[T](e: Expr[T])(using QuoteContext, Type[T]): Expr[T] = e match case Const(s: String) => Expr(s.reverse) match case '{ $x: T } => x diff --git a/tests/run-macros/expr-map-2/Macro_1.scala b/tests/run-macros/expr-map-2/Macro_1.scala index 0f64f7940e8d..bcca9acc50a8 100644 --- a/tests/run-macros/expr-map-2/Macro_1.scala +++ b/tests/run-macros/expr-map-2/Macro_1.scala @@ -3,12 +3,12 @@ import scala.quoted.matching._ inline def rewrite[T](inline x: Any): Any = ${ stringRewriter('x) } -private def stringRewriter(e: Expr[Any]) with QuoteContext : Expr[Any] = +private def stringRewriter(e: Expr[Any])(using QuoteContext): Expr[Any] = StringRewriter.transform(e) private object StringRewriter extends util.ExprMap { - def transform[T](e: Expr[T]) with (QuoteContext, Type[T]) : Expr[T] = e match + def transform[T](e: Expr[T])(using QuoteContext, Type[T]): Expr[T] = e match case '{ ($x: Foo).x } => '{ new Foo(4).x } match case '{ $e: T } => e diff --git a/tests/run-macros/f-interpolation-1/FQuote_1.scala b/tests/run-macros/f-interpolation-1/FQuote_1.scala index d025f3c4a87b..c69342479ddf 100644 --- a/tests/run-macros/f-interpolation-1/FQuote_1.scala +++ b/tests/run-macros/f-interpolation-1/FQuote_1.scala @@ -9,7 +9,7 @@ object FQuote { inline def ff(args: => Any*): String = ${impl('this, 'args)} } - /*private*/ def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]]) with (qctx: QuoteContext) : Expr[String] = { + /*private*/ def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} def liftListOfAny(lst: List[Term]): Expr[List[Any]] = lst match { diff --git a/tests/run-macros/f-interpolator-neg/Macros_1.scala b/tests/run-macros/f-interpolator-neg/Macros_1.scala index a45e3abecedd..5fb3ab3421bd 100644 --- a/tests/run-macros/f-interpolator-neg/Macros_1.scala +++ b/tests/run-macros/f-interpolator-neg/Macros_1.scala @@ -12,7 +12,7 @@ object TestFooErrors { // Defined in tests object Macro { - def fooErrors(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]]) with QuoteContext : Expr[List[(Boolean, Int, Int, Int, String)]] = { + def fooErrors(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using QuoteContext): Expr[List[(Boolean, Int, Int, Int, String)]] = { (strCtxExpr, argsExpr) match { case ('{ StringContext(${ExprSeq(parts)}: _*) }, ExprSeq(args)) => fooErrorsImpl(parts, args, argsExpr) @@ -21,7 +21,7 @@ object Macro { } } - def fooErrorsImpl(parts0: Seq[Expr[String]], args: Seq[Expr[Any]], argsExpr: Expr[Seq[Any]]) with QuoteContext = { + def fooErrorsImpl(parts0: Seq[Expr[String]], args: Seq[Expr[Any]], argsExpr: Expr[Seq[Any]])(using QuoteContext)= { val errors = List.newBuilder[Expr[(Boolean, Int, Int, Int, String)]] // true if error, false if warning // 0 if part, 1 if arg, 2 if strCtx, 3 if args diff --git a/tests/run-macros/flops-rewrite-2/Macro_1.scala b/tests/run-macros/flops-rewrite-2/Macro_1.scala index 291309a274ea..d5cb4c2f6207 100644 --- a/tests/run-macros/flops-rewrite-2/Macro_1.scala +++ b/tests/run-macros/flops-rewrite-2/Macro_1.scala @@ -7,7 +7,7 @@ def plus(x: Int, y: Int): Int = x + y def times(x: Int, y: Int): Int = x * y def power(x: Int, y: Int): Int = if y == 0 then 1 else times(x, power(x, y - 1)) -private def rewriteMacro[T: Type](x: Expr[T]) with QuoteContext : Expr[T] = { +private def rewriteMacro[T: Type](x: Expr[T])(using QuoteContext): Expr[T] = { val rewriter = Rewriter( postTransform = List( Transformation[Int] { @@ -50,7 +50,7 @@ object Transformation { new Transformation(transform) } class Transformation[T: Type](transform: PartialFunction[Expr[T], Expr[T]]) { - def apply[U: Type](e: Expr[U]) with QuoteContext : Expr[U] = { + def apply[U: Type](e: Expr[U])(using QuoteContext): Expr[U] = { e match { case '{ $e: T } => transform.applyOrElse(e, identity) match { case '{ $e2: U } => e2 } case e => e @@ -64,7 +64,7 @@ private object Rewriter { } private class Rewriter(preTransform: List[Transformation[_]] = Nil, postTransform: List[Transformation[_]] = Nil, fixPoint: Boolean) extends util.ExprMap { - def transform[T](e: Expr[T]) with (QuoteContext, Type[T]) : Expr[T] = { + def transform[T](e: Expr[T])(using QuoteContext, Type[T]): Expr[T] = { val e2 = preTransform.foldLeft(e)((ei, transform) => transform(ei)) val e3 = transformChildren(e2) val e4 = postTransform.foldLeft(e3)((ei, transform) => transform(ei)) diff --git a/tests/run-macros/flops-rewrite-3/Macro_1.scala b/tests/run-macros/flops-rewrite-3/Macro_1.scala index e39adfe63a68..004fcf44c9f4 100644 --- a/tests/run-macros/flops-rewrite-3/Macro_1.scala +++ b/tests/run-macros/flops-rewrite-3/Macro_1.scala @@ -7,7 +7,7 @@ def plus(x: Int, y: Int): Int = x + y def times(x: Int, y: Int): Int = x * y def power(x: Int, y: Int): Int = if y == 0 then 1 else times(x, power(x, y - 1)) -private def rewriteMacro[T: Type](x: Expr[T]) with QuoteContext : Expr[T] = { +private def rewriteMacro[T: Type](x: Expr[T])(using QuoteContext): Expr[T] = { val rewriter = Rewriter().withFixPoint.withPost( Transformation.safe[Int] { case '{ plus($x, $y) } => @@ -56,7 +56,7 @@ object Transformation { } class CheckedTransformation(transform: PartialFunction[Expr[Any], Expr[Any]]) extends Transformation { - def apply[T: Type](e: Expr[T]) with QuoteContext : Expr[T] = { + def apply[T: Type](e: Expr[T])(using QuoteContext): Expr[T] = { transform.applyOrElse(e, identity) match { case '{ $e2: T } => e2 case '{ $e2: $t } => @@ -76,7 +76,7 @@ class CheckedTransformation(transform: PartialFunction[Expr[Any], Expr[Any]]) ex } class SafeTransformation[U: Type](transform: PartialFunction[Expr[U], Expr[U]]) extends Transformation { - def apply[T: Type](e: Expr[T]) with QuoteContext : Expr[T] = { + def apply[T: Type](e: Expr[T])(using QuoteContext): Expr[T] = { e match { case '{ $e: U } => transform.applyOrElse(e, identity) match { case '{ $e2: T } => e2 } case e => e @@ -85,7 +85,7 @@ class SafeTransformation[U: Type](transform: PartialFunction[Expr[U], Expr[U]]) } abstract class Transformation { - def apply[T: Type](e: Expr[T]) with QuoteContext : Expr[T] + def apply[T: Type](e: Expr[T])(using QuoteContext): Expr[T] } private object Rewriter { @@ -101,7 +101,7 @@ private class Rewriter private (preTransform: List[Transformation] = Nil, postTr def withPost(transform: Transformation): Rewriter = new Rewriter(preTransform, transform :: postTransform, fixPoint) - def transform[T](e: Expr[T]) with (QuoteContext, Type[T]) : Expr[T] = { + def transform[T](e: Expr[T])(using QuoteContext, Type[T]): Expr[T] = { val e2 = preTransform.foldLeft(e)((ei, transform) => transform(ei)) val e3 = transformChildren(e2) val e4 = postTransform.foldLeft(e3)((ei, transform) => transform(ei)) diff --git a/tests/run-macros/flops-rewrite/Macro_1.scala b/tests/run-macros/flops-rewrite/Macro_1.scala index b8aad1c308be..2722623dac26 100644 --- a/tests/run-macros/flops-rewrite/Macro_1.scala +++ b/tests/run-macros/flops-rewrite/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ inline def rewrite[T](inline x: T): T = ${ rewriteMacro('x) } -private def rewriteMacro[T: Type](x: Expr[T]) with QuoteContext : Expr[T] = { +private def rewriteMacro[T: Type](x: Expr[T])(using QuoteContext): Expr[T] = { val rewriter = Rewriter( postTransform = { case '{ Nil.map[$t]($f) } => '{ Nil } @@ -29,7 +29,7 @@ private object Rewriter { } private class Rewriter(preTransform: Expr[Any] => Expr[Any], postTransform: Expr[Any] => Expr[Any], fixPoint: Boolean) extends util.ExprMap { - def transform[T](e: Expr[T]) with (QuoteContext, Type[T]) : Expr[T] = { + def transform[T](e: Expr[T])(using QuoteContext, Type[T]): Expr[T] = { val e2 = checkedTransform(e, preTransform) val e3 = transformChildren(e2) val e4 = checkedTransform(e3, postTransform) @@ -37,7 +37,7 @@ private class Rewriter(preTransform: Expr[Any] => Expr[Any], postTransform: Expr else e4 } - private def checkedTransform[T: Type](e: Expr[T], transform: Expr[T] => Expr[Any]) with QuoteContext : Expr[T] = { + private def checkedTransform[T: Type](e: Expr[T], transform: Expr[T] => Expr[Any])(using QuoteContext): Expr[T] = { transform(e) match { case '{ $x: T } => x case '{ $x: $t } => throw new Exception( diff --git a/tests/run-macros/gestalt-optional-staging/Macro_1.scala b/tests/run-macros/gestalt-optional-staging/Macro_1.scala index 7e431731bf56..9e0ad715a723 100644 --- a/tests/run-macros/gestalt-optional-staging/Macro_1.scala +++ b/tests/run-macros/gestalt-optional-staging/Macro_1.scala @@ -17,12 +17,12 @@ final class Optional[+A >: Null](val value: A) extends AnyVal { object Optional { // FIXME fix issue #5097 and enable private - /*private*/ def getOrElseImpl[T >: Null : Type](opt: Expr[Optional[T]], alt: Expr[T]) with QuoteContext : Expr[T] = '{ + /*private*/ def getOrElseImpl[T >: Null : Type](opt: Expr[Optional[T]], alt: Expr[T])(using QuoteContext): Expr[T] = '{ if ($opt.isEmpty) $alt else $opt.value } // FIXME fix issue #5097 and enable private - /*private*/ def mapImpl[A >: Null : Type, B >: Null : Type](opt: Expr[Optional[A]], f: Expr[A => B]) with QuoteContext : Expr[Optional[B]] = '{ + /*private*/ def mapImpl[A >: Null : Type, B >: Null : Type](opt: Expr[Optional[A]], f: Expr[A => B])(using QuoteContext): Expr[Optional[B]] = '{ if ($opt.isEmpty) new Optional(null) else new Optional(${Expr.betaReduce(f)('{$opt.value})}) } diff --git a/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala b/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala index 06476f6b6992..00f59e9e15e1 100644 --- a/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala +++ b/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala @@ -6,28 +6,28 @@ import scala.quoted._ object TypeToolbox { /** are the two types equal? */ inline def =:=[A, B]: Boolean = ${tpEqImpl('[A], '[B])} - private def tpEqImpl[A, B](a: Type[A], b: Type[B]) with (qctx: QuoteContext) : Expr[Boolean] = { + private def tpEqImpl[A, B](a: Type[A], b: Type[B])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} Expr(a.unseal.tpe =:= b.unseal.tpe) } /** is `tp1` a subtype of `tp2` */ inline def <:<[A, B]: Boolean = ${tpLEqImpl('[A], '[B])} - private def tpLEqImpl[A, B](a: Type[A], b: Type[B]) with (qctx: QuoteContext) : Expr[Boolean] = { + private def tpLEqImpl[A, B](a: Type[A], b: Type[B])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} Expr(a.unseal.tpe <:< b.unseal.tpe) } /** type associated with the tree */ inline def typeOf[T, Expected](a: T): Boolean = ${typeOfImpl('a, '[Expected])} - private def typeOfImpl(a: Expr[_], expected: Type[_]) with (qctx: QuoteContext) : Expr[Boolean] = { + private def typeOfImpl(a: Expr[_], expected: Type[_])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} Expr(a.unseal.tpe =:= expected.unseal.tpe) } /** does the type refer to a case class? */ inline def isCaseClass[A]: Boolean = ${isCaseClassImpl('[A])} - private def isCaseClassImpl(tp: Type[_]) with (qctx: QuoteContext) : Expr[Boolean] = { + private def isCaseClassImpl(tp: Type[_])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} val sym = tp.unseal.symbol Expr(sym.isClassDef && sym.flags.is(Flags.Case)) @@ -35,66 +35,66 @@ object TypeToolbox { /** val fields of a case class Type -- only the ones declared in primary constructor */ inline def caseFields[T]: List[String] = ${caseFieldsImpl('[T])} - private def caseFieldsImpl(tp: Type[_]) with (qctx: QuoteContext) : Expr[List[String]] = { + private def caseFieldsImpl(tp: Type[_])(using qctx: QuoteContext) : Expr[List[String]] = { import qctx.tasty.{_, given _} val fields = tp.unseal.symbol.caseFields.map(_.name) Expr(fields) } inline def fieldIn[T](inline mem: String): String = ${fieldInImpl('[T], 'mem)} - private def fieldInImpl(t: Type[_], mem: Expr[String]) with (qctx: QuoteContext) : Expr[String] = { + private def fieldInImpl(t: Type[_], mem: Expr[String])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given} val field = t.unseal.symbol.field(mem.value) Expr(if field.isNoSymbol then "" else field.name) } inline def fieldsIn[T]: Seq[String] = ${fieldsInImpl('[T])} - private def fieldsInImpl(t: Type[_]) with (qctx: QuoteContext) : Expr[Seq[String]] = { + private def fieldsInImpl(t: Type[_])(using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.tasty.{_, given _} val fields = t.unseal.symbol.fields Expr(fields.map(_.name).toList) } inline def methodIn[T](inline mem: String): Seq[String] = ${methodInImpl('[T], 'mem)} - private def methodInImpl(t: Type[_], mem: Expr[String]) with (qctx: QuoteContext) : Expr[Seq[String]] = { + private def methodInImpl(t: Type[_], mem: Expr[String])(using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.tasty.{_, given} Expr(t.unseal.symbol.classMethod(mem.value).map(_.name)) } inline def methodsIn[T]: Seq[String] = ${methodsInImpl('[T])} - private def methodsInImpl(t: Type[_]) with (qctx: QuoteContext) : Expr[Seq[String]] = { + private def methodsInImpl(t: Type[_])(using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.tasty.{_, given _} Expr(t.unseal.symbol.classMethods.map(_.name)) } inline def method[T](inline mem: String): Seq[String] = ${methodImpl('[T], 'mem)} - private def methodImpl(t: Type[_], mem: Expr[String]) with (qctx: QuoteContext) : Expr[Seq[String]] = { + private def methodImpl(t: Type[_], mem: Expr[String])(using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.tasty.{_, given} Expr(t.unseal.symbol.method(mem.value).map(_.name)) } inline def methods[T]: Seq[String] = ${methodsImpl('[T])} - private def methodsImpl(t: Type[_]) with (qctx: QuoteContext) : Expr[Seq[String]] = { + private def methodsImpl(t: Type[_])(using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.tasty.{_, given _} Expr(t.unseal.symbol.methods.map(_.name)) } inline def typeTag[T](x: T): String = ${typeTagImpl('[T])} - private def typeTagImpl(tp: Type[_]) with (qctx: QuoteContext) : Expr[String] = { + private def typeTagImpl(tp: Type[_])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} val res = tp.unseal.tpe.show Expr(res) } inline def companion[T1, T2]: Boolean = ${companionImpl('[T1], '[T2])} - private def companionImpl(t1: Type[_], t2: Type[_]) with (qctx: QuoteContext) : Expr[Boolean] = { + private def companionImpl(t1: Type[_], t2: Type[_])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} val res = t1.unseal.symbol.companionModule == t2.unseal.symbol Expr(res) } inline def companionName[T1]: String = ${companionNameImpl('[T1])} - private def companionNameImpl(tp: Type[_]) with (qctx: QuoteContext) : Expr[String] = { + private def companionNameImpl(tp: Type[_])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} val sym = tp.unseal.symbol val companionClass = diff --git a/tests/run-macros/i4515/Macro_1.scala b/tests/run-macros/i4515/Macro_1.scala index 6df5253ad7ca..4a76d45597eb 100644 --- a/tests/run-macros/i4515/Macro_1.scala +++ b/tests/run-macros/i4515/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def foo[X](x: X): Unit = ${fooImpl('x)} - def fooImpl[X: quoted.Type](x: Expr[X]) with QuoteContext : Expr[Unit] = '{} + def fooImpl[X: quoted.Type](x: Expr[X])(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/run-macros/i4515b/Macro_1.scala b/tests/run-macros/i4515b/Macro_1.scala index 88865527e41e..920b80040d9e 100644 --- a/tests/run-macros/i4515b/Macro_1.scala +++ b/tests/run-macros/i4515b/Macro_1.scala @@ -2,5 +2,5 @@ import scala.quoted._ object Macro { inline def foo: Unit = ${ fooImpl } - def fooImpl with QuoteContext : Expr[Unit] = '{} + def fooImpl(using QuoteContext): Expr[Unit] = '{} } diff --git a/tests/run-macros/i4734/Macro_1.scala b/tests/run-macros/i4734/Macro_1.scala index 681a54aa4ddb..607d65cd57aa 100644 --- a/tests/run-macros/i4734/Macro_1.scala +++ b/tests/run-macros/i4734/Macro_1.scala @@ -6,10 +6,10 @@ object Macros { inline def unrolledForeach(seq: IndexedSeq[Int], f: => Int => Unit, inline unrollSize: Int): Unit = // or f: Int => Unit ${ unrolledForeachImpl('seq, 'f, 'unrollSize) } - def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSizeExpr: Expr[Int]) with QuoteContext : Expr[Unit] = + def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSizeExpr: Expr[Int]) (using QuoteContext): Expr[Unit] = unrolledForeachImpl(seq, f, unrollSizeExpr.value) - def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSize: Int) with QuoteContext : Expr[Unit] = '{ + def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSize: Int)(using QuoteContext): Expr[Unit] = '{ val size = ($seq).length assert(size % (${unrollSize}) == 0) // for simplicity of the implementation var i = 0 @@ -27,7 +27,7 @@ object Macros { } class UnrolledRange(start: Int, end: Int) { - def foreach(f: Int => Expr[Unit]) with QuoteContext : Expr[Unit] = { + def foreach(f: Int => Expr[Unit])(using QuoteContext): Expr[Unit] = { @tailrec def loop(i: Int, acc: Expr[Unit]): Expr[Unit] = if (i >= 0) loop(i - 1, '{ ${f(i)}; $acc }) else acc diff --git a/tests/run-macros/i4735/Macro_1.scala b/tests/run-macros/i4735/Macro_1.scala index 03fee16542b2..01ad4f3cf07e 100644 --- a/tests/run-macros/i4735/Macro_1.scala +++ b/tests/run-macros/i4735/Macro_1.scala @@ -8,7 +8,7 @@ object Macro { inline def unrolledForeach(inline unrollSize: Int, seq: Array[Int], f: => Int => Unit): Unit = // or f: Int => Unit ${ unrolledForeachImpl('unrollSize, 'seq, 'f) } - private def unrolledForeachImpl(unrollSize: Expr[Int], seq: Expr[Array[Int]], f: Expr[Int => Unit]) with QuoteContext : Expr[Unit] = '{ + private def unrolledForeachImpl(unrollSize: Expr[Int], seq: Expr[Array[Int]], f: Expr[Int => Unit]) (using QuoteContext): Expr[Unit] = '{ val size = ($seq).length assert(size % (${unrollSize}) == 0) // for simplicity of the implementation var i = 0 @@ -26,7 +26,7 @@ object Macro { } private class UnrolledRange(start: Int, end: Int) { - def foreach(f: Int => Expr[Unit]) with QuoteContext : Expr[Unit] = { + def foreach(f: Int => Expr[Unit]) (using QuoteContext): Expr[Unit] = { @tailrec def loop(i: Int, acc: Expr[Unit]): Expr[Unit] = if (i >= 0) loop(i - 1, '{ ${f(i)}; $acc }) else acc diff --git a/tests/run-macros/i4803/Macro_1.scala b/tests/run-macros/i4803/Macro_1.scala index 6b29cde85716..71e96606fcb2 100644 --- a/tests/run-macros/i4803/Macro_1.scala +++ b/tests/run-macros/i4803/Macro_1.scala @@ -1,10 +1,10 @@ import scala.quoted._ object PowerMacro { - def powerCode(x: Expr[Double], n: Expr[Long]) with QuoteContext : Expr[Double] = + def powerCode(x: Expr[Double], n: Expr[Long]) (using QuoteContext): Expr[Double] = powerCode(x, n.value) - def powerCode(x: Expr[Double], n: Long) with QuoteContext : Expr[Double] = + def powerCode(x: Expr[Double], n: Long) (using QuoteContext): Expr[Double] = if (n == 0) '{1.0} else if (n % 2 == 0) '{ val y = $x * $x; ${ powerCode('y, n / 2) } } else '{ $x * ${ powerCode(x, n - 1) } } diff --git a/tests/run-macros/i4803b/Macro_1.scala b/tests/run-macros/i4803b/Macro_1.scala index 1c24c77c8cb2..0f7f94e280b9 100644 --- a/tests/run-macros/i4803b/Macro_1.scala +++ b/tests/run-macros/i4803b/Macro_1.scala @@ -1,10 +1,10 @@ import scala.quoted._ object PowerMacro { - def powerCode(x: Expr[Double], n: Expr[Long]) with QuoteContext : Expr[Double] = + def powerCode(x: Expr[Double], n: Expr[Long]) (using QuoteContext): Expr[Double] = powerCode(x, n.value) - def powerCode(x: Expr[Double], n: Long) with QuoteContext : Expr[Double] = + def powerCode(x: Expr[Double], n: Long) (using QuoteContext): Expr[Double] = if (n == 0) '{1.0} else if (n % 2 == 0) '{ val y = $x * $x; ${ powerCode('y, n / 2) } } else '{ $x * ${ powerCode(x, n - 1) } } diff --git a/tests/run-macros/i4803c/Macro_1.scala b/tests/run-macros/i4803c/Macro_1.scala index df09fc95023a..904b61769198 100644 --- a/tests/run-macros/i4803c/Macro_1.scala +++ b/tests/run-macros/i4803c/Macro_1.scala @@ -1,10 +1,10 @@ import scala.quoted._ object PowerMacro { - def powerCode(x: Expr[Double], n: Expr[Long]) with QuoteContext : Expr[Double] = + def powerCode(x: Expr[Double], n: Expr[Long]) (using QuoteContext): Expr[Double] = powerCode(x, n.value) - def powerCode(x: Expr[Double], n: Long) with QuoteContext : Expr[Double] = + def powerCode(x: Expr[Double], n: Long) (using QuoteContext): Expr[Double] = if (n == 0) '{1.0} else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('y, n / 2)} } else '{ $x * ${powerCode(x, n - 1)} } diff --git a/tests/run-macros/i4803e/Macro_1.scala b/tests/run-macros/i4803e/Macro_1.scala index 32121be592c7..1050ecdf9d3a 100644 --- a/tests/run-macros/i4803e/Macro_1.scala +++ b/tests/run-macros/i4803e/Macro_1.scala @@ -1,7 +1,7 @@ import scala.quoted._ object PowerMacro { - def power2(x: Expr[Double]) with QuoteContext = '{ + def power2(x: Expr[Double])(using QuoteContext) = '{ inline def power(x: Double, n: Long): Double = if (n == 0) 1.0 else if (n % 2 == 0) { val y = x * x; power(y, n / 2) } diff --git a/tests/run-macros/i4803f/Macro_1.scala b/tests/run-macros/i4803f/Macro_1.scala index a53cbeddb5b6..941b07451384 100644 --- a/tests/run-macros/i4803f/Macro_1.scala +++ b/tests/run-macros/i4803f/Macro_1.scala @@ -1,12 +1,12 @@ import scala.quoted._ object PowerMacro { - def powerCode(x: Expr[Double], n: Long) with QuoteContext : Expr[Double] = + def powerCode(x: Expr[Double], n: Long)(using QuoteContext): Expr[Double] = if (n == 0) '{1.0} else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('y, n / 2)} } else '{ $x * ${powerCode(x, n - 1)} } - def power2(x: Expr[Double]) with QuoteContext = '{ + def power2(x: Expr[Double])(using QuoteContext) = '{ inline def power(x: Double): Double = ${powerCode('x, 2)} power($x) } diff --git a/tests/run-macros/i4947e/Macro_1.scala b/tests/run-macros/i4947e/Macro_1.scala index de9e1edab2e5..4ab4f3fc076a 100644 --- a/tests/run-macros/i4947e/Macro_1.scala +++ b/tests/run-macros/i4947e/Macro_1.scala @@ -4,7 +4,7 @@ object Macros { def printStack(tag: String): Unit = { println(tag + ": "+ new Exception().getStackTrace().apply(1)) } - def assertImpl(expr: Expr[Boolean]) with QuoteContext = '{ + def assertImpl(expr: Expr[Boolean])(using QuoteContext) = '{ printStack("assertImpl") println($expr) } diff --git a/tests/run-macros/i4947f/Macro_1.scala b/tests/run-macros/i4947f/Macro_1.scala index a1a300367055..400e6701cd7f 100644 --- a/tests/run-macros/i4947f/Macro_1.scala +++ b/tests/run-macros/i4947f/Macro_1.scala @@ -4,7 +4,7 @@ object Macros { def printStack(tag: String): Unit = { println(tag + ": "+ new Exception().getStackTrace().apply(1)) } - def assertImpl(expr: Expr[Boolean]) with QuoteContext = '{ + def assertImpl(expr: Expr[Boolean])(using QuoteContext) = '{ printStack("assertImpl") println($expr) } diff --git a/tests/run-macros/i5119/Macro_1.scala b/tests/run-macros/i5119/Macro_1.scala index f99c5b01bf25..354277244440 100644 --- a/tests/run-macros/i5119/Macro_1.scala +++ b/tests/run-macros/i5119/Macro_1.scala @@ -6,7 +6,7 @@ object Macro { inline def ff(args: => Any*): String = ${ Macro.impl('sc, 'args) } } implicit inline def XmlQuote(sc: => StringContext): StringContextOps = new StringContextOps(sc) - def impl(sc: Expr[StringContext], args: Expr[Seq[Any]]) with (qctx: QuoteContext) : Expr[String] = { + def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} (sc.unseal.underlyingArgument.showExtractors + "\n" + args.unseal.underlyingArgument.showExtractors) } diff --git a/tests/run-macros/i5119b/Macro_1.scala b/tests/run-macros/i5119b/Macro_1.scala index 602a2cfd4213..db157034175f 100644 --- a/tests/run-macros/i5119b/Macro_1.scala +++ b/tests/run-macros/i5119b/Macro_1.scala @@ -6,7 +6,7 @@ object Macro { inline def ff(arg1: Any, arg2: Any): String = ${ Macro.impl('{arg1}, '{arg2}) } - def impl(arg1: Expr[Any], arg2: Expr[Any]) with (qctx: QuoteContext) : Expr[String] = { + def impl(arg1: Expr[Any], arg2: Expr[Any])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} (arg1.unseal.underlyingArgument.showExtractors + "\n" + arg2.unseal.underlyingArgument.showExtractors) } diff --git a/tests/run-macros/i5188a/Macro_1.scala b/tests/run-macros/i5188a/Macro_1.scala index 14e21a349eff..88f40447468d 100644 --- a/tests/run-macros/i5188a/Macro_1.scala +++ b/tests/run-macros/i5188a/Macro_1.scala @@ -3,5 +3,5 @@ import scala.quoted.autolift.{given _} object Lib { inline def sum(inline args: Int*): Int = ${ impl('args) } - def impl(args: Expr[Seq[Int]]) with QuoteContext : Expr[Int] = args.value.sum + def impl(args: Expr[Seq[Int]]) (using QuoteContext): Expr[Int] = args.value.sum } diff --git a/tests/run-macros/i5533/Macro_1.scala b/tests/run-macros/i5533/Macro_1.scala index 9c39c5a425d7..ce9667d6f300 100644 --- a/tests/run-macros/i5533/Macro_1.scala +++ b/tests/run-macros/i5533/Macro_1.scala @@ -7,7 +7,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)} - def assertImpl(condition: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(condition: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = condition.unseal diff --git a/tests/run-macros/i5533b/Macro_1.scala b/tests/run-macros/i5533b/Macro_1.scala index 4a2cf04e290e..8d57bf4db1d0 100644 --- a/tests/run-macros/i5533b/Macro_1.scala +++ b/tests/run-macros/i5533b/Macro_1.scala @@ -6,7 +6,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)} - def assertImpl(condition: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(condition: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = condition.unseal def exprStr: String = condition.show diff --git a/tests/run-macros/i5536/Macro_1.scala b/tests/run-macros/i5536/Macro_1.scala index 732f4930aead..4404eaa0e59b 100644 --- a/tests/run-macros/i5536/Macro_1.scala +++ b/tests/run-macros/i5536/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object scalatest { inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)} - def assertImpl(condition: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(condition: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = condition.unseal def exprStr: String = condition.show diff --git a/tests/run-macros/i5629/Macro_1.scala b/tests/run-macros/i5629/Macro_1.scala index 770b38959f41..87d09670ddde 100644 --- a/tests/run-macros/i5629/Macro_1.scala +++ b/tests/run-macros/i5629/Macro_1.scala @@ -4,7 +4,7 @@ object Macros { inline def assert(condition: => Boolean): Unit = ${ assertImpl('{condition}, '{""}) } - def assertImpl(cond: Expr[Boolean], clue: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val b = cond.unseal.underlyingArgument.seal.cast[Boolean] '{ scala.Predef.assert($b) } @@ -12,7 +12,7 @@ object Macros { inline def thisLineNumber = ${ thisLineNumberImpl } - def thisLineNumberImpl with (qctx: QuoteContext) : Expr[Int] = { + def thisLineNumberImpl(using qctx: QuoteContext) : Expr[Int] = { import qctx.tasty.{_, given _} Expr(rootPosition.startLine) } diff --git a/tests/run-macros/i5715/Macro_1.scala b/tests/run-macros/i5715/Macro_1.scala index d2bdb99e5b25..1861f594f387 100644 --- a/tests/run-macros/i5715/Macro_1.scala +++ b/tests/run-macros/i5715/Macro_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } - def assertImpl(cond: Expr[Boolean], clue: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} cond.unseal.underlyingArgument match { diff --git a/tests/run-macros/i5941/macro_1.scala b/tests/run-macros/i5941/macro_1.scala index cbe66e7ffd39..0fb7d087ef99 100644 --- a/tests/run-macros/i5941/macro_1.scala +++ b/tests/run-macros/i5941/macro_1.scala @@ -11,7 +11,7 @@ object Lens { def set(t: T, s: S): S = _set(t)(s) } - def impl[S: Type, T: Type](getter: Expr[S => T]) with (qctx: QuoteContext) : Expr[Lens[S, T]] = { + def impl[S: Type, T: Type](getter: Expr[S => T])(using qctx: QuoteContext) : Expr[Lens[S, T]] = { import qctx.tasty.{_, given _} import util._ @@ -84,7 +84,7 @@ object Iso { def to(s: S): A = _to(s) } - def impl[S: Type, A: Type] with (qctx: QuoteContext) : Expr[Iso[S, A]] = { + def impl[S: Type, A: Type](using qctx: QuoteContext) : Expr[Iso[S, A]] = { import qctx.tasty.{_, given _} import util._ @@ -123,7 +123,7 @@ object Iso { } } - def implUnit[S: Type] with (qctx: QuoteContext) : Expr[Iso[S, 1]] = { + def implUnit[S: Type](using qctx: QuoteContext) : Expr[Iso[S, 1]] = { import qctx.tasty.{_, given _} import util._ @@ -160,7 +160,7 @@ object Iso { } // TODO: require whitebox macro - def implFields[S: Type] with (qctx: QuoteContext) : Expr[Iso[S, Any]] = ??? + def implFields[S: Type](using qctx: QuoteContext) : Expr[Iso[S, Any]] = ??? } object GenIso { @@ -195,7 +195,7 @@ object Prism { def apply(a: A): S = app(a) } - def impl[S: Type, A <: S : Type] with (qctx: QuoteContext) : Expr[Prism[S, A]] = { + def impl[S: Type, A <: S : Type](using qctx: QuoteContext) : Expr[Prism[S, A]] = { import qctx.tasty.{_, given _} import util._ diff --git a/tests/run-macros/i6171/Macro_1.scala b/tests/run-macros/i6171/Macro_1.scala index 455ca48a86fe..7ce4c78b41bc 100644 --- a/tests/run-macros/i6171/Macro_1.scala +++ b/tests/run-macros/i6171/Macro_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } - def assertImpl(cond: Expr[Boolean], clue: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} import util._ diff --git a/tests/run-macros/i6201/macro_1.scala b/tests/run-macros/i6201/macro_1.scala index f4ae53ad05c4..cc05f8f7f9bc 100644 --- a/tests/run-macros/i6201/macro_1.scala +++ b/tests/run-macros/i6201/macro_1.scala @@ -3,11 +3,11 @@ import scala.quoted._ inline def (inline x: String) strip: String = ${ stripImpl('x) } -def stripImpl(x: Expr[String]) with (qctx: QuoteContext) : Expr[String] = +def stripImpl(x: Expr[String])(using qctx: QuoteContext) : Expr[String] = Expr(x.value.stripMargin) inline def isHello(inline x: String): Boolean = ${ isHelloImpl('x) } -def isHelloImpl(x: Expr[String]) with (qctx: QuoteContext) : Expr[Boolean] = +def isHelloImpl(x: Expr[String])(using qctx: QuoteContext) : Expr[Boolean] = if (x.value == "hello") Expr(true) else Expr(false) diff --git a/tests/run-macros/i6253-b/quoted_1.scala b/tests/run-macros/i6253-b/quoted_1.scala index ae2605c3e806..0fca81cf70b8 100644 --- a/tests/run-macros/i6253-b/quoted_1.scala +++ b/tests/run-macros/i6253-b/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { inline def (self: => StringContext) xyz(args: => String*): String = ${impl('self, 'args)} - private def impl(self: Expr[StringContext], args: Expr[Seq[String]]) with QuoteContext : Expr[String] = { + private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = { self match { case '{ StringContext($parts: _*) } => '{ diff --git a/tests/run-macros/i6253/quoted_1.scala b/tests/run-macros/i6253/quoted_1.scala index 2194e764cf47..8abc259ff86c 100644 --- a/tests/run-macros/i6253/quoted_1.scala +++ b/tests/run-macros/i6253/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { inline def (self: => StringContext) xyz(args: => String*): String = ${impl('self, 'args)} - private def impl(self: Expr[StringContext], args: Expr[Seq[String]]) with QuoteContext : Expr[String] = { + private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = { self match { case '{ StringContext($parts: _*) } => '{ StringContext($parts: _*).s($args: _*) } diff --git a/tests/run-macros/i6270/Macro_1.scala b/tests/run-macros/i6270/Macro_1.scala index 786e66679eea..f17369e85ffb 100644 --- a/tests/run-macros/i6270/Macro_1.scala +++ b/tests/run-macros/i6270/Macro_1.scala @@ -5,7 +5,7 @@ object api { inline def (inline x: String) reflect : String = ${ reflImpl('x) } - private def reflImpl(x: Expr[String]) with (qctx: QuoteContext) : Expr[String] = { + private def reflImpl(x: Expr[String])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} Expr(x.show) } @@ -13,7 +13,7 @@ object api { inline def (x: => String) reflectColor : String = ${ reflImplColor('x) } - private def reflImplColor(x: Expr[String]) with (qctx: QuoteContext) : Expr[String] = { + private def reflImplColor(x: Expr[String])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} Expr(x.show(ANSI)) } diff --git a/tests/run-macros/i6518/Macro_1.scala b/tests/run-macros/i6518/Macro_1.scala index dcd3f6a5c87d..fef98d4695b1 100644 --- a/tests/run-macros/i6518/Macro_1.scala +++ b/tests/run-macros/i6518/Macro_1.scala @@ -5,7 +5,7 @@ object Macros { inline def test(): String = ${ testImpl } - private def testImpl with (qctx: QuoteContext) : Expr[String] = { + private def testImpl(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} val classSym = typeOf[Function1[_, _]].classSymbol.get classSym.classMethod("apply") diff --git a/tests/run-macros/i6679/Macro_1.scala b/tests/run-macros/i6679/Macro_1.scala index e2bd2542e429..dac29fed5285 100644 --- a/tests/run-macros/i6679/Macro_1.scala +++ b/tests/run-macros/i6679/Macro_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ -def makeMatch[A: Type](head : Expr[A]) with (qctx : QuoteContext) : Expr[Unit] = { +def makeMatch[A: Type](head : Expr[A])(using qctx : QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val sacrifice = '{ $head match { case _ => ??? } } diff --git a/tests/run-macros/i6765-b/Macro_1.scala b/tests/run-macros/i6765-b/Macro_1.scala index 014f2a5312b8..462f343b82da 100644 --- a/tests/run-macros/i6765-b/Macro_1.scala +++ b/tests/run-macros/i6765-b/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted.{given _} inline def foo = ${fooImpl} -def fooImpl with (qctx: QuoteContext) = { +def fooImpl(using qctx: QuoteContext) = { val res = Expr.ofList(List('{"One"})) Expr(res.show) } diff --git a/tests/run-macros/i6765-c/Macro_1.scala b/tests/run-macros/i6765-c/Macro_1.scala index c134b3c0c08c..477d2109a32a 100644 --- a/tests/run-macros/i6765-c/Macro_1.scala +++ b/tests/run-macros/i6765-c/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted.{given _} inline def foo(inline n: Int) = ${fooImpl('n)} -def fooImpl(n: Expr[Int])with (qctx: QuoteContext) = { +def fooImpl(n: Expr[Int])(using qctx: QuoteContext) = { val res = Expr.ofList(List.tabulate(n.value)(i => Expr("#" + i))) '{ ${Expr(res.show)} + "\n" + $res.toString + "\n" } } diff --git a/tests/run-macros/i6765/Macro_1.scala b/tests/run-macros/i6765/Macro_1.scala index 08e09baed0a5..502790dc8bc3 100644 --- a/tests/run-macros/i6765/Macro_1.scala +++ b/tests/run-macros/i6765/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted.{given _} inline def foo = ${fooImpl} -def fooImpl with (qctx: QuoteContext) = { +def fooImpl(using qctx: QuoteContext) = { import qctx.tasty.{_, given _} val res = Expr.ofList(List('{"One"})) Expr(res.show) diff --git a/tests/run-macros/i6803/Macro_1.scala b/tests/run-macros/i6803/Macro_1.scala index 50c81c6212cb..b88e51825c3e 100644 --- a/tests/run-macros/i6803/Macro_1.scala +++ b/tests/run-macros/i6803/Macro_1.scala @@ -8,7 +8,7 @@ object AsObject { object LineNo { def unsafe(i: Int): LineNo = new LineNo(i) inline given LineNo = ${impl} - private def impl with (qctx: QuoteContext): Expr[LineNo] = { + private def impl(using qctx: QuoteContext): Expr[LineNo] = { import qctx.tasty.{given, _} '{unsafe(${Expr(rootPosition.startLine)})} } @@ -20,7 +20,7 @@ package AsPackage { object LineNo { def unsafe(i: Int): LineNo = new LineNo(i) inline given LineNo = ${impl} - private def impl with (qctx: QuoteContext): Expr[LineNo] = { + private def impl(using qctx: QuoteContext): Expr[LineNo] = { import qctx.tasty.{given, _} '{unsafe(${Expr(rootPosition.startLine)})} } diff --git a/tests/run-macros/i6988/FirstArg_1.scala b/tests/run-macros/i6988/FirstArg_1.scala index 5d6f32456c86..7385b5e9aceb 100644 --- a/tests/run-macros/i6988/FirstArg_1.scala +++ b/tests/run-macros/i6988/FirstArg_1.scala @@ -8,7 +8,7 @@ object FirstArg { object Macros { import scala.quoted._ - def argsImpl with (qctx: QuoteContext) : Expr[FirstArg] = { + def argsImpl(using qctx: QuoteContext) : Expr[FirstArg] = { import qctx.tasty.{_, given _} def enclosingClass(cur: Symbol = rootContext.owner): Symbol = diff --git a/tests/run-macros/i6988/Test_2.scala b/tests/run-macros/i6988/Test_2.scala index fe1e3ea3f934..1a5826ef6094 100644 --- a/tests/run-macros/i6988/Test_2.scala +++ b/tests/run-macros/i6988/Test_2.scala @@ -6,7 +6,7 @@ object Test { assert("p1" == firstArgName) assert("something" == firstArgValue) } - def debug with foo.FirstArg : Unit = { + def debug(using foo.FirstArg): Unit = { firstArgName = summon[foo.FirstArg].source firstArgValue = summon[foo.FirstArg].value } diff --git a/tests/run-macros/i7008/macro_1.scala b/tests/run-macros/i7008/macro_1.scala index 4e964af2588e..4a0fa0721756 100644 --- a/tests/run-macros/i7008/macro_1.scala +++ b/tests/run-macros/i7008/macro_1.scala @@ -6,13 +6,13 @@ case class Box[T](v: T) inline def mcr(expr: => Boolean): Unit = ${mcrProxy('expr)} -def mcrProxy(expr: Expr[Boolean]) with QuoteContext : Expr[Unit] = { +def mcrProxy(expr: Expr[Boolean])(using QuoteContext): Expr[Unit] = { val res = mcrImpl[Boolean]('{ (esx: Seq[Box[Boolean]]) => () }, expr) // println(s"Out: ${res.show}") res } -def mcrImpl[T](func: Expr[Seq[Box[T]] => Unit], expr: Expr[T]) with (ctx: QuoteContext, tt: Type[T]) : Expr[Unit] = { +def mcrImpl[T](func: Expr[Seq[Box[T]] => Unit], expr: Expr[T])(using ctx: QuoteContext, tt: Type[T]): Expr[Unit] = { import ctx.tasty._ val arg = Expr.ofSeq(Seq('{(Box($expr))})) Expr.betaReduce(func)(arg) diff --git a/tests/run-macros/i7025/Macros_1.scala b/tests/run-macros/i7025/Macros_1.scala index 17523271e040..838b70a78ce6 100644 --- a/tests/run-macros/i7025/Macros_1.scala +++ b/tests/run-macros/i7025/Macros_1.scala @@ -3,7 +3,7 @@ object Macros { inline def debug: Unit = ${Macros.debugImpl} - def debugImpl with (qctx: QuoteContext): Expr[Unit] = { + def debugImpl(using qctx: QuoteContext): Expr[Unit] = { import qctx.tasty.{given, _} def nearestEnclosingDef(owner: Symbol): Symbol = diff --git a/tests/run-macros/i7048/Lib_1.scala b/tests/run-macros/i7048/Lib_1.scala index c45159dccb98..f0a22254ef9a 100644 --- a/tests/run-macros/i7048/Lib_1.scala +++ b/tests/run-macros/i7048/Lib_1.scala @@ -12,13 +12,13 @@ given [U] : IsExpr[Expr[U]] = new IsExpr[Expr[U]] { def f(x: Any): String = x.toString -def g[T](x: T) with (e: IsExpr[T], tu: Type[e.Underlying]) : QuoteContext ?=> Expr[String] = { +def g[T](x: T)(using e: IsExpr[T], tu: Type[e.Underlying]): QuoteContext ?=> Expr[String] = { val underlying: Expr[e.Underlying] = e.toExpr(x) '{f($underlying)} } inline def mcr(): Any = ${mcrImpl} -def mcrImpl with QuoteContext : Expr[Any] = { +def mcrImpl(using QuoteContext): Expr[Any] = { val x = '{1} g(x) } diff --git a/tests/run-macros/i7519c/Macro_1.scala b/tests/run-macros/i7519c/Macro_1.scala index 4c87cdc3f2ff..415500ef17c3 100644 --- a/tests/run-macros/i7519c/Macro_1.scala +++ b/tests/run-macros/i7519c/Macro_1.scala @@ -7,7 +7,7 @@ class Quoted[T] inline def quote[T]: String = ${ quoteImpl[T] } -def quoteImpl[T: Type] with (qctx: QuoteContext) : Expr[String] = { +def quoteImpl[T: Type](using qctx: QuoteContext): Expr[String] = { val value: Expr[Int] = '{ 42 } Expr(('{ new Quoted[T @Annot($value)] }).show) } diff --git a/tests/run-macros/i7715/Macros_1.scala b/tests/run-macros/i7715/Macros_1.scala index dae722a8b100..990fc203ac35 100644 --- a/tests/run-macros/i7715/Macros_1.scala +++ b/tests/run-macros/i7715/Macros_1.scala @@ -1,6 +1,6 @@ import scala.quoted.{ given _, _ } inline def mcr(e: => Any): Any = ${mcrImpl('e)} -def mcrImpl(e: Expr[Any]) with (ctx: QuoteContext) : Expr[Any] = +def mcrImpl(e: Expr[Any])(using ctx: QuoteContext): Expr[Any] = e match case '{ $body } => body diff --git a/tests/run-macros/i7887/Macro_1.scala b/tests/run-macros/i7887/Macro_1.scala index 99a35135b52b..e076111b3032 100644 --- a/tests/run-macros/i7887/Macro_1.scala +++ b/tests/run-macros/i7887/Macro_1.scala @@ -1,4 +1,4 @@ -def myMacroImpl(a: quoted.Expr[_])(given qctx: quoted.QuoteContext) = { +def myMacroImpl(a: quoted.Expr[_])(using qctx: quoted.QuoteContext) = { import qctx.tasty.{_, given} def typed[A] = { implicit val t: quoted.Type[A] = a.unseal.tpe.widen.seal.asInstanceOf[quoted.Type[A]] diff --git a/tests/run-macros/i7898/Macro_1.scala b/tests/run-macros/i7898/Macro_1.scala index e4423fca7fc3..38cfd47e506a 100644 --- a/tests/run-macros/i7898/Macro_1.scala +++ b/tests/run-macros/i7898/Macro_1.scala @@ -2,7 +2,7 @@ import quoted._ import quoted.unsafe._ object Main { - def myMacroImpl(body: Expr[_]) with (qctx: QuoteContext) : Expr[_] = { + def myMacroImpl(body: Expr[_])(using qctx: QuoteContext) : Expr[_] = { import qctx.tasty.{_, given _} val bodyTerm = UnsafeExpr.underlyingArgument(body).unseal val showed = bodyTerm.show diff --git a/tests/run-macros/i7964/Macro_1.scala b/tests/run-macros/i7964/Macro_1.scala index f7dec33b09f5..c0a992141b63 100644 --- a/tests/run-macros/i7964/Macro_1.scala +++ b/tests/run-macros/i7964/Macro_1.scala @@ -7,7 +7,7 @@ enum Num { // TODO derive a quoted.ValueOfExpr inline def foo(inline num: Num): Int = ${ fooExpr('num) } -private def fooExpr(numExpr: Expr[Num]) with QuoteContext : Expr[Int] = +private def fooExpr(numExpr: Expr[Num]) (using QuoteContext): Expr[Int] = val num = numExpr match { case '{ Num.One } => Num.One case '{ Num.Two } => Num.Two diff --git a/tests/run-macros/i7987/Macros_1.scala b/tests/run-macros/i7987/Macros_1.scala index 48a13a68fecd..50962e6bfc48 100644 --- a/tests/run-macros/i7987/Macros_1.scala +++ b/tests/run-macros/i7987/Macros_1.scala @@ -5,7 +5,7 @@ import scala.quoted.matching._ object Macros { inline def m(): String = ${ macroImpl() } - def macroImpl[T]()(given qctx: QuoteContext): Expr[String] = { + def macroImpl[T]()(using qctx: QuoteContext): Expr[String] = { summonExpr[Mirror.Of[Some[Int]]] match case Some('{ $_ : $t }) => Expr(t.show) } diff --git a/tests/run-macros/i8007/Macro_1.scala b/tests/run-macros/i8007/Macro_1.scala index 20e6f5997dbf..a4c44c1f69c5 100644 --- a/tests/run-macros/i8007/Macro_1.scala +++ b/tests/run-macros/i8007/Macro_1.scala @@ -4,7 +4,7 @@ import scala.quoted.matching._ object Macro1 { - def mirrorFields[T](t: Type[T])(given qctx: QuoteContext): List[String] = + def mirrorFields[T](t: Type[T])(using qctx: QuoteContext): List[String] = t match { case '[$field *: $fields] => field.show :: mirrorFields(fields) case '[Unit] => Nil @@ -16,12 +16,12 @@ object Macro1 { inline def test1[T](value: =>T): List[String] = ${ test1Impl('value) } - def test1Impl[T: Type](value: Expr[T])(given qctx: QuoteContext): Expr[List[String]] = { + def test1Impl[T: Type](value: Expr[T])(using qctx: QuoteContext): Expr[List[String]] = { import qctx.tasty.{_, given} val mirrorTpe = '[Mirror.Of[T]] - summonExpr(given mirrorTpe).get match { + summonExpr(using mirrorTpe).get match { case '{ $m: Mirror.ProductOf[T]{ type MirroredElemLabels = $t } } => { Expr(mirrorFields(t)) } diff --git a/tests/run-macros/i8007/Macro_2.scala b/tests/run-macros/i8007/Macro_2.scala index ed65f04bf4a8..6f7d80f49815 100644 --- a/tests/run-macros/i8007/Macro_2.scala +++ b/tests/run-macros/i8007/Macro_2.scala @@ -4,7 +4,7 @@ import scala.quoted.matching._ object Macro2 { - def mirrorFields[T](t: Type[T])(given qctx: QuoteContext): List[String] = + def mirrorFields[T](t: Type[T])(using qctx: QuoteContext): List[String] = t match { case '[$field *: $fields] => field.show.substring(1, field.show.length-1) :: mirrorFields(fields) case '[Unit] => Nil @@ -20,7 +20,7 @@ object Macro2 { def encode(elem: T): String = body(elem) } - def derived[T: Type](ev: Expr[Mirror.Of[T]])(given qctx: QuoteContext): Expr[JsonEncoder[T]] = { + def derived[T: Type](ev: Expr[Mirror.Of[T]])(using qctx: QuoteContext): Expr[JsonEncoder[T]] = { import qctx.tasty.{_, given} val fields = ev match { @@ -42,11 +42,11 @@ object Macro2 { inline def test2[T](value: =>T): Unit = ${ test2Impl('value) } - def test2Impl[T: Type](value: Expr[T])(given qctx: QuoteContext): Expr[Unit] = { + def test2Impl[T: Type](value: Expr[T])(using qctx: QuoteContext): Expr[Unit] = { import qctx.tasty.{_, given} val mirrorTpe = '[Mirror.Of[T]] - val mirrorExpr = summonExpr(given mirrorTpe).get + val mirrorExpr = summonExpr(using mirrorTpe).get val derivedInstance = JsonEncoder.derived(mirrorExpr) '{ diff --git a/tests/run-macros/i8007/Macro_3.scala b/tests/run-macros/i8007/Macro_3.scala index d530f86427b6..21b651e48fde 100644 --- a/tests/run-macros/i8007/Macro_3.scala +++ b/tests/run-macros/i8007/Macro_3.scala @@ -25,17 +25,17 @@ object Eq { def eqv(x: T, y: T): Boolean = body(x, y) } - def summonAll[T](t: Type[T])(given qctx: QuoteContext): List[Expr[Eq[_]]] = t match { + def summonAll[T](t: Type[T])(using qctx: QuoteContext): List[Expr[Eq[_]]] = t match { case '[String *: $tpes] => '{ summon[Eq[String]] } :: summonAll(tpes) case '[Int *: $tpes] => '{ summon[Eq[Int]] } :: summonAll(tpes) - case '[$tpe *: $tpes] => derived(given tpe, qctx) :: summonAll(tpes) + case '[$tpe *: $tpes] => derived(using tpe, qctx) :: summonAll(tpes) case '[Unit] => Nil } - given derived[T: Type](given qctx: QuoteContext): Expr[Eq[T]] = { + given derived[T: Type](using qctx: QuoteContext): Expr[Eq[T]] = { import qctx.tasty.{_, given} - val ev: Expr[Mirror.Of[T]] = summonExpr(given '[Mirror.Of[T]]).get + val ev: Expr[Mirror.Of[T]] = summonExpr(using '[Mirror.Of[T]]).get ev match { case '{ $m: Mirror.ProductOf[T] { type MirroredElemTypes = $elementTypes }} => @@ -73,7 +73,7 @@ object Eq { } object Macro3 { - inline def [T](x: =>T) === (y: =>T)(given eq: Eq[T]): Boolean = eq.eqv(x, y) + inline def [T](x: =>T) === (y: =>T)(using eq: Eq[T]): Boolean = eq.eqv(x, y) implicit inline def eqGen[T]: Eq[T] = ${ Eq.derived[T] } } \ No newline at end of file diff --git a/tests/run-macros/i8115/Macro_2.scala b/tests/run-macros/i8115/Macro_2.scala index 3737865774f5..5543f1157c93 100644 --- a/tests/run-macros/i8115/Macro_2.scala +++ b/tests/run-macros/i8115/Macro_2.scala @@ -4,7 +4,7 @@ import scala.quoted._ object MyClassMaker { inline def make: MyClass = ${ makeImpl } - def makeImpl(given qctx: QuoteContext): Expr[MyClass] = { + def makeImpl(using qctx: QuoteContext): Expr[MyClass] = { '{ new MyClass { } /* eventually I want to add properties inside */ } diff --git a/tests/run-macros/i8115b/Macro_2.scala b/tests/run-macros/i8115b/Macro_2.scala index 998263767989..85368256e639 100644 --- a/tests/run-macros/i8115b/Macro_2.scala +++ b/tests/run-macros/i8115b/Macro_2.scala @@ -4,7 +4,7 @@ import scala.quoted._ object MyClassMaker { inline def make: MyClass = ${ makeImpl } - def makeImpl(given qctx: QuoteContext): Expr[MyClass] = { + def makeImpl(using qctx: QuoteContext): Expr[MyClass] = { '{ new MyClass { override def toString(): String = "MyClassMaker.make.MyClass" diff --git a/tests/run-macros/inferred-repeated-result/test_1.scala b/tests/run-macros/inferred-repeated-result/test_1.scala index 3f19d4461f78..d0629b85daf8 100644 --- a/tests/run-macros/inferred-repeated-result/test_1.scala +++ b/tests/run-macros/inferred-repeated-result/test_1.scala @@ -3,7 +3,7 @@ object Macros { import scala.quoted.autolift.{given _} inline def go[T](inline t: T) = ${ impl('t) } - def impl[T](expr: Expr[T]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl[T](expr: Expr[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = expr.unseal diff --git a/tests/run-macros/inline-case-objects/Macro_1.scala b/tests/run-macros/inline-case-objects/Macro_1.scala index 62a8adf2f576..6c4f2e59a143 100644 --- a/tests/run-macros/inline-case-objects/Macro_1.scala +++ b/tests/run-macros/inline-case-objects/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macros { - def impl(expr: Expr[Any]) with QuoteContext : Expr[String] = + def impl(expr: Expr[Any]) (using QuoteContext): Expr[String] = val obj = expr match { case '{ None } => None case '{ scala.collection.immutable.Nil } => Nil diff --git a/tests/run-macros/inline-macro-inner-object/Macro_1.scala b/tests/run-macros/inline-macro-inner-object/Macro_1.scala index 8e41e851833b..425c9b8a0ab3 100644 --- a/tests/run-macros/inline-macro-inner-object/Macro_1.scala +++ b/tests/run-macros/inline-macro-inner-object/Macro_1.scala @@ -4,17 +4,17 @@ import scala.quoted._ object A { inline def f: Unit = ${impl} - private def impl with (qctx: QuoteContext) : Expr[Unit] = { + private def impl(using qctx: QuoteContext): Expr[Unit] = { '{println("A.f")} } object B { inline def f: Unit = ${impl} - private def impl with (qctx: QuoteContext) : Expr[Unit] = { + private def impl(using qctx: QuoteContext): Expr[Unit] = { '{println("A.B.f")} } object C { inline def f: Unit = ${impl} - private def impl with (qctx: QuoteContext) : Expr[Unit] = { + private def impl(using qctx: QuoteContext): Expr[Unit] = { '{println("A.B.C.f")} } } diff --git a/tests/run-macros/inline-macro-staged-interpreter/Macro_1.scala b/tests/run-macros/inline-macro-staged-interpreter/Macro_1.scala index 442137b4a9da..cd03d18aceaa 100644 --- a/tests/run-macros/inline-macro-staged-interpreter/Macro_1.scala +++ b/tests/run-macros/inline-macro-staged-interpreter/Macro_1.scala @@ -6,69 +6,69 @@ object E { inline def eval[T](inline x: E[T]): T = ${ impl('x) } - def impl[T: Type](expr: Expr[E[T]]) with QuoteContext : Expr[T] = + def impl[T: Type](expr: Expr[E[T]]) (using QuoteContext): Expr[T] = expr.value.lift implicit def ev1[T: Type]: ValueOfExpr[E[T]] = new ValueOfExpr { // TODO use type class derivation - def apply(x: Expr[E[T]]) with QuoteContext : Option[E[T]] = (x match { + def apply(x: Expr[E[T]]) (using QuoteContext): Option[E[T]] = (x match { case '{ I(${Const(n)}) } => Some(I(n)) case '{ D(${Const(n)}) } => Some(D(n)) - case '{ Plus[Int](${Value(x)}, ${Value(y)})(given $op) } => Some(Plus(x, y)(given Plus2.IPlus)) - case '{ Plus[Double](${Value(x)}, ${Value(y)})(given $op) } => Some(Plus(x, y)(given Plus2.DPlus)) - case '{ Times[Int](${Value(x)}, ${Value(y)})(given $op) } => Some(Times(x, y)(given Times2.ITimes)) - case '{ Times[Double](${Value(x)}, ${Value(y)})(given $op) } => Some(Times(x, y)(given Times2.DTimes)) + case '{ Plus[Int](${Value(x)}, ${Value(y)})(using $op) } => Some(Plus(x, y)(using Plus2.IPlus)) + case '{ Plus[Double](${Value(x)}, ${Value(y)})(using $op) } => Some(Plus(x, y)(using Plus2.DPlus)) + case '{ Times[Int](${Value(x)}, ${Value(y)})(using $op) } => Some(Times(x, y)(using Times2.ITimes)) + case '{ Times[Double](${Value(x)}, ${Value(y)})(using $op) } => Some(Times(x, y)(using Times2.DTimes)) case _ => None }).asInstanceOf[Option[E[T]]] } object Value { - def unapply[T, U >: T](expr: Expr[T])(given ValueOfExpr[U], QuoteContext): Option[U] = expr.getValue + def unapply[T, U >: T](expr: Expr[T])(using ValueOfExpr[U], QuoteContext): Option[U] = expr.getValue } } trait E[T] { - def lift with QuoteContext : Expr[T] + def lift (using QuoteContext): Expr[T] } case class I(n: Int) extends E[Int] { - def lift with QuoteContext : Expr[Int] = Expr(n) + def lift (using QuoteContext): Expr[Int] = Expr(n) } case class D(n: Double) extends E[Double] { - def lift with QuoteContext : Expr[Double] = Expr(n) + def lift (using QuoteContext): Expr[Double] = Expr(n) } case class Plus[T](x: E[T], y: E[T])(implicit op: Plus2[T]) extends E[T] { - def lift with QuoteContext : Expr[T] = op(x.lift, y.lift) + def lift (using QuoteContext): Expr[T] = op(x.lift, y.lift) } case class Times[T](x: E[T], y: E[T])(implicit op: Times2[T]) extends E[T] { - def lift with QuoteContext : Expr[T] = op(x.lift, y.lift) + def lift (using QuoteContext): Expr[T] = op(x.lift, y.lift) } trait Op2[T] { - def apply(x: Expr[T], y: Expr[T]) with QuoteContext : Expr[T] + def apply(x: Expr[T], y: Expr[T]) (using QuoteContext): Expr[T] } trait Plus2[T] extends Op2[T] object Plus2 { implicit case object IPlus extends Plus2[Int] { - def apply(x: Expr[Int], y: Expr[Int]) with QuoteContext : Expr[Int] = '{$x + $y} + def apply(x: Expr[Int], y: Expr[Int]) (using QuoteContext): Expr[Int] = '{$x + $y} } implicit case object DPlus extends Plus2[Double] { - def apply(x: Expr[Double], y: Expr[Double]) with QuoteContext : Expr[Double] = '{$x + $y} + def apply(x: Expr[Double], y: Expr[Double]) (using QuoteContext): Expr[Double] = '{$x + $y} } } trait Times2[T] extends Op2[T] object Times2 { implicit case object ITimes extends Times2[Int] { - def apply(x: Expr[Int], y: Expr[Int]) with QuoteContext : Expr[Int] = '{$x * $y} + def apply(x: Expr[Int], y: Expr[Int]) (using QuoteContext): Expr[Int] = '{$x * $y} } implicit case object DTimes extends Times2[Double] { - def apply(x: Expr[Double], y: Expr[Double]) with QuoteContext : Expr[Double] = '{$x * $y} + def apply(x: Expr[Double], y: Expr[Double]) (using QuoteContext): Expr[Double] = '{$x * $y} } } diff --git a/tests/run-macros/inline-option/Macro_1.scala b/tests/run-macros/inline-option/Macro_1.scala index c8e28b23d7da..dd1e08a97c8b 100644 --- a/tests/run-macros/inline-option/Macro_1.scala +++ b/tests/run-macros/inline-option/Macro_1.scala @@ -4,11 +4,11 @@ import scala.quoted.autolift.{given _} object Macros { - def impl(opt: Expr[Option[Int]]) with QuoteContext : Expr[Int] = opt.value match { + def impl(opt: Expr[Option[Int]]) (using QuoteContext): Expr[Int] = opt.value match { case Some(i) => i case None => '{-1} } - def impl2(opt: Expr[Option[Option[Int]]]) with QuoteContext : Expr[Int] = impl(opt.value.flatten) + def impl2(opt: Expr[Option[Option[Int]]]) (using QuoteContext): Expr[Int] = impl(opt.value.flatten) } diff --git a/tests/run-macros/inline-tuples-1/Macro_1.scala b/tests/run-macros/inline-tuples-1/Macro_1.scala index bdf0bdf0f63d..44a92b1dc08d 100644 --- a/tests/run-macros/inline-tuples-1/Macro_1.scala +++ b/tests/run-macros/inline-tuples-1/Macro_1.scala @@ -3,26 +3,26 @@ import scala.quoted._ import scala.quoted.autolift.{given _} object Macros { - def tup1(tup: Expr[Tuple1[Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup2(tup: Expr[Tuple2[Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup3(tup: Expr[Tuple3[Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup8(tup: Expr[Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup9(tup: Expr[Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup10(tup: Expr[Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup11(tup: Expr[Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup12(tup: Expr[Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup13(tup: Expr[Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup14(tup: Expr[Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup15(tup: Expr[Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup16(tup: Expr[Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup17(tup: Expr[Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup18(tup: Expr[Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup19(tup: Expr[Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup20(tup: Expr[Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup21(tup: Expr[Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum - def tup22(tup: Expr[Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) with QuoteContext : Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup1(tup: Expr[Tuple1[Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup2(tup: Expr[Tuple2[Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup3(tup: Expr[Tuple3[Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup8(tup: Expr[Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup9(tup: Expr[Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup10(tup: Expr[Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup11(tup: Expr[Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup12(tup: Expr[Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup13(tup: Expr[Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup14(tup: Expr[Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup15(tup: Expr[Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup16(tup: Expr[Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup17(tup: Expr[Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup18(tup: Expr[Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup19(tup: Expr[Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup20(tup: Expr[Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup21(tup: Expr[Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum + def tup22(tup: Expr[Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using QuoteContext): Expr[Int] = tup.value.productIterator.map(_.asInstanceOf[Int]).sum } diff --git a/tests/run-macros/inline-tuples-2/Macro_1.scala b/tests/run-macros/inline-tuples-2/Macro_1.scala index b9991026751e..f1c62d31473c 100644 --- a/tests/run-macros/inline-tuples-2/Macro_1.scala +++ b/tests/run-macros/inline-tuples-2/Macro_1.scala @@ -4,8 +4,8 @@ import scala.quoted.autolift.{given _} object Macros { - def impl(tup: Expr[Tuple1[Int]]) with QuoteContext : Expr[Int] = tup.value._1 + def impl(tup: Expr[Tuple1[Int]]) (using QuoteContext): Expr[Int] = tup.value._1 - def impl2(tup: Expr[Tuple1[Tuple1[Int]]]) with QuoteContext : Expr[Int] = impl(tup.value._1) + def impl2(tup: Expr[Tuple1[Tuple1[Int]]]) (using QuoteContext): Expr[Int] = impl(tup.value._1) } diff --git a/tests/run-macros/inline-varargs-1/Macro_1.scala b/tests/run-macros/inline-varargs-1/Macro_1.scala index 49a2cb188dd4..d1d495e001d8 100644 --- a/tests/run-macros/inline-varargs-1/Macro_1.scala +++ b/tests/run-macros/inline-varargs-1/Macro_1.scala @@ -3,5 +3,5 @@ import scala.quoted._ import scala.quoted.autolift.{given _} object Macros { - def sum(nums: Expr[Int]*) with QuoteContext : Expr[Int] = nums.map(_.value).sum + def sum(nums: Expr[Int]*) (using QuoteContext): Expr[Int] = nums.map(_.value).sum } diff --git a/tests/run-macros/macros-in-same-project1/Foo.scala b/tests/run-macros/macros-in-same-project1/Foo.scala index b2dbc8b0fbe8..a59dc01f6ca7 100644 --- a/tests/run-macros/macros-in-same-project1/Foo.scala +++ b/tests/run-macros/macros-in-same-project1/Foo.scala @@ -4,6 +4,6 @@ object Foo { inline def myMacro(): Unit = ${ aMacroImplementation } - def aMacroImplementation with QuoteContext : Expr[Unit] = '{ println("Hello") } + def aMacroImplementation(using QuoteContext): Expr[Unit] = '{ println("Hello") } } \ No newline at end of file diff --git a/tests/run-macros/quote-and-splice/Macros_1.scala b/tests/run-macros/quote-and-splice/Macros_1.scala index acce3c6add55..b041d4abd8c0 100644 --- a/tests/run-macros/quote-and-splice/Macros_1.scala +++ b/tests/run-macros/quote-and-splice/Macros_1.scala @@ -3,26 +3,26 @@ import scala.quoted._ object Macros { inline def macro1 = ${ macro1Impl } - def macro1Impl with QuoteContext = '{3} + def macro1Impl (using QuoteContext)= '{3} inline def macro2(inline p: Boolean) = ${ macro2Impl('p) } - def macro2Impl(p: Expr[Boolean]) with QuoteContext = if (p.value) '{3} else '{4} + def macro2Impl(p: Expr[Boolean]) (using QuoteContext)= if (p.value) '{3} else '{4} inline def macro3(n: Int) = ${ macro3Impl('n) } - def macro3Impl(p: Expr[Int]) with QuoteContext = '{ 2 + $p } + def macro3Impl(p: Expr[Int]) (using QuoteContext)= '{ 2 + $p } inline def macro4(i: Int)(j: Int) = ${ macro4Impl('i)('j) } - def macro4Impl(i: Expr[Int])(j: Expr[Int]) with QuoteContext = '{ $i + $j } + def macro4Impl(i: Expr[Int])(j: Expr[Int]) (using QuoteContext)= '{ $i + $j } inline def macro5(i: Int, j: Int) = ${ macro5Impl(j = 'j, i = 'i) } - def macro5Impl(i: Expr[Int], j: Expr[Int]) with QuoteContext = '{ $i + $j } + def macro5Impl(i: Expr[Int], j: Expr[Int]) (using QuoteContext)= '{ $i + $j } inline def power(inline n: Int, x: Double) = ${ powerCode('n, 'x) } - def powerCode(n: Expr[Int], x: Expr[Double]) with QuoteContext : Expr[Double] = + def powerCode(n: Expr[Int], x: Expr[Double]) (using QuoteContext): Expr[Double] = powerCode(n.value, x) - def powerCode(n: Int, x: Expr[Double]) with QuoteContext : Expr[Double] = + def powerCode(n: Int, x: Expr[Double]) (using QuoteContext): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, 'y)} } } diff --git a/tests/run-macros/quote-change-owner/Macro_1.scala b/tests/run-macros/quote-change-owner/Macro_1.scala index 5bb0a792f80b..f12c5c355c12 100644 --- a/tests/run-macros/quote-change-owner/Macro_1.scala +++ b/tests/run-macros/quote-change-owner/Macro_1.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Macros { inline def assert2(expr: => Boolean): Unit = ${ assertImpl('expr) } - def assertImpl(expr: Expr[Boolean]) with QuoteContext = '{ + def assertImpl(expr: Expr[Boolean])(using QuoteContext) = '{ def foo(): Unit = $expr foo() } diff --git a/tests/run-macros/quote-elide-prefix/quoted_1.scala b/tests/run-macros/quote-elide-prefix/quoted_1.scala index 94cff7c47598..c47f3583fc56 100644 --- a/tests/run-macros/quote-elide-prefix/quoted_1.scala +++ b/tests/run-macros/quote-elide-prefix/quoted_1.scala @@ -5,5 +5,5 @@ object Macro { // By name StringContext is used to elide the prefix inline def (sc: => StringContext) ff (args: => Any*): String = ${ Macro.impl('sc, 'args) } - def impl(sc: Expr[StringContext], args: Expr[Seq[Any]]) with QuoteContext : Expr[String] = '{ $args.mkString } + def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(using QuoteContext): Expr[String] = '{ $args.mkString } } diff --git a/tests/run-macros/quote-force/quoted_1.scala b/tests/run-macros/quote-force/quoted_1.scala index f93c8f26f86d..a0557b0b07c2 100644 --- a/tests/run-macros/quote-force/quoted_1.scala +++ b/tests/run-macros/quote-force/quoted_1.scala @@ -7,7 +7,7 @@ object Location { implicit inline def location: Location = ${impl} - def impl with QuoteContext : Expr[Location] = { + def impl(using QuoteContext): Expr[Location] = { val list = List("a", "b", "c", "d", "e", "f") '{new Location(${list})} } diff --git a/tests/run-macros/quote-implicitMatch/Macro_1.scala b/tests/run-macros/quote-implicitMatch/Macro_1.scala index 707def9b0b8e..08f317805b5f 100644 --- a/tests/run-macros/quote-implicitMatch/Macro_1.scala +++ b/tests/run-macros/quote-implicitMatch/Macro_1.scala @@ -5,7 +5,7 @@ import scala.quoted.matching._ inline def f1[T]() = ${ f1Impl[T] } -def f1Impl[T: Type] with QuoteContext = { +def f1Impl[T: Type](using QuoteContext) = { summonExpr[Ordering[T]] match { case Some(ord) => '{ new TreeSet[T]()($ord) } case _ => '{ new HashSet[T] } @@ -17,7 +17,7 @@ class B inline def g = ${ gImpl } -def gImpl with QuoteContext = { +def gImpl(using QuoteContext) = { if (summonExpr[A].isDefined) '{ println("A") } else if (summonExpr[B].isDefined) '{ println("B") } else throw new MatchError("") diff --git a/tests/run-macros/quote-impure-by-name/quoted_1.scala b/tests/run-macros/quote-impure-by-name/quoted_1.scala index e75743d1d6a5..e324b5ae6f94 100644 --- a/tests/run-macros/quote-impure-by-name/quoted_1.scala +++ b/tests/run-macros/quote-impure-by-name/quoted_1.scala @@ -11,7 +11,7 @@ object Index { implicit inline def succ[K, H, T](implicit inline prev: Index[K, T]): Index[K, (H, T)] = ${ succImpl[K, H, T]('prev) } - def succImpl[K: Type, H: Type, T: Type](prev: Expr[Index[K, T]]) with QuoteContext : Expr[Index[K, (H, T)]] = { + def succImpl[K: Type, H: Type, T: Type](prev: Expr[Index[K, T]])(using QuoteContext): Expr[Index[K, (H, T)]] = { val value = s"1 + {${prev.show}}" '{new Index(${value})} } diff --git a/tests/run-macros/quote-indexed-map-by-name/quoted_1.scala b/tests/run-macros/quote-indexed-map-by-name/quoted_1.scala index d2a8cd9652f9..bb89353a23c0 100644 --- a/tests/run-macros/quote-indexed-map-by-name/quoted_1.scala +++ b/tests/run-macros/quote-indexed-map-by-name/quoted_1.scala @@ -7,7 +7,7 @@ object Index { implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ${succImpl('[K], '[H], '[T])} - def succImpl[K, H, T](k: Type[K], h: Type[H], t: Type[T]) with QuoteContext : Expr[Index[K, (H, T)]] = { + def succImpl[K, H, T](k: Type[K], h: Type[H], t: Type[T])(using QuoteContext): Expr[Index[K, (H, T)]] = { implicit val kk: Type[K] = k implicit val hh: Type[H] = h implicit val tt: Type[T] = t diff --git a/tests/run-macros/quote-inline-function/quoted_1.scala b/tests/run-macros/quote-inline-function/quoted_1.scala index 345e699b36b1..2a647795a13e 100644 --- a/tests/run-macros/quote-inline-function/quoted_1.scala +++ b/tests/run-macros/quote-inline-function/quoted_1.scala @@ -7,7 +7,7 @@ object Macros { inline def foreach2(start: Int, end: Int, f: => Int => Unit): String = ${impl('start, 'end, 'f)} inline def foreach3(start: Int, end: Int, inline f: Int => Unit): String = ${impl('start, 'end, 'f)} - def impl(start: Expr[Int], end: Expr[Int], f: Expr[Int => Unit]) with (qctx: QuoteContext) : Expr[String] = { + def impl(start: Expr[Int], end: Expr[Int], f: Expr[Int => Unit])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} val res = '{ var i = $start diff --git a/tests/run-macros/quote-matcher-power/Macro_1.scala b/tests/run-macros/quote-matcher-power/Macro_1.scala index 0d857a995c93..d44e957b70b3 100644 --- a/tests/run-macros/quote-matcher-power/Macro_1.scala +++ b/tests/run-macros/quote-matcher-power/Macro_1.scala @@ -3,10 +3,10 @@ import scala.quoted.matching._ object Macros { - def power_s(x: Expr[Double], n: Expr[Int]) with QuoteContext : Expr[Double] = + def power_s(x: Expr[Double], n: Expr[Int]) (using QuoteContext): Expr[Double] = power_s(x, n.value) - def power_s(x: Expr[Double], n: Int) with QuoteContext : Expr[Double] = + def power_s(x: Expr[Double], n: Int) (using QuoteContext): Expr[Double] = if (n == 0) '{1.0} else if (n % 2 == 1) '{ $x * ${power_s(x, n - 1)} } else '{ val y = $x * $x; ${power_s('y, n / 2)} } @@ -19,7 +19,7 @@ object Macros { inline def rewrite(expr: => Double): Double = ${rewrite('expr)} // simple, 1-level, non-recursive rewriter for exponents - def rewrite(expr: Expr[Double]) with QuoteContext : Expr[Double] = { + def rewrite(expr: Expr[Double]) (using QuoteContext): Expr[Double] = { val res = expr match { // product rule case '{ power2($a, $x) * power2($b, $y)} if a.matches(b) => '{ power2($a, $x + $y) } diff --git a/tests/run-macros/quote-matcher-runtime/quoted_1.scala b/tests/run-macros/quote-matcher-runtime/quoted_1.scala index 3fec31faaf26..bf007b939411 100644 --- a/tests/run-macros/quote-matcher-runtime/quoted_1.scala +++ b/tests/run-macros/quote-matcher-runtime/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { inline def matches[A, B](inline a: A, inline b: B): Unit = ${impl('a, 'b)} - private def impl[A, B](a: Expr[A], b: Expr[B]) with (qctx: QuoteContext) : Expr[Unit] = { + private def impl[A, B](a: Expr[A], b: Expr[B])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{Bind => _, given, _} val res = scala.internal.quoted.Expr.unapply[Tuple, Tuple](a)(b, true, qctx).map { tup => 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 559ca528646f..fea93a1fce7e 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 @@ -6,7 +6,7 @@ object Macros { inline def (self: => StringContext) xyz(inline args: String*): String = ${impl('self, 'args)} - private def impl(self: Expr[StringContext], args: Expr[Seq[String]]) with QuoteContext : Expr[String] = { + private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = { (self, args) match { case ('{ StringContext(${ExprSeq(parts)}: _*) }, ExprSeq(args1)) => val strParts = parts.map { case Const(str) => str.reverse } 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 0d9bbaf24b10..121d2cb8fbf1 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 @@ -6,7 +6,7 @@ object Macros { inline def (self: => StringContext) S(args: => String*): String = ${impl('self, 'args)} - private def impl(self: Expr[StringContext], args: Expr[Seq[String]]) with QuoteContext : Expr[String] = { + private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = { self match { case '{ StringContext(${ConstSeq(parts)}: _*) } => val upprerParts: List[String] = parts.toList.map(_.toUpperCase) 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 1308c771f4eb..128d551a34b6 100644 --- a/tests/run-macros/quote-matcher-string-interpolator/quoted_1.scala +++ b/tests/run-macros/quote-matcher-string-interpolator/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { inline def (self: => StringContext) xyz(args: => String*): String = ${impl('self, 'args)} - private def impl(self: Expr[StringContext], args: Expr[Seq[String]]) with QuoteContext : Expr[String] = { + private def impl(self: Expr[StringContext], args: Expr[Seq[String]])(using QuoteContext): Expr[String] = { self match { case '{ StringContext(${ExprSeq(parts)}: _*) } => val parts2 = Expr.ofList(parts.map(x => '{ $x.reverse })) diff --git a/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala index bd8e6478fc30..50544a59c0e9 100644 --- a/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { inline def lift[T](sym: Symantics[T])(a: => DSL): T = ${impl[T]('sym, 'a)} - private def impl[T: Type](sym: Expr[Symantics[T]], a: Expr[DSL]) with (qctx: QuoteContext) : Expr[T] = { + private def impl[T: Type](sym: Expr[Symantics[T]], a: Expr[DSL])(using qctx: QuoteContext): Expr[T] = { def lift(e: Expr[DSL]): Expr[T] = e match { diff --git a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala index 0d91c315285c..00157f24324f 100644 --- a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala @@ -10,7 +10,7 @@ object Macros { inline def liftAST(a: => DSL): ASTNum = ${impl(ASTNum, 'a)} - private def impl[T: Type](sym: Symantics[T], a: Expr[DSL]) with (qctx: QuoteContext) : Expr[T] = { + private def impl[T: Type](sym: Symantics[T], a: Expr[DSL])(using qctx: QuoteContext): Expr[T] = { def lift(e: Expr[DSL])(implicit env: Map[Int, Expr[T]]): Expr[T] = e match { @@ -55,7 +55,7 @@ object Macros { } -def freshEnvVar() with QuoteContext : (Int, Expr[DSL]) = { +def freshEnvVar()(using QuoteContext): (Int, Expr[DSL]) = { v += 1 (v, '{envVar(${Expr(v)})}) } @@ -77,35 +77,35 @@ case class LitDSL(x: Int) extends DSL // trait Symantics[Num] { - def value(x: Int) with QuoteContext : Expr[Num] - def plus(x: Expr[Num], y: Expr[Num]) with QuoteContext : Expr[Num] - def times(x: Expr[Num], y: Expr[Num]) with QuoteContext : Expr[Num] - def app(f: Expr[Num => Num], x: Expr[Num]) with QuoteContext : Expr[Num] - def lam(body: Expr[Num] => Expr[Num]) with QuoteContext : Expr[Num => Num] + def value(x: Int)(using QuoteContext): Expr[Num] + def plus(x: Expr[Num], y: Expr[Num])(using QuoteContext): Expr[Num] + def times(x: Expr[Num], y: Expr[Num])(using QuoteContext): Expr[Num] + def app(f: Expr[Num => Num], x: Expr[Num])(using QuoteContext): Expr[Num] + def lam(body: Expr[Num] => Expr[Num])(using QuoteContext): Expr[Num => Num] } object StringNum extends Symantics[String] { - def value(x: Int) with QuoteContext : Expr[String] = Expr(x.toString) - def plus(x: Expr[String], y: Expr[String]) with QuoteContext : Expr[String] = '{ s"${$x} + ${$y}" } // '{ x + " + " + y } - def times(x: Expr[String], y: Expr[String]) with QuoteContext : Expr[String] = '{ s"${$x} * ${$y}" } - def app(f: Expr[String => String], x: Expr[String]) with QuoteContext : Expr[String] = Expr.betaReduce(f)(x) - def lam(body: Expr[String] => Expr[String]) with QuoteContext : Expr[String => String] = '{ (x: String) => ${body('x)} } + def value(x: Int)(using QuoteContext): Expr[String] = Expr(x.toString) + def plus(x: Expr[String], y: Expr[String])(using QuoteContext): Expr[String] = '{ s"${$x} + ${$y}" } // '{ x + " + " + y } + def times(x: Expr[String], y: Expr[String])(using QuoteContext): Expr[String] = '{ s"${$x} * ${$y}" } + def app(f: Expr[String => String], x: Expr[String])(using QuoteContext): Expr[String] = Expr.betaReduce(f)(x) + def lam(body: Expr[String] => Expr[String])(using QuoteContext): Expr[String => String] = '{ (x: String) => ${body('x)} } } object ComputeNum extends Symantics[Int] { - def value(x: Int) with QuoteContext : Expr[Int] = Expr(x) - def plus(x: Expr[Int], y: Expr[Int]) with QuoteContext : Expr[Int] = '{ $x + $y } - def times(x: Expr[Int], y: Expr[Int]) with QuoteContext : Expr[Int] = '{ $x * $y } - def app(f: Expr[Int => Int], x: Expr[Int]) with QuoteContext : Expr[Int] = '{ $f($x) } - def lam(body: Expr[Int] => Expr[Int]) with QuoteContext : Expr[Int => Int] = '{ (x: Int) => ${body('x)} } + def value(x: Int)(using QuoteContext): Expr[Int] = Expr(x) + def plus(x: Expr[Int], y: Expr[Int])(using QuoteContext): Expr[Int] = '{ $x + $y } + def times(x: Expr[Int], y: Expr[Int])(using QuoteContext): Expr[Int] = '{ $x * $y } + def app(f: Expr[Int => Int], x: Expr[Int])(using QuoteContext): Expr[Int] = '{ $f($x) } + def lam(body: Expr[Int] => Expr[Int])(using QuoteContext): Expr[Int => Int] = '{ (x: Int) => ${body('x)} } } object ASTNum extends Symantics[ASTNum] { - def value(x: Int) with QuoteContext : Expr[ASTNum] = '{ LitAST(${Expr(x)}) } - def plus(x: Expr[ASTNum], y: Expr[ASTNum]) with QuoteContext : Expr[ASTNum] = '{ PlusAST($x, $y) } - def times(x: Expr[ASTNum], y: Expr[ASTNum]) with QuoteContext : Expr[ASTNum] = '{ TimesAST($x, $y) } - def app(f: Expr[ASTNum => ASTNum], x: Expr[ASTNum]) with QuoteContext : Expr[ASTNum] = '{ AppAST($f, $x) } - def lam(body: Expr[ASTNum] => Expr[ASTNum]) with QuoteContext : Expr[ASTNum => ASTNum] = '{ (x: ASTNum) => ${body('x)} } + def value(x: Int)(using QuoteContext): Expr[ASTNum] = '{ LitAST(${Expr(x)}) } + def plus(x: Expr[ASTNum], y: Expr[ASTNum])(using QuoteContext): Expr[ASTNum] = '{ PlusAST($x, $y) } + def times(x: Expr[ASTNum], y: Expr[ASTNum])(using QuoteContext): Expr[ASTNum] = '{ TimesAST($x, $y) } + def app(f: Expr[ASTNum => ASTNum], x: Expr[ASTNum])(using QuoteContext): Expr[ASTNum] = '{ AppAST($f, $x) } + def lam(body: Expr[ASTNum] => Expr[ASTNum])(using QuoteContext): Expr[ASTNum => ASTNum] = '{ (x: ASTNum) => ${body('x)} } } trait ASTNum diff --git a/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala index 01bc7d9e029f..94615a355612 100644 --- a/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala @@ -8,17 +8,17 @@ object Macros { inline def lift[R[_]](sym: Symantics { type Repr = R })(a: => Int): R[Int] = ${impl('sym, 'a)} - private def impl[R[_]: Type](sym: Expr[Symantics { type Repr[X] = R[X] }], expr: Expr[Int]) with QuoteContext : Expr[R[Int]] = { + private def impl[R[_]: Type](sym: Expr[Symantics { type Repr[X] = R[X] }], expr: Expr[Int])(using QuoteContext): Expr[R[Int]] = { type Env = Map[Int, Any] given ev0 as Env = Map.empty - def envWith[T](id: Int, ref: Expr[R[T]]) with (env: Env) : Env = + def envWith[T](id: Int, ref: Expr[R[T]])(using env: Env): Env = env.updated(id, ref) object FromEnv { - def unapply[T](e: Expr[Any]) with (env: Env) : Option[Expr[R[T]]] = + def unapply[T](e: Expr[Any])(using env: Env): Option[Expr[R[T]]] = e match case '{envVar[$t](${Const(id)})} => env.get(id).asInstanceOf[Option[Expr[R[T]]]] // We can only add binds that have the same type as the refs @@ -26,7 +26,7 @@ object Macros { None } - def lift[T: Type](e: Expr[T]) with (env: Env) : Expr[R[T]] = ((e: Expr[Any]) match { + def lift[T: Type](e: Expr[T])(using env: Env): Expr[R[T]] = ((e: Expr[Any]) match { case Const(e: Int) => '{ $sym.int(${Expr(e)}).asInstanceOf[R[T]] } case Const(e: Boolean) => '{ $sym.bool(${Expr(e)}).asInstanceOf[R[T]] } @@ -48,17 +48,17 @@ object Macros { case '{ (x0: Int) => ($bodyFn: Int => Any)(x0) } => val (i, nEnvVar) = freshEnvVar[Int]() val body2 = UnsafeExpr.open(bodyFn) { (body1, close) => close(body1)(nEnvVar) } - '{ $sym.lam((x: R[Int]) => ${given Env = envWith(i, 'x).with(env); lift(body2)}).asInstanceOf[R[T]] } + '{ $sym.lam((x: R[Int]) => ${given Env = envWith(i, 'x)(using env); lift(body2)}).asInstanceOf[R[T]] } case '{ (x0: Boolean) => ($bodyFn: Boolean => Any)(x0) } => val (i, nEnvVar) = freshEnvVar[Boolean]() val body2 = UnsafeExpr.open(bodyFn) { (body1, close) => close(body1)(nEnvVar) } - '{ $sym.lam((x: R[Boolean]) => ${given Env = envWith(i, 'x).with(env); lift(body2)}).asInstanceOf[R[T]] } + '{ $sym.lam((x: R[Boolean]) => ${given Env = envWith(i, 'x)(using env); lift(body2)}).asInstanceOf[R[T]] } case '{ (x0: Int => Int) => ($bodyFn: (Int => Int) => Any)(x0) } => val (i, nEnvVar) = freshEnvVar[Int => Int]() val body2 = UnsafeExpr.open(bodyFn) { (body1, close) => close(body1)(nEnvVar) } - '{ $sym.lam((x: R[Int => Int]) => ${given Env = envWith(i, 'x).with(env); lift(body2)}).asInstanceOf[R[T]] } + '{ $sym.lam((x: R[Int => Int]) => ${given Env = envWith(i, 'x)(using env); lift(body2)}).asInstanceOf[R[T]] } case '{ Symantics.fix[$t, $u]($f) } => '{ $sym.fix[$t, $u]((x: R[$t => $u]) => $sym.app(${lift(f)}, x)).asInstanceOf[R[T]] } @@ -76,7 +76,7 @@ object Macros { } -def freshEnvVar[T: Type]() with QuoteContext : (Int, Expr[T]) = { +def freshEnvVar[T: Type]()(using QuoteContext): (Int, Expr[T]) = { v += 1 (v, '{envVar[T](${Expr(v)})}) } diff --git a/tests/run-macros/quote-matcher-type-bind/Macro_1.scala b/tests/run-macros/quote-matcher-type-bind/Macro_1.scala index d3ed25fffb0c..63f7e06adeb7 100644 --- a/tests/run-macros/quote-matcher-type-bind/Macro_1.scala +++ b/tests/run-macros/quote-matcher-type-bind/Macro_1.scala @@ -5,7 +5,7 @@ object Macros { inline def swapFandG(x: => Unit): Unit = ${impl('x)} - private def impl(x: Expr[Unit]) with QuoteContext : Expr[Unit] = { + private def impl(x: Expr[Unit])(using QuoteContext): Expr[Unit] = { x match { case '{ DSL.f[$t]($x) } => '{ DSL.g[$t]($x) } case '{ DSL.g[$t]($x) } => '{ DSL.f[$t]($x) } diff --git a/tests/run-macros/quote-matching-open/Macro_1.scala b/tests/run-macros/quote-matching-open/Macro_1.scala index 999c7140e99f..755c92e3e634 100644 --- a/tests/run-macros/quote-matching-open/Macro_1.scala +++ b/tests/run-macros/quote-matching-open/Macro_1.scala @@ -4,7 +4,7 @@ object Macro { inline def openTest(x: => Any): Any = ${ Macro.impl('x) } - def impl(x: Expr[Any]) with QuoteContext : Expr[Any] = { + def impl(x: Expr[Any])(using QuoteContext): Expr[Any] = { x match { case '{ (x: Int) => ($body: Int => Int)(x) } => UnsafeExpr.open(body) { (body, close) => close(body)(Expr(2)) } case '{ (x1: Int, x2: Int) => ($body: (Int, Int) => Int)(x1, x2) } => UnsafeExpr.open(body) { (body, close) => close(body)(Expr(2), Expr(3)) } diff --git a/tests/run-macros/quote-matching-optimize-1/Macro_1.scala b/tests/run-macros/quote-matching-optimize-1/Macro_1.scala index c788e089de21..0319a8614619 100644 --- a/tests/run-macros/quote-matching-optimize-1/Macro_1.scala +++ b/tests/run-macros/quote-matching-optimize-1/Macro_1.scala @@ -5,7 +5,7 @@ object Macro { inline def optimize[T](inline x: T): Any = ${ Macro.impl('x) } - def impl[T: Type](x: Expr[T]) with QuoteContext : Expr[Any] = { + def impl[T: Type](x: Expr[T])(using QuoteContext): Expr[Any] = { def optimize(x: Expr[Any]): Expr[Any] = x match { case '{ type $t; ($ls: List[`$t`]).filter($f).filter($g) } => diff --git a/tests/run-macros/quote-matching-optimize-2/Macro_1.scala b/tests/run-macros/quote-matching-optimize-2/Macro_1.scala index a0b24f4ccde0..fe5614606f60 100644 --- a/tests/run-macros/quote-matching-optimize-2/Macro_1.scala +++ b/tests/run-macros/quote-matching-optimize-2/Macro_1.scala @@ -7,7 +7,7 @@ object Macro { inline def optimize[T](inline x: T): Any = ${ Macro.impl('x) } - def impl[T: Type](x: Expr[T]) with QuoteContext : Expr[Any] = { + def impl[T: Type](x: Expr[T])(using QuoteContext): Expr[Any] = { def optimize(x: Expr[Any]): Expr[Any] = x match { case '{ ($ls: List[$t]).filter($f).filter($g) } => diff --git a/tests/run-macros/quote-matching-optimize-3/Macro_1.scala b/tests/run-macros/quote-matching-optimize-3/Macro_1.scala index aa08354b1b10..9e11235232f2 100644 --- a/tests/run-macros/quote-matching-optimize-3/Macro_1.scala +++ b/tests/run-macros/quote-matching-optimize-3/Macro_1.scala @@ -7,7 +7,7 @@ object Macro { inline def optimize[T](inline x: T): Any = ${ Macro.impl('x) } - def impl[T: Type](x: Expr[T]) with QuoteContext : Expr[Any] = { + def impl[T: Type](x: Expr[T])(using QuoteContext): Expr[Any] = { def optimize(x: Expr[Any]): Expr[Any] = x match { case '{ ($ls: List[$t]).filter($f).filter($g) } => diff --git a/tests/run-macros/quote-sep-comp-2/Macro_1.scala b/tests/run-macros/quote-sep-comp-2/Macro_1.scala index e37641646299..e9c94843dc9e 100644 --- a/tests/run-macros/quote-sep-comp-2/Macro_1.scala +++ b/tests/run-macros/quote-sep-comp-2/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macros { - def assertImpl(expr: Expr[Boolean]) with QuoteContext = '{ println($expr) } + def assertImpl(expr: Expr[Boolean])(using QuoteContext) = '{ println($expr) } } diff --git a/tests/run-macros/quote-sep-comp/Macro_1.scala b/tests/run-macros/quote-sep-comp/Macro_1.scala index f709ac0a532c..33e9b0f2ed4e 100644 --- a/tests/run-macros/quote-sep-comp/Macro_1.scala +++ b/tests/run-macros/quote-sep-comp/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macros { inline def assert2(expr: => Boolean): Unit = ${ assertImpl('expr) } - def assertImpl(expr: Expr[Boolean]) with QuoteContext = '{ println($expr) } + def assertImpl(expr: Expr[Boolean])(using QuoteContext) = '{ println($expr) } } diff --git a/tests/run-macros/quote-simple-macro/quoted_1.scala b/tests/run-macros/quote-simple-macro/quoted_1.scala index 52627d77062e..ea0335bb999d 100644 --- a/tests/run-macros/quote-simple-macro/quoted_1.scala +++ b/tests/run-macros/quote-simple-macro/quoted_1.scala @@ -3,5 +3,5 @@ import scala.quoted.autolift.{given _} object Macros { inline def foo(inline i: Int, dummy: Int, j: Int): Int = ${ bar('i, 'j) } - def bar(x: Expr[Int], y: Expr[Int]) with QuoteContext : Expr[Int] = '{ ${x.value} + $y } + def bar(x: Expr[Int], y: Expr[Int]) (using QuoteContext): Expr[Int] = '{ ${x.value} + $y } } diff --git a/tests/run-macros/quote-toExprOfSeq/Macro_1.scala b/tests/run-macros/quote-toExprOfSeq/Macro_1.scala index 88b5a356002a..5483aaedef1f 100644 --- a/tests/run-macros/quote-toExprOfSeq/Macro_1.scala +++ b/tests/run-macros/quote-toExprOfSeq/Macro_1.scala @@ -3,6 +3,6 @@ import scala.quoted.{given _} inline def seq = ${fooImpl} -def fooImpl with (qctx: QuoteContext) = { +def fooImpl(using qctx: QuoteContext) = { Expr.ofSeq(List('{1}, '{2}, '{3})) } diff --git a/tests/run-macros/quote-toExprOfTuple/Macro_1.scala b/tests/run-macros/quote-toExprOfTuple/Macro_1.scala index 0dd47ec8d38a..4f2e527d8f1b 100644 --- a/tests/run-macros/quote-toExprOfTuple/Macro_1.scala +++ b/tests/run-macros/quote-toExprOfTuple/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Macro { inline def t2[T0, T1](t0: T0, t1: T1): (T0, T1) = ${ impl2('{t0}, '{t1}) } - def impl2[T0: Type, T1: Type](t0: Expr[T0], t1: Expr[T1]) with (qctx: QuoteContext) : Expr[(T0, T1)] = { + def impl2[T0: Type, T1: Type](t0: Expr[T0], t1: Expr[T1])(using qctx: QuoteContext) : Expr[(T0, T1)] = { import qctx.tasty.{_, given _} import util._ diff --git a/tests/run-macros/quote-type-matcher-2/quoted_1.scala b/tests/run-macros/quote-type-matcher-2/quoted_1.scala index e3360eef133c..d11f5221e25a 100644 --- a/tests/run-macros/quote-type-matcher-2/quoted_1.scala +++ b/tests/run-macros/quote-type-matcher-2/quoted_1.scala @@ -4,7 +4,7 @@ object Macros { inline def lift[A]: String = ${ matchesExpr('[A]) } - private def matchesExpr(tp: Type[_]) with QuoteContext : Expr[String] = { + private def matchesExpr(tp: Type[_])(using QuoteContext): Expr[String] = { def lift(tp: Type[_]): String = tp match { case '[Int] => "%Int%" case '[List[$t]] => s"%List[${lift(t)}]%" diff --git a/tests/run-macros/quote-type-matcher/quoted_1.scala b/tests/run-macros/quote-type-matcher/quoted_1.scala index 425dc5948e78..795f53b2282c 100644 --- a/tests/run-macros/quote-type-matcher/quoted_1.scala +++ b/tests/run-macros/quote-type-matcher/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { inline def matches[A, B]: Unit = ${ matchesExpr('[A], '[B]) } - private def matchesExpr[A, B](a: Type[A], b: Type[B]) with (qctx: QuoteContext) : Expr[Unit] = { + private def matchesExpr[A, B](a: Type[A], b: Type[B])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{Bind => _, given, _} val res = scala.internal.quoted.Type.unapply[Tuple, Tuple](a)(b, true, qctx).map { tup => diff --git a/tests/run-macros/quote-unrolled-foreach/quoted_1.scala b/tests/run-macros/quote-unrolled-foreach/quoted_1.scala index 37f0e4b649a9..3254e6b32a71 100644 --- a/tests/run-macros/quote-unrolled-foreach/quoted_1.scala +++ b/tests/run-macros/quote-unrolled-foreach/quoted_1.scala @@ -7,10 +7,10 @@ object Macro { inline def unrolledForeach(inline unrollSize: Int, seq: Array[Int])(f: => Int => Unit): Unit = // or f: Int => Unit ${unrolledForeachImpl('unrollSize, 'seq, 'f)} - private def unrolledForeachImpl(unrollSizeExpr: Expr[Int], seq: Expr[Array[Int]], f: Expr[Int => Unit]) with QuoteContext : Expr[Unit] = + private def unrolledForeachImpl(unrollSizeExpr: Expr[Int], seq: Expr[Array[Int]], f: Expr[Int => Unit]) (using QuoteContext): Expr[Unit] = unrolledForeachImpl(unrollSizeExpr.value, seq, f) - private def unrolledForeachImpl(unrollSize: Int, seq: Expr[Array[Int]], f: Expr[Int => Unit]) with QuoteContext : Expr[Unit] = '{ + private def unrolledForeachImpl(unrollSize: Int, seq: Expr[Array[Int]], f: Expr[Int => Unit])(using QuoteContext): Expr[Unit] = '{ val size = $seq.length assert(size % (${unrollSize}) == 0) // for simplicity of the implementation var i = 0 diff --git a/tests/run-macros/quote-whitebox/Macro_1.scala b/tests/run-macros/quote-whitebox/Macro_1.scala index 7ea1a14b76a3..50ab2371b8c6 100644 --- a/tests/run-macros/quote-whitebox/Macro_1.scala +++ b/tests/run-macros/quote-whitebox/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macros { inline def defaultOf(inline str: String) <: Any = ${ defaultOfImpl('str) } - def defaultOfImpl(str: Expr[String]) with QuoteContext : Expr[Any] = str.value match { + def defaultOfImpl(str: Expr[String]) (using QuoteContext): Expr[Any] = str.value match { case "int" => '{1} case "string" => '{"a"} } diff --git a/tests/run-macros/quoted-expr-block/quoted_1.scala b/tests/run-macros/quoted-expr-block/quoted_1.scala index bc60399f820e..0e8868b98ffe 100644 --- a/tests/run-macros/quoted-expr-block/quoted_1.scala +++ b/tests/run-macros/quoted-expr-block/quoted_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ inline def replicate(inline times: Int, code: => Any) = ${replicateImpl('times, 'code)} -private def replicateImpl(times: Expr[Int], code: Expr[Any]) with QuoteContext = { +private def replicateImpl(times: Expr[Int], code: Expr[Any]) (using QuoteContext)= { @annotation.tailrec def loop(n: Int, accum: List[Expr[Any]]): List[Expr[Any]] = if (n > 0) loop(n - 1, code :: accum) else accum Expr.block(loop(times.value, Nil), '{}) 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 dc537fe09b4a..d9f01311b070 100644 --- a/tests/run-macros/quoted-matching-docs-2/Macro_1.scala +++ b/tests/run-macros/quoted-matching-docs-2/Macro_1.scala @@ -6,10 +6,10 @@ def sum(args: Int*): Int = args.sum inline def showOptimize(arg: Int): String = ${ showOptimizeExpr('arg) } inline def optimize(arg: Int): Int = ${ optimizeExpr('arg) } -private def showOptimizeExpr(body: Expr[Int]) with QuoteContext : Expr[String] = +private def showOptimizeExpr(body: Expr[Int])(using QuoteContext): Expr[String] = Expr(optimizeExpr(body).show) -private def optimizeExpr(body: Expr[Int]) with QuoteContext : Expr[Int] = body match { +private def optimizeExpr(body: Expr[Int])(using QuoteContext): Expr[Int] = body match { // Match a call to sum without any arguments case '{ sum() } => Expr(0) // Match a call to sum with an argument $n of type Int. n will be the Expr[Int] representing the argument. @@ -19,7 +19,7 @@ private def optimizeExpr(body: Expr[Int]) with QuoteContext : Expr[Int] = body m case body => body } -private def sumExpr(args1: Seq[Expr[Int]]) with QuoteContext : Expr[Int] = { +private def sumExpr(args1: Seq[Expr[Int]])(using QuoteContext): Expr[Int] = { def flatSumArgs(arg: Expr[Int]): Seq[Expr[Int]] = arg match { case '{ sum(${ExprSeq(subArgs)}: _*) } => subArgs.flatMap(flatSumArgs) case arg => Seq(arg) diff --git a/tests/run-macros/quoted-matching-docs/Macro_1.scala b/tests/run-macros/quoted-matching-docs/Macro_1.scala index 00852b23d3f2..627ed02e996f 100644 --- a/tests/run-macros/quoted-matching-docs/Macro_1.scala +++ b/tests/run-macros/quoted-matching-docs/Macro_1.scala @@ -6,10 +6,10 @@ inline def sum(args: Int*): Int = ${ sumExpr('args) } inline def sumShow(args: Int*): String = ${ sumExprShow('args) } -private def sumExprShow(argsExpr: Expr[Seq[Int]]) with QuoteContext : Expr[String] = +private def sumExprShow(argsExpr: Expr[Seq[Int]]) (using QuoteContext): Expr[String] = Expr(sumExpr(argsExpr).show) -private def sumExpr(argsExpr: Expr[Seq[Int]]) with (qctx: QuoteContext) : Expr[Int] = { +private def sumExpr(argsExpr: Expr[Seq[Int]])(using qctx: QuoteContext) : Expr[Int] = { import qctx.tasty.{given _, _} UnsafeExpr.underlyingArgument(argsExpr) match { case ConstSeq(args) => // args is of type Seq[Int] diff --git a/tests/run-macros/quoted-pattern-open-expr/Macro_1.scala b/tests/run-macros/quoted-pattern-open-expr/Macro_1.scala index 2bc1b3f8eddb..c6b05434c9a3 100644 --- a/tests/run-macros/quoted-pattern-open-expr/Macro_1.scala +++ b/tests/run-macros/quoted-pattern-open-expr/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ inline def test(e: Int): String = ${testExpr('e)} -private def testExpr(e: Expr[Int]) with QuoteContext : Expr[String] = { +private def testExpr(e: Expr[Int])(using QuoteContext): Expr[String] = { e match { case '{ val y: Int = 4; $body } => Expr("Matched closed\n" + body.show) case '{ val y: Int = 4; ($body: Int => Int)(y) } => Expr("Matched open\n" + body.show) diff --git a/tests/run-macros/quoted-pattern-type/Macro_1.scala b/tests/run-macros/quoted-pattern-type/Macro_1.scala index 826f059f491e..11aa24e866d3 100644 --- a/tests/run-macros/quoted-pattern-type/Macro_1.scala +++ b/tests/run-macros/quoted-pattern-type/Macro_1.scala @@ -4,7 +4,7 @@ object Lib { inline def foo[T](arg: => T): T = ${ impl('arg) } - private def impl[T: Type](arg: Expr[T]) with QuoteContext : Expr[T] = { + private def impl[T: Type](arg: Expr[T])(using QuoteContext): Expr[T] = { arg match { case e @ '{ $x: Boolean } => '{ println("Boolean: " + $e); $e } case e @ '{ $x: Int } => '{ println("Int: " + $x); $x } diff --git a/tests/run-macros/refined-selectable-macro/Macro_1.scala b/tests/run-macros/refined-selectable-macro/Macro_1.scala index 8f229701afcf..42454e9968b3 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 { inline def fromTuple[T <: Tuple](s: T) <: Any = ${ fromTupleImpl('s, '{ (x: Array[(String, Any)]) => fromUntypedTuple(x: _*) } ) } } - private def toTupleImpl(s: Expr[Selectable]) with (qctx:QuoteContext) : Expr[Tuple] = { + private def toTupleImpl(s: Expr[Selectable])(using qctx:QuoteContext) : Expr[Tuple] = { import qctx.tasty.{given _, _} val repr = s.unseal.tpe.widenTermRefExpr.dealias @@ -45,7 +45,7 @@ object Macro { Expr.ofTuple(ret) } - private def fromTupleImpl[T: Type](s: Expr[Tuple], newRecord: Expr[Array[(String, Any)] => T]) with (qctx:QuoteContext) : Expr[Any] = { + private def fromTupleImpl[T: Type](s: Expr[Tuple], newRecord: Expr[Array[(String, Any)] => T])(using qctx:QuoteContext) : Expr[Any] = { import qctx.tasty.{given _, _} val repr = s.unseal.tpe.widenTermRefExpr.dealias diff --git a/tests/run-macros/refined-selectable-macro/Macro_2.scala b/tests/run-macros/refined-selectable-macro/Macro_2.scala index 40154c1c7a98..cccfcc74e44c 100644 --- a/tests/run-macros/refined-selectable-macro/Macro_2.scala +++ b/tests/run-macros/refined-selectable-macro/Macro_2.scala @@ -16,7 +16,7 @@ object Macro2 { inline def apply[R <: Record](elems: (String, Any)*) : R = ${ applyImpl('elems, '[R]) } - def applyImpl[R <: Record: Type](elems: Expr[Seq[(String, Any)]], ev: Type[R]) with (qctx: QuoteContext) = { + def applyImpl[R <: Record: Type](elems: Expr[Seq[(String, Any)]], ev: Type[R])(using qctx: QuoteContext) = { '{ new Record($elems:_*).asInstanceOf[$ev] } } diff --git a/tests/run-macros/reflect-dsl/assert_1.scala b/tests/run-macros/reflect-dsl/assert_1.scala index 218b5484af93..1c0fe6a5eab5 100644 --- a/tests/run-macros/reflect-dsl/assert_1.scala +++ b/tests/run-macros/reflect-dsl/assert_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } - def assertImpl(cond: Expr[Boolean], clue: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using qctx: QuoteContext): Expr[Unit] = { import qctx.tasty.{_, given _} import util._ diff --git a/tests/run-macros/reflect-inline/assert_1.scala b/tests/run-macros/reflect-inline/assert_1.scala index 6435d6760822..99de4445f349 100644 --- a/tests/run-macros/reflect-inline/assert_1.scala +++ b/tests/run-macros/reflect-inline/assert_1.scala @@ -4,13 +4,13 @@ object api { inline def (inline x: String) stripMargin: String = ${ stripImpl('x) } - private def stripImpl(x: Expr[String]) with (qctx: QuoteContext) : Expr[String] = + private def stripImpl(x: Expr[String])(using qctx: QuoteContext): Expr[String] = Expr(augmentString(x.value).stripMargin) inline def typeChecks(inline x: String): Boolean = ${ typeChecksImpl('{scala.compiletime.testing.typeChecks(x)}) } - private def typeChecksImpl(b: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Boolean] = { + private def typeChecksImpl(b: Expr[Boolean])(using qctx: QuoteContext): Expr[Boolean] = { if (b.value) Expr(true) else Expr(false) } } diff --git a/tests/run-macros/reflect-lambda/assert_1.scala b/tests/run-macros/reflect-lambda/assert_1.scala index c39768add34d..27dfd4233249 100644 --- a/tests/run-macros/reflect-lambda/assert_1.scala +++ b/tests/run-macros/reflect-lambda/assert_1.scala @@ -4,7 +4,7 @@ object lib { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } - def assertImpl(cond: Expr[Boolean], clue: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} import util._ diff --git a/tests/run-macros/reflect-pos-fun/assert_1.scala b/tests/run-macros/reflect-pos-fun/assert_1.scala index b89a7176f2b1..d350138ae14d 100644 --- a/tests/run-macros/reflect-pos-fun/assert_1.scala +++ b/tests/run-macros/reflect-pos-fun/assert_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition) } - def assertImpl(cond: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} import util._ diff --git a/tests/run-macros/reflect-select-constructor/assert_1.scala b/tests/run-macros/reflect-select-constructor/assert_1.scala index 566e4976321d..523069c25447 100644 --- a/tests/run-macros/reflect-select-constructor/assert_1.scala +++ b/tests/run-macros/reflect-select-constructor/assert_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } - def assertImpl(cond: Expr[Boolean], clue: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} import util._ diff --git a/tests/run-macros/reflect-select-copy-2/assert_1.scala b/tests/run-macros/reflect-select-copy-2/assert_1.scala index 32f35038ed9b..fc3424ead339 100644 --- a/tests/run-macros/reflect-select-copy-2/assert_1.scala +++ b/tests/run-macros/reflect-select-copy-2/assert_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } - def assertImpl(cond: Expr[Boolean], clue: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} import util._ diff --git a/tests/run-macros/reflect-select-copy/assert_1.scala b/tests/run-macros/reflect-select-copy/assert_1.scala index 66a724487def..5fd24b2d2f67 100644 --- a/tests/run-macros/reflect-select-copy/assert_1.scala +++ b/tests/run-macros/reflect-select-copy/assert_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } - def assertImpl(cond: Expr[Boolean], clue: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} cond.unseal.underlyingArgument match { diff --git a/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala b/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala index f62523b6f091..3dc5fe215850 100644 --- a/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala +++ b/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } - def assertImpl(cond: Expr[Boolean], clue: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} import util._ diff --git a/tests/run-macros/reflect-select-value-class/assert_1.scala b/tests/run-macros/reflect-select-value-class/assert_1.scala index 566e4976321d..523069c25447 100644 --- a/tests/run-macros/reflect-select-value-class/assert_1.scala +++ b/tests/run-macros/reflect-select-value-class/assert_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } - def assertImpl(cond: Expr[Boolean], clue: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} import util._ diff --git a/tests/run-macros/reflect-typeChecks/assert_1.scala b/tests/run-macros/reflect-typeChecks/assert_1.scala index 10e2921aa384..22a0d58e7570 100644 --- a/tests/run-macros/reflect-typeChecks/assert_1.scala +++ b/tests/run-macros/reflect-typeChecks/assert_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assertCompile(inline code: String): Unit = ${ assertImpl('code, '{compiletime.testing.typeChecks(code)}, true) } inline def assertNotCompile(inline code: String): Unit = ${ assertImpl('code, '{compiletime.testing.typeChecks(code)}, false) } - def assertImpl(code: Expr[String], actual: Expr[Boolean], expect: Boolean) with (qctx: QuoteContext) : Expr[Unit] = { + def assertImpl(code: Expr[String], actual: Expr[Boolean], expect: Boolean)(using qctx: QuoteContext) : Expr[Unit] = { '{ assert(${Expr(expect)} == $actual) } } } diff --git a/tests/run-macros/requiredSymbols/Macro_1.scala b/tests/run-macros/requiredSymbols/Macro_1.scala index 6e6dd9d92170..c047e65f9376 100644 --- a/tests/run-macros/requiredSymbols/Macro_1.scala +++ b/tests/run-macros/requiredSymbols/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macro { inline def foo: String = ${ fooImpl } - def fooImpl with (qctx: QuoteContext) : Expr[String] = { + def fooImpl(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{given _, _} val list = List( rootContext.requiredPackage("java"), diff --git a/tests/run-macros/string-context-implicits/Macro_1.scala b/tests/run-macros/string-context-implicits/Macro_1.scala index 03f72fda7b5c..24870d35c0b3 100644 --- a/tests/run-macros/string-context-implicits/Macro_1.scala +++ b/tests/run-macros/string-context-implicits/Macro_1.scala @@ -3,13 +3,13 @@ import scala.quoted.matching._ inline def (sc: StringContext) showMe(inline args: Any*): String = ${ showMeExpr('sc, 'args) } -private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]]) with (qctx: QuoteContext) : Expr[String] = { +private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext): Expr[String] = { argsExpr match { case ExprSeq(argExprs) => val argShowedExprs = argExprs.map { case '{ $arg: $tp } => val showTp = '[Show[$tp]] - summonExpr.with(showTp) match { + summonExpr(using showTp) match { case Some(showExpr) => '{ $showExpr.show($arg) } case None => qctx.error(s"could not find implicit for ${showTp.show}", arg); '{???} } diff --git a/tests/run-macros/tasty-argument-tree-1/quoted_1.scala b/tests/run-macros/tasty-argument-tree-1/quoted_1.scala index 1f99faecf950..96761552d7e2 100644 --- a/tests/run-macros/tasty-argument-tree-1/quoted_1.scala +++ b/tests/run-macros/tasty-argument-tree-1/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { inline def inspect[T](x: T): Unit = ${ impl('x) } - def impl[T](x: Expr[T]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl[T](x: Expr[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = x.unseal '{ diff --git a/tests/run-macros/tasty-construct-types/Macro_1.scala b/tests/run-macros/tasty-construct-types/Macro_1.scala index eabf07e8953f..f95e2e83bf88 100644 --- a/tests/run-macros/tasty-construct-types/Macro_1.scala +++ b/tests/run-macros/tasty-construct-types/Macro_1.scala @@ -11,9 +11,9 @@ object Macros { class TestAnnotation extends scala.annotation.Annotation - def theTestBlockImpl(given qctx : QuoteContext) : Expr[Unit] = { + def theTestBlockImpl(using qctx : QuoteContext) : Expr[Unit] = { import qctx.tasty.{_,given} - + val x1T = ConstantType(Constant(1)) val x2T = OrType(ConstantType(Constant(1)), ConstantType(Constant(2))) val x3T = AndType(ConstantType(Constant(3)), typeOf[Any]) diff --git a/tests/run-macros/tasty-create-method-symbol/Macro_1.scala b/tests/run-macros/tasty-create-method-symbol/Macro_1.scala index 8296d95f962b..ec9dd9f0ff84 100644 --- a/tests/run-macros/tasty-create-method-symbol/Macro_1.scala +++ b/tests/run-macros/tasty-create-method-symbol/Macro_1.scala @@ -4,7 +4,7 @@ object Macros { inline def theTestBlock : Unit = ${ theTestBlockImpl } - def theTestBlockImpl(given qctx: QuoteContext) : Expr[Unit] = { + def theTestBlockImpl(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_,given} // simple smoke test diff --git a/tests/run-macros/tasty-custom-show/quoted_1.scala b/tests/run-macros/tasty-custom-show/quoted_1.scala index e333856e171e..ab73326f1275 100644 --- a/tests/run-macros/tasty-custom-show/quoted_1.scala +++ b/tests/run-macros/tasty-custom-show/quoted_1.scala @@ -7,7 +7,7 @@ object Macros { implicit inline def printOwners[T](inline x: T): Unit = ${ impl('x) } - def impl[T](x: Expr[T]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl[T](x: Expr[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val buff = new StringBuilder @@ -38,7 +38,7 @@ object Macros { '{print(${buff.result()})} } - def dummyShow with (qctx: QuoteContext) : scala.tasty.reflect.Printer[qctx.tasty.type] = { + def dummyShow(using qctx: QuoteContext) : scala.tasty.reflect.Printer[qctx.tasty.type] = { new scala.tasty.reflect.Printer { val tasty = qctx.tasty import qctx.tasty.{_, given _} diff --git a/tests/run-macros/tasty-dealias/quoted_1.scala b/tests/run-macros/tasty-dealias/quoted_1.scala index 8cce8eaee86b..4cbd4213b293 100644 --- a/tests/run-macros/tasty-dealias/quoted_1.scala +++ b/tests/run-macros/tasty-dealias/quoted_1.scala @@ -4,7 +4,7 @@ object Macros { inline def dealias[T]: String = ${ impl('[T]) } - def impl[T](x: quoted.Type[T]) with (qctx: QuoteContext) : Expr[String] = { + def impl[T](x: quoted.Type[T])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} Expr(x.unseal.tpe.dealias.show) } diff --git a/tests/run-macros/tasty-definitions-1/quoted_1.scala b/tests/run-macros/tasty-definitions-1/quoted_1.scala index 234c5c50e7e9..aa54ddf036d4 100644 --- a/tests/run-macros/tasty-definitions-1/quoted_1.scala +++ b/tests/run-macros/tasty-definitions-1/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { inline def testDefinitions(): Unit = ${testDefinitionsImpl} - def testDefinitionsImpl with (qctx: QuoteContext) : Expr[Unit] = { + def testDefinitionsImpl(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val buff = List.newBuilder[String] diff --git a/tests/run-macros/tasty-eval/quoted_1.scala b/tests/run-macros/tasty-eval/quoted_1.scala index 835ed79b5717..12cb5fecd2ea 100644 --- a/tests/run-macros/tasty-eval/quoted_1.scala +++ b/tests/run-macros/tasty-eval/quoted_1.scala @@ -6,18 +6,18 @@ object Macros { implicit inline def foo(i: Int): String = ${ impl('i) } - def impl(i: Expr[Int]) with QuoteContext : Expr[String] = { + def impl(i: Expr[Int]) (using QuoteContext): Expr[String] = { value(i).toString } inline implicit def value[X](e: Expr[X])(implicit qctx: QuoteContext, ev: Valuable[X]): Option[X] = ev.value(e) trait Valuable[X] { - def value(e: Expr[X]) with QuoteContext : Option[X] + def value(e: Expr[X]) (using QuoteContext): Option[X] } implicit def intIsEvalable: Valuable[Int] = new Valuable[Int] { - override def value(e: Expr[Int]) with (qctx: QuoteContext) : Option[Int] = { + override def value(e: Expr[Int])(using qctx: QuoteContext) : Option[Int] = { import qctx.tasty.{_, given _} e.unseal.tpe match { diff --git a/tests/run-macros/tasty-extractors-1/quoted_1.scala b/tests/run-macros/tasty-extractors-1/quoted_1.scala index 383373ee03a3..ff18677803b1 100644 --- a/tests/run-macros/tasty-extractors-1/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-1/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { implicit inline def printTree[T](inline x: T): Unit = ${ impl('x) } - def impl[T](x: Expr[T]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl[T](x: Expr[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = x.unseal diff --git a/tests/run-macros/tasty-extractors-2/quoted_1.scala b/tests/run-macros/tasty-extractors-2/quoted_1.scala index 47c054ba36ee..bbc943adafbb 100644 --- a/tests/run-macros/tasty-extractors-2/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-2/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { implicit inline def printTree[T](inline x: T): Unit = ${ impl('x) } - def impl[T](x: Expr[T]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl[T](x: Expr[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = x.unseal diff --git a/tests/run-macros/tasty-extractors-3/quoted_1.scala b/tests/run-macros/tasty-extractors-3/quoted_1.scala index 7847e1b649f4..990ee97c476b 100644 --- a/tests/run-macros/tasty-extractors-3/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-3/quoted_1.scala @@ -7,7 +7,7 @@ object Macros { implicit inline def printTypes[T](inline x: T): Unit = ${impl('x)} - def impl[T](x: Expr[T]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl[T](x: Expr[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val buff = new StringBuilder diff --git a/tests/run-macros/tasty-extractors-constants-1/quoted_1.scala b/tests/run-macros/tasty-extractors-constants-1/quoted_1.scala index d0b70d9312b9..b012786ba319 100644 --- a/tests/run-macros/tasty-extractors-constants-1/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-constants-1/quoted_1.scala @@ -7,7 +7,7 @@ object Macros { implicit inline def testMacro: Unit = ${impl} - def impl with QuoteContext : Expr[Unit] = { + def impl(using QuoteContext): Expr[Unit] = { val buff = new StringBuilder def stagedPrintln(x: Any): Unit = buff append java.util.Objects.toString(x) append "\n" diff --git a/tests/run-macros/tasty-extractors-types/quoted_1.scala b/tests/run-macros/tasty-extractors-types/quoted_1.scala index d9dd8c34ed25..2d5f68f8d8c5 100644 --- a/tests/run-macros/tasty-extractors-types/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-types/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { implicit inline def printType[T]: Unit = ${ impl('[T]) } - def impl[T](x: Type[T]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl[T](x: Type[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = x.unseal diff --git a/tests/run-macros/tasty-getfile-implicit-fun-context/Macro_1.scala b/tests/run-macros/tasty-getfile-implicit-fun-context/Macro_1.scala index 99366348dccf..e24c79f82df8 100644 --- a/tests/run-macros/tasty-getfile-implicit-fun-context/Macro_1.scala +++ b/tests/run-macros/tasty-getfile-implicit-fun-context/Macro_1.scala @@ -4,7 +4,7 @@ import scala.quoted.autolift.{given _} object SourceFiles { type Macro[X] = QuoteContext ?=> Expr[X] - def tastyContext with (qctx: QuoteContext) : QuoteContext = qctx + def tastyContext(using qctx: QuoteContext): QuoteContext = qctx implicit inline def getThisFile: String = ${getThisFileImpl} diff --git a/tests/run-macros/tasty-getfile/Macro_1.scala b/tests/run-macros/tasty-getfile/Macro_1.scala index 470ee8912654..1a67e515e427 100644 --- a/tests/run-macros/tasty-getfile/Macro_1.scala +++ b/tests/run-macros/tasty-getfile/Macro_1.scala @@ -7,7 +7,7 @@ object SourceFiles { implicit inline def getThisFile: String = ${getThisFileImpl} - private def getThisFileImpl with (qctx: QuoteContext) : Expr[String] = { + private def getThisFileImpl(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} rootContext.source.getFileName.toString } diff --git a/tests/run-macros/tasty-implicit-fun-context-2/Macro_1.scala b/tests/run-macros/tasty-implicit-fun-context-2/Macro_1.scala index 8fa5e1f24a2d..5b252adf07bb 100644 --- a/tests/run-macros/tasty-implicit-fun-context-2/Macro_1.scala +++ b/tests/run-macros/tasty-implicit-fun-context-2/Macro_1.scala @@ -8,7 +8,7 @@ object Foo { implicit inline def foo: String = ${fooImpl} - def fooImpl with QuoteContext : QuoteContext ?=> Tastier[QuoteContext ?=> Macro[String]] = { + def fooImpl(using QuoteContext): QuoteContext ?=> Tastier[QuoteContext ?=> Macro[String]] = { '{"abc"} } diff --git a/tests/run-macros/tasty-interpolation-1/Macro.scala b/tests/run-macros/tasty-interpolation-1/Macro.scala index 6f25fe436584..9bc8d7b16a6a 100644 --- a/tests/run-macros/tasty-interpolation-1/Macro.scala +++ b/tests/run-macros/tasty-interpolation-1/Macro.scala @@ -14,24 +14,24 @@ object Macro { } object SIntepolator extends MacroStringInterpolator[String] { - protected def interpolate(strCtx: StringContext, args: List[Expr[Any]]) with QuoteContext : Expr[String] = + protected def interpolate(strCtx: StringContext, args: List[Expr[Any]]) (using QuoteContext): Expr[String] = '{(${strCtx}).s(${Expr.ofList(args)}: _*)} } object RawIntepolator extends MacroStringInterpolator[String] { - protected def interpolate(strCtx: StringContext, args: List[Expr[Any]]) with QuoteContext : Expr[String] = + protected def interpolate(strCtx: StringContext, args: List[Expr[Any]]) (using QuoteContext): Expr[String] = '{(${strCtx}).raw(${Expr.ofList(args)}: _*)} } object FooIntepolator extends MacroStringInterpolator[String] { - protected def interpolate(strCtx: StringContext, args: List[Expr[Any]]) with QuoteContext : Expr[String] = + protected def interpolate(strCtx: StringContext, args: List[Expr[Any]]) (using QuoteContext): Expr[String] = '{(${strCtx}).s(${Expr.ofList(args.map(_ => '{"foo"}))}: _*)} } // TODO put this class in the stdlib or separate project? abstract class MacroStringInterpolator[T] { - final def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]]) with (qctx: QuoteContext) : Expr[T] = { + final def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[T] = { try interpolate(strCtxExpr, argsExpr) catch { case ex: NotStaticlyKnownError => @@ -49,12 +49,12 @@ abstract class MacroStringInterpolator[T] { } } - protected def interpolate(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]]) with QuoteContext : Expr[T] = + protected def interpolate(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]]) (using QuoteContext): Expr[T] = interpolate(getStaticStringContext(strCtxExpr), getArgsList(argsExpr)) - protected def interpolate(strCtx: StringContext, argExprs: List[Expr[Any]]) with QuoteContext : Expr[T] + protected def interpolate(strCtx: StringContext, argExprs: List[Expr[Any]]) (using QuoteContext): Expr[T] - protected def getStaticStringContext(strCtxExpr: Expr[StringContext]) with (qctx: QuoteContext) : StringContext = { + protected def getStaticStringContext(strCtxExpr: Expr[StringContext])(using qctx: QuoteContext) : StringContext = { import qctx.tasty.{_, given _} strCtxExpr.unseal.underlyingArgument match { case Select(Typed(Apply(_, List(Apply(_, List(Typed(Repeated(strCtxArgTrees, _), Inferred()))))), _), _) => @@ -68,7 +68,7 @@ abstract class MacroStringInterpolator[T] { } } - protected def getArgsList(argsExpr: Expr[Seq[Any]]) with (qctx: QuoteContext) : List[Expr[Any]] = { + protected def getArgsList(argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext) : List[Expr[Any]] = { import qctx.tasty.{_, given _} argsExpr.unseal.underlyingArgument match { case Typed(Repeated(args, _), _) => args.map(_.seal) diff --git a/tests/run-macros/tasty-linenumber-2/quoted_1.scala b/tests/run-macros/tasty-linenumber-2/quoted_1.scala index c61112074e51..17fe835be0c1 100644 --- a/tests/run-macros/tasty-linenumber-2/quoted_1.scala +++ b/tests/run-macros/tasty-linenumber-2/quoted_1.scala @@ -9,7 +9,7 @@ object LineNumber { implicit inline def line: LineNumber = ${lineImpl} - def lineImpl with (qctx: QuoteContext) : Expr[LineNumber] = { + def lineImpl(using qctx: QuoteContext) : Expr[LineNumber] = { import qctx.tasty.{_, given _} '{new LineNumber(${rootPosition.startLine})} } diff --git a/tests/run-macros/tasty-linenumber/quoted_1.scala b/tests/run-macros/tasty-linenumber/quoted_1.scala index d3bae92734fb..83a4328d1128 100644 --- a/tests/run-macros/tasty-linenumber/quoted_1.scala +++ b/tests/run-macros/tasty-linenumber/quoted_1.scala @@ -10,7 +10,7 @@ object LineNumber { implicit inline def line[T >: Unit <: Unit]: LineNumber = ${lineImpl('[T])} - def lineImpl(x: Type[Unit]) with (qctx: QuoteContext) : Expr[LineNumber] = { + def lineImpl(x: Type[Unit])(using qctx: QuoteContext) : Expr[LineNumber] = { import qctx.tasty.{_, given _} '{new LineNumber(${rootPosition.startLine})} } diff --git a/tests/run-macros/tasty-location/quoted_1.scala b/tests/run-macros/tasty-location/quoted_1.scala index c37166fdea38..fffc7e95401c 100644 --- a/tests/run-macros/tasty-location/quoted_1.scala +++ b/tests/run-macros/tasty-location/quoted_1.scala @@ -7,7 +7,7 @@ object Location { implicit inline def location: Location = ${impl} - def impl with (qctx: QuoteContext) : Expr[Location] = { + def impl(using qctx: QuoteContext) : Expr[Location] = { import qctx.tasty.{_, given _} def listOwnerNames(sym: Symbol, acc: List[String]): List[String] = diff --git a/tests/run-macros/tasty-macro-assert/quoted_1.scala b/tests/run-macros/tasty-macro-assert/quoted_1.scala index 178af48d82f1..f602e1d06562 100644 --- a/tests/run-macros/tasty-macro-assert/quoted_1.scala +++ b/tests/run-macros/tasty-macro-assert/quoted_1.scala @@ -12,7 +12,7 @@ object Asserts { inline def macroAssert(inline cond: Boolean): Unit = ${impl('cond)} - def impl(cond: Expr[Boolean]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl(cond: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val tree = cond.unseal diff --git a/tests/run-macros/tasty-macro-const/quoted_1.scala b/tests/run-macros/tasty-macro-const/quoted_1.scala index 5370b92927db..71d332b7fa96 100644 --- a/tests/run-macros/tasty-macro-const/quoted_1.scala +++ b/tests/run-macros/tasty-macro-const/quoted_1.scala @@ -4,7 +4,7 @@ object Macros { inline def natConst(x: Int): Int = ${ natConstImpl('x) } - def natConstImpl(x: Expr[Int]) with (qctx: QuoteContext) : Expr[Int] = { + def natConstImpl(x: Expr[Int])(using qctx: QuoteContext) : Expr[Int] = { import qctx.tasty.{_, given _} val xTree: Term = x.unseal xTree match { diff --git a/tests/run-macros/tasty-macro-positions/quoted_1.scala b/tests/run-macros/tasty-macro-positions/quoted_1.scala index 9a587cfb8662..964f9dd9d579 100644 --- a/tests/run-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/run-macros/tasty-macro-positions/quoted_1.scala @@ -8,7 +8,7 @@ object Macros { inline def fun3[T]: Unit = ${ impl2('[T]) } - def impl(x: Expr[Any]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl(x: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val pos = x.unseal.underlyingArgument.pos val code = x.unseal.underlyingArgument.show @@ -18,7 +18,7 @@ object Macros { } } - def impl2[T](x: quoted.Type[T]) with (qctx: QuoteContext) : Expr[Unit] = { + def impl2[T](x: quoted.Type[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val pos = x.unseal.pos val code = x.unseal.show diff --git a/tests/run-macros/tasty-original-source/Macros_1.scala b/tests/run-macros/tasty-original-source/Macros_1.scala index 77cce9842e5b..13543e3f4e08 100644 --- a/tests/run-macros/tasty-original-source/Macros_1.scala +++ b/tests/run-macros/tasty-original-source/Macros_1.scala @@ -5,7 +5,7 @@ object Macros { implicit inline def withSource(arg: Any): (String, Any) = ${ impl('arg) } - private def impl(arg: Expr[Any]) with (qctx: QuoteContext) : Expr[(String, Any)] = { + private def impl(arg: Expr[Any])(using qctx: QuoteContext) : Expr[(String, Any)] = { import qctx.tasty.{_, given _} val source = arg.unseal.underlyingArgument.pos.sourceCode.toString '{Tuple2($source, $arg)} diff --git a/tests/run-macros/tasty-seal-method/quoted_1.scala b/tests/run-macros/tasty-seal-method/quoted_1.scala index bf9be727b5fc..809fc2d5eda8 100644 --- a/tests/run-macros/tasty-seal-method/quoted_1.scala +++ b/tests/run-macros/tasty-seal-method/quoted_1.scala @@ -6,7 +6,7 @@ object Asserts { ${ zeroLastArgsImpl('x) } /** Replaces last argument list by 0s */ - def zeroLastArgsImpl(x: Expr[Int]) with (qctx: QuoteContext) : Expr[Int] = { + def zeroLastArgsImpl(x: Expr[Int])(using qctx: QuoteContext) : Expr[Int] = { import qctx.tasty.{_, given _} // For simplicity assumes that all parameters are Int and parameter lists have no more than 3 elements x.unseal.underlyingArgument match { @@ -28,7 +28,7 @@ object Asserts { ${ zeroAllArgsImpl('x) } /** Replaces all argument list by 0s */ - def zeroAllArgsImpl(x: Expr[Int]) with (qctx: QuoteContext) : Expr[Int] = { + def zeroAllArgsImpl(x: Expr[Int])(using qctx: QuoteContext) : Expr[Int] = { import qctx.tasty.{_, given _} // For simplicity assumes that all parameters are Int and parameter lists have no more than 3 elements def rec(term: Term): Term = term match { diff --git a/tests/run-macros/tasty-simplified/quoted_1.scala b/tests/run-macros/tasty-simplified/quoted_1.scala index d2b4fb9515fc..ccc61ed6b1b8 100644 --- a/tests/run-macros/tasty-simplified/quoted_1.scala +++ b/tests/run-macros/tasty-simplified/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { inline def simplified[T <: Tuple]: Seq[String] = ${ impl[T] } - def impl[T: Type] with (qctx: QuoteContext) : Expr[Seq[String]] = { + def impl[T: Type](using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.tasty.{_, given _} def unpackTuple(tp: Type): List[Type] = { 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 e07771d50ac3..cd17684c2ca9 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 @@ -19,7 +19,7 @@ object TestFooErrors { // Defined in tests object Macro { - def foo(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]]) with (qctx: QuoteContext) : Expr[String] = { + def foo(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext): Expr[String] = { (sc, argsExpr) match { case ('{ StringContext(${ExprSeq(parts)}: _*) }, ExprSeq(args)) => val reporter = new Reporter { @@ -32,7 +32,7 @@ object Macro { } } - def fooErrors(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]]) with (qctx: QuoteContext) : Expr[List[(Int, Int, Int, String)]] = { + def fooErrors(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext): Expr[List[(Int, Int, Int, String)]] = { (sc, argsExpr) match { case ('{ StringContext(${ExprSeq(parts)}: _*) }, ExprSeq(args)) => val errors = List.newBuilder[Expr[(Int, Int, Int, String)]] @@ -51,7 +51,7 @@ object Macro { } - private def fooCore(parts: Seq[Expr[String]], args: Seq[Expr[Any]], reporter: Reporter) with QuoteContext : Expr[String] = { + private def fooCore(parts: Seq[Expr[String]], args: Seq[Expr[Any]], reporter: Reporter)(using QuoteContext): Expr[String] = { for ((part, idx) <- parts.zipWithIndex) { val Const(v: String) = part if (v.contains("#")) diff --git a/tests/run-macros/tasty-subtyping/quoted_1.scala b/tests/run-macros/tasty-subtyping/quoted_1.scala index dc809f2dd691..7c7102aff766 100644 --- a/tests/run-macros/tasty-subtyping/quoted_1.scala +++ b/tests/run-macros/tasty-subtyping/quoted_1.scala @@ -9,13 +9,13 @@ object Macros { inline def isSubTypeOf[T, U]: Boolean = ${isSubTypeOfImpl('[T], '[U])} - def isTypeEqualImpl[T, U](t: Type[T], u: Type[U]) with (qctx: QuoteContext) : Expr[Boolean] = { + def isTypeEqualImpl[T, U](t: Type[T], u: Type[U])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} val isTypeEqual = t.unseal.tpe =:= u.unseal.tpe isTypeEqual } - def isSubTypeOfImpl[T, U](t: Type[T], u: Type[U]) with (qctx: QuoteContext) : Expr[Boolean] = { + def isSubTypeOfImpl[T, U](t: Type[T], u: Type[U])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.tasty.{_, given _} val isTypeEqual = t.unseal.tpe <:< u.unseal.tpe isTypeEqual diff --git a/tests/run-macros/tasty-tree-map/quoted_1.scala b/tests/run-macros/tasty-tree-map/quoted_1.scala index e88234325f2d..05ebc0e7f86c 100644 --- a/tests/run-macros/tasty-tree-map/quoted_1.scala +++ b/tests/run-macros/tasty-tree-map/quoted_1.scala @@ -4,7 +4,7 @@ object Macros { implicit inline def identityMaped[T](x: => T): T = ${ impl('x) } - def impl[T: Type](x: Expr[T]) with (qctx: QuoteContext) : Expr[T] = { + def impl[T: Type](x: Expr[T])(using qctx: QuoteContext) : Expr[T] = { import qctx.tasty.{_, given _} val identityMap = new TreeMap { } val transformed = identityMap.transformTerm(x.unseal).seal.cast[T] diff --git a/tests/run-macros/tasty-typeof/Macro_1.scala b/tests/run-macros/tasty-typeof/Macro_1.scala index 85530dc420ef..43b3bacb5a6c 100644 --- a/tests/run-macros/tasty-typeof/Macro_1.scala +++ b/tests/run-macros/tasty-typeof/Macro_1.scala @@ -5,7 +5,7 @@ object Macros { inline def testTypeOf(): Unit = ${ testTypeOfImpl } - private def testTypeOfImpl with (qctx: QuoteContext) : Expr[Unit] = { + private def testTypeOfImpl(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} '{ assert(${(typeOf[Unit] =:= defn.UnitType)}, "Unit") diff --git a/tests/run-macros/tasty-unsafe-let/quoted_1.scala b/tests/run-macros/tasty-unsafe-let/quoted_1.scala index c7295b3a2c18..5ef193e65500 100644 --- a/tests/run-macros/tasty-unsafe-let/quoted_1.scala +++ b/tests/run-macros/tasty-unsafe-let/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { inline def let[T](rhs: => T)(body: => T => Unit): Unit = ${ impl('rhs, 'body) } - private def impl[T](rhs: Expr[T], body: Expr[T => Unit]) with (qctx: QuoteContext) : Expr[Unit] = { + private def impl[T](rhs: Expr[T], body: Expr[T => Unit])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given _} val rhsTerm = rhs.unseal diff --git a/tests/run-macros/type-show/Macro_1.scala b/tests/run-macros/type-show/Macro_1.scala index fda1bf8f006f..5bfb318fe5af 100644 --- a/tests/run-macros/type-show/Macro_1.scala +++ b/tests/run-macros/type-show/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object TypeToolbox { inline def show[A]: String = ${ showImpl('[A]) } - private def showImpl[A, B](a: Type[A]) with (qctx: QuoteContext) : Expr[String] = { + private def showImpl[A, B](a: Type[A])(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty.{_, given _} Expr(a.show) } diff --git a/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala index fba59cea1f36..9932c7313e30 100644 --- a/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala @@ -13,7 +13,7 @@ object XmlQuote { } def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]]) - with (qctx: QuoteContext) : Expr[Xml] = { + (using qctx: QuoteContext) : Expr[Xml] = { import qctx.tasty.{_, given _} // for debugging purpose diff --git a/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala index a6cef4f057c5..95fdee9a7a82 100644 --- a/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala @@ -14,7 +14,7 @@ object XmlQuote { } implicit inline def SCOps(ctx: => StringContext): SCOps = new SCOps(ctx) - def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]]) with (qctx: QuoteContext) : Expr[Xml] = { + def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]])(using qctx: QuoteContext) : Expr[Xml] = { import qctx.tasty.{_, given _} // for debugging purpose diff --git a/tests/run-macros/xml-interpolation-3/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-3/XmlQuote_1.scala index 7c91050512ed..3d05234e354d 100644 --- a/tests/run-macros/xml-interpolation-3/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-3/XmlQuote_1.scala @@ -12,7 +12,7 @@ object XmlQuote { ${XmlQuote.impl('ctx, 'args)} } - def impl(receiver: Expr[StringContext], args: Expr[Seq[Any]]) with QuoteContext : Expr[Xml] = { + def impl(receiver: Expr[StringContext], args: Expr[Seq[Any]])(using QuoteContext): Expr[Xml] = { val string = receiver.value.parts.mkString("??") '{new Xml(${string}, $args.toList)} } diff --git a/tests/run-macros/xml-interpolation-4/Macros_1.scala b/tests/run-macros/xml-interpolation-4/Macros_1.scala index add33064cc93..8c526b6ff19e 100644 --- a/tests/run-macros/xml-interpolation-4/Macros_1.scala +++ b/tests/run-macros/xml-interpolation-4/Macros_1.scala @@ -6,12 +6,12 @@ import scala.language.implicitConversions object XmlQuote { implicit object SCOps { - inline def (ctx: => StringContext) xml (args: => (Scope ?=> Any)*) with Scope : String = + inline def (ctx: => StringContext) xml (args: => (Scope ?=> Any)*)(using Scope): String = ${XmlQuote.impl('ctx, 'args, '{implicitly[Scope]})} } - private def impl(receiver: Expr[StringContext], args: Expr[Seq[Scope ?=> Any]], scope: Expr[Scope]) with QuoteContext : Expr[String] = '{ - $receiver.s($args.map(_.with($scope.inner)): _*) + private def impl(receiver: Expr[StringContext], args: Expr[Seq[Scope ?=> Any]], scope: Expr[Scope])(using QuoteContext): Expr[String] = '{ + $receiver.s($args.map(_(using $scope.inner)): _*) } } diff --git a/tests/run-staging/i3876-b.scala b/tests/run-staging/i3876-b.scala index 674e40d1e3f3..ba45b6f17c3d 100644 --- a/tests/run-staging/i3876-b.scala +++ b/tests/run-staging/i3876-b.scala @@ -4,9 +4,9 @@ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) - def x with QuoteContext : Expr[Int] = '{3} + def x(using QuoteContext): Expr[Int] = '{3} - def f2 with QuoteContext : Expr[Int => Int] = '{ + def f2(using QuoteContext): Expr[Int => Int] = '{ def f(x: Int): Int = x + x f } diff --git a/tests/run-staging/i3876-c.scala b/tests/run-staging/i3876-c.scala index 0c4bda3f02fb..48a73c654f39 100644 --- a/tests/run-staging/i3876-c.scala +++ b/tests/run-staging/i3876-c.scala @@ -4,9 +4,9 @@ object Test { def main(args: Array[String]): Unit = { implicit def toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader) - def x with QuoteContext : Expr[Int] = '{3} + def x(using QuoteContext): Expr[Int] = '{3} - def f3 with QuoteContext : Expr[Int => Int] = '{ + def f3(using QuoteContext): Expr[Int => Int] = '{ val f: (x: Int) => Int = x => x + x f } diff --git a/tests/run-staging/i3876-d.scala b/tests/run-staging/i3876-d.scala index 391ee357d0f4..853d41c52854 100644 --- a/tests/run-staging/i3876-d.scala +++ b/tests/run-staging/i3876-d.scala @@ -4,9 +4,9 @@ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) - def x with QuoteContext : Expr[Int] = '{3} + def x(using QuoteContext): Expr[Int] = '{3} - def f4 with QuoteContext : Expr[Int => Int] = '{ + def f4(using QuoteContext): Expr[Int => Int] = '{ inlineLambda } println(run(Expr.betaReduce(f4)(x))) diff --git a/tests/run-staging/i3876-e.scala b/tests/run-staging/i3876-e.scala index b53bda6f7256..f51e67127484 100644 --- a/tests/run-staging/i3876-e.scala +++ b/tests/run-staging/i3876-e.scala @@ -4,9 +4,9 @@ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) - def x with QuoteContext : Expr[Int] = '{ println(); 3 } + def x(using QuoteContext): Expr[Int] = '{ println(); 3 } - def f4 with QuoteContext : Expr[Int => Int] = '{ + def f4(using QuoteContext): Expr[Int => Int] = '{ inlineLambda } println(run(Expr.betaReduce(f4)(x))) diff --git a/tests/run-staging/i3876.scala b/tests/run-staging/i3876.scala index bc51bc9f7541..655e23e0681a 100644 --- a/tests/run-staging/i3876.scala +++ b/tests/run-staging/i3876.scala @@ -4,9 +4,9 @@ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) - def x with QuoteContext : Expr[Int] = '{3} + def x(using QuoteContext): Expr[Int] = '{3} - def f with QuoteContext : Expr[Int => Int] = '{ (x: Int) => x + x } + def f(using QuoteContext): Expr[Int => Int] = '{ (x: Int) => x + x } println(run(Expr.betaReduce(f)(x))) println(withQuoteContext(Expr.betaReduce(f)(x).show)) diff --git a/tests/run-staging/i3946.scala b/tests/run-staging/i3946.scala index 4aa5f83e7536..1bfbdc10658d 100644 --- a/tests/run-staging/i3946.scala +++ b/tests/run-staging/i3946.scala @@ -3,7 +3,7 @@ import scala.quoted.staging._ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) - def u with QuoteContext : Expr[Unit] = '{} + def u(using QuoteContext): Expr[Unit] = '{} println(withQuoteContext(u.show)) println(run(u)) } diff --git a/tests/run-staging/i4044b.scala b/tests/run-staging/i4044b.scala index c2c143527737..c23774c5fb02 100644 --- a/tests/run-staging/i4044b.scala +++ b/tests/run-staging/i4044b.scala @@ -2,17 +2,17 @@ import scala.quoted._ import scala.quoted.staging._ sealed abstract class VarRef[T] { - def update(expr: Expr[T]) with QuoteContext : Expr[Unit] - def expr with QuoteContext : Expr[T] + def update(expr: Expr[T])(using QuoteContext): Expr[Unit] + def expr(using QuoteContext): Expr[T] } object VarRef { - def apply[T: Type, U: Type](init: Expr[T])(body: VarRef[T] => Expr[U]) with QuoteContext : Expr[U] = '{ + def apply[T: Type, U: Type](init: Expr[T])(body: VarRef[T] => Expr[U])(using QuoteContext): Expr[U] = '{ var x = $init ${body( new VarRef { - def update(e: Expr[T]) with QuoteContext : Expr[Unit] = '{ x = $e } - def expr with QuoteContext : Expr[T] = 'x + def update(e: Expr[T])(using QuoteContext): Expr[Unit] = '{ x = $e } + def expr(using QuoteContext): Expr[T] = 'x } )} } diff --git a/tests/run-staging/i4350.scala b/tests/run-staging/i4350.scala index ce06aebe79f2..908a5e63613e 100644 --- a/tests/run-staging/i4350.scala +++ b/tests/run-staging/i4350.scala @@ -3,7 +3,7 @@ import scala.quoted._ import scala.quoted.staging._ class Foo[T: Type] { - def q with QuoteContext = '{(null: Any).asInstanceOf[T]} + def q(using QuoteContext) = '{(null: Any).asInstanceOf[T]} } object Test { diff --git a/tests/run-staging/i4591.scala b/tests/run-staging/i4591.scala index 02d4341a9495..c4653c799ebe 100644 --- a/tests/run-staging/i4591.scala +++ b/tests/run-staging/i4591.scala @@ -3,7 +3,7 @@ import scala.quoted.staging._ object Test { - def foo[T: Type](init: Expr[T]) with QuoteContext : Expr[Unit] = '{ + def foo[T: Type](init: Expr[T])(using QuoteContext): Expr[Unit] = '{ var x = $init println(x) } diff --git a/tests/run-staging/i4730.scala b/tests/run-staging/i4730.scala index 6282a0bd9caf..148544af238a 100644 --- a/tests/run-staging/i4730.scala +++ b/tests/run-staging/i4730.scala @@ -3,7 +3,7 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) - def ret with QuoteContext : Expr[Int => Int] = '{ (x: Int) => + def ret(using QuoteContext): Expr[Int => Int] = '{ (x: Int) => ${ val z = run('{x + 1}) // throws a RunScopeException Expr(z) diff --git a/tests/run-staging/i5144.scala b/tests/run-staging/i5144.scala index 842d247e8fd4..a79a4e795bdb 100644 --- a/tests/run-staging/i5144.scala +++ b/tests/run-staging/i5144.scala @@ -3,9 +3,9 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) - def eval1(ff: Expr[Int => Int]) with QuoteContext : Expr[Int] = '{$ff(42)} + def eval1(ff: Expr[Int => Int])(using QuoteContext): Expr[Int] = '{$ff(42)} - def peval1() with QuoteContext : Expr[Unit] = '{ + def peval1()(using QuoteContext): Expr[Unit] = '{ def f(x: Int): Int = ${eval1('f)} } diff --git a/tests/run-staging/i5144b.scala b/tests/run-staging/i5144b.scala index 008253ce38ee..86c58a8b0854 100644 --- a/tests/run-staging/i5144b.scala +++ b/tests/run-staging/i5144b.scala @@ -3,9 +3,9 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) - def eval1(ff: Expr[Int => Int]) with QuoteContext : Expr[Int] = Expr.betaReduce(ff)('{42}) + def eval1(ff: Expr[Int => Int])(using QuoteContext): Expr[Int] = Expr.betaReduce(ff)('{42}) - def peval1() with QuoteContext : Expr[Unit] = '{ + def peval1()(using QuoteContext): Expr[Unit] = '{ def f(x: Int): Int = ${eval1('f)} } diff --git a/tests/run-staging/i5152.scala b/tests/run-staging/i5152.scala index 44634eea4514..45b379f2594b 100644 --- a/tests/run-staging/i5152.scala +++ b/tests/run-staging/i5152.scala @@ -3,9 +3,9 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) - def eval1(ff: Expr[Int => Int]) with QuoteContext : Expr[Int => Int] = '{identity} + def eval1(ff: Expr[Int => Int])(using QuoteContext): Expr[Int => Int] = '{identity} - def peval1() with QuoteContext : Expr[Unit] = '{ + def peval1()(using QuoteContext): Expr[Unit] = '{ lazy val f: Int => Int = ${eval1('{(y: Int) => f(y)})} } diff --git a/tests/run-staging/i5161.scala b/tests/run-staging/i5161.scala index 3dd1c8e7c247..9f2e6abaa4d4 100644 --- a/tests/run-staging/i5161.scala +++ b/tests/run-staging/i5161.scala @@ -10,7 +10,7 @@ object Test { } import Exp._ - def evalTest(e: Exp) with QuoteContext : Expr[Option[Int]] = e match { + def evalTest(e: Exp)(using QuoteContext): Expr[Option[Int]] = e match { case Int2(x) => '{ Some(${Expr(x)}) } case Add(e1, e2) => '{ @@ -25,7 +25,7 @@ object Test { def main(args: Array[String]): Unit = { val test = Add(Int2(1), Int2(1)) - def res with QuoteContext = evalTest(test) + def res(using QuoteContext) = evalTest(test) println("run : " + run(res)) println("show : " + withQuoteContext(res.show)) } diff --git a/tests/run-staging/i5161b.scala b/tests/run-staging/i5161b.scala index 927325b85451..f99c0adf15cf 100644 --- a/tests/run-staging/i5161b.scala +++ b/tests/run-staging/i5161b.scala @@ -5,7 +5,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = { - def res with QuoteContext = '{ + def res(using QuoteContext) = '{ val x: Option[Int] = Option(3) if (x.isInstanceOf[Some[_]]) Option(1) else None diff --git a/tests/run-staging/i5247.scala b/tests/run-staging/i5247.scala index d10d61db60c6..da2a4ee4eae3 100644 --- a/tests/run-staging/i5247.scala +++ b/tests/run-staging/i5247.scala @@ -7,11 +7,11 @@ object Test { println(foo[Object].show) println(bar[Object].show) } - def foo[H : Type] with QuoteContext : Expr[H] = { + def foo[H : Type](using QuoteContext): Expr[H] = { val t = '[H] '{ null.asInstanceOf[$t] } } - def bar[H : Type] with QuoteContext : Expr[List[H]] = { + def bar[H : Type](using QuoteContext): Expr[List[H]] = { val t = '[List[H]] '{ null.asInstanceOf[$t] } } diff --git a/tests/run-staging/i5965.scala b/tests/run-staging/i5965.scala index f08614a61ef0..5d5f15b17a77 100644 --- a/tests/run-staging/i5965.scala +++ b/tests/run-staging/i5965.scala @@ -7,20 +7,20 @@ object Test { def main(args: Array[String]): Unit = { withQuoteContext('[List]) - def list with QuoteContext = bound('{List(1, 2, 3)}) + def list(using QuoteContext) = bound('{List(1, 2, 3)}) println(withQuoteContext(list.show)) println(run(list)) - def opt with QuoteContext = bound('{Option(4)}) + def opt(using QuoteContext) = bound('{Option(4)}) println(withQuoteContext(opt.show)) println(run(opt)) - def map with QuoteContext = bound('{Map(4 -> 1)}) + def map(using QuoteContext) = bound('{Map(4 -> 1)}) println(withQuoteContext(map.show)) println(run(map)) } - def bound[T: Type, S[_]: Type](x: Expr[S[T]]) with QuoteContext : Expr[S[T]] = '{ + def bound[T: Type, S[_]: Type](x: Expr[S[T]])(using QuoteContext): Expr[S[T]] = '{ val y: S[T] = $x y } diff --git a/tests/run-staging/i5965b.scala b/tests/run-staging/i5965b.scala index f0388f9d90de..8850619b912c 100644 --- a/tests/run-staging/i5965b.scala +++ b/tests/run-staging/i5965b.scala @@ -7,20 +7,20 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) withQuoteContext('[List]) - def list with QuoteContext = bound('{List(1, 2, 3)}) + def list(using QuoteContext) = bound('{List(1, 2, 3)}) println(withQuoteContext(list.show)) println(run(list)) - def opt with QuoteContext = bound('{Option(4)}) + def opt(using QuoteContext) = bound('{Option(4)}) println(withQuoteContext(opt.show)) println(run(opt)) - def map with QuoteContext = bound('{Map(4 -> 1)}) + def map(using QuoteContext) = bound('{Map(4 -> 1)}) println(withQuoteContext(map.show)) println(run(map)) } - def bound[T: Type, S[_]: Type](x: Expr[S[T]]) with QuoteContext : Expr[S[T]] = '{ + def bound[T: Type, S[_]: Type](x: Expr[S[T]])(using QuoteContext): Expr[S[T]] = '{ val y = $x y } diff --git a/tests/run-staging/i6281.scala b/tests/run-staging/i6281.scala index 75f8faa068b2..26c0bc4c0318 100644 --- a/tests/run-staging/i6281.scala +++ b/tests/run-staging/i6281.scala @@ -18,31 +18,31 @@ object Test extends App { } trait Effects[L <: HList] { - def reify[A] with Type[A] : STM[A, L] => Expr[Stm[A, L]] - def reflect[A] with Type[A] : Expr[Stm[A, L]] => STM[A, L] + def reify[A](using Type[A]): STM[A, L] => Expr[Stm[A, L]] + def reflect[A](using Type[A]): Expr[Stm[A, L]] => STM[A, L] } given empty as Effects[HNil] { - def reify[A] with Type[A] = m => m - def reflect[A] with Type[A] = m => m + def reify[A](using Type[A]) = m => m + def reflect[A](using Type[A]) = m => m } // for reify, we need type tags for E and also strangely for L. - implicit def cons [E, L <: HList] with Effects[L] with Type[E] with Type[L] with QuoteContext : Effects[E :: L] = new Effects[E :: L] { - def reify[A] with Type[A] = m => '{ k => ${ Effects[L].reify[E] { m( a => Effects[L].reflect[E](Expr.betaReduce('k)(a))) } }} - def reflect[A] with Type[A] = m => k => Effects[L].reflect[E] { Expr.betaReduce(m)('{ a => ${ Effects[L].reify[E]( k('a)) } })} + implicit def cons [E, L <: HList](using Effects[L])(using Type[E])(using Type[L])(using QuoteContext): Effects[E :: L] = new Effects[E :: L] { + def reify[A](using Type[A]) = m => '{ k => ${ Effects[L].reify[E] { m( a => Effects[L].reflect[E](Expr.betaReduce('k)(a))) } }} + def reflect[A](using Type[A]) = m => k => Effects[L].reflect[E] { Expr.betaReduce(m)('{ a => ${ Effects[L].reify[E]( k('a)) } })} } - def Effects[L <: HList] with Effects[L] : Effects[L] = summon[Effects[L]] + def Effects[L <: HList](using Effects[L]): Effects[L] = summon[Effects[L]] type RS = Boolean :: RS2 type RS2 = Int :: String :: HNil - def m with QuoteContext : STM[Int, RS] = k => k('{42}) + def m(using QuoteContext): STM[Int, RS] = k => k('{42}) implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader) withQuoteContext { println(Effects[RS].reify[Int] { m }.show) - val effects = cons[Boolean, RS2].with(cons[Int, String :: HNil].with(cons[String, HNil].with(empty))) + val effects = cons[Boolean, RS2](using cons[Int, String :: HNil](using cons[String, HNil](using empty))) println(effects.reify[Int] { m }.show) val res : Expr[Stm[Int, RS]] = '{ k => ${ Effects[RS2].reify[Boolean] { m(a => Effects[RS2].reflect[Boolean](Expr.betaReduce('k)(a))) }}} diff --git a/tests/run-staging/i6754.scala b/tests/run-staging/i6754.scala index 41b97b435ea7..2fbc6ae7e27e 100644 --- a/tests/run-staging/i6754.scala +++ b/tests/run-staging/i6754.scala @@ -6,8 +6,8 @@ object Test { implicit val tbx: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = { - def y with QuoteContext : Expr[Unit] = '{ - def x with QuoteContext : Expr[Unit] = '{println("bar")} + def y(using QuoteContext): Expr[Unit] = '{ + def x(using QuoteContext): Expr[Unit] = '{println("bar")} println("foo") run(x) } diff --git a/tests/run-staging/i6992/Macro_1.scala b/tests/run-staging/i6992/Macro_1.scala index 3e2e16df83da..72f98106e009 100644 --- a/tests/run-staging/i6992/Macro_1.scala +++ b/tests/run-staging/i6992/Macro_1.scala @@ -10,7 +10,7 @@ object macros { class Foo { val x = 10 } - def mcrImpl(body: Expr[Any]) with (ctx: QuoteContext) : Expr[Any] = { + def mcrImpl(body: Expr[Any])(using ctx: QuoteContext): Expr[Any] = { import ctx.tasty._ try { body match { diff --git a/tests/run-staging/inline-quote.scala b/tests/run-staging/inline-quote.scala index f73fa66feefc..cd48b4b773b8 100644 --- a/tests/run-staging/inline-quote.scala +++ b/tests/run-staging/inline-quote.scala @@ -3,7 +3,7 @@ import scala.quoted.staging._ object Test { - inline def foo(x: Expr[Int]) with QuoteContext : Expr[Int] = '{ + inline def foo(x: Expr[Int])(using QuoteContext): Expr[Int] = '{ println("foo") $x } diff --git a/tests/run-staging/quote-ackermann-1.scala b/tests/run-staging/quote-ackermann-1.scala index 11be62848456..a322297a1b4e 100644 --- a/tests/run-staging/quote-ackermann-1.scala +++ b/tests/run-staging/quote-ackermann-1.scala @@ -12,7 +12,7 @@ object Test { println(ack3(4)) } - def ackermann(m: Int) with QuoteContext : Expr[Int => Int] = { + def ackermann(m: Int)(using QuoteContext): Expr[Int => Int] = { if (m == 0) '{ n => n + 1 } else '{ n => def `ackermann(m-1)`(n: Int): Int = ${Expr.betaReduce(ackermann(m - 1))('n)} // Expr[Int => Int] applied to Expr[Int] diff --git a/tests/run-staging/quote-fun-app-1.scala b/tests/run-staging/quote-fun-app-1.scala index 2dd0e42d8cd7..b259142b0679 100644 --- a/tests/run-staging/quote-fun-app-1.scala +++ b/tests/run-staging/quote-fun-app-1.scala @@ -12,8 +12,8 @@ object Test { println(f(43)) } - def f1 with QuoteContext : Expr[Int => Int] = '{ n => ${Expr.betaReduce(f2)('n)} } - def f2 with QuoteContext : Expr[Int => Int] = '{ n => ${Expr.betaReduce(f3)('n)} } - def f3 with QuoteContext : Expr[Int => Int] = '{ n => ${Expr.betaReduce(f4)('n)} } - def f4 with QuoteContext : Expr[Int => Int] = '{ n => n } + def f1(using QuoteContext): Expr[Int => Int] = '{ n => ${Expr.betaReduce(f2)('n)} } + def f2(using QuoteContext): Expr[Int => Int] = '{ n => ${Expr.betaReduce(f3)('n)} } + def f3(using QuoteContext): Expr[Int => Int] = '{ n => ${Expr.betaReduce(f4)('n)} } + def f4(using QuoteContext): Expr[Int => Int] = '{ n => n } } diff --git a/tests/run-staging/quote-lib.scala b/tests/run-staging/quote-lib.scala index 74ba1d064c06..a70866824bd8 100644 --- a/tests/run-staging/quote-lib.scala +++ b/tests/run-staging/quote-lib.scala @@ -116,7 +116,7 @@ package liftable { object Exprs { implicit class LiftExprOps[T](x: T) extends AnyVal { - def toExpr with (Liftable[T], QuoteContext) : Expr[T] = + def toExpr(using Liftable[T], QuoteContext): Expr[T] = summon[Liftable[T]].toExpr(x) } } @@ -137,8 +137,8 @@ package liftable { } object Loops { - def liftedWhile(cond: Expr[Boolean])(body: Expr[Unit]) with QuoteContext : Expr[Unit] = '{ while ($cond) $body } - def liftedDoWhile(body: Expr[Unit])(cond: Expr[Boolean]) with QuoteContext : Expr[Unit] = '{ while { $body ; $cond } do () } + def liftedWhile(cond: Expr[Boolean])(body: Expr[Unit])(using QuoteContext): Expr[Unit] = '{ while ($cond) $body } + def liftedDoWhile(body: Expr[Unit])(cond: Expr[Boolean])(using QuoteContext): Expr[Unit] = '{ while { $body ; $cond } do () } } @@ -147,7 +147,7 @@ package liftable { implicit class LiftedOps[T: Liftable](list: Expr[List[T]])(implicit t: Type[T]) { def foldLeft[U](acc: Expr[U])(f: Expr[(U, T) => U])(implicit u: Type[U], qctx: QuoteContext): Expr[U] = '{ ($list).foldLeft[$u]($acc)($f) } - def foreach(f: Expr[T => Unit]) with QuoteContext : Expr[Unit] = + def foreach(f: Expr[T => Unit])(using QuoteContext): Expr[Unit] = '{ ($list).foreach($f) } } diff --git a/tests/run-staging/quote-macro-in-splice/quoted_1.scala b/tests/run-staging/quote-macro-in-splice/quoted_1.scala index 8476ca3e8062..6dd7658f5083 100644 --- a/tests/run-staging/quote-macro-in-splice/quoted_1.scala +++ b/tests/run-staging/quote-macro-in-splice/quoted_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macros { - def impl(x: Expr[Int]) with QuoteContext : Expr[Int] = '{ $x + 1 } + def impl(x: Expr[Int])(using QuoteContext): Expr[Int] = '{ $x + 1 } } diff --git a/tests/run-staging/quote-owners-2.scala b/tests/run-staging/quote-owners-2.scala index 6bf423c97ea1..6bb0935ee1d3 100644 --- a/tests/run-staging/quote-owners-2.scala +++ b/tests/run-staging/quote-owners-2.scala @@ -10,7 +10,7 @@ object Test { '{ println($q) } } - def f(t: Type[List[Int]]) with QuoteContext : Expr[Int] = '{ + def f(t: Type[List[Int]])(using QuoteContext): Expr[Int] = '{ def ff: Int = { val a: $t = { type T = $t @@ -22,5 +22,5 @@ object Test { ff } - def g[T](a: Type[T]) with QuoteContext : Type[List[T]] = '[List[$a]] + def g[T](a: Type[T])(using QuoteContext): Type[List[T]] = '[List[$a]] } diff --git a/tests/run-staging/quote-owners.scala b/tests/run-staging/quote-owners.scala index 53a425c17892..c7746c247425 100644 --- a/tests/run-staging/quote-owners.scala +++ b/tests/run-staging/quote-owners.scala @@ -4,19 +4,19 @@ import scala.quoted.staging._ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) - def q with QuoteContext = f + def q(using QuoteContext) = f println(run(q)) println(withQuoteContext(q.show)) } - def f with QuoteContext : Expr[Int] = '{ + def f(using QuoteContext): Expr[Int] = '{ def ff: Int = { $g } ff } - def g with QuoteContext : Expr[Int] = '{ + def g(using QuoteContext): Expr[Int] = '{ val a = 9 a + 0 } diff --git a/tests/run-staging/quote-run-b.scala b/tests/run-staging/quote-run-b.scala index dc37997bffec..dc8d487e2507 100644 --- a/tests/run-staging/quote-run-b.scala +++ b/tests/run-staging/quote-run-b.scala @@ -5,7 +5,7 @@ import scala.quoted.staging._ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) - def lambdaExpr with QuoteContext = '{ + def lambdaExpr(using QuoteContext) = '{ (x: Int) => println("lambda(" + x + ")") } println() diff --git a/tests/run-staging/quote-run-c.scala b/tests/run-staging/quote-run-c.scala index df21b34303c6..f9303333c59d 100644 --- a/tests/run-staging/quote-run-c.scala +++ b/tests/run-staging/quote-run-c.scala @@ -5,13 +5,13 @@ import scala.quoted.staging._ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) - def classExpr with QuoteContext = '{ + def classExpr(using QuoteContext) = '{ class A { override def toString: String = "Foo" } new A } - def classExpr2 with QuoteContext = '{ + def classExpr2(using QuoteContext) = '{ class A { override def toString: String = "Bar" } diff --git a/tests/run-staging/quote-run-large.scala b/tests/run-staging/quote-run-large.scala index e5c663b4690f..e2526cdcd067 100644 --- a/tests/run-staging/quote-run-large.scala +++ b/tests/run-staging/quote-run-large.scala @@ -3,7 +3,7 @@ import scala.quoted.staging._ object Test { def main(args: Array[String]): Unit = { - def a with QuoteContext = '{ // ' + def a(using QuoteContext) = '{ // ' class Foo(x: Int) { override def toString(): String = s"Foo($x)" def foo1: Int = x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x diff --git a/tests/run-staging/quote-run-many.scala b/tests/run-staging/quote-run-many.scala index 72b8eaeaf4ac..8771e53a6a17 100644 --- a/tests/run-staging/quote-run-many.scala +++ b/tests/run-staging/quote-run-many.scala @@ -5,7 +5,7 @@ import scala.quoted.autolift.{given _} object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) - def expr(i: Int) with QuoteContext = '{ + def expr(i: Int)(using QuoteContext) = '{ val a = 3 + ${i} 2 + a } diff --git a/tests/run-staging/quote-run-staged-interpreter.scala b/tests/run-staging/quote-run-staged-interpreter.scala index 73e494049b74..d4c5c27ce7c2 100644 --- a/tests/run-staging/quote-run-staged-interpreter.scala +++ b/tests/run-staging/quote-run-staged-interpreter.scala @@ -12,7 +12,7 @@ enum Exp { object Test { import Exp._ - def compile(e: Exp, env: Map[String, Expr[Int]], keepLets: Boolean) with QuoteContext : Expr[Int] = { + def compile(e: Exp, env: Map[String, Expr[Int]], keepLets: Boolean)(using QuoteContext): Expr[Int] = { def compileImpl(e: Exp, env: Map[String, Expr[Int]]): Expr[Int] = e match { case Num(n) => n case Plus(e1, e2) => '{${compileImpl(e1, env)} + ${compileImpl(e2, env)}} @@ -32,7 +32,7 @@ object Test { val exp = Plus(Plus(Num(2), Var("x")), Num(4)) val letExp = Let("x", Num(3), exp) - def res1 with QuoteContext = '{ (x: Int) => ${compile(exp, Map("x" -> 'x), false)} } + def res1(using QuoteContext) = '{ (x: Int) => ${compile(exp, Map("x" -> 'x), false)} } println(withQuoteContext(res1.show)) @@ -44,13 +44,13 @@ object Test { println("---") - def res2 with QuoteContext = compile(letExp, Map(), false) + def res2(using QuoteContext) = compile(letExp, Map(), false) println(withQuoteContext(res2.show)) println(run(res2)) println("---") - def res3 with QuoteContext = compile(letExp, Map(), true) + def res3(using QuoteContext) = compile(letExp, Map(), true) println(withQuoteContext(res3.show)) println(run(res3)) } diff --git a/tests/run-staging/quote-run-with-settings.scala b/tests/run-staging/quote-run-with-settings.scala index 4a9d81dc92ca..2ec3c1f36c68 100644 --- a/tests/run-staging/quote-run-with-settings.scala +++ b/tests/run-staging/quote-run-with-settings.scala @@ -7,7 +7,7 @@ import scala.quoted.staging._ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) - def expr with QuoteContext = '{ + def expr(using QuoteContext) = '{ val a = 3 println("foo") 2 + a diff --git a/tests/run-staging/quote-run.scala b/tests/run-staging/quote-run.scala index 4b7b8fedd183..c816f102409f 100644 --- a/tests/run-staging/quote-run.scala +++ b/tests/run-staging/quote-run.scala @@ -4,7 +4,7 @@ import scala.quoted.staging._ object Test { def main(args: Array[String]): Unit = { given Toolbox = Toolbox.make(getClass.getClassLoader) - def expr with QuoteContext = '{ + def expr(using QuoteContext) = '{ val a = 3 println("foo") 2 + a diff --git a/tests/run-staging/quote-unrolled-foreach.scala b/tests/run-staging/quote-unrolled-foreach.scala index 2a19e99fe589..8ac2a001c9a7 100644 --- a/tests/run-staging/quote-unrolled-foreach.scala +++ b/tests/run-staging/quote-unrolled-foreach.scala @@ -6,31 +6,31 @@ import scala.quoted.autolift.{given _} object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def code1 with QuoteContext = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach1('arr, 'f) } } + def code1(using QuoteContext) = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach1('arr, 'f) } } println(code1.show) println() - def code1Tpe with QuoteContext = '{ (arr: Array[String], f: String => Unit) => ${ foreach1Tpe1('arr, 'f) } } + def code1Tpe(using QuoteContext) = '{ (arr: Array[String], f: String => Unit) => ${ foreach1Tpe1('arr, 'f) } } println(code1Tpe.show) println() - def code1Tpe2 with QuoteContext = '{ (arr: Array[String], f: String => Unit) => ${ foreach1Tpe1('arr, 'f) } } + def code1Tpe2(using QuoteContext) = '{ (arr: Array[String], f: String => Unit) => ${ foreach1Tpe1('arr, 'f) } } println(code1Tpe2.show) println() - def code2 with QuoteContext = '{ (arr: Array[Int]) => ${ foreach1('arr, '{i => System.out.println(i)}) } } + def code2(using QuoteContext) = '{ (arr: Array[Int]) => ${ foreach1('arr, '{i => System.out.println(i)}) } } println(code2.show) println() - def code3 with QuoteContext = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach3('arr, 'f) } } + def code3(using QuoteContext) = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach3('arr, 'f) } } println(code3.show) println() - def code4 with QuoteContext = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach4('arr, 'f, 4) } } + def code4(using QuoteContext) = '{ (arr: Array[Int], f: Int => Unit) => ${ foreach4('arr, 'f, 4) } } println(code4.show) println() - def liftedArray with QuoteContext : Expr[Array[Int]] = Array(1, 2, 3, 4) + def liftedArray(using QuoteContext): Expr[Array[Int]] = Array(1, 2, 3, 4) println(liftedArray.show) println() @@ -44,7 +44,7 @@ object Test { '{} } - def foreach1(arrRef: Expr[Array[Int]], f: Expr[Int => Unit]) with QuoteContext : Expr[Unit] = '{ + def foreach1(arrRef: Expr[Array[Int]], f: Expr[Int => Unit])(using QuoteContext): Expr[Unit] = '{ val size = ($arrRef).length var i = 0 while (i < size) { @@ -64,7 +64,7 @@ object Test { } } - def foreach1Tpe2[T: Type](arrRef: Expr[Array[T]], f: Expr[T => Unit]) with QuoteContext : Expr[Unit] = '{ + def foreach1Tpe2[T: Type](arrRef: Expr[Array[T]], f: Expr[T => Unit])(using QuoteContext): Expr[Unit] = '{ val size = ($arrRef).length var i = 0 while (i < size) { @@ -74,7 +74,7 @@ object Test { } } - def foreach2(arrRef: Expr[Array[Int]], f: Expr[Int => Unit]) with QuoteContext : Expr[Unit] = '{ + def foreach2(arrRef: Expr[Array[Int]], f: Expr[Int => Unit])(using QuoteContext): Expr[Unit] = '{ val size = ($arrRef).length var i = 0 while (i < size) { @@ -84,7 +84,7 @@ object Test { } } - def foreach3(arrRef: Expr[Array[Int]], f: Expr[Int => Unit]) with QuoteContext : Expr[Unit] = '{ + def foreach3(arrRef: Expr[Array[Int]], f: Expr[Int => Unit])(using QuoteContext): Expr[Unit] = '{ val size = ($arrRef).length var i = 0 if (size % 3 != 0) throw new Exception("...")// for simplicity of the implementation @@ -96,7 +96,7 @@ object Test { } } - def foreach3_2(arrRef: Expr[Array[Int]], f: Expr[Int => Unit]) with QuoteContext : Expr[Unit] = '{ + def foreach3_2(arrRef: Expr[Array[Int]], f: Expr[Int => Unit])(using QuoteContext): Expr[Unit] = '{ val size = ($arrRef).length var i = 0 if (size % 3 != 0) throw new Exception("...")// for simplicity of the implementation @@ -108,7 +108,7 @@ object Test { } } - def foreach4(arrRef: Expr[Array[Int]], f: Expr[Int => Unit], unrollSize: Int) with QuoteContext : Expr[Unit] = '{ + def foreach4(arrRef: Expr[Array[Int]], f: Expr[Int => Unit], unrollSize: Int)(using QuoteContext): Expr[Unit] = '{ val size = ($arrRef).length var i = 0 if (size % ${unrollSize} != 0) throw new Exception("...") // for simplicity of the implementation @@ -126,7 +126,7 @@ object Test { } } - def foreachInRange(start: Int, end: Int)(f: Int => Expr[Unit]) with QuoteContext : Expr[Unit] = { + def foreachInRange(start: Int, end: Int)(f: Int => Expr[Unit])(using QuoteContext): Expr[Unit] = { @tailrec def unroll(i: Int, acc: Expr[Unit]): Expr[Unit] = if (i < end) unroll(i + 1, '{ $acc; ${f(i)} }) else acc if (start < end) unroll(start + 1, f(start)) else '{} diff --git a/tests/run-staging/quote-valueof-list.scala b/tests/run-staging/quote-valueof-list.scala index 6a68cffb5274..dd72b29a83e5 100644 --- a/tests/run-staging/quote-valueof-list.scala +++ b/tests/run-staging/quote-valueof-list.scala @@ -8,7 +8,7 @@ object Test { def main(args: Array[String]): Unit = withQuoteContext { implicit def ValueOfExprInt: ValueOfExpr[Int] = new { - def apply(n: Expr[Int]) with QuoteContext : Option[Int] = n match { + def apply(n: Expr[Int])(using QuoteContext): Option[Int] = n match { case '{ 0 } => Some(0) case '{ 1 } => Some(1) case '{ 2 } => Some(1) @@ -17,7 +17,7 @@ object Test { } implicit def ValueOfExprBoolean: ValueOfExpr[Boolean] = new ValueOfExpr[Boolean] { - def apply(b: Expr[Boolean]) with QuoteContext : Option[Boolean] = b match { + def apply(b: Expr[Boolean])(using QuoteContext): Option[Boolean] = b match { case '{ true } => Some(true) case '{ false } => Some(false) case _ => None @@ -25,7 +25,7 @@ object Test { } implicit def ValueOfExprList[T: ValueOfExpr: Type]: ValueOfExpr[List[T]] = new { - def apply(xs: Expr[List[T]]) with QuoteContext : Option[List[T]] = (xs: Expr[Any]) match { + def apply(xs: Expr[List[T]])(using QuoteContext): Option[List[T]] = (xs: Expr[Any]) match { case '{ ($xs1: List[T]).::($x) } => for { head <- x.getValue; tail <- xs1.getValue } yield head :: tail @@ -35,7 +35,7 @@ object Test { } implicit def ValueOfExprOption[T: ValueOfExpr: Type]: ValueOfExpr[Option[T]] = new { - def apply(expr: Expr[Option[T]]) with QuoteContext : Option[Option[T]] = expr match { + def apply(expr: Expr[Option[T]])(using QuoteContext): Option[Option[T]] = expr match { case '{ Some[T]($x) } => for (v <- x.getValue) yield Some(v) case '{ None } => Some(None) case _ => None diff --git a/tests/run-staging/quote-var.scala b/tests/run-staging/quote-var.scala index 61ff8b78124f..4efc90dd5766 100644 --- a/tests/run-staging/quote-var.scala +++ b/tests/run-staging/quote-var.scala @@ -4,18 +4,18 @@ import scala.quoted.staging._ object Test { sealed trait Var { - def get with QuoteContext : Expr[String] - def update(x: Expr[String]) with QuoteContext : Expr[Unit] + def get(using QuoteContext): Expr[String] + def update(x: Expr[String])(using QuoteContext): Expr[Unit] } object Var { - def apply(init: Expr[String])(body: Var => Expr[String]) with QuoteContext : Expr[String] = '{ + def apply(init: Expr[String])(body: Var => Expr[String])(using QuoteContext): Expr[String] = '{ var x = $init ${ body( new Var { - def get with QuoteContext : Expr[String] = 'x - def update(e: Expr[String]) with QuoteContext : Expr[Unit] = '{ x = $e } + def get(using QuoteContext): Expr[String] = 'x + def update(e: Expr[String])(using QuoteContext): Expr[Unit] = '{ x = $e } } ) } @@ -23,7 +23,7 @@ object Test { } - def test1() with QuoteContext : Expr[String] = Var('{"abc"}) { x => + def test1()(using QuoteContext): Expr[String] = Var('{"abc"}) { x => '{ ${ x.update('{"xyz"}) } ${ x.get } diff --git a/tests/run-staging/quoted-show-name.scala b/tests/run-staging/quoted-show-name.scala index f7fe12f4a959..57617e8d8fbe 100644 --- a/tests/run-staging/quoted-show-name.scala +++ b/tests/run-staging/quoted-show-name.scala @@ -9,10 +9,10 @@ object Test { println(powerCode(77).show) } - def powerCode(n: Long) with QuoteContext : Expr[Double => Double] = + def powerCode(n: Long)(using QuoteContext): Expr[Double => Double] = '{ x1 => ${powerCode(n, 2, 'x1)} } - def powerCode(n: Long, idx: Int, x: Expr[Double]) with QuoteContext : Expr[Double] = + def powerCode(n: Long, idx: Int, x: Expr[Double])(using QuoteContext): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x else if (n % 2 == 0) '{ @showName(${Expr("x" + idx)}) val y = $x * $x; ${powerCode(n / 2, idx * 2, '{y})} } diff --git a/tests/run-staging/shonan-hmm-simple.scala b/tests/run-staging/shonan-hmm-simple.scala index f4ab7f1eae86..f1cdd9aec7c0 100644 --- a/tests/run-staging/shonan-hmm-simple.scala +++ b/tests/run-staging/shonan-hmm-simple.scala @@ -18,7 +18,7 @@ class RingInt extends Ring[Int] val mul = (x, y) => x * y -class RingIntExpr with QuoteContext extends Ring[Expr[Int]] +class RingIntExpr(using QuoteContext) extends Ring[Expr[Int]] val zero = '{0} val one = '{1} val add = (x, y) => '{$x + $y} @@ -34,15 +34,15 @@ class RingComplex[U](u: Ring[U]) extends Ring[Complex[U]] { } sealed trait PV[T] - def expr with (Liftable[T], QuoteContext) : Expr[T] + def expr(using Liftable[T], QuoteContext): Expr[T] case class Sta[T](x: T) extends PV[T] - def expr with (Liftable[T], QuoteContext) : Expr[T] = x + def expr(using Liftable[T], QuoteContext): Expr[T] = x case class Dyn[T](x: Expr[T]) extends PV[T] - def expr with (Liftable[T], QuoteContext) : Expr[T] = x + def expr(using Liftable[T], QuoteContext): Expr[T] = x -class RingPV[U: Liftable](u: Ring[U], eu: Ring[Expr[U]]) with QuoteContext extends Ring[PV[U]] { +class RingPV[U: Liftable](u: Ring[U], eu: Ring[Expr[U]])(using QuoteContext) extends Ring[PV[U]] { val zero: PV[U] = Sta(u.zero) val one: PV[U] = Sta(u.one) val add = (x: PV[U], y: PV[U]) => (x, y) match { @@ -96,7 +96,7 @@ class StaticVecOps[T] extends VecOps[Int, T] { } } -class ExprVecOps[T: Type] with QuoteContext extends VecOps[Expr[Int], Expr[T]] +class ExprVecOps[T: Type](using QuoteContext) extends VecOps[Expr[Int], Expr[T]] val reduce: ((Expr[T], Expr[T]) => Expr[T], Expr[T], Vec[Expr[Int], Expr[T]]) => Expr[T] = (plus, zero, vec) => '{ var sum = $zero var i = 0 @@ -137,8 +137,8 @@ object Test { println(res2) println() - def blasStaticIntExpr with QuoteContext = new Blas1(new RingIntExpr, new StaticVecOps) - def resCode1 with QuoteContext = blasStaticIntExpr.dot( + def blasStaticIntExpr(using QuoteContext) = new Blas1(new RingIntExpr, new StaticVecOps) + def resCode1(using QuoteContext) = blasStaticIntExpr.dot( vec1.map(Expr(_)), vec2.map(Expr(_)) ) @@ -146,8 +146,8 @@ object Test { println(run(resCode1)) println() - def blasExprIntExpr with QuoteContext = new Blas1(new RingIntExpr, new ExprVecOps) - def resCode2 with QuoteContext : Expr[(Array[Int], Array[Int]) => Int] = '{ + def blasExprIntExpr(using QuoteContext) = new Blas1(new RingIntExpr, new ExprVecOps) + def resCode2(using QuoteContext): Expr[(Array[Int], Array[Int]) => Int] = '{ (arr1, arr2) => if (arr1.length != arr2.length) throw new Exception("...") ${ @@ -161,8 +161,8 @@ object Test { println(run(resCode2).apply(arr1, arr2)) println() - def blasStaticIntPVExpr with QuoteContext = new Blas1(new RingPV[Int](new RingInt, new RingIntExpr), new StaticVecOps) - def resCode3 with QuoteContext = blasStaticIntPVExpr.dot( + def blasStaticIntPVExpr(using QuoteContext) = new Blas1(new RingPV[Int](new RingInt, new RingIntExpr), new StaticVecOps) + def resCode3(using QuoteContext) = blasStaticIntPVExpr.dot( vec1.map(i => Dyn(i)), vec2.map(i => Sta(i)) ).expr @@ -170,8 +170,8 @@ object Test { println(run(resCode3)) println() - def blasExprIntPVExpr with QuoteContext = new Blas1(new RingPV[Int](new RingInt, new RingIntExpr), new StaticVecOps) - def resCode4 with QuoteContext : Expr[Array[Int] => Int] = '{ + def blasExprIntPVExpr(using QuoteContext) = new Blas1(new RingPV[Int](new RingInt, new RingIntExpr), new StaticVecOps) + def resCode4(using QuoteContext): Expr[Array[Int] => Int] = '{ arr => if (arr.length != ${vec2.size}) throw new Exception("...") ${ @@ -187,8 +187,8 @@ object Test { println() import Complex.isLiftable - def blasExprComplexPVInt with QuoteContext = new Blas1[Int, Complex[PV[Int]]](new RingComplex(new RingPV[Int](new RingInt, new RingIntExpr)), new StaticVecOps) - def resCode5 with QuoteContext : Expr[Array[Complex[Int]] => Complex[Int]] = '{ + def blasExprComplexPVInt(using QuoteContext) = new Blas1[Int, Complex[PV[Int]]](new RingComplex(new RingPV[Int](new RingInt, new RingIntExpr)), new StaticVecOps) + def resCode5(using QuoteContext): Expr[Array[Complex[Int]] => Complex[Int]] = '{ arr => if (arr.length != ${cmpxVec2.size}) throw new Exception("...") ${ @@ -203,12 +203,12 @@ object Test { println(run(resCode5).apply(cmpxArr1)) println() - def RingPVInt with QuoteContext = new RingPV[Int](new RingInt, new RingIntExpr) + def RingPVInt(using QuoteContext) = new RingPV[Int](new RingInt, new RingIntExpr) // Staged loop of dot product on vectors of Int or Expr[Int] - def dotIntOptExpr with QuoteContext = new Blas1(RingPVInt, new StaticVecOps).dot + def dotIntOptExpr(using QuoteContext) = new Blas1(RingPVInt, new StaticVecOps).dot // will generate the code '{ ((arr: scala.Array[scala.Int]) => arr.apply(1).+(arr.apply(3))) } - def staticVec with QuoteContext = Vec[Int, PV[Int]](5, i => Sta((i % 2))) - def code with QuoteContext = '{(arr: Array[Int]) => ${dotIntOptExpr(Vec(5, i => Dyn('{arr(${i})})), staticVec).expr} } + def staticVec(using QuoteContext) = Vec[Int, PV[Int]](5, i => Sta((i % 2))) + def code(using QuoteContext) = '{(arr: Array[Int]) => ${dotIntOptExpr(Vec(5, i => Dyn('{arr(${i})})), staticVec).expr} } println(withQuoteContext(code.show)) println() } diff --git a/tests/run-staging/shonan-hmm/Complex.scala b/tests/run-staging/shonan-hmm/Complex.scala index 0e834e6bb33b..85c3ee76762d 100644 --- a/tests/run-staging/shonan-hmm/Complex.scala +++ b/tests/run-staging/shonan-hmm/Complex.scala @@ -8,6 +8,8 @@ object Complex { def toExpr(c: Complex[T]) = '{ Complex(${Expr(c.re)}, ${Expr(c.im)}) } } - def of_complex_expr(x: Expr[Complex[Int]]) with QuoteContext : Complex[Expr[Int]] = Complex('{$x.re}, '{$x.im}) - def of_expr_complex(x: Complex[Expr[Int]]) with QuoteContext : Expr[Complex[Int]] = '{Complex(${x.re}, ${x.im})} + def of_complex_expr(x: Expr[Complex[Int]])(using QuoteContext): Complex[Expr[Int]] = Complex('{$x.re}, '{$x.im}) + def of_expr_complex(x: Complex[Expr[Int]])(using QuoteContext): Expr[Complex[Int]] = '{Complex(${x.re}, ${x.im})} + + } \ No newline at end of file diff --git a/tests/run-staging/shonan-hmm/Lifters.scala b/tests/run-staging/shonan-hmm/Lifters.scala index b095975b46f7..d625b28f5d83 100644 --- a/tests/run-staging/shonan-hmm/Lifters.scala +++ b/tests/run-staging/shonan-hmm/Lifters.scala @@ -6,7 +6,7 @@ import scala.quoted._ import scala.quoted.autolift.{given _} object Lifters { - implicit def LiftedClassTag[T: Type: ClassTag] with QuoteContext : Expr[ClassTag[T]] = { + implicit def LiftedClassTag[T: Type: ClassTag] (using QuoteContext): Expr[ClassTag[T]] = { '{ ClassTag(${summon[ClassTag[T]].runtimeClass })} } @@ -24,7 +24,7 @@ object Lifters { } } - private def initArray[T : Liftable : Type](arr: Array[T], array: Expr[Array[T]]) with QuoteContext : Expr[Array[T]] = { + private def initArray[T : Liftable : Type](arr: Array[T], array: Expr[Array[T]])(using QuoteContext): Expr[Array[T]] = { UnrolledExpr.block( arr.zipWithIndex.map { case (x, i) => '{ $array(${i}) = ${x} } diff --git a/tests/run-staging/shonan-hmm/MVmult.scala b/tests/run-staging/shonan-hmm/MVmult.scala index ff564e8e33b5..5cff7a5c6a28 100644 --- a/tests/run-staging/shonan-hmm/MVmult.scala +++ b/tests/run-staging/shonan-hmm/MVmult.scala @@ -22,7 +22,7 @@ object MVmult { MV.mvmult(vout_, a_, v_) } - def mvmult_c with QuoteContext : Expr[(Array[Int], Array[Array[Int]], Array[Int]) => Unit] = '{ + def mvmult_c(using QuoteContext): Expr[(Array[Int], Array[Array[Int]], Array[Int]) => Unit] = '{ (vout, a, v) => { val n = vout.length val m = v.length @@ -37,7 +37,7 @@ object MVmult { } } - def mvmult_mc(n: Int, m: Int) with QuoteContext : Expr[(Array[Int], Array[Array[Int]], Array[Int]) => Unit] = { + def mvmult_mc(n: Int, m: Int)(using QuoteContext): Expr[(Array[Int], Array[Array[Int]], Array[Int]) => Unit] = { val MV = new MVmult[Int, Expr[Int], Expr[Unit]](new RingIntExpr, new VecRStaDim(new RingIntExpr)) '{ (vout, a, v) => { @@ -54,7 +54,7 @@ object MVmult { } } - def mvmult_ac(a: Array[Array[Int]]) with QuoteContext : Expr[(Array[Int], Array[Int]) => Unit] = { + def mvmult_ac(a: Array[Array[Int]])(using QuoteContext): Expr[(Array[Int], Array[Int]) => Unit] = { import Lifters._ '{ val arr = ${a} @@ -65,7 +65,7 @@ object MVmult { } } - def mvmult_opt(a: Array[Array[Int]]) with QuoteContext : Expr[(Array[Int], Array[Int]) => Unit] = { + def mvmult_opt(a: Array[Array[Int]])(using QuoteContext): Expr[(Array[Int], Array[Int]) => Unit] = { import Lifters._ '{ val arr = ${a} @@ -76,7 +76,7 @@ object MVmult { } } - def mvmult_roll(a: Array[Array[Int]]) with QuoteContext : Expr[(Array[Int], Array[Int]) => Unit] = { + def mvmult_roll(a: Array[Array[Int]])(using QuoteContext): Expr[(Array[Int], Array[Int]) => Unit] = { import Lifters._ '{ val arr = ${a} @@ -87,19 +87,19 @@ object MVmult { } } - def mvmult_let1(a: Array[Array[Int]]) with QuoteContext : Expr[(Array[Int], Array[Int]) => Unit] = { + def mvmult_let1(a: Array[Array[Int]])(using QuoteContext): Expr[(Array[Int], Array[Int]) => Unit] = { val (n, m, a2) = amatCopy(a, copy_row1) mvmult_abs0(new RingIntOPExpr, new VecRStaOptDynInt(new RingIntPExpr))(n, m, a2) } - def mvmult_let(a: Array[Array[Int]]) with QuoteContext : Expr[(Array[Int], Array[Int]) => Unit] = { + def mvmult_let(a: Array[Array[Int]])(using QuoteContext): Expr[(Array[Int], Array[Int]) => Unit] = { initRows(a) { rows => val (n, m, a2) = amat2(a, rows) mvmult_abs0(new RingIntOPExpr, new VecRStaOptDynInt(new RingIntPExpr))(n, m, a2) } } - def initRows[T: Type](a: Array[Array[Int]])(cont: Array[Expr[Array[Int]]] => Expr[T]) with QuoteContext : Expr[T] = { + def initRows[T: Type](a: Array[Array[Int]])(cont: Array[Expr[Array[Int]]] => Expr[T])(using QuoteContext): Expr[T] = { import Lifters._ def loop(i: Int, acc: List[Expr[Array[Int]]]): Expr[T] = { if (i >= a.length) cont(acc.toArray.reverse) @@ -114,7 +114,7 @@ object MVmult { loop(0, Nil) } - def amat1(a: Array[Array[Int]], aa: Expr[Array[Array[Int]]]) with QuoteContext : (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { + def amat1(a: Array[Array[Int]], aa: Expr[Array[Array[Int]]])(using QuoteContext): (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { val n = a.length val m = a(0).length val vec: Vec[PV[Int], Vec[PV[Int], PV[Int]]] = Vec(Sta(n), i => Vec(Sta(m), j => (i, j) match { @@ -125,7 +125,7 @@ object MVmult { (n, m, vec) } - def amat2(a: Array[Array[Int]], refs: Array[Expr[Array[Int]]]) with QuoteContext : (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { + def amat2(a: Array[Array[Int]], refs: Array[Expr[Array[Int]]])(using QuoteContext): (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { val n = a.length val m = a(0).length val vec: Vec[PV[Int], Vec[PV[Int], PV[Int]]] = Vec(Sta(n), i => Vec(Sta(m), j => (i, j) match { @@ -135,7 +135,7 @@ object MVmult { (n, m, vec) } - def amatCopy(a: Array[Array[Int]], copyRow: Array[Int] => (Expr[Int] => Expr[Int])) with QuoteContext : (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { + def amatCopy(a: Array[Array[Int]], copyRow: Array[Int] => (Expr[Int] => Expr[Int]))(using QuoteContext): (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { val n = a.length val m = a(0).length val vec: Vec[PV[Int], Vec[PV[Int], PV[Int]]] = Vec(Sta(n), i => Vec(Sta(m), j => (i, j) match { @@ -148,19 +148,19 @@ object MVmult { (n, m, vec) } - def copy_row1 with QuoteContext : Array[Int] => (Expr[Int] => Expr[Int]) = v => { + def copy_row1(using QuoteContext): Array[Int] => (Expr[Int] => Expr[Int]) = v => { import Lifters._ val arr = v i => '{ ($arr).apply($i) } } - def copy_row_let with QuoteContext : Array[Int] => (Expr[Int] => Expr[Int]) = v => { + def copy_row_let(using QuoteContext): Array[Int] => (Expr[Int] => Expr[Int]) = v => { import Lifters._ val arr: Expr[Array[Int]] = ??? // FIXME used genlet v i => '{ ($arr).apply($i) } } - private def mvmult_abs0(ring: Ring[PV[Int]], vecOp: VecROp[PV[Int], PV[Int], Expr[Unit]])(n: Int, m: Int, a: Vec[PV[Int], Vec[PV[Int], PV[Int]]]) with QuoteContext : Expr[(Array[Int], Array[Int]) => Unit] = { + private def mvmult_abs0(ring: Ring[PV[Int]], vecOp: VecROp[PV[Int], PV[Int], Expr[Unit]])(n: Int, m: Int, a: Vec[PV[Int], Vec[PV[Int], PV[Int]]])(using QuoteContext): Expr[(Array[Int], Array[Int]) => Unit] = { '{ (vout, v) => { if (${n} != vout.length) throw new IndexOutOfBoundsException(${n.toString}) diff --git a/tests/run-staging/shonan-hmm/PV.scala b/tests/run-staging/shonan-hmm/PV.scala index c56fc92ff4bf..ce7b092b7ed5 100644 --- a/tests/run-staging/shonan-hmm/PV.scala +++ b/tests/run-staging/shonan-hmm/PV.scala @@ -8,9 +8,9 @@ case class Sta[T](x: T) extends PV[T] case class Dyn[T](x: Expr[T]) extends PV[T] object Dyns { - def dyn[T: Liftable](pv: PV[T]) with QuoteContext : Expr[T] = pv match { + def dyn[T: Liftable](pv: PV[T])(using QuoteContext): Expr[T] = pv match { case Sta(x) => Expr(x) case Dyn(x) => x } - def dyni with QuoteContext : PV[Int] => Expr[Int] = dyn[Int] + def dyni(using QuoteContext): PV[Int] => Expr[Int] = dyn[Int] } diff --git a/tests/run-staging/shonan-hmm/Ring.scala b/tests/run-staging/shonan-hmm/Ring.scala index 7cde34ca3d04..02c930175446 100644 --- a/tests/run-staging/shonan-hmm/Ring.scala +++ b/tests/run-staging/shonan-hmm/Ring.scala @@ -24,7 +24,7 @@ object RingInt extends Ring[Int] { override def toString(): String = "RingInt" } -class RingIntExpr with QuoteContext extends Ring[Expr[Int]] { +class RingIntExpr(using QuoteContext) extends Ring[Expr[Int]] { val zero = '{0} val one = '{1} val add = (x, y) => '{$x + $y} @@ -43,7 +43,7 @@ case class RingComplex[U](u: Ring[U]) extends Ring[Complex[U]] { override def toString(): String = s"RingComplex($u)" } -case class RingPV[U: Liftable](staRing: Ring[U], dynRing: Ring[Expr[U]]) with QuoteContext extends Ring[PV[U]] { +case class RingPV[U: Liftable](staRing: Ring[U], dynRing: Ring[Expr[U]])(using QuoteContext) extends Ring[PV[U]] { type T = PV[U] val dyn = Dyns.dyn[U] @@ -66,9 +66,9 @@ case class RingPV[U: Liftable](staRing: Ring[U], dynRing: Ring[Expr[U]]) with Qu } } -class RingIntPExpr with QuoteContext extends RingPV(RingInt, new RingIntExpr) +class RingIntPExpr(using QuoteContext) extends RingPV(RingInt, new RingIntExpr) -class RingIntOPExpr with QuoteContext extends RingIntPExpr { +class RingIntOPExpr(using QuoteContext) extends RingIntPExpr { override def add = (x: PV[Int], y: PV[Int]) => (x, y) match { case (Sta(0), y) => y case (x, Sta(0)) => x diff --git a/tests/run-staging/shonan-hmm/UnrolledExpr.scala b/tests/run-staging/shonan-hmm/UnrolledExpr.scala index c48b0d5b784a..a761496bd948 100644 --- a/tests/run-staging/shonan-hmm/UnrolledExpr.scala +++ b/tests/run-staging/shonan-hmm/UnrolledExpr.scala @@ -8,7 +8,7 @@ object UnrolledExpr { } // TODO support blocks in the compiler to avoid creating trees of blocks? - def block[T: Type](stats: Iterable[Expr[_]], expr: Expr[T]) with QuoteContext : Expr[T] = { + def block[T: Type](stats: Iterable[Expr[_]], expr: Expr[T])(using QuoteContext): Expr[T] = { def rec(stats: List[Expr[_]]): Expr[T] = stats match { case x :: xs => '{ $x; ${rec(xs)} } case Nil => expr @@ -21,10 +21,10 @@ object UnrolledExpr { class UnrolledExpr[T: Liftable, It <: Iterable[T]](xs: It) { import UnrolledExpr._ - def foreach[U](f: T => Expr[U]) with QuoteContext : Expr[Unit] = block(xs.map(f), '{}) + def foreach[U](f: T => Expr[U])(using QuoteContext): Expr[Unit] = block(xs.map(f), '{}) - def withFilter(f: T => Boolean) with QuoteContext : UnrolledExpr[T, Iterable[T]] = new UnrolledExpr(xs.filter(f)) + def withFilter(f: T => Boolean)(using QuoteContext): UnrolledExpr[T, Iterable[T]] = new UnrolledExpr(xs.filter(f)) - def foldLeft[U](acc: Expr[U])(f: (Expr[U], T) => Expr[U]) with QuoteContext : Expr[U] = + def foldLeft[U](acc: Expr[U])(f: (Expr[U], T) => Expr[U])(using QuoteContext): Expr[U] = xs.foldLeft(acc)((acc, x) => f(acc, x)) } diff --git a/tests/run-staging/shonan-hmm/VecOp.scala b/tests/run-staging/shonan-hmm/VecOp.scala index b0590f132206..011657deffbe 100644 --- a/tests/run-staging/shonan-hmm/VecOp.scala +++ b/tests/run-staging/shonan-hmm/VecOp.scala @@ -12,7 +12,7 @@ class VecSta extends VecOp[Int, Unit] { override def toString(): String = s"StaticVec" } -class VecDyn with QuoteContext extends VecOp[Expr[Int], Expr[Unit]] { +class VecDyn(using QuoteContext) extends VecOp[Expr[Int], Expr[Unit]] { def iter: Vec[Expr[Int], Expr[Unit]] => Expr[Unit] = arr => '{ var i = 0 while (i < ${arr.size}) { diff --git a/tests/run-staging/shonan-hmm/VecROp.scala b/tests/run-staging/shonan-hmm/VecROp.scala index fbdd2468b9b1..c4d446926889 100644 --- a/tests/run-staging/shonan-hmm/VecROp.scala +++ b/tests/run-staging/shonan-hmm/VecROp.scala @@ -17,7 +17,7 @@ class StaticVecR[T](r: Ring[T]) extends VecSta with VecROp[Int, T, Unit] { override def toString(): String = s"StaticVecR($r)" } -class VecRDyn[T: Type] with QuoteContext extends VecDyn with VecROp[Expr[Int], Expr[T], Expr[Unit]] { +class VecRDyn[T: Type](using QuoteContext) extends VecDyn with VecROp[Expr[Int], Expr[T], Expr[Unit]] { def reduce: ((Expr[T], Expr[T]) => Expr[T], Expr[T], Vec[Expr[Int], Expr[T]]) => Expr[T] = { (plus, zero, vec) => '{ var sum = $zero @@ -32,7 +32,7 @@ class VecRDyn[T: Type] with QuoteContext extends VecDyn with VecROp[Expr[Int], E override def toString(): String = s"VecRDyn" } -class VecRStaDim[T: Type](r: Ring[T]) with QuoteContext extends VecROp[Int, T, Expr[Unit]] { +class VecRStaDim[T: Type](r: Ring[T])(using QuoteContext) extends VecROp[Int, T, Expr[Unit]] { val M = new StaticVecR[T](r) def reduce: ((T, T) => T, T, Vec[Int, T]) => T = M.reduce val seq: (Expr[Unit], Expr[Unit]) => Expr[Unit] = (e1, e2) => '{ $e1; $e2 } @@ -46,7 +46,7 @@ class VecRStaDim[T: Type](r: Ring[T]) with QuoteContext extends VecROp[Int, T, E override def toString(): String = s"VecRStaDim($r)" } -class VecRStaDyn[T : Type : Liftable](r: Ring[PV[T]]) with QuoteContext extends VecROp[PV[Int], PV[T], Expr[Unit]] { +class VecRStaDyn[T : Type : Liftable](r: Ring[PV[T]])(using QuoteContext) extends VecROp[PV[Int], PV[T], Expr[Unit]] { val VSta: VecROp[Int, PV[T], Expr[Unit]] = new VecRStaDim(r) val VDyn = new VecRDyn val dyn = Dyns.dyn[T] @@ -74,7 +74,7 @@ object VecRStaOptDynInt { val threshold = 3 } -class VecRStaOptDynInt(r: Ring[PV[Int]]) with QuoteContext extends VecRStaDyn(r) { +class VecRStaOptDynInt(r: Ring[PV[Int]]) (using QuoteContext) extends VecRStaDyn(r) { val M: VecROp[PV[Int], PV[Int], Expr[Unit]] = new VecRStaDyn(r) override def reduce: ((PV[Int], PV[Int]) => PV[Int], PV[Int], Vec[PV[Int], PV[Int]]) => PV[Int] = (plus, zero, vec) => vec match { diff --git a/tests/run-staging/shonan-hmm/Vmults.scala b/tests/run-staging/shonan-hmm/Vmults.scala index fcd63e52ec3b..e61b5bd7837b 100644 --- a/tests/run-staging/shonan-hmm/Vmults.scala +++ b/tests/run-staging/shonan-hmm/Vmults.scala @@ -19,7 +19,7 @@ object Vmults { V.vmult(vout_, v1_, v2_) } - def vmultCA with QuoteContext : Expr[(Array[Complex[Int]], Array[Complex[Int]], Array[Complex[Int]]) => Unit] = '{ + def vmultCA(using QuoteContext): Expr[(Array[Complex[Int]], Array[Complex[Int]], Array[Complex[Int]]) => Unit] = '{ (vout, v1, v2) => { val n = vout.length ${ diff --git a/tests/run-staging/staged-streams_1.scala b/tests/run-staging/staged-streams_1.scala index d99f707a8a03..0e6481fd5414 100644 --- a/tests/run-staging/staged-streams_1.scala +++ b/tests/run-staging/staged-streams_1.scala @@ -205,7 +205,7 @@ object Test { * @return a new stream consisting of all elements of the input stream that do satisfy the given * predicate `pred`. */ - def filter(pred: (Expr[A] => Expr[Boolean])) with QuoteContext : Stream[A] = { + def filter(pred: (Expr[A] => Expr[Boolean]))(using QuoteContext): Stream[A] = { val filterStream = (a: Expr[A]) => new Producer[Expr[A]] { @@ -305,7 +305,7 @@ object Test { * @tparam A the type of the producer's elements. * @return a linear or nested stream aware of the variable reference to decrement. */ - private def takeRaw[A: Type](n: Expr[Int], stream: StagedStream[A]) with QuoteContext : StagedStream[A] = { + private def takeRaw[A: Type](n: Expr[Int], stream: StagedStream[A])(using QuoteContext): StagedStream[A] = { stream match { case linear: Linear[A] => { val enhancedProducer: Producer[(Var[Int], A)] = addCounter[A](n, linear.producer) @@ -334,9 +334,9 @@ object Test { } /** A stream containing the first `n` elements of this stream. */ - def take(n: Expr[Int]) with QuoteContext : Stream[A] = Stream(takeRaw[Expr[A]](n, stream)) + def take(n: Expr[Int])(using QuoteContext): Stream[A] = Stream(takeRaw[Expr[A]](n, stream)) - private def zipRaw[A: Type, B: Type](stream1: StagedStream[Expr[A]], stream2: StagedStream[B]) with QuoteContext : StagedStream[(Expr[A], B)] = { + private def zipRaw[A: Type, B: Type](stream1: StagedStream[Expr[A]], stream2: StagedStream[B])(using QuoteContext): StagedStream[(Expr[A], B)] = { (stream1, stream2) match { case (Linear(producer1), Linear(producer2)) => @@ -404,7 +404,7 @@ object Test { * @tparam A * @return */ - private def makeLinear[A: Type](stream: StagedStream[Expr[A]]) with QuoteContext : Producer[Expr[A]] = { + private def makeLinear[A: Type](stream: StagedStream[Expr[A]])(using QuoteContext): Producer[Expr[A]] = { stream match { case Linear(producer) => producer case Nested(producer, nestedf) => { @@ -507,7 +507,7 @@ object Test { } } - private def pushLinear[A, B, C](producer: Producer[A], nestedProducer: Producer[B], nestedf: (B => StagedStream[C])) with QuoteContext : StagedStream[(A, C)] = { + private def pushLinear[A, B, C](producer: Producer[A], nestedProducer: Producer[B], nestedf: (B => StagedStream[C]))(using QuoteContext): StagedStream[(A, C)] = { val newProducer = new Producer[(Var[Boolean], producer.St, B)] { type St = (Var[Boolean], producer.St, nestedProducer.St) @@ -565,14 +565,14 @@ object Test { } /** zip **/ - def zip[B: Type, C: Type](f: (Expr[A] => Expr[B] => Expr[C]), stream2: Stream[B]) with QuoteContext : Stream[C] = { + def zip[B: Type, C: Type](f: (Expr[A] => Expr[B] => Expr[C]), stream2: Stream[B])(using QuoteContext): Stream[C] = { val Stream(stream_b) = stream2 Stream(mapRaw[(Expr[A], Expr[B]), Expr[C]]((t => k => k(f(t._1)(t._2))), zipRaw[A, Expr[B]](stream, stream_b))) } } object Stream { - def of[A: Type](arr: Expr[Array[A]]) with QuoteContext : Stream[A] = { + def of[A: Type](arr: Expr[Array[A]])(using QuoteContext): Stream[A] = { val prod = new Producer[Expr[A]] { type St = (Var[Int], Var[Int], Expr[Array[A]]) @@ -607,52 +607,52 @@ object Test { } } - def test1() with QuoteContext = Stream + def test1()(using QuoteContext) = Stream .of('{Array(1, 2, 3)}) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test2() with QuoteContext = Stream + def test2()(using QuoteContext) = Stream .of('{Array(1, 2, 3)}) .map((a: Expr[Int]) => '{ $a * 2 }) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test3() with QuoteContext = Stream + def test3()(using QuoteContext) = Stream .of('{Array(1, 2, 3)}) .flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d * $dp })) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test4() with QuoteContext = Stream + def test4()(using QuoteContext) = Stream .of('{Array(1, 2, 3)}) .filter((d: Expr[Int]) => '{ $d % 2 == 0 }) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test5() with QuoteContext = Stream + def test5()(using QuoteContext) = Stream .of('{Array(1, 2, 3)}) .take('{2}) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test6() with QuoteContext = Stream + def test6()(using QuoteContext) = Stream .of('{Array(1, 1, 1)}) .flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).take('{2})) .take('{5}) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test7() with QuoteContext = Stream + def test7()(using QuoteContext) = Stream .of('{Array(1, 2, 3)}) .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)})) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test8() with QuoteContext = Stream + def test8()(using QuoteContext) = Stream .of('{Array(1, 2, 3)}) .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp }))) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test9() with QuoteContext = Stream + def test9()(using QuoteContext) = Stream .of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp })) .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)}) ) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test10() with QuoteContext = Stream + def test10()(using QuoteContext) = Stream .of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp })) .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp })) ) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) diff --git a/tests/run-staging/staged-tuples/StagedTuple.scala b/tests/run-staging/staged-tuples/StagedTuple.scala index b13c20dd6d82..a3fefd3cef13 100644 --- a/tests/run-staging/staged-tuples/StagedTuple.scala +++ b/tests/run-staging/staged-tuples/StagedTuple.scala @@ -14,7 +14,7 @@ object StagedTuple { private final val specialize = true - def toArrayStaged(tup: Expr[Tuple], size: Option[Int]) with QuoteContext : Expr[Array[Object]] = { + def toArrayStaged(tup: Expr[Tuple], size: Option[Int])(using QuoteContext): Expr[Array[Object]] = { if (!specialize) '{dynamicToArray($tup)} else size match { case Some(0) => @@ -36,7 +36,7 @@ object StagedTuple { } } - def fromArrayStaged[T <: Tuple : Type](xs: Expr[Array[Object]], size: Option[Int]) with QuoteContext : Expr[T] = { + def fromArrayStaged[T <: Tuple : Type](xs: Expr[Array[Object]], size: Option[Int])(using QuoteContext): Expr[T] = { if (!specialize) '{dynamicFromArray[T]($xs)} else xs.bind { xs => val tup: Expr[Any] = size match { @@ -70,7 +70,7 @@ object StagedTuple { } } - def sizeStaged[Res <: Int : Type](tup: Expr[Tuple], size: Option[Int]) with QuoteContext : Expr[Res] = { + def sizeStaged[Res <: Int : Type](tup: Expr[Tuple], size: Option[Int])(using QuoteContext): Expr[Res] = { val res = if (!specialize) '{dynamicSize($tup)} else size match { @@ -80,7 +80,7 @@ object StagedTuple { res.as[Res] } - def headStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int]) with QuoteContext : Expr[Head[Tup]] = { + def headStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int])(using QuoteContext): Expr[Head[Tup]] = { if (!specialize) '{dynamicApply[Tup, 0]($tup, 0)} else { val resVal = size match { @@ -103,7 +103,7 @@ object StagedTuple { } } - def tailStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int]) with QuoteContext : Expr[Tail[Tup]] = { + def tailStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int])(using QuoteContext): Expr[Tail[Tup]] = { if (!specialize) '{dynamicTail[Tup]($tup)} else { val res = size match { @@ -127,7 +127,7 @@ object StagedTuple { } } - def applyStaged[Tup <: NonEmptyTuple : Type, N <: Int : Type](tup: Expr[Tup], size: Option[Int], n: Expr[N], nValue: Option[Int]) with (qctx: QuoteContext) : Expr[Elem[Tup, N]] = { + def applyStaged[Tup <: NonEmptyTuple : Type, N <: Int : Type](tup: Expr[Tup], size: Option[Int], n: Expr[N], nValue: Option[Int])(using qctx: QuoteContext): Expr[Elem[Tup, N]] = { import reflect._ if (!specialize) '{dynamicApply($tup, $n)} @@ -187,7 +187,7 @@ object StagedTuple { } } - def consStaged[T <: Tuple & Singleton : Type, H : Type](self: Expr[T], x: Expr[H], tailSize: Option[Int]) with QuoteContext : Expr[H *: T] = + def consStaged[T <: Tuple & Singleton : Type, H : Type](self: Expr[T], x: Expr[H], tailSize: Option[Int])(using QuoteContext): Expr[H *: T] = if (!specialize) '{dynamicCons[H, T]($x, $self)} else { val res = tailSize match { @@ -209,7 +209,7 @@ object StagedTuple { res.as[H *: T] } - def concatStaged[Self <: Tuple & Singleton : Type, That <: Tuple & Singleton : Type](self: Expr[Self], selfSize: Option[Int], that: Expr[That], thatSize: Option[Int]) with QuoteContext : Expr[Concat[Self, That]] = { + def concatStaged[Self <: Tuple & Singleton : Type, That <: Tuple & Singleton : Type](self: Expr[Self], selfSize: Option[Int], that: Expr[That], thatSize: Option[Int])(using QuoteContext): Expr[Concat[Self, That]] = { if (!specialize) '{dynamicConcat[Self, That]($self, $that)} else { def genericConcat(xs: Expr[Tuple], ys: Expr[Tuple]): Expr[Tuple] = @@ -260,9 +260,9 @@ object StagedTuple { private implicit class ExprOps[U: Type](expr: Expr[U]) { - def as[T: Type] with QuoteContext : Expr[T] = '{ $expr.asInstanceOf[T] } + def as[T: Type](using QuoteContext): Expr[T] = '{ $expr.asInstanceOf[T] } - def bind[T: Type](in: Expr[U] => Expr[T]) with QuoteContext : Expr[T] = '{ + def bind[T: Type](in: Expr[U] => Expr[T])(using QuoteContext): Expr[T] = '{ val t: U = $expr ${in('t)} } diff --git a/tests/run-staging/tasty-extractors-constants-2/quoted_1.scala b/tests/run-staging/tasty-extractors-constants-2/quoted_1.scala index 617ae13e8b6c..5a0a91e4ad5d 100644 --- a/tests/run-staging/tasty-extractors-constants-2/quoted_1.scala +++ b/tests/run-staging/tasty-extractors-constants-2/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { inline def testMacro: Unit = ${impl} - def impl with QuoteContext : Expr[Unit] = { + def impl(using QuoteContext): Expr[Unit] = { given Toolbox = Toolbox.make(getClass.getClassLoader) // 2 is a lifted constant val show1 = withQuoteContext(power(2, 3.0).show) @@ -22,7 +22,7 @@ object Macros { val run3 = run(power('{2}, 5.0)) // n2 is not a constant - def n2 with QuoteContext = '{ println("foo"); 2 } + def n2(using QuoteContext) = '{ println("foo"); 2 } val show4 = withQuoteContext(power(n2, 6.0).show) val run4 = run(power(n2, 6.0)) @@ -41,7 +41,7 @@ object Macros { } } - def power(n: Expr[Int], x: Expr[Double]) with QuoteContext : Expr[Double] = { + def power(n: Expr[Int], x: Expr[Double])(using QuoteContext): Expr[Double] = { import quoted.matching.Const n match { case Const(n1) => powerCode(n1, x) @@ -49,7 +49,7 @@ object Macros { } } - def powerCode(n: Int, x: Expr[Double]) with QuoteContext : Expr[Double] = + def powerCode(n: Int, x: Expr[Double])(using QuoteContext): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, 'y)} } } diff --git a/tests/run/Signals.scala b/tests/run/Signals.scala index b9cec0b1000e..7cebb604d675 100644 --- a/tests/run/Signals.scala +++ b/tests/run/Signals.scala @@ -9,10 +9,10 @@ package frp: changeTo(expr) protected def changeTo(expr: Signal.Caller ?=> T @uncheckedVariance): Unit = - myExpr = (caller => expr.with(caller)) + myExpr = (caller => expr(using caller)) computeValue() - def apply() with (caller: Signal.Caller) = + def apply()(using caller: Signal.Caller) = observers += caller assert(!caller.observers.contains(this), "cyclic signal definition") myValue diff --git a/tests/run/Signals1.scala b/tests/run/Signals1.scala index 30fffdae5878..285a40609e79 100644 --- a/tests/run/Signals1.scala +++ b/tests/run/Signals1.scala @@ -3,7 +3,7 @@ import annotation.unchecked._ package frp: trait Signal[+T]: - def apply() with (caller: Signal.Caller) : T + def apply()(using caller: Signal.Caller): T object Signal: @@ -22,7 +22,7 @@ package frp: observers = Set() obs.foreach(_.computeValue()) - def apply() with (caller: Caller) : T = + def apply()(using caller: Caller): T = observers += caller assert(!caller.observers.contains(this), "cyclic signal definition") currentValue @@ -30,15 +30,15 @@ package frp: def apply[T](expr: Caller ?=> T): Signal[T] = new AbstractSignal[T]: - protected val eval = expr.with(_) + protected val eval = expr(using _) computeValue() class Var[T](expr: Caller ?=> T) extends AbstractSignal[T]: - protected var eval: Caller => T = expr.with(_) + protected var eval: Caller => T = expr(using _) computeValue() def update(expr: Caller ?=> T): Unit = - eval = expr.with(_) + eval = expr(using _) computeValue() end Var diff --git a/tests/run/cochis-example.scala b/tests/run/cochis-example.scala index ff7a57955be9..657c90406508 100644 --- a/tests/run/cochis-example.scala +++ b/tests/run/cochis-example.scala @@ -2,7 +2,7 @@ import Predef.{$conforms => _} trait A { given id[X] as (X => X) = x => x - def trans[X](x: X) with (f: X => X) = f(x) // (2) + def trans[X](x: X)(using f: X => X) = f(x) // (2) } object Test extends A with App{ given succ as (Int => Int) = x => x + 1 // (3) diff --git a/tests/run/config.scala b/tests/run/config.scala index 7e04e50f10e4..8476ab673fc4 100644 --- a/tests/run/config.scala +++ b/tests/run/config.scala @@ -29,8 +29,8 @@ object Imperative { ).onError(None) def main(args: Array[String]) = { - println(readPerson.with(Config("John Doe", 20))) - println(readPerson.with(Config("Incognito", 99))) + println(readPerson(using Config("John Doe", 20))) + println(readPerson(using Config("Incognito", 99))) } } @@ -56,7 +56,7 @@ object Exceptions { class OnError[T](op: Possibly[T]) { def onError(fallback: => T): T = - try op.with(new CanThrow) + try op(using new CanThrow) catch { case ex: E => fallback } } } @@ -85,8 +85,8 @@ object Test extends App { val config1 = Config("John Doe", 20) val config2 = Config("Incognito", 99) - println(readPerson.with(config1)) - println(readPerson.with(config2)) + println(readPerson(using config1)) + println(readPerson(using config2)) } object OptionTest extends App { diff --git a/tests/run/extmethods2.scala b/tests/run/extmethods2.scala index b975d8d7bbde..f454612762ea 100644 --- a/tests/run/extmethods2.scala +++ b/tests/run/extmethods2.scala @@ -2,18 +2,18 @@ object Test extends App { class TC - given stringListOps with TC as Object { + given stringListOps(using TC) as Object { type T = List[String] def (x: T).foo(y: T) = (x ++ y, summon[TC]) def (x: T).bar(y: Int) = (x(0)(y), summon[TC]) } - def test with TC = { + def test(using TC) = { assert(List("abc").foo(List("def"))._1 == List("abc", "def")) assert(List("abc").bar(2)._1 == 'c') } - test.with(TC()) + test(using TC()) object A { extension listOps on [T](xs: List[T]) { diff --git a/tests/run/given-eta.scala b/tests/run/given-eta.scala index cbc1e73713a0..3d290afb4718 100644 --- a/tests/run/given-eta.scala +++ b/tests/run/given-eta.scala @@ -4,8 +4,8 @@ trait D type T def trans(other: T): T -def f(x: Int) with (c: C) (y: Int) = x + c.x + y -def g(x: Int) with (d: D) (y: d.T): d.T = d.trans(y) +def f(x: Int)(using c: C) (y: Int) = x + c.x + y +def g(x: Int)(using d: D) (y: d.T): d.T = d.trans(y) @main def Test = given C(1) diff --git a/tests/run/i2146.scala b/tests/run/i2146.scala index 9b5e8a7f8413..4805ebfb8d74 100644 --- a/tests/run/i2146.scala +++ b/tests/run/i2146.scala @@ -16,8 +16,8 @@ object Test { def main(args: Array[String]) = { println(foo[A, B]) - println(foo[A, B].with(a)) - println(foo.with(a).with(b)) + println(foo[A, B](using a)) + println(foo(using a)(using b)) val s: A ?=> A = simple[A] println(s) val x0: A ?=> B ?=> (A, B) = foo[A, B] @@ -26,7 +26,7 @@ object Test { println(x1) println(bar[A, B]) - println(bar[A, B].with(a)) - println(bar.with(a).with(b)) + println(bar[A, B](using a)) + println(bar(using a)(using b)) } } diff --git a/tests/run/i2567.scala b/tests/run/i2567.scala index c59c73a5a7c9..e9ff8a5638b4 100644 --- a/tests/run/i2567.scala +++ b/tests/run/i2567.scala @@ -2,15 +2,15 @@ class TC given tc : TC -class Foo with TC { +class Foo(using TC) { println("hi") } object Test extends App { new Foo - new Foo.with(tc) + new Foo(using tc) new Foo() - new Foo().with(tc) + new Foo()(using tc) Foo() - Foo().with(tc) + Foo()(using tc) } \ No newline at end of file diff --git a/tests/run/i2939.scala b/tests/run/i2939.scala index 569a3dedd6fa..f032dc06aaf1 100644 --- a/tests/run/i2939.scala +++ b/tests/run/i2939.scala @@ -8,7 +8,7 @@ class Tag(val name: String, val buffer: Buffer[Tag] = ArrayBuffer()) { } def apply[U](f: Tag ?=> U)(implicit tag: Tag = null): this.type = { - f.with(this) + f(using this) if(tag != null) tag.buffer += this this } diff --git a/tests/run/i3448.scala b/tests/run/i3448.scala index 294590221dde..4acd986573a1 100644 --- a/tests/run/i3448.scala +++ b/tests/run/i3448.scala @@ -8,6 +8,6 @@ object Test extends App { val xs0: List[IF[Int]] = List(_ ?=> x) val xs: List[IF[Int]] = List(x) val ys: IF[List[Int]] = xs.map(x => x) - val zs = ys.with(C(22)) + val zs = ys(using C(22)) assert(zs == List(22)) } diff --git a/tests/run/i7788.scala b/tests/run/i7788.scala index bb88841e77d6..99d16ba1521c 100644 --- a/tests/run/i7788.scala +++ b/tests/run/i7788.scala @@ -4,9 +4,9 @@ trait Show[-A]: given Show[String] = x => x given Show[Int] = _.toString -given showEither[A,B] with (sA: Show[A]) with Show[B] as Show[Either[A,B]] = +given showEither[A,B](using sA: Show[A])(using Show[B]): Show[Either[A,B]] = _.fold(a => s"Left(${summon[Show[A]].show(a)})", b => s"Right(${summon[Show[B]].show(b)})") -given [A,B] with (sA: Show[A]) with (sB: Show[B]) as Show[(A,B)] = (a,b) => s"(${sA.show(a)}), ${sB.show(b)})" +given [A,B](using sA: Show[A])(using sB: Show[B]): Show[(A,B)] = (a,b) => s"(${sA.show(a)}), ${sB.show(b)})" @main def Test = diff --git a/tests/run/i7868.scala b/tests/run/i7868.scala index 8d4132ccfe7d..9b866dfd951c 100644 --- a/tests/run/i7868.scala +++ b/tests/run/i7868.scala @@ -1,8 +1,8 @@ import scala.compiletime.S object Test extends App { - def plusOne[I <: Int] with (x: ValueOf[S[I]]) : S[I] = x.value - def plusTwo[I <: Int] with (x: ValueOf[S[S[I]]]) : S[S[I]] = x.value + def plusOne[I <: Int](using x: ValueOf[S[I]]): S[I] = x.value + def plusTwo[I <: Int](using x: ValueOf[S[S[I]]]): S[S[I]] = x.value assert(plusOne[0] == 1) assert(plusTwo[0] == 2) } diff --git a/tests/run/implicit-alias.scala b/tests/run/implicit-alias.scala index aab501f124a8..f10f85603175 100644 --- a/tests/run/implicit-alias.scala +++ b/tests/run/implicit-alias.scala @@ -53,7 +53,7 @@ object Test extends App { locally { println("with given") - given t with TC1 as TC = new TC + given t(using TC1) as TC = new TC summon[TC] summon[TC] } diff --git a/tests/run/implicit-disambiguation.scala b/tests/run/implicit-disambiguation.scala index 7ca65906a3d3..881e4ec8083f 100644 --- a/tests/run/implicit-disambiguation.scala +++ b/tests/run/implicit-disambiguation.scala @@ -8,7 +8,7 @@ class C extends A { def show = "C" } object M { - def f with (B, C) : String = { + def f(using B, C): String = { given a as A = summon[B] summon[A].show } diff --git a/tests/run/implicit-specifity.scala b/tests/run/implicit-specifity.scala index 4ed9e3d59b04..bfde7b414824 100644 --- a/tests/run/implicit-specifity.scala +++ b/tests/run/implicit-specifity.scala @@ -9,7 +9,7 @@ object Show { class Generic object Generic { given gen as Generic = new Generic - given showGen[T] with Generic as Show[T] = new Show[T](2) + given showGen[T](using Generic) as Show[T] = new Show[T](2) } class Generic2 @@ -27,11 +27,11 @@ object Contextual { given ctx as Context - given showGen[T] with Generic as Show[T] = new Show[T](2) + given showGen[T](using Generic) as Show[T] = new Show[T](2) - given showGen[T] with (Generic, Context) as Show[T] = new Show[T](3) + given showGen[T](using Generic, Context) as Show[T] = new Show[T](3) - given showGen[T] with SubGen as Show[T] = new Show[T](4) + given showGen[T](using SubGen) as Show[T] = new Show[T](4) } object Test extends App { diff --git a/tests/run/implicitFunctionXXL.scala b/tests/run/implicitFunctionXXL.scala index 38ce4e0d141d..b4131080577d 100644 --- a/tests/run/implicitFunctionXXL.scala +++ b/tests/run/implicitFunctionXXL.scala @@ -5,7 +5,7 @@ object Test { implicit val intWorld: Int = 42 implicit val strWorld: String = "Hello " - val i1 = ( ( x1: Int, + val i1 = (( x1: Int, x2: String, x3: Int, x4: Int, diff --git a/tests/run/implicitFuns.scala b/tests/run/implicitFuns.scala index d10374b00eb1..d505eeea0d7a 100644 --- a/tests/run/implicitFuns.scala +++ b/tests/run/implicitFuns.scala @@ -13,14 +13,14 @@ object Test { val xx: (String, Int) ?=> Int = (x: String, y: Int) ?=> x.length + y - val y: String => Boolean = x.with(_) + val y: String => Boolean = x(using _) object nested { implicit val empty: String = "" assert(!x) } - val yy: (String, Int) => Any = xx.with(_, _) + val yy: (String, Int) => Any = xx(using _, _) val z1: String ?=> Boolean = implicitly[String].length >= 2 assert(z1) @@ -40,7 +40,7 @@ object Test { val z4: GenericImplicit[String] = implicitly[String].length >= 2 assert(z4) - val b = x.with("hello") + val b = x(using "hello") val b1: Boolean = b @@ -48,7 +48,7 @@ object Test { val bi1: Boolean = bi - val c = xx.with("hh", 22) + val c = xx(using "hh", 22) val c1: Int = c @@ -81,11 +81,11 @@ object Contextual { def ctx: Ctx[Context] = implicitly[Context] def compile(s: String): Ctx[Boolean] = - runOn(new java.io.File(s)).with(ctx.withBinding(Source, s)) >= 0 + runOn(new java.io.File(s))(using ctx.withBinding(Source, s)) >= 0 def runOn(f: java.io.File): Ctx[Int] = { val options = List("-verbose", "-explaintypes") - process(f).apply.with(ctx.withBinding(Options, options)) + process(f).apply(using ctx.withBinding(Options, options)) } def process(f: java.io.File): Ctx[Int] = diff --git a/tests/run/implied-divergence.scala b/tests/run/implied-divergence.scala index d07ce132bf4e..62b4c76137ae 100644 --- a/tests/run/implied-divergence.scala +++ b/tests/run/implied-divergence.scala @@ -6,7 +6,7 @@ given e : E(null) object Test extends App { - given f with (e: E) as E(e) + given f(using e: E) as E(e) assert(summon[E].toString == "E(E(null))") diff --git a/tests/run/implied-for.scala b/tests/run/implied-for.scala index 5f2c23408e3c..ead431a67372 100644 --- a/tests/run/implied-for.scala +++ b/tests/run/implied-for.scala @@ -31,7 +31,7 @@ class Monoid[T] object Instances { given intOrd as Ordering[Int] - given listOrd[T] with Ordering[T] as Ordering[List[T]] + given listOrd[T](using Ordering[T]) as Ordering[List[T]] given ec as ExecutionContext given im as Monoid[Int] } diff --git a/tests/run/implied-priority.scala b/tests/run/implied-priority.scala index ee9043edaf5a..a1e3a32981ee 100644 --- a/tests/run/implied-priority.scala +++ b/tests/run/implied-priority.scala @@ -15,7 +15,7 @@ class LowPriorityImplicits { } object NormalImplicits extends LowPriorityImplicits { - given t2[T] with Arg[T] as E[T]("norm") + given t2[T](using Arg[T]) as E[T]("norm") } def test1 = { @@ -38,8 +38,8 @@ object Priority { } object Impl2 { - given t1[T] with Priority.Low as E[T]("low") - given t2[T] with Priority.High with Arg[T] as E[T]("norm") + given t1[T](using Priority.Low) as E[T]("low") + given t2[T](using Priority.High)(using Arg[T]) as E[T]("norm") } def test2 = { @@ -103,11 +103,11 @@ def test3 = { object Impl4 { given t1 as E[String]("string") - given t2[T] with Arg[T] as E[T]("generic") + given t2[T](using Arg[T]) as E[T]("generic") } object fallback4 { - def withFallback[T] with (ev: E[T] = new E[T]("fallback") ): E[T] = ev + def withFallback[T](using ev: E[T] = new E[T]("fallback")): E[T] = ev } def test4 = { @@ -134,7 +134,7 @@ object HigherPriority { } object fallback5 { - given [T] with (ev: E[T] = new E[T]("fallback") ) as (E[T] & HigherPriority.Type) = HigherPriority.inject(ev) + given [T](using ev: E[T] = new E[T]("fallback")) as (E[T] & HigherPriority.Type) = HigherPriority.inject(ev) } def test5 = { diff --git a/tests/run/implied-specifity-2.scala b/tests/run/implied-specifity-2.scala index 855f2617c5d3..2457512dd913 100644 --- a/tests/run/implied-specifity-2.scala +++ b/tests/run/implied-specifity-2.scala @@ -13,20 +13,20 @@ object High { class Foo[T](val i: Int) object Foo { - def apply[T] with (fooT: Foo[T]) : Int = fooT.i + def apply[T](using fooT: Foo[T]): Int = fooT.i - given foo[T] with Low as Foo[T](0) - given foobar[T] with Low as Foo[Bar[T]](1) - given foobarbaz with Low as Foo[Bar[Baz]](2) + given foo[T](using Low) as Foo[T](0) + given foobar[T](using Low) as Foo[Bar[T]](1) + given foobarbaz(using Low) as Foo[Bar[Baz]](2) } class Bar[T] object Bar { - given foobar[T] with Medium as Foo[Bar[T]](3) - given foobarbaz with Medium as Foo[Bar[Baz]](4) + given foobar[T](using Medium) as Foo[Bar[T]](3) + given foobarbaz(using Medium) as Foo[Bar[Baz]](4) } class Baz object Baz { - given baz with High as Foo[Bar[Baz]](5) + given baz(using High) as Foo[Bar[Baz]](5) } class Arg @@ -35,24 +35,24 @@ given Arg class Bam(val str: String) -given lo with Low : Bam("lo") +given lo(using Low): Bam("lo") -given hi with High with Arg : Bam("hi") +given hi(using High)(using Arg): Bam("hi") class Bam2(val str: String) -given lo2 with Low : Bam2("lo") +given lo2(using Low) : Bam2("lo") -given mid2 with High with Arg : Bam2("mid") +given mid2(using High)(using Arg) : Bam2("mid") given hi2 : Bam2("hi") class Arg2 class Red(val str: String) -given normal with Arg2 : Red("normal") +given normal(using Arg2) : Red("normal") -given reduced with (ev: Arg2 | Low) : Red("reduced") +given reduced(using ev: Arg2 | Low) : Red("reduced") object Test extends App { assert(Foo[Int] == 0) diff --git a/tests/run/poly-kinded-derives.scala b/tests/run/poly-kinded-derives.scala index c5efcbb0ddb4..549e1953c1b7 100644 --- a/tests/run/poly-kinded-derives.scala +++ b/tests/run/poly-kinded-derives.scala @@ -5,11 +5,11 @@ object Test extends App { trait Show[T] object Show { given Show[Int] {} - given [T] with (st: Show[T]) as Show[Tuple1[T]] - given t2[T, U] with (st: Show[T], su: Show[U]) as Show[(T, U)] - given t3 [T, U, V] with (st: Show[T], su: Show[U], sv: Show[V]) as Show[(T, U, V)] + given [T](using st: Show[T]) as Show[Tuple1[T]] + given t2[T, U](using st: Show[T], su: Show[U]) as Show[(T, U)] + given t3 [T, U, V](using st: Show[T], su: Show[U], sv: Show[V]) as Show[(T, U, V)] - def derived[T] with (m: Mirror.Of[T], r: Show[m.MirroredElemTypes]) : Show[T] = new Show[T] {} + def derived[T](using m: Mirror.Of[T], r: Show[m.MirroredElemTypes]): Show[T] = new Show[T] {} } case class Mono(i: Int) derives Show @@ -27,7 +27,7 @@ object Test extends App { given t2 [T] as Functor[[U] =>> (T, U)] {} given t3 [T, U] as Functor[[V] =>> (T, U, V)] {} - def derived[F[_]] with (m: Mirror { type MirroredType = F ; type MirroredElemTypes[_] }, r: Functor[m.MirroredElemTypes]) : Functor[F] = new Functor[F] {} + def derived[F[_]](using m: Mirror { type MirroredType = F ; type MirroredElemTypes[_] }, r: Functor[m.MirroredElemTypes]): Functor[F] = new Functor[F] {} } case class Mono(i: Int) derives Functor @@ -43,7 +43,7 @@ object Test extends App { given [C] as FunctorK[[F[_]] =>> C] {} given [T] as FunctorK[[F[_]] =>> Tuple1[F[T]]] - def derived[F[_[_]]] with (m: Mirror { type MirroredType = F ; type MirroredElemTypes[_[_]] }, r: FunctorK[m.MirroredElemTypes]) : FunctorK[F] = new FunctorK[F] {} + def derived[F[_[_]]](using m: Mirror { type MirroredType = F ; type MirroredElemTypes[_[_]] }, r: FunctorK[m.MirroredElemTypes]): FunctorK[F] = new FunctorK[F] {} } case class Mono(i: Int) derives FunctorK @@ -61,7 +61,7 @@ object Test extends App { given t2 as Bifunctor[[T, U] =>> (T, U)] {} given t3 [T] as Bifunctor[[U, V] =>> (T, U, V)] {} - def derived[F[_, _]] with (m: Mirror { type MirroredType = F ; type MirroredElemTypes[_, _] }, r: Bifunctor[m.MirroredElemTypes]) : Bifunctor[F] = ??? + def derived[F[_, _]](using m: Mirror { type MirroredType = F ; type MirroredElemTypes[_, _] }, r: Bifunctor[m.MirroredElemTypes]): Bifunctor[F] = ??? } case class Mono(i: Int) derives Bifunctor diff --git a/tests/run/returning.scala b/tests/run/returning.scala index 9b3f1f4c67a3..33cfebf62fad 100644 --- a/tests/run/returning.scala +++ b/tests/run/returning.scala @@ -16,7 +16,7 @@ object NonLocalReturns { def returning[T](op: ReturnThrowable[T] ?=> T): T = { val returner = new ReturnThrowable[T] - try op.with(returner) + try op(using returner) catch { case ex: ReturnThrowable[_] => if (ex `eq` returner) ex.result.asInstanceOf[T] else throw ex diff --git a/tests/run/string-context-implicits-with-conversion.scala b/tests/run/string-context-implicits-with-conversion.scala index ee4fd7c263d7..c3ec5af884ff 100644 --- a/tests/run/string-context-implicits-with-conversion.scala +++ b/tests/run/string-context-implicits-with-conversion.scala @@ -4,7 +4,7 @@ object Lib { opaque type Showed = String - given [T] with (show: Show[T]) as Conversion[T, Showed] = x => show(x) + given [T](using show: Show[T]) as Conversion[T, Showed] = x => show(x) trait Show[T] { def apply(x: T): String diff --git a/tests/run/tagless.scala b/tests/run/tagless.scala index e04953f7f39b..3147c7c8020b 100644 --- a/tests/run/tagless.scala +++ b/tests/run/tagless.scala @@ -24,19 +24,19 @@ object Test extends App { } // An example tree - def tf0[T] with (e: Exp[T]) : T = + def tf0[T](using e: Exp[T]): T = e.add(e.lit(8), e.neg(e.add(e.lit(1), e.lit(2)))) // Typeclass-style Exp syntax object ExpSyntax { - def lit[T](i: Int) with (e: Exp[T]) : T = e.lit(i) - def neg[T](t: T) with (e: Exp[T]) : T = e.neg(t) - def add[T](l: T, r: T) with (e: Exp[T]) : T = e.add(l, r) + def lit[T](i: Int) (using e: Exp[T]): T = e.lit(i) + def neg[T](t: T) (using e: Exp[T]): T = e.neg(t) + def add[T](l: T, r: T)(using e: Exp[T]): T = e.add(l, r) } import ExpSyntax._ // It's safe to always have these in scope // Another tree - def tf1[T] with Exp[T] : T = + def tf1[T](using Exp[T]): T = add(lit(8), neg(add(lit(1), lit(2)))) // Base operations as typeclasses @@ -60,7 +60,7 @@ object Test extends App { def mul(l: T, r: T): T } object MultSyntax { - def mul[T](l: T, r: T) with (e: Mult[T]) : T = e.mul(l, r) + def mul[T](l: T, r: T)(using e: Mult[T]): T = e.mul(l, r) } import MultSyntax._ @@ -106,7 +106,7 @@ object Test extends App { object CanThrow { private class Exc(msg: String) extends Exception(msg) - def _throw(msg: String) with CanThrow : Nothing = throw new Exc(msg) + def _throw(msg: String)(using CanThrow): Nothing = throw new Exc(msg) def _try[T](op: Maybe[T])(handler: String => T): T = { given CanThrow try op @@ -138,7 +138,7 @@ object Test extends App { show(readInt("2")) show(readInt("X")) - def fromTree[T](t: Tree) with Exp[T] : Maybe[T] = t match { + def fromTree[T](t: Tree)(using Exp[T]): Maybe[T] = t match { case Node("Lit", Leaf(n)) => lit(readInt(n)) case Node("Neg", t) => neg(fromTree(t)) case Node("Add", l , r) => add(fromTree(l), fromTree(r)) @@ -150,18 +150,18 @@ object Test extends App { show(fromTree[Tree](tf1Tree)) trait Wrapped { - def value[T] with Exp[T] : T + def value[T](using Exp[T]): T } given Exp[Wrapped] { def lit(i: Int) = new Wrapped { - def value[T] with (e: Exp[T]) : T = e.lit(i) + def value[T](using e: Exp[T]): T = e.lit(i) } def neg(t: Wrapped) = new Wrapped { - def value[T] with (e: Exp[T]) : T = e.neg(t.value) + def value[T](using e: Exp[T]): T = e.neg(t.value) } def add(l: Wrapped, r: Wrapped) = new Wrapped { - def value[T] with (e: Exp[T]) : T = e.add(l.value, r.value) + def value[T](using e: Exp[T]): T = e.add(l.value, r.value) } } @@ -170,7 +170,7 @@ object Test extends App { s"${t.value[Int]}\n${t.value[String]}" } - def fromTreeExt[T](recur: => Tree => Maybe[T]) with Exp[T] : Tree => Maybe[T] = { + def fromTreeExt[T](recur: => Tree => Maybe[T])(using Exp[T]): Tree => Maybe[T] = { case Node("Lit", Leaf(n)) => lit(readInt(n)) case Node("Neg", t) => neg(recur(t)) case Node("Add", l , r) => add(recur(l), recur(r)) @@ -181,7 +181,7 @@ object Test extends App { def fromTree2[T: Exp](t: Tree): Maybe[T] = fix(fromTreeExt[T])(t) - def fromTreeExt2[T](recur: => Tree => Maybe[T]) with (Exp[T], Mult[T]) : Tree => Maybe[T] = { + def fromTreeExt2[T](recur: => Tree => Maybe[T])(using Exp[T], Mult[T]): Tree => Maybe[T] = { case Node("Mult", l , r) => mul(recur(l), recur(r)) case t => fromTreeExt(recur)(t) } @@ -196,7 +196,7 @@ object Test extends App { // Added operation: negation pushdown enum NCtx { case Pos, Neg } - given [T] with (e: Exp[T]) as Exp[NCtx => T] { + given [T](using e: Exp[T]) as Exp[NCtx => T] { import NCtx._ def lit(i: Int) = { case Pos => e.lit(i) @@ -216,7 +216,7 @@ object Test extends App { println(pushNeg(tf1[NCtx => String])) println(pushNeg(pushNeg(pushNeg(tf1))): String) - given [T] with (e: Mult[T]) as Mult[NCtx => T] { + given [T](using e: Mult[T]) as Mult[NCtx => T] { import NCtx._ def mul(l: NCtx => T, r: NCtx => T): NCtx => T = { case Pos => e.mul(l(Pos), r(Pos)) @@ -237,7 +237,7 @@ object Test extends App { } // Going from ADT encoding to type class encoding - def finalize[T](i: IExp) with (e: Exp[T]) : T = i match { + def finalize[T](i: IExp)(using e: Exp[T]): T = i match { case Lit(l) => e.lit(l) case Neg(n) => e.neg(finalize[T](n)) case Add(l, r) => e.add(finalize[T](l), finalize[T](r)) diff --git a/tests/run/tupled-function-andThen.scala b/tests/run/tupled-function-andThen.scala index c7d81f25b0e3..8bc7fa941a47 100644 --- a/tests/run/tupled-function-andThen.scala +++ b/tests/run/tupled-function-andThen.scala @@ -32,7 +32,7 @@ object Test { * @tparam GArgs the tuple type with the same types as the function arguments of G and return type of F * @tparam R the return type of G */ - def [F, G, FArgs <: Tuple, GArgs <: Tuple, R](f: F) andThen (g: G) with (tf: TupledFunction[F, FArgs => GArgs], tg: TupledFunction[G, GArgs => R]) : FArgs => R = { + def [F, G, FArgs <: Tuple, GArgs <: Tuple, R](f: F) andThen (g: G)(using tf: TupledFunction[F, FArgs => GArgs], tg: TupledFunction[G, GArgs => R]): FArgs => R = { x => tg.tupled(g)(tf.tupled(f)(x)) } diff --git a/tests/run/tupled-function-apply.scala b/tests/run/tupled-function-apply.scala index 69b876750739..2a0cfd68d7be 100644 --- a/tests/run/tupled-function-apply.scala +++ b/tests/run/tupled-function-apply.scala @@ -113,6 +113,6 @@ object Test { * @tparam Args the tuple type with the same types as the function arguments of F * @tparam R the return type of F */ - def [F, Args <: Tuple, R](f: F) apply (args: Args) with (tf: TupledFunction[F, Args => R]) : R = + def [F, Args <: Tuple, R](f: F) apply (args: Args)(using tf: TupledFunction[F, Args => R]): R = tf.tupled(f)(args) } \ No newline at end of file diff --git a/tests/run/tupled-function-compose.scala b/tests/run/tupled-function-compose.scala index b7ff1983289d..d929e9bb2956 100644 --- a/tests/run/tupled-function-compose.scala +++ b/tests/run/tupled-function-compose.scala @@ -33,7 +33,7 @@ object Test { * @tparam GArgs the tuple type with the same types as the function arguments of G * @tparam R the return type of F */ - def [F, G, FArgs <: Tuple, GArgs <: Tuple, R](f: F) compose (g: G) with (tg: TupledFunction[G, GArgs => FArgs], tf: TupledFunction[F, FArgs => R]) : GArgs => R = { + def [F, G, FArgs <: Tuple, GArgs <: Tuple, R](f: F) compose (g: G)(using tg: TupledFunction[G, GArgs => FArgs], tf: TupledFunction[F, FArgs => R]): GArgs => R = { x => tf.tupled(f)(tg.tupled(g)(x)) } diff --git a/tests/run/tupled-function-extension-method.scala b/tests/run/tupled-function-extension-method.scala index 48b29e85ded5..f58a70ac1e9a 100644 --- a/tests/run/tupled-function-extension-method.scala +++ b/tests/run/tupled-function-extension-method.scala @@ -36,12 +36,12 @@ object Test { // Specialized only for arity 0 and one as auto tupling will not provide the disired effect def [R](e: Expr[() => R]) apply (): R = e.x() def [Arg, R](e: Expr[Arg => R]) apply (arg: Arg): R = e.x(arg) - def [Arg, R](e: Expr[Arg ?=> R]) applyGiven(arg: Arg): R = e.x.with(arg) + def [Arg, R](e: Expr[Arg ?=> R]) applyGiven(arg: Arg): R = e.x(using arg) // Applied to all funtions of arity 2 or more (including more than 22 parameters) - def [F, Args <: Tuple, R](e: Expr[F]) apply (args: Args) with (tf: TupledFunction[F, Args => R]) : R = + def [F, Args <: Tuple, R](e: Expr[F]) apply (args: Args)(using tf: TupledFunction[F, Args => R]): R = tf.tupled(e.x)(args) - def [F, Args <: Tuple, R](e: Expr[F]) applyGiven (args: Args) with (tf: TupledFunction[F, Args ?=> R]) : R = - tf.tupled(e.x).with(args) + def [F, Args <: Tuple, R](e: Expr[F]) applyGiven (args: Args)(using tf: TupledFunction[F, Args ?=> R]): R = + tf.tupled(e.x)(using args) } \ No newline at end of file diff --git a/tests/run/tupled-function-tupled.scala b/tests/run/tupled-function-tupled.scala index abd3ad829d00..90b5360c4f33 100644 --- a/tests/run/tupled-function-tupled.scala +++ b/tests/run/tupled-function-tupled.scala @@ -24,5 +24,5 @@ object Test { * @tparam Args the tuple type with the same types as the function arguments of F * @tparam R the return type of F */ - def [F, Args <: Tuple, R](f: F) tupled with (tf: TupledFunction[F, Args => R]) : Args => R = tf.tupled(f) + def [F, Args <: Tuple, R](f: F) tupled (using tf: TupledFunction[F, Args => R]): Args => R = tf.tupled(f) } diff --git a/tests/run/tupled-function-untupled.scala b/tests/run/tupled-function-untupled.scala index 4473e6f671d0..466874e4eda5 100644 --- a/tests/run/tupled-function-untupled.scala +++ b/tests/run/tupled-function-untupled.scala @@ -104,5 +104,5 @@ object Test { * @tparam Args the tuple type with the same types as the function arguments of F * @tparam R the return type of F */ - def [F, Args <: Tuple, R](f: Args => R) untupled with (tf: TupledFunction[F, Args => R]) : F = tf.untupled(f) + def [F, Args <: Tuple, R](f: Args => R) untupled(using tf: TupledFunction[F, Args => R]): F = tf.untupled(f) } diff --git a/tests/run/typeclass-derivation-doc-example.scala b/tests/run/typeclass-derivation-doc-example.scala index 2e03f3ab0317..4ee9bd5644a9 100644 --- a/tests/run/typeclass-derivation-doc-example.scala +++ b/tests/run/typeclass-derivation-doc-example.scala @@ -40,7 +40,7 @@ object Eq { } } - inline given derived[T] with (m: Mirror.Of[T]) : Eq[T] = { + inline given derived[T](using m: Mirror.Of[T]): Eq[T] = { val elemInstances = summonAll[m.MirroredElemTypes] inline m match { case s: Mirror.SumOf[T] => eqSum(s, elemInstances) diff --git a/tests/semanticdb/expect/Enums.expect.scala b/tests/semanticdb/expect/Enums.expect.scala index 68d775c982fe..6b7665bce7f8 100644 --- a/tests/semanticdb/expect/Enums.expect.scala +++ b/tests/semanticdb/expect/Enums.expect.scala @@ -49,7 +49,7 @@ object Enums/*<-_empty_::Enums.*/: object <:_empty_::Enums.`<:<`.given_T().[T]*/ <:_empty_::Enums.`<:<`#*/ T/*->_empty_::Enums.`<:<`.given_T().[T]*/) = Refl/*->_empty_::Enums.`<:<`.Refl.*//*->_empty_::Enums.`<:<`.Refl.apply().*/() - def [A, B]/*<-_empty_::Enums.unwrap().*//*<-_empty_::Enums.unwrap().[A]*//*<-_empty_::Enums.unwrap().[B]*/(opt/*<-_empty_::Enums.unwrap().(opt)*/: Option/*->scala::Option#*/[A/*->_empty_::Enums.unwrap().[A]*/]) unwrap with (ev/*<-_empty_::Enums.unwrap().(ev)*/: A/*->_empty_::Enums.unwrap().[A]*/ <:_empty_::Enums.`<:<`#*/ Option/*->scala::Option#*/[B/*->_empty_::Enums.unwrap().[B]*/]) : Option/*->scala::Option#*/[B/*->_empty_::Enums.unwrap().[B]*/] = ev/*->_empty_::Enums.unwrap().(ev)*/ match + def [A, B]/*<-_empty_::Enums.unwrap().*//*<-_empty_::Enums.unwrap().[A]*//*<-_empty_::Enums.unwrap().[B]*/(opt/*<-_empty_::Enums.unwrap().(opt)*/: Option/*->scala::Option#*/[A/*->_empty_::Enums.unwrap().[A]*/]) unwrap(using ev/*<-_empty_::Enums.unwrap().(ev)*/: A/*->_empty_::Enums.unwrap().[A]*/ <:_empty_::Enums.`<:<`#*/ Option/*->scala::Option#*/[B/*->_empty_::Enums.unwrap().[B]*/]): Option/*->scala::Option#*/[B/*->_empty_::Enums.unwrap().[B]*/] = ev/*->_empty_::Enums.unwrap().(ev)*/ match case Refl/*->_empty_::Enums.`<:<`.Refl.*//*->_empty_::Enums.`<:<`.Refl.unapply().*/() => opt/*->_empty_::Enums.unwrap().(opt)*/.flatMap/*->scala::Option#flatMap().*/(identity/*->scala::Predef.identity().*//*->local0*/[Option/*->scala::Option#*/[B/*->_empty_::Enums.unwrap().[B]*/]]) val some1/*<-_empty_::Enums.some1.*/ = /*->_empty_::Enums.unwrap().*/Some/*->scala::Some.*//*->scala::Some.apply().*/(Some/*->scala::Some.*//*->scala::Some.apply().*/(1))/*->_empty_::Enums.`<:<`.given_T().*/.unwrap diff --git a/tests/semanticdb/expect/Enums.scala b/tests/semanticdb/expect/Enums.scala index 77e27c381a87..b93bc164c7bf 100644 --- a/tests/semanticdb/expect/Enums.scala +++ b/tests/semanticdb/expect/Enums.scala @@ -49,7 +49,7 @@ object Enums: object <:< : given [T] as (T <:< T) = Refl() - def [A, B](opt: Option[A]) unwrap with (ev: A <:< Option[B]) : Option[B] = ev match + def [A, B](opt: Option[A]) unwrap(using ev: A <:< Option[B]): Option[B] = ev match case Refl() => opt.flatMap(identity[Option[B]]) val some1 = Some(Some(1)).unwrap diff --git a/tests/semanticdb/expect/Givens.expect.scala b/tests/semanticdb/expect/Givens.expect.scala index 48340466ae98..9b16c187fb22 100644 --- a/tests/semanticdb/expect/Givens.expect.scala +++ b/tests/semanticdb/expect/Givens.expect.scala @@ -24,4 +24,4 @@ object Givens/*<-a::b::Givens.*/ inline given int2String/*<-a::b::Givens.int2String().*/: Conversion/*->scala::Conversion#*/[Int/*->scala::Int#*/, String/*->scala::Predef.String#*/] = _.toString/*->scala::Any#toString().*/ - def foo/*<-a::b::Givens.foo().*/[A/*<-a::b::Givens.foo().[A]*/] with (A/*<-a::b::Givens.foo().(A)*/: Monoid/*->a::b::Givens.Monoid#*/[A/*->a::b::Givens.foo().[A]*/]) : A/*->a::b::Givens.foo().[A]*/ = A/*->a::b::Givens.foo().(A)*/.combine/*->a::b::Givens.Monoid#combine().*/(A/*->a::b::Givens.foo().(A)*/.empty/*->a::b::Givens.Monoid#empty().*/)(A/*->a::b::Givens.foo().(A)*/.empty/*->a::b::Givens.Monoid#empty().*/) + def foo/*<-a::b::Givens.foo().*/[A/*<-a::b::Givens.foo().[A]*/](using A/*<-a::b::Givens.foo().(A)*/: Monoid/*->a::b::Givens.Monoid#*/[A/*->a::b::Givens.foo().[A]*/]): A/*->a::b::Givens.foo().[A]*/ = A/*->a::b::Givens.foo().(A)*/.combine/*->a::b::Givens.Monoid#combine().*/(A/*->a::b::Givens.foo().(A)*/.empty/*->a::b::Givens.Monoid#empty().*/)(A/*->a::b::Givens.foo().(A)*/.empty/*->a::b::Givens.Monoid#empty().*/) diff --git a/tests/semanticdb/expect/Givens.scala b/tests/semanticdb/expect/Givens.scala index b30a5447dcdb..0ce2c44e1bb6 100644 --- a/tests/semanticdb/expect/Givens.scala +++ b/tests/semanticdb/expect/Givens.scala @@ -24,4 +24,4 @@ object Givens inline given int2String: Conversion[Int, String] = _.toString - def foo[A] with (A: Monoid[A]) : A = A.combine(A.empty)(A.empty) + def foo[A](using A: Monoid[A]): A = A.combine(A.empty)(A.empty) diff --git a/tests/semanticdb/metac.expect b/tests/semanticdb/metac.expect index 044a6fadcd6e..a5515f94f6b5 100644 --- a/tests/semanticdb/metac.expect +++ b/tests/semanticdb/metac.expect @@ -852,9 +852,9 @@ Occurrences: [51:48..51:51): <:< -> _empty_/Enums.`<:<`# [51:52..51:58): Option -> scala/Option# [51:59..51:60): B -> _empty_/Enums.unwrap().[B] -[51:65..51:71): Option -> scala/Option# -[51:72..51:73): B -> _empty_/Enums.unwrap().[B] -[51:77..51:79): ev -> _empty_/Enums.unwrap().(ev) +[51:64..51:70): Option -> scala/Option# +[51:71..51:72): B -> _empty_/Enums.unwrap().[B] +[51:76..51:78): ev -> _empty_/Enums.unwrap().(ev) [52:9..52:13): Refl -> _empty_/Enums.`<:<`.Refl. [52:13..52:13): -> _empty_/Enums.`<:<`.Refl.unapply(). [52:19..52:22): opt -> _empty_/Enums.unwrap().(opt) @@ -1370,13 +1370,13 @@ Occurrences: [26:19..26:20): A <- a/b/Givens.foo().(A) [26:22..26:28): Monoid -> a/b/Givens.Monoid# [26:29..26:30): A -> a/b/Givens.foo().[A] -[26:35..26:36): A -> a/b/Givens.foo().[A] -[26:39..26:40): A -> a/b/Givens.foo().(A) -[26:41..26:48): combine -> a/b/Givens.Monoid#combine(). -[26:49..26:50): A -> a/b/Givens.foo().(A) -[26:51..26:56): empty -> a/b/Givens.Monoid#empty(). -[26:58..26:59): A -> a/b/Givens.foo().(A) -[26:60..26:65): empty -> a/b/Givens.Monoid#empty(). +[26:34..26:35): A -> a/b/Givens.foo().[A] +[26:38..26:39): A -> a/b/Givens.foo().(A) +[26:40..26:47): combine -> a/b/Givens.Monoid#combine(). +[26:48..26:49): A -> a/b/Givens.foo().(A) +[26:50..26:55): empty -> a/b/Givens.Monoid#empty(). +[26:57..26:58): A -> a/b/Givens.foo().(A) +[26:59..26:64): empty -> a/b/Givens.Monoid#empty(). expect/ImplicitConversion.scala -------------------------------