From 57d5b211dfe4bf5ab8cd54469fc85d85e646764b Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 17 Sep 2019 18:04:35 +0200 Subject: [PATCH 01/20] Drop `delegate` --- .../dotty/tools/dotc/parsing/Parsers.scala | 19 +++++++++---------- .../src/dotty/tools/dotc/parsing/Tokens.scala | 17 +++++++---------- tests/new/test.scala | 1 - tests/pos/i6997b.scala | 3 +-- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 48f246f14cfe..9f99da6cef59 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -2518,7 +2518,6 @@ object Parsers { case ABSTRACT => Mod.Abstract() case FINAL => Mod.Final() case IMPLICIT => Mod.Implicit() - case IMPLIED => Mod.Given() case GIVEN => Mod.Given() case ERASED => Mod.Erased() case LAZY => Mod.Lazy() @@ -2622,10 +2621,10 @@ object Parsers { * FunTypeMods ::= { ‘erased’ | ‘given’} */ val closureMods: BitSet = - if allowOldGiven then BitSet(GIVEN, IMPLIED, IMPLICIT, ERASED) + if allowOldGiven then BitSet(GIVEN, IMPLICIT, ERASED) else BitSet(IMPLICIT, ERASED) - val funTypeMods: BitSet = BitSet(IMPLIED, ERASED) + val funTypeMods: BitSet = BitSet(ERASED) val funTypeArgMods: BitSet = BitSet(GIVEN, ERASED) @@ -2923,7 +2922,7 @@ object Parsers { */ def importClause(leading: Token, mkTree: ImportConstr): List[Tree] = { val offset = accept(leading) - val importGiven = allowOldGiven && in.token == IMPLIED || in.token == GIVEN + val importGiven = allowOldGiven && in.token == GIVEN if (importGiven) in.nextToken() commaSeparated(importExpr(importGiven, mkTree)) match { case t :: rest => @@ -3267,8 +3266,8 @@ object Parsers { objectDef(start, posMods(start, mods | Case | Module)) case ENUM => enumDef(start, posMods(start, mods | Enum)) - case IMPLIED | GIVEN => - instanceDef(in.token == GIVEN, start, mods, atSpan(in.skipToken()) { Mod.Given() }) + case GIVEN => + instanceDef(start, mods, atSpan(in.skipToken()) { Mod.Given() }) case _ => syntaxErrorOrIncomplete(ExpectedStartOfTopLevelDefinition()) EmptyTree @@ -3384,7 +3383,7 @@ object Parsers { * GivenSig ::= [id] [DefTypeParamClause] {GivenParamClause} * ExtParamClause ::= [DefTypeParamClause] DefParamClause {GivenParamClause} */ - def instanceDef(newStyle: Boolean, start: Offset, mods: Modifiers, instanceMod: Mod) = atSpan(start, nameStart) { + def instanceDef(start: Offset, mods: Modifiers, instanceMod: Mod) = atSpan(start, nameStart) { var mods1 = addMod(mods, instanceMod) val hasGivenSig = followingIsGivenSig() val name = if isIdent && hasGivenSig then ident() else EmptyTermName @@ -3409,7 +3408,7 @@ object Parsers { parseParams(isExtension = !hasGivenSig) var oldSyntax = false val parents = - if allowOldGiven && (!newStyle && in.token == FOR || isIdent(nme.as)) then + if allowOldGiven && isIdent(nme.as) then oldSyntax = true // for the moment, accept both `delegate for` and `given as` in.nextToken() @@ -3734,12 +3733,12 @@ object Parsers { setLastStatOffset() if (in.token == IMPORT) stats ++= importClause(IMPORT, Import) - else if (in.token == IMPLIED || in.token == GIVEN) { + else if (in.token == GIVEN) { val start = in.offset val mods = modifiers(closureMods) mods.mods match { case givenMod :: Nil if !isBindingIntro => - stats += instanceDef(true, start, EmptyModifiers, Mod.Given().withSpan(givenMod.span)) + stats += instanceDef(start, EmptyModifiers, Mod.Given().withSpan(givenMod.span)) case _ => stats += implicitClosure(in.offset, Location.InBlock, mods) } diff --git a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala index 8294b8d4254d..f9cc888268b9 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala @@ -182,10 +182,9 @@ object Tokens extends TokensCommon { final val FORSOME = 61; enter(FORSOME, "forSome") // TODO: deprecate final val ENUM = 62; enter(ENUM, "enum") final val ERASED = 63; enter(ERASED, "erased") - final val IMPLIED = 64; enter(IMPLIED, "delegate") - final val GIVEN = 65; enter(GIVEN, "given") - final val EXPORT = 66; enter(EXPORT, "export") - final val MACRO = 67; enter(MACRO, "macro") // TODO: remove + final val GIVEN = 64; enter(GIVEN, "given") + final val EXPORT = 65; enter(EXPORT, "export") + final val MACRO = 66; enter(MACRO, "macro") // TODO: remove /** special symbols */ final val NEWLINE = 78; enter(NEWLINE, "end of statement", "new line") @@ -221,14 +220,14 @@ object Tokens extends TokensCommon { USCORE, NULL, THIS, SUPER, TRUE, FALSE, RETURN, QUOTEID, XMLSTART) final val canStartExpressionTokens: TokenSet = atomicExprTokens | BitSet( - LBRACE, LPAREN, INDENT, QUOTE, IF, DO, WHILE, FOR, NEW, TRY, THROW, GIVEN) + LBRACE, LPAREN, INDENT, QUOTE, IF, DO, WHILE, FOR, NEW, TRY, THROW) final val canStartTypeTokens: TokenSet = literalTokens | identifierTokens | BitSet( THIS, SUPER, USCORE, LPAREN, AT) final val templateIntroTokens: TokenSet = BitSet(CLASS, TRAIT, OBJECT, ENUM, CASECLASS, CASEOBJECT) - final val dclIntroTokens: TokenSet = BitSet(DEF, VAL, VAR, TYPE, IMPLIED, GIVEN) + final val dclIntroTokens: TokenSet = BitSet(DEF, VAL, VAR, TYPE, GIVEN) final val defIntroTokens: TokenSet = templateIntroTokens | dclIntroTokens @@ -245,8 +244,6 @@ object Tokens extends TokensCommon { final val modifierFollowers = modifierTokens | defIntroTokens - final val paramIntroTokens: TokenSet = modifierTokens | identifierTokens | BitSet(AT, VAL, VAR, IMPLICIT) - /** Is token only legal as start of statement (eof also included)? */ final val mustStartStatTokens: TokenSet = defIntroTokens | modifierTokens | BitSet(IMPORT, EXPORT, PACKAGE) @@ -268,7 +265,7 @@ object Tokens extends TokensCommon { final val canStartIndentTokens: BitSet = statCtdTokens | BitSet(COLONEOL, EQUALS, ARROW, LARROW, WHILE, TRY, FOR) - // `if` is excluded because it often comes after `else` which makes for awkward indentation rules + // `if` is excluded because it often comes after `else` which makes for awkward indentation rules TODO: try to do without the exception /** Faced with the choice between a type and a formal parameter, the following * tokens determine it's a formal parameter. @@ -285,7 +282,7 @@ object Tokens extends TokensCommon { final val noIndentAfterConditionTokens = BitSet(THEN, DO) final val noIndentAfterEnumeratorTokens = BitSet(YIELD, DO) - final val scala3keywords = BitSet(ENUM, ERASED, GIVEN, IMPLIED) + final val scala3keywords = BitSet(ENUM, ERASED, GIVEN) final val softModifierNames = Set(nme.inline, nme.opaque) } diff --git a/tests/new/test.scala b/tests/new/test.scala index 36519f92c28c..33676a6ecbe0 100644 --- a/tests/new/test.scala +++ b/tests/new/test.scala @@ -4,7 +4,6 @@ trait T { type U = (given Int) => Int type V = (given Int) => Int - val u = delegate (x: Int) => x val v = given (x: Int) => x val w = (given x: Int) => x val w2: V = (given x) => x diff --git a/tests/pos/i6997b.scala b/tests/pos/i6997b.scala index e375b77541ac..84481ca4d4c8 100644 --- a/tests/pos/i6997b.scala +++ b/tests/pos/i6997b.scala @@ -1,7 +1,6 @@ package playground -import scala.quoted._, scala.quoted.matching._ -import delegate scala.quoted._ +import scala.quoted.{_, given}, scala.quoted.matching._ inline def mcr(x: => Any): Any = ${mcrImpl('x)} From 898e45fd95416e97321d8d529fa609f16b30edb3 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 17 Sep 2019 18:07:58 +0200 Subject: [PATCH 02/20] Change name generation scheme for anonymous givens. Instead of `T_given` it's now `given_T`. Reason: we want to follow the convention that these names start with a lowercase letter. --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 2 +- compiler/test/dotty/tools/repl/ReplCompilerTests.scala | 2 +- .../docs/reference/contextual-new/relationship-implicits.md | 2 +- tests/pos/reference/delegates.scala | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 6c698ce1f182..63331aa69c5f 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -933,7 +933,7 @@ object desugar { /** Invent a name for an anonympus given of type or template `impl`. */ def inventGivenName(impl: Tree)(implicit ctx: Context): SimpleName = - avoidIllegalChars(s"${inventName(impl)}_given".toTermName.asSimpleName) + avoidIllegalChars(s"given_${inventName(impl)}".toTermName.asSimpleName) /** The normalized name of `mdef`. This means * 1. Check that the name does not redefine a Scala core class. diff --git a/compiler/test/dotty/tools/repl/ReplCompilerTests.scala b/compiler/test/dotty/tools/repl/ReplCompilerTests.scala index 34867fa29474..5818b559c4f3 100644 --- a/compiler/test/dotty/tools/repl/ReplCompilerTests.scala +++ b/compiler/test/dotty/tools/repl/ReplCompilerTests.scala @@ -132,7 +132,7 @@ class ReplCompilerTests extends ReplTest { fromInitialState { implicit state => run("given as Int = 10") } .andThen { implicit state => assertEquals( - "def Int_given: Int", + "def given_Int: Int", storedOutput().trim ) run("implicitly[Int]") diff --git a/docs/docs/reference/contextual-new/relationship-implicits.md b/docs/docs/reference/contextual-new/relationship-implicits.md index 51825dd25798..fdae632b72fc 100644 --- a/docs/docs/reference/contextual-new/relationship-implicits.md +++ b/docs/docs/reference/contextual-new/relationship-implicits.md @@ -43,7 +43,7 @@ Given instances can be mapped to combinations of implicit objects, classes and i would map to ```scala final implicit lazy val global: ExecutionContext = new ForkJoinContext() - final implicit def Context_given = ctx + final implicit def given_Context = ctx ``` ### Anonymous Given Instances diff --git a/tests/pos/reference/delegates.scala b/tests/pos/reference/delegates.scala index 404ecfee6cf4..00f5dfcb322f 100644 --- a/tests/pos/reference/delegates.scala +++ b/tests/pos/reference/delegates.scala @@ -226,13 +226,13 @@ object Implicits extends Common { } implicit def ListOrd[T: Ord]: Ord[List[T]] = new ListOrd[T] - class Convertible_List_List_given[From, To](implicit c: Convertible[From, To]) + class given_Convertible_List_List[From, To](implicit c: Convertible[From, To]) extends Convertible[List[From], List[To]] { def (x: List[From]) convert: List[To] = x.map(c.convert) } - implicit def Convertible_List_List_given[From, To](implicit c: Convertible[From, To]) + implicit def given_Convertible_List_List[From, To](implicit c: Convertible[From, To]) : Convertible[List[From], List[To]] = - new Convertible_List_List_given[From, To] + new given_Convertible_List_List[From, To] def maximum[T](xs: List[T]) (implicit cmp: Ord[T]): T = From 6b73bbdf2d2543d9be3ecf8b11e4baee5eebc89e Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 17 Sep 2019 20:42:49 +0200 Subject: [PATCH 03/20] Drop `given as` syntax --- .../src/dotty/tools/dotc/core/StdNames.scala | 1 - .../dotty/tools/dotc/parsing/Parsers.scala | 53 +------------------ 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index d85ba1e3878a..a7b6d9154a25 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -388,7 +388,6 @@ object StdNames { val array_length : N = "array_length" val array_update : N = "array_update" val arraycopy: N = "arraycopy" - val as: N = "as" val asTerm: N = "asTerm" val asModule: N = "asModule" val asMethod: N = "asMethod" diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 9f99da6cef59..8065e6815e9f 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -868,8 +868,6 @@ object Parsers { while lookahead.token == LPAREN || lookahead.token == LBRACKET do lookahead.skipParens() lookahead.token == COLON - || lookahead.token == FOR - || lookahead.token == IDENTIFIER && lookahead.name == nme.as /* --------- OPERAND/OPERATOR STACK --------------------------------------- */ @@ -2830,50 +2828,10 @@ object Parsers { ofCaseClass: Boolean = false, ofInstance: Boolean = false): List[List[ValDef]] = { - /** For given instance definitions we have a disambiguation problem: - * given A as B - * given C ... - * Is the second line a parameter `given C` for the first `given` definition, or is it - * a second `given` definition? We only know if we find a `for` or `as` in `...` - * The same problem arises for - * class A - * given C ... - * For method definitions we do not have this problem since a parameter clause - * in a method definition is always followed by something else. So in - * def m(...) - * given C ... - * we know that `given` must start a parameter list. It cannot be a new given` definition. - */ - def followingIsInstanceDef = - (ofClass || ofInstance) && { - val lookahead = in.LookaheadScanner() // skips newline on startup - lookahead.nextToken() // skip the `given` - if (lookahead.token == LBRACKET) true - else { - if (lookahead.token == IDENTIFIER && lookahead.name != nme.as || - lookahead.token == BACKQUOTED_IDENT) { - lookahead.nextToken() - if (lookahead.token == LBRACKET) { - lookahead.nextToken() - var openBrackets = 1 - while (openBrackets > 0 && lookahead.token != EOF) { - if (lookahead.token == LBRACKET) openBrackets += 1 - else if (lookahead.token == RBRACKET) openBrackets -= 1 - lookahead.nextToken() - } - } - } - lookahead.token == FOR || - lookahead.token == IDENTIFIER && lookahead.name == nme.as - } - } - def recur(firstClause: Boolean, nparams: Int, contextualOnly: Boolean): List[List[ValDef]] = { var initialMods = EmptyModifiers val isNewLine = in.token == NEWLINE newLineOptWhenFollowedBy(LPAREN) - if (in.token == NEWLINE && in.next.token == GIVEN && allowOldGiven && !followingIsInstanceDef) - in.nextToken() if (in.token == GIVEN && allowOldGiven) { in.nextToken() initialMods |= Given @@ -3406,14 +3364,8 @@ object Parsers { checkExtensionParams(paramsStart, vparamss) parseParams(isExtension = !hasGivenSig) - var oldSyntax = false val parents = - if allowOldGiven && isIdent(nme.as) then - oldSyntax = true - // for the moment, accept both `delegate for` and `given as` - in.nextToken() - tokenSeparated(COMMA, constrApp) - else if in.token == COLON then + if in.token == COLON then in.nextToken() if in.token == LBRACE || in.token == LBRACKET @@ -3427,9 +3379,6 @@ object Parsers { tokenSeparated(COMMA, constrApp) else Nil - if oldSyntax && vparamss.isEmpty then - vparamss = paramClauses(ofInstance = true) - val gdef = if in.token == EQUALS && parents.length == 1 && parents.head.isType then in.nextToken() From 44f75756c09117956e0b86282effa730191bf5b2 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 17 Sep 2019 21:13:19 +0200 Subject: [PATCH 04/20] Drop `given as` in tests --- .../dotty/tools/dotc/ast/MainProxies.scala | 2 +- .../dotty/tools/dotc/core/Annotations.scala | 2 +- .../dotty/tools/dotc/core/Definitions.scala | 30 +- .../tools/dotc/quoted/QuoteContext.scala | 6 +- .../ReflectionCompilerInterface.scala | 822 +++++++++--------- .../dotc/transform/CacheAliasImplicits.scala | 2 +- .../dotc/transform/NonLocalReturns.scala | 2 +- .../dotc/transform/PCPCheckAndHeal.scala | 2 +- .../dotty/tools/dotc/typer/Applications.scala | 4 +- .../dotty/tools/repl/ReplCompilerTests.scala | 4 +- ...2019-08-30-18th-dotty-milestone-release.md | 2 +- .../changed-features/implicit-resolution.md | 4 +- .../changed-features/numeric-literals.md | 4 +- .../reference/metaprogramming/macros-spec.md | 4 +- docs/docs/reference/metaprogramming/macros.md | 6 +- .../docs/reference/metaprogramming/staging.md | 4 +- .../scala/quoted/Liftable.scala | 102 +-- .../scala/tasty/reflect/TreeUtils.scala | 2 +- .../src/scala/internal/quoted/Matcher.scala | 12 +- library/src/scala/quoted/Type.scala | 18 +- .../tasty/reflect/CompilerInterface.scala | 2 +- library/src/scala/util/FromDigits.scala | 4 +- library/src/scala/util/FromString.scala | 16 +- library/src/scalaShadowing/language.scala | 4 +- .../src/main/scala/hello/Hello.scala | 2 +- .../src/scala/quoted/staging/Toolbox.scala | 4 +- tests/neg-macros/i6976/Macro_1.scala | 2 +- tests/pos-macros/i7011/Macros_1.scala | 2 +- tests/pos/i5978.scala | 2 +- tests/run-macros/i6765-c/Macro_1.scala | 2 +- tests/run-macros/i7008/macro_1.scala | 2 +- .../quote-toExprOfSeq/Macro_1.scala | 2 +- tests/run-staging/i6992/Macro_1.scala | 2 +- 33 files changed, 540 insertions(+), 540 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/MainProxies.scala b/compiler/src/dotty/tools/dotc/ast/MainProxies.scala index dbed71918b29..a2181e78a05e 100644 --- a/compiler/src/dotty/tools/dotc/ast/MainProxies.scala +++ b/compiler/src/dotty/tools/dotc/ast/MainProxies.scala @@ -26,7 +26,7 @@ import ast.Trees._ */ object MainProxies { - def mainProxies(stats: List[tpd.Tree]) given Context: List[untpd.Tree] = { + def mainProxies(stats: List[tpd.Tree])(given Context): List[untpd.Tree] = { import tpd._ def mainMethods(stats: List[Tree]): List[Symbol] = stats.flatMap { case stat: DefDef if stat.symbol.hasAnnotation(defn.MainAnnot) => diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index e535ed4821b2..976134ff0517 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -10,7 +10,7 @@ import util.Spans.Span object Annotations { - def annotClass(tree: Tree) given Context = + def annotClass(tree: Tree)(given Context) = if (tree.symbol.isConstructor) tree.symbol.owner else tree.tpe.typeSymbol diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index d0cf0047343b..ccb7b8bb1fde 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -403,7 +403,7 @@ class Definitions { @tu lazy val CollectionSeqType: TypeRef = ctx.requiredClassRef("scala.collection.Seq") @tu lazy val SeqType: TypeRef = ctx.requiredClassRef("scala.collection.immutable.Seq") - def SeqClass given Context: ClassSymbol = SeqType.symbol.asClass + def SeqClass(given Context): ClassSymbol = SeqType.symbol.asClass @tu lazy val Seq_apply : Symbol = SeqClass.requiredMethod(nme.apply) @tu lazy val Seq_head : Symbol = SeqClass.requiredMethod(nme.head) @tu lazy val Seq_drop : Symbol = SeqClass.requiredMethod(nme.drop) @@ -412,7 +412,7 @@ class Definitions { @tu lazy val Seq_toSeq : Symbol = SeqClass.requiredMethod(nme.toSeq) @tu lazy val ArrayType: TypeRef = ctx.requiredClassRef("scala.Array") - def ArrayClass given Context: ClassSymbol = ArrayType.symbol.asClass + def ArrayClass(given Context): ClassSymbol = ArrayType.symbol.asClass @tu lazy val Array_apply : Symbol = ArrayClass.requiredMethod(nme.apply) @tu lazy val Array_update : Symbol = ArrayClass.requiredMethod(nme.update) @tu lazy val Array_length : Symbol = ArrayClass.requiredMethod(nme.length) @@ -422,10 +422,10 @@ class Definitions { @tu lazy val ArrayModule: Symbol = ctx.requiredModule("scala.Array") @tu lazy val UnitType: TypeRef = valueTypeRef("scala.Unit", java.lang.Void.TYPE, UnitEnc, nme.specializedTypeNames.Void) - def UnitClass given Context: ClassSymbol = UnitType.symbol.asClass - def UnitModuleClass given Context: Symbol = UnitType.symbol.asClass.linkedClass + def UnitClass(given Context): ClassSymbol = UnitType.symbol.asClass + def UnitModuleClass(given Context): Symbol = UnitType.symbol.asClass.linkedClass @tu lazy val BooleanType: TypeRef = valueTypeRef("scala.Boolean", java.lang.Boolean.TYPE, BooleanEnc, nme.specializedTypeNames.Boolean) - def BooleanClass given Context: ClassSymbol = BooleanType.symbol.asClass + def BooleanClass(given Context): ClassSymbol = BooleanType.symbol.asClass @tu lazy val Boolean_! : Symbol = BooleanClass.requiredMethod(nme.UNARY_!) @tu lazy val Boolean_&& : Symbol = BooleanClass.requiredMethod(nme.ZAND) // ### harmonize required... calls @tu lazy val Boolean_|| : Symbol = BooleanClass.requiredMethod(nme.ZOR) @@ -441,13 +441,13 @@ class Definitions { }).symbol @tu lazy val ByteType: TypeRef = valueTypeRef("scala.Byte", java.lang.Byte.TYPE, ByteEnc, nme.specializedTypeNames.Byte) - def ByteClass given Context: ClassSymbol = ByteType.symbol.asClass + def ByteClass(given Context): ClassSymbol = ByteType.symbol.asClass @tu lazy val ShortType: TypeRef = valueTypeRef("scala.Short", java.lang.Short.TYPE, ShortEnc, nme.specializedTypeNames.Short) - def ShortClass given Context: ClassSymbol = ShortType.symbol.asClass + def ShortClass(given Context): ClassSymbol = ShortType.symbol.asClass @tu lazy val CharType: TypeRef = valueTypeRef("scala.Char", java.lang.Character.TYPE, CharEnc, nme.specializedTypeNames.Char) - def CharClass given Context: ClassSymbol = CharType.symbol.asClass + def CharClass(given Context): ClassSymbol = CharType.symbol.asClass @tu lazy val IntType: TypeRef = valueTypeRef("scala.Int", java.lang.Integer.TYPE, IntEnc, nme.specializedTypeNames.Int) - def IntClass given Context: ClassSymbol = IntType.symbol.asClass + def IntClass(given Context): ClassSymbol = IntType.symbol.asClass @tu lazy val Int_- : Symbol = IntClass.requiredMethod(nme.MINUS, List(IntType)) @tu lazy val Int_+ : Symbol = IntClass.requiredMethod(nme.PLUS, List(IntType)) @tu lazy val Int_/ : Symbol = IntClass.requiredMethod(nme.DIV, List(IntType)) @@ -456,18 +456,18 @@ class Definitions { @tu lazy val Int_>= : Symbol = IntClass.requiredMethod(nme.GE, List(IntType)) @tu lazy val Int_<= : Symbol = IntClass.requiredMethod(nme.LE, List(IntType)) @tu lazy val LongType: TypeRef = valueTypeRef("scala.Long", java.lang.Long.TYPE, LongEnc, nme.specializedTypeNames.Long) - def LongClass given Context: ClassSymbol = LongType.symbol.asClass + def LongClass(given Context): ClassSymbol = LongType.symbol.asClass @tu lazy val Long_+ : Symbol = LongClass.requiredMethod(nme.PLUS, List(LongType)) @tu lazy val Long_* : Symbol = LongClass.requiredMethod(nme.MUL, List(LongType)) @tu lazy val Long_/ : Symbol = LongClass.requiredMethod(nme.DIV, List(LongType)) @tu lazy val FloatType: TypeRef = valueTypeRef("scala.Float", java.lang.Float.TYPE, FloatEnc, nme.specializedTypeNames.Float) - def FloatClass given Context: ClassSymbol = FloatType.symbol.asClass + def FloatClass(given Context): ClassSymbol = FloatType.symbol.asClass @tu lazy val DoubleType: TypeRef = valueTypeRef("scala.Double", java.lang.Double.TYPE, DoubleEnc, nme.specializedTypeNames.Double) - def DoubleClass given Context: ClassSymbol = DoubleType.symbol.asClass + def DoubleClass(given Context): ClassSymbol = DoubleType.symbol.asClass @tu lazy val BoxedUnitClass: ClassSymbol = ctx.requiredClass("scala.runtime.BoxedUnit") - def BoxedUnit_UNIT given Context: TermSymbol = BoxedUnitClass.linkedClass.requiredValue("UNIT") + def BoxedUnit_UNIT(given Context): TermSymbol = BoxedUnitClass.linkedClass.requiredValue("UNIT") @tu lazy val BoxedBooleanClass: ClassSymbol = ctx.requiredClass("java.lang.Boolean") @tu lazy val BoxedByteClass : ClassSymbol = ctx.requiredClass("java.lang.Byte") @@ -533,9 +533,9 @@ class Definitions { // in scalac modified to have Any as parent @tu lazy val ThrowableType: TypeRef = ctx.requiredClassRef("java.lang.Throwable") - def ThrowableClass given Context: ClassSymbol = ThrowableType.symbol.asClass + def ThrowableClass(given Context): ClassSymbol = ThrowableType.symbol.asClass @tu lazy val SerializableType: TypeRef = JavaSerializableClass.typeRef - def SerializableClass given Context: ClassSymbol = SerializableType.symbol.asClass + def SerializableClass(given Context): ClassSymbol = SerializableType.symbol.asClass @tu lazy val JavaEnumClass: ClassSymbol = { val cls = ctx.requiredClass("java.lang.Enum") diff --git a/compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala b/compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala index 1501a940b08e..e13f475c4772 100644 --- a/compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala +++ b/compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala @@ -5,17 +5,17 @@ import dotty.tools.dotc.tastyreflect.ReflectionImpl object QuoteContext { - def apply() given Context: scala.quoted.QuoteContext = + def apply()(given Context): scala.quoted.QuoteContext = new scala.quoted.QuoteContext(ReflectionImpl(the[Context])) type ScopeId = Int - private[dotty] def checkScopeId(id: ScopeId) given Context: Unit = + private[dotty] def checkScopeId(id: ScopeId)(given Context): Unit = if (id != scopeId) throw new scala.quoted.ScopeException("Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`") // TODO Explore more fine grained scope ids. // This id can only differentiate scope extrusion from one compiler instance to another. - private[dotty] def scopeId given Context: ScopeId = + private[dotty] def scopeId(given Context): ScopeId = the[Context].outersIterator.toList.last.hashCode() } diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala index 1f6a5ad315bf..dc3923e86ffd 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala @@ -87,358 +87,358 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Tree = tpd.Tree - def Tree_pos(self: Tree) given Context: Position = self.sourcePos - def Tree_symbol(self: Tree) given Context: Symbol = self.symbol + def Tree_pos(self: Tree)(given Context): Position = self.sourcePos + def Tree_symbol(self: Tree)(given Context): Symbol = self.symbol type PackageClause = tpd.PackageDef - def matchPackageClause(tree: Tree) given Context: Option[PackageClause] = tree match { + def matchPackageClause(tree: Tree)(given Context): Option[PackageClause] = tree match { case x: tpd.PackageDef => Some(x) case _ => None } - def PackageClause_pid(self: PackageClause) given Context: Ref = self.pid - def PackageClause_stats(self: PackageClause) given Context: List[Tree] = self.stats + def PackageClause_pid(self: PackageClause)(given Context): Ref = self.pid + def PackageClause_stats(self: PackageClause)(given Context): List[Tree] = self.stats - def PackageClause_apply(pid: Ref, stats: List[Tree]) given Context: PackageClause = + def PackageClause_apply(pid: Ref, stats: List[Tree])(given Context): PackageClause = withDefaultPos(tpd.PackageDef(pid.asInstanceOf[tpd.RefTree], stats)) - def PackageClause_copy(original: PackageClause)(pid: Ref, stats: List[Tree]) given Context: PackageClause = + def PackageClause_copy(original: PackageClause)(pid: Ref, stats: List[Tree])(given Context): PackageClause = tpd.cpy.PackageDef(original)(pid, stats) type Statement = tpd.Tree - def matchStatement(tree: Tree) given Context: Option[Statement] = tree match { + def matchStatement(tree: Tree)(given Context): Option[Statement] = tree match { case tree if tree.isTerm => Some(tree) case _ => matchDefinition(tree) } type Import = tpd.Import - def matchImport(tree: Tree) given Context: Option[Import] = tree match { + def matchImport(tree: Tree)(given Context): Option[Import] = tree match { case tree: tpd.Import => Some(tree) case _ => None } def Import_implied(self: Import): Boolean = false // TODO: adapt to new import scheme - def Import_expr(self: Import) given Context: Tree = self.expr - def Import_selectors(self: Import) given Context: List[ImportSelector] = self.selectors + def Import_expr(self: Import)(given Context): Tree = self.expr + def Import_selectors(self: Import)(given Context): List[ImportSelector] = self.selectors - def Import_apply(expr: Term, selectors: List[ImportSelector]) given Context: Import = + def Import_apply(expr: Term, selectors: List[ImportSelector])(given Context): Import = withDefaultPos(tpd.Import(expr, selectors)) - def Import_copy(original: Import)(expr: Term, selectors: List[ImportSelector]) given Context: Import = + def Import_copy(original: Import)(expr: Term, selectors: List[ImportSelector])(given Context): Import = tpd.cpy.Import(original)(expr, selectors) type Definition = tpd.Tree - def matchDefinition(tree: Tree) given Context: Option[Definition] = tree match { + def matchDefinition(tree: Tree)(given Context): Option[Definition] = tree match { case tree: tpd.MemberDef => Some(tree) case tree: PackageDefinition => Some(tree) case _ => None } - def Definition_name(self: Definition) given Context: String = self match { + def Definition_name(self: Definition)(given Context): String = self match { case self: tpd.MemberDef => self.name.toString case self: PackageDefinition => self.symbol.name.toString // TODO make PackageDefinition a MemberDef or NameTree } type PackageDef = PackageDefinition - def matchPackageDef(tree: Tree) given Context: Option[PackageDef] = tree match { + def matchPackageDef(tree: Tree)(given Context): Option[PackageDef] = tree match { case x: PackageDefinition => Some(x) case _ => None } - def PackageDef_owner(self: PackageDef) given Context: PackageDef = packageDefFromSym(self.symbol.owner) + def PackageDef_owner(self: PackageDef)(given Context): PackageDef = packageDefFromSym(self.symbol.owner) - def PackageDef_members(self: PackageDef) given Context: List[Statement] = + def PackageDef_members(self: PackageDef)(given Context): List[Statement] = if (self.symbol.is(core.Flags.JavaDefined)) Nil // FIXME should also support java packages else self.symbol.info.decls.iterator.map(definitionFromSym).toList - def PackageDef_symbol(self: PackageDef) given Context: PackageDefSymbol = self.symbol + def PackageDef_symbol(self: PackageDef)(given Context): PackageDefSymbol = self.symbol type ClassDef = tpd.TypeDef - def matchClassDef(tree: Tree) given Context: Option[ClassDef] = tree match { + def matchClassDef(tree: Tree)(given Context): Option[ClassDef] = tree match { case x: tpd.TypeDef if x.isClassDef => Some(x) case _ => None } - def ClassDef_constructor(self: ClassDef) given Context: DefDef = ClassDef_rhs(self).constr - def ClassDef_parents(self: ClassDef) given Context: List[Term | TypeTree] = ClassDef_rhs(self).parents - def ClassDef_derived(self: ClassDef) given Context: List[TypeTree] = ClassDef_rhs(self).derived.asInstanceOf[List[TypeTree]] - def ClassDef_self(self: ClassDef) given Context: Option[ValDef] = optional(ClassDef_rhs(self).self) - def ClassDef_body(self: ClassDef) given Context: List[Statement] = ClassDef_rhs(self).body - def ClassDef_symbol(self: ClassDef) given Context: ClassDefSymbol = self.symbol.asClass + def ClassDef_constructor(self: ClassDef)(given Context): DefDef = ClassDef_rhs(self).constr + def ClassDef_parents(self: ClassDef)(given Context): List[Term | TypeTree] = ClassDef_rhs(self).parents + def ClassDef_derived(self: ClassDef)(given Context): List[TypeTree] = ClassDef_rhs(self).derived.asInstanceOf[List[TypeTree]] + def ClassDef_self(self: ClassDef)(given Context): Option[ValDef] = optional(ClassDef_rhs(self).self) + def ClassDef_body(self: ClassDef)(given Context): List[Statement] = ClassDef_rhs(self).body + def ClassDef_symbol(self: ClassDef)(given Context): ClassDefSymbol = self.symbol.asClass private def ClassDef_rhs(self: ClassDef) = self.rhs.asInstanceOf[tpd.Template] - def ClassDef_copy(original: ClassDef)(name: String, constr: DefDef, parents: List[Term | TypeTree], derived: List[TypeTree], selfOpt: Option[ValDef], body: List[Statement]) given Context: ClassDef = { + def ClassDef_copy(original: ClassDef)(name: String, constr: DefDef, parents: List[Term | TypeTree], derived: List[TypeTree], selfOpt: Option[ValDef], body: List[Statement])(given Context): ClassDef = { val Trees.TypeDef(_, originalImpl: tpd.Template) = original tpd.cpy.TypeDef(original)(name.toTypeName, tpd.cpy.Template(originalImpl)(constr, parents, derived, selfOpt.getOrElse(tpd.EmptyValDef), body)) } type TypeDef = tpd.TypeDef - def matchTypeDef(tree: Tree) given Context: Option[TypeDef] = tree match { + def matchTypeDef(tree: Tree)(given Context): Option[TypeDef] = tree match { case x: tpd.TypeDef if !x.symbol.isClass => Some(x) case _ => None } - def TypeDef_rhs(self: TypeDef) given Context: TypeTree | TypeBoundsTree = self.rhs - def TypeDef_symbol(self: TypeDef) given Context: TypeDefSymbol = self.symbol.asType + def TypeDef_rhs(self: TypeDef)(given Context): TypeTree | TypeBoundsTree = self.rhs + def TypeDef_symbol(self: TypeDef)(given Context): TypeDefSymbol = self.symbol.asType - def TypeDef_apply(symbol: TypeDefSymbol) given Context: TypeDef = withDefaultPos(tpd.TypeDef(symbol)) - def TypeDef_copy(original: TypeDef)(name: String, rhs: TypeTree | TypeBoundsTree) given Context: TypeDef = + def TypeDef_apply(symbol: TypeDefSymbol)(given Context): TypeDef = withDefaultPos(tpd.TypeDef(symbol)) + def TypeDef_copy(original: TypeDef)(name: String, rhs: TypeTree | TypeBoundsTree)(given Context): TypeDef = tpd.cpy.TypeDef(original)(name.toTypeName, rhs) type DefDef = tpd.DefDef - def matchDefDef(tree: Tree) given Context: Option[DefDef] = tree match { + def matchDefDef(tree: Tree)(given Context): Option[DefDef] = tree match { case x: tpd.DefDef => Some(x) case _ => None } - def DefDef_typeParams(self: DefDef) given Context: List[TypeDef] = self.tparams - def DefDef_paramss(self: DefDef) given Context: List[List[ValDef]] = self.vparamss - def DefDef_returnTpt(self: DefDef) given Context: TypeTree = self.tpt - def DefDef_rhs(self: DefDef) given Context: Option[Tree] = optional(self.rhs) - def DefDef_symbol(self: DefDef) given Context: DefDefSymbol = self.symbol.asTerm + def DefDef_typeParams(self: DefDef)(given Context): List[TypeDef] = self.tparams + def DefDef_paramss(self: DefDef)(given Context): List[List[ValDef]] = self.vparamss + def DefDef_returnTpt(self: DefDef)(given Context): TypeTree = self.tpt + def DefDef_rhs(self: DefDef)(given Context): Option[Tree] = optional(self.rhs) + def DefDef_symbol(self: DefDef)(given Context): DefDefSymbol = self.symbol.asTerm - def DefDef_apply(symbol: DefDefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term]) given Context: DefDef = + def DefDef_apply(symbol: DefDefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(given Context): DefDef = withDefaultPos(tpd.polyDefDef(symbol, tparams => vparamss => rhsFn(tparams)(vparamss).getOrElse(tpd.EmptyTree))) - def DefDef_copy(original: DefDef)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term]) given Context: DefDef = + def DefDef_copy(original: DefDef)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term])(given Context): DefDef = tpd.cpy.DefDef(original)(name.toTermName, typeParams, paramss, tpt, rhs.getOrElse(tpd.EmptyTree)) type ValDef = tpd.ValDef - def matchValDef(tree: Tree) given Context: Option[ValDef] = tree match { + def matchValDef(tree: Tree)(given Context): Option[ValDef] = tree match { case x: tpd.ValDef => Some(x) case _ => None } - def ValDef_tpt(self: ValDef) given Context: TypeTree = self.tpt - def ValDef_rhs(self: ValDef) given Context: Option[Tree] = optional(self.rhs) - def ValDef_symbol(self: ValDef) given Context: ValDefSymbol = self.symbol.asTerm + def ValDef_tpt(self: ValDef)(given Context): TypeTree = self.tpt + def ValDef_rhs(self: ValDef)(given Context): Option[Tree] = optional(self.rhs) + def ValDef_symbol(self: ValDef)(given Context): ValDefSymbol = self.symbol.asTerm - def ValDef_apply(symbol: ValDefSymbol, rhs: Option[Term]) given Context: ValDef = + def ValDef_apply(symbol: ValDefSymbol, rhs: Option[Term])(given Context): ValDef = tpd.ValDef(symbol, rhs.getOrElse(tpd.EmptyTree)) - def ValDef_copy(original: ValDef)(name: String, tpt: TypeTree, rhs: Option[Term]) given Context: ValDef = + def ValDef_copy(original: ValDef)(name: String, tpt: TypeTree, rhs: Option[Term])(given Context): ValDef = tpd.cpy.ValDef(original)(name.toTermName, tpt, rhs.getOrElse(tpd.EmptyTree)) type Term = tpd.Tree - def matchTerm(tree: Tree) given Context: Option[Term] = tree match { + def matchTerm(tree: Tree)(given Context): Option[Term] = tree match { case x: tpd.SeqLiteral => Some(tree) case _ if tree.isTerm => Some(tree) case _ => None } - def Term_pos(self: Term) given Context: Position = self.sourcePos - def Term_tpe(self: Term) given Context: Type = self.tpe - def Term_underlyingArgument(self: Term) given Context: Term = self.underlyingArgument - def Term_underlying(self: Term) given Context: Term = self.underlying + def Term_pos(self: Term)(given Context): Position = self.sourcePos + def Term_tpe(self: Term)(given Context): Type = self.tpe + def Term_underlyingArgument(self: Term)(given Context): Term = self.underlyingArgument + def Term_underlying(self: Term)(given Context): Term = self.underlying type Ref = tpd.RefTree - def matchRef(tree: Tree) given Context: Option[Ref] = tree match { + def matchRef(tree: Tree)(given Context): Option[Ref] = tree match { case x: tpd.RefTree if x.isTerm => Some(x) case _ => None } - def Ref_apply(sym: Symbol) given Context: Ref = + def Ref_apply(sym: Symbol)(given Context): Ref = withDefaultPos(tpd.ref(sym).asInstanceOf[tpd.RefTree]) type Ident = tpd.Ident - def matchIdent(x: Term) given Context: Option[Ident] = x match { + def matchIdent(x: Term)(given Context): Option[Ident] = x match { case x: tpd.Ident if x.isTerm => Some(x) case _ => None } - def Ident_name(self: Ident) given Context: String = self.name.show + def Ident_name(self: Ident)(given Context): String = self.name.show - def Ident_apply(tmref: TermRef) given Context: Term = + def Ident_apply(tmref: TermRef)(given Context): Term = withDefaultPos(tpd.ref(tmref).asInstanceOf[Term]) - def Ident_copy(original: Tree)(name: String) given Context: Ident = + def Ident_copy(original: Tree)(name: String)(given Context): Ident = tpd.cpy.Ident(original)(name.toTermName) type Select = tpd.Select - def matchSelect(x: Term) given Context: Option[Select] = x match { + def matchSelect(x: Term)(given Context): Option[Select] = x match { case x: tpd.Select if x.isTerm => Some(x) case _ => None } - def Select_qualifier(self: Select) given Context: Term = self.qualifier - def Select_name(self: Select) given Context: String = self.name.toString - def Select_signature(self: Select) given Context: Option[Signature] = + def Select_qualifier(self: Select)(given Context): Term = self.qualifier + def Select_name(self: Select)(given Context): String = self.name.toString + def Select_signature(self: Select)(given Context): Option[Signature] = if (self.symbol.signature == core.Signature.NotAMethod) None else Some(self.symbol.signature) - def Select_apply(qualifier: Term, symbol: Symbol) given Context: Select = + def Select_apply(qualifier: Term, symbol: Symbol)(given Context): Select = withDefaultPos(tpd.Select(qualifier, Types.TermRef(qualifier.tpe, symbol))) - def Select_unique(qualifier: Term, name: String) given Context: Select = { + def Select_unique(qualifier: Term, name: String)(given Context): Select = { val denot = qualifier.tpe.member(name.toTermName) assert(!denot.isOverloaded, s"The symbol `$name` is overloaded. The method Select.unique can only be used for non-overloaded symbols.") withDefaultPos(tpd.Select(qualifier, name.toTermName)) } // TODO rename, this returns an Apply and not a Select - def Select_overloaded(qualifier: Term, name: String, targs: List[Type], args: List[Term]) given Context: Apply = + def Select_overloaded(qualifier: Term, name: String, targs: List[Type], args: List[Term])(given Context): Apply = withDefaultPos(tpd.applyOverloaded(qualifier, name.toTermName, args, targs, Types.WildcardType).asInstanceOf[Apply]) - def Select_copy(original: Tree)(qualifier: Term, name: String) given Context: Select = + def Select_copy(original: Tree)(qualifier: Term, name: String)(given Context): Select = tpd.cpy.Select(original)(qualifier, name.toTermName) type Literal = tpd.Literal - def matchLiteral(x: Term) given Context: Option[Literal] = x match { + def matchLiteral(x: Term)(given Context): Option[Literal] = x match { case x: tpd.Literal => Some(x) case _ => None } - def Literal_constant(self: Literal) given Context: Constant = self.const + def Literal_constant(self: Literal)(given Context): Constant = self.const - def Literal_apply(constant: Constant) given Context: Literal = + def Literal_apply(constant: Constant)(given Context): Literal = withDefaultPos(tpd.Literal(constant)) - def Literal_copy(original: Tree)(constant: Constant) given Context: Literal = + def Literal_copy(original: Tree)(constant: Constant)(given Context): Literal = tpd.cpy.Literal(original)(constant) type This = tpd.This - def matchThis(x: Term) given Context: Option[This] = x match { + def matchThis(x: Term)(given Context): Option[This] = x match { case x: tpd.This => Some(x) case _ => None } - def This_id(self: This) given Context: Option[Id] = optional(self.qual) + def This_id(self: This)(given Context): Option[Id] = optional(self.qual) - def This_apply(cls: ClassDefSymbol) given Context: This = + def This_apply(cls: ClassDefSymbol)(given Context): This = withDefaultPos(tpd.This(cls)) - def This_copy(original: Tree)(qual: Option[Id]) given Context: This = + def This_copy(original: Tree)(qual: Option[Id])(given Context): This = tpd.cpy.This(original)(qual.getOrElse(untpd.EmptyTypeIdent)) type New = tpd.New - def matchNew(x: Term) given Context: Option[New] = x match { + def matchNew(x: Term)(given Context): Option[New] = x match { case x: tpd.New => Some(x) case _ => None } - def New_tpt(self: New) given Context: TypeTree = self.tpt + def New_tpt(self: New)(given Context): TypeTree = self.tpt - def New_apply(tpt: TypeTree) given Context: New = withDefaultPos(tpd.New(tpt)) + def New_apply(tpt: TypeTree)(given Context): New = withDefaultPos(tpd.New(tpt)) - def New_copy(original: Tree)(tpt: TypeTree) given Context: New = + def New_copy(original: Tree)(tpt: TypeTree)(given Context): New = tpd.cpy.New(original)(tpt) type NamedArg = tpd.NamedArg - def matchNamedArg(x: Term) given Context: Option[NamedArg] = x match { + def matchNamedArg(x: Term)(given Context): Option[NamedArg] = x match { case x: tpd.NamedArg if x.name.isInstanceOf[core.Names.TermName] => Some(x) // TODO: Now, the name should alwas be a term name case _ => None } - def NamedArg_name(self: NamedArg) given Context: String = self.name.toString - def NamedArg_value(self: NamedArg) given Context: Term = self.arg + def NamedArg_name(self: NamedArg)(given Context): String = self.name.toString + def NamedArg_value(self: NamedArg)(given Context): Term = self.arg - def NamedArg_apply(name: String, arg: Term) given Context: NamedArg = + def NamedArg_apply(name: String, arg: Term)(given Context): NamedArg = withDefaultPos(tpd.NamedArg(name.toTermName, arg)) - def NamedArg_copy(tree: NamedArg)(name: String, arg: Term) given Context: NamedArg = + def NamedArg_copy(tree: NamedArg)(name: String, arg: Term)(given Context): NamedArg = tpd.cpy.NamedArg(tree)(name.toTermName, arg) type Apply = tpd.Apply - def matchApply(x: Term) given Context: Option[Apply] = x match { + def matchApply(x: Term)(given Context): Option[Apply] = x match { case x: tpd.Apply => Some(x) case _ => None } - def Apply_fun(self: Apply) given Context: Term = self.fun - def Apply_args(self: Apply) given Context: List[Term] = self.args + def Apply_fun(self: Apply)(given Context): Term = self.fun + def Apply_args(self: Apply)(given Context): List[Term] = self.args - def Apply_apply(fn: Term, args: List[Term]) given Context: Apply = + def Apply_apply(fn: Term, args: List[Term])(given Context): Apply = withDefaultPos(tpd.Apply(fn, args)) - def Apply_copy(original: Tree)(fun: Term, args: List[Term]) given Context: Apply = + def Apply_copy(original: Tree)(fun: Term, args: List[Term])(given Context): Apply = tpd.cpy.Apply(original)(fun, args) type TypeApply = tpd.TypeApply - def matchTypeApply(x: Term) given Context: Option[TypeApply] = x match { + def matchTypeApply(x: Term)(given Context): Option[TypeApply] = x match { case x: tpd.TypeApply => Some(x) case _ => None } - def TypeApply_fun(self: TypeApply) given Context: Term = self.fun - def TypeApply_args(self: TypeApply) given Context: List[TypeTree] = self.args + def TypeApply_fun(self: TypeApply)(given Context): Term = self.fun + def TypeApply_args(self: TypeApply)(given Context): List[TypeTree] = self.args - def TypeApply_apply(fn: Term, args: List[TypeTree]) given Context: TypeApply = + def TypeApply_apply(fn: Term, args: List[TypeTree])(given Context): TypeApply = withDefaultPos(tpd.TypeApply(fn, args)) - def TypeApply_copy(original: Tree)(fun: Term, args: List[TypeTree]) given Context: TypeApply = + def TypeApply_copy(original: Tree)(fun: Term, args: List[TypeTree])(given Context): TypeApply = tpd.cpy.TypeApply(original)(fun, args) type Super = tpd.Super - def matchSuper(x: Term) given Context: Option[Super] = x match { + def matchSuper(x: Term)(given Context): Option[Super] = x match { case x: tpd.Super => Some(x) case _ => None } - def Super_qualifier(self: Super) given Context: Term = self.qual - def Super_id(self: Super) given Context: Option[Id] = optional(self.mix) + def Super_qualifier(self: Super)(given Context): Term = self.qual + def Super_id(self: Super)(given Context): Option[Id] = optional(self.mix) - def Super_apply(qual: Term, mix: Option[Id]) given Context: Super = + def Super_apply(qual: Term, mix: Option[Id])(given Context): Super = withDefaultPos(tpd.Super(qual, mix.getOrElse(untpd.EmptyTypeIdent), false, NoSymbol)) - def Super_copy(original: Tree)(qual: Term, mix: Option[Id]) given Context: Super = + def Super_copy(original: Tree)(qual: Term, mix: Option[Id])(given Context): Super = tpd.cpy.Super(original)(qual, mix.getOrElse(untpd.EmptyTypeIdent)) type Typed = tpd.Typed - def matchTyped(x: Term) given Context: Option[Typed] = x match { + def matchTyped(x: Term)(given Context): Option[Typed] = x match { case x: tpd.Typed => Some(x) case _ => None } - def Typed_expr(self: Typed) given Context: Term = self.expr - def Typed_tpt(self: Typed) given Context: TypeTree = self.tpt + def Typed_expr(self: Typed)(given Context): Term = self.expr + def Typed_tpt(self: Typed)(given Context): TypeTree = self.tpt - def Typed_apply(expr: Term, tpt: TypeTree) given Context: Typed = + def Typed_apply(expr: Term, tpt: TypeTree)(given Context): Typed = withDefaultPos(tpd.Typed(expr, tpt)) - def Typed_copy(original: Tree)(expr: Term, tpt: TypeTree) given Context: Typed = + def Typed_copy(original: Tree)(expr: Term, tpt: TypeTree)(given Context): Typed = tpd.cpy.Typed(original)(expr, tpt) type Assign = tpd.Assign - def matchAssign(x: Term) given Context: Option[Assign] = x match { + def matchAssign(x: Term)(given Context): Option[Assign] = x match { case x: tpd.Assign => Some(x) case _ => None } - def Assign_lhs(self: Assign) given Context: Term = self.lhs - def Assign_rhs(self: Assign) given Context: Term = self.rhs + def Assign_lhs(self: Assign)(given Context): Term = self.lhs + def Assign_rhs(self: Assign)(given Context): Term = self.rhs - def Assign_apply(lhs: Term, rhs: Term) given Context: Assign = + def Assign_apply(lhs: Term, rhs: Term)(given Context): Assign = withDefaultPos(tpd.Assign(lhs, rhs)) - def Assign_copy(original: Tree)(lhs: Term, rhs: Term) given Context: Assign = + def Assign_copy(original: Tree)(lhs: Term, rhs: Term)(given Context): Assign = tpd.cpy.Assign(original)(lhs, rhs) type Block = tpd.Block - def matchBlock(x: Term) given Context: Option[Block] = normalizedLoops(x) match { + def matchBlock(x: Term)(given Context): Option[Block] = normalizedLoops(x) match { case x: tpd.Block => Some(x) case _ => None } @@ -447,7 +447,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend * i) Put `while` loops in their own blocks: `{ def while$() = ...; while$() }` * ii) Put closures in their own blocks: `{ def anon$() = ...; closure(anon$, ...) }` */ - private def normalizedLoops(tree: tpd.Tree) given Context: tpd.Tree = tree match { + private def normalizedLoops(tree: tpd.Tree)(given Context): tpd.Tree = tree match { case block: tpd.Block if block.stats.size > 1 => def normalizeInnerLoops(stats: List[tpd.Tree]): List[tpd.Tree] = stats match { case (x: tpd.DefDef) :: y :: xs if needsNormalization(y) => @@ -468,126 +468,126 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend } /** If it is the second statement of a closure. See: `normalizedLoops` */ - private def needsNormalization(tree: tpd.Tree) given Context: Boolean = tree match { + private def needsNormalization(tree: tpd.Tree)(given Context): Boolean = tree match { case _: tpd.Closure => true case _ => false } - def Block_statements(self: Block) given Context: List[Statement] = self.stats - def Block_expr(self: Block) given Context: Term = self.expr + def Block_statements(self: Block)(given Context): List[Statement] = self.stats + def Block_expr(self: Block)(given Context): Term = self.expr - def Block_apply(stats: List[Statement], expr: Term) given Context: Block = + def Block_apply(stats: List[Statement], expr: Term)(given Context): Block = withDefaultPos(tpd.Block(stats, expr)) - def Block_copy(original: Tree)(stats: List[Statement], expr: Term) given Context: Block = + def Block_copy(original: Tree)(stats: List[Statement], expr: Term)(given Context): Block = tpd.cpy.Block(original)(stats, expr) type Inlined = tpd.Inlined - def matchInlined(x: Term) given Context: Option[Inlined] = x match { + def matchInlined(x: Term)(given Context): Option[Inlined] = x match { case x: tpd.Inlined => Some(x) case _ => None } - def Inlined_call(self: Inlined) given Context: Option[Term | TypeTree] = optional(self.call) - def Inlined_bindings(self: Inlined) given Context: List[Definition] = self.bindings - def Inlined_body(self: Inlined) given Context: Term = self.expansion + def Inlined_call(self: Inlined)(given Context): Option[Term | TypeTree] = optional(self.call) + def Inlined_bindings(self: Inlined)(given Context): List[Definition] = self.bindings + def Inlined_body(self: Inlined)(given Context): Term = self.expansion - def Inlined_apply(call: Option[Term | TypeTree], bindings: List[Definition], expansion: Term) given Context: Inlined = + def Inlined_apply(call: Option[Term | TypeTree], bindings: List[Definition], expansion: Term)(given Context): Inlined = withDefaultPos(tpd.Inlined(call.getOrElse(tpd.EmptyTree), bindings.map { case b: tpd.MemberDef => b }, expansion)) - def Inlined_copy(original: Tree)(call: Option[Term | TypeTree], bindings: List[Definition], expansion: Term) given Context: Inlined = + def Inlined_copy(original: Tree)(call: Option[Term | TypeTree], bindings: List[Definition], expansion: Term)(given Context): Inlined = tpd.cpy.Inlined(original)(call.getOrElse(tpd.EmptyTree), bindings.asInstanceOf[List[tpd.MemberDef]], expansion) type Closure = tpd.Closure - def matchClosure(x: Term) given Context: Option[Closure] = x match { + def matchClosure(x: Term)(given Context): Option[Closure] = x match { case x: tpd.Closure => Some(x) case _ => None } - def Closure_meth(self: Closure) given Context: Term = self.meth - def Closure_tpeOpt(self: Closure) given Context: Option[Type] = optional(self.tpt).map(_.tpe) + def Closure_meth(self: Closure)(given Context): Term = self.meth + def Closure_tpeOpt(self: Closure)(given Context): Option[Type] = optional(self.tpt).map(_.tpe) - def Closure_apply(meth: Term, tpe: Option[Type]) given Context: Closure = + def Closure_apply(meth: Term, tpe: Option[Type])(given Context): Closure = withDefaultPos(tpd.Closure(Nil, meth, tpe.map(tpd.TypeTree(_)).getOrElse(tpd.EmptyTree))) - def Closure_copy(original: Tree)(meth: Tree, tpe: Option[Type]) given Context: Closure = + def Closure_copy(original: Tree)(meth: Tree, tpe: Option[Type])(given Context): Closure = tpd.cpy.Closure(original)(Nil, meth, tpe.map(tpd.TypeTree(_)).getOrElse(tpd.EmptyTree)) type If = tpd.If - def matchIf(x: Term) given Context: Option[If] = x match { + def matchIf(x: Term)(given Context): Option[If] = x match { case x: tpd.If => Some(x) case _ => None } - def If_cond(self: If) given Context: Term = self.cond - def If_thenp(self: If) given Context: Term = self.thenp - def If_elsep(self: If) given Context: Term = self.elsep + def If_cond(self: If)(given Context): Term = self.cond + def If_thenp(self: If)(given Context): Term = self.thenp + def If_elsep(self: If)(given Context): Term = self.elsep - def If_apply(cond: Term, thenp: Term, elsep: Term) given Context: If = + def If_apply(cond: Term, thenp: Term, elsep: Term)(given Context): If = withDefaultPos(tpd.If(cond, thenp, elsep)) - def If_copy(original: Tree)(cond: Term, thenp: Term, elsep: Term) given Context: If = + def If_copy(original: Tree)(cond: Term, thenp: Term, elsep: Term)(given Context): If = tpd.cpy.If(original)(cond, thenp, elsep) type Match = tpd.Match - def matchMatch(x: Term) given Context: Option[Match] = x match { + def matchMatch(x: Term)(given Context): Option[Match] = x match { case x: tpd.Match if !x.selector.isEmpty => Some(x) case _ => None } - def Match_scrutinee(self: Match) given Context: Term = self.selector - def Match_cases(self: Match) given Context: List[CaseDef] = self.cases + def Match_scrutinee(self: Match)(given Context): Term = self.selector + def Match_cases(self: Match)(given Context): List[CaseDef] = self.cases - def Match_apply(selector: Term, cases: List[CaseDef]) given Context: Match = + def Match_apply(selector: Term, cases: List[CaseDef])(given Context): Match = withDefaultPos(tpd.Match(selector, cases)) - def Match_copy(original: Tree)(selector: Term, cases: List[CaseDef]) given Context: Match = + def Match_copy(original: Tree)(selector: Term, cases: List[CaseDef])(given Context): Match = tpd.cpy.Match(original)(selector, cases) type ImpliedMatch = tpd.Match - def matchImplicitMatch(x: Term) given Context: Option[Match] = x match { + def matchImplicitMatch(x: Term)(given Context): Option[Match] = x match { case x: tpd.Match if x.selector.isEmpty => Some(x) case _ => None } - def ImplicitMatch_cases(self: Match) given Context: List[CaseDef] = self.cases + def ImplicitMatch_cases(self: Match)(given Context): List[CaseDef] = self.cases - def ImplicitMatch_apply(cases: List[CaseDef]) given Context: ImpliedMatch = + def ImplicitMatch_apply(cases: List[CaseDef])(given Context): ImpliedMatch = withDefaultPos(tpd.Match(tpd.EmptyTree, cases)) - def ImplicitMatch_copy(original: Tree)(cases: List[CaseDef]) given Context: ImpliedMatch = + def ImplicitMatch_copy(original: Tree)(cases: List[CaseDef])(given Context): ImpliedMatch = tpd.cpy.Match(original)(tpd.EmptyTree, cases) type Try = tpd.Try - def matchTry(x: Term) given Context: Option[Try] = x match { + def matchTry(x: Term)(given Context): Option[Try] = x match { case x: tpd.Try => Some(x) case _ => None } - def Try_body(self: Try) given Context: Term = self.expr - def Try_cases(self: Try) given Context: List[CaseDef] = self.cases - def Try_finalizer(self: Try) given Context: Option[Term] = optional(self.finalizer) + def Try_body(self: Try)(given Context): Term = self.expr + def Try_cases(self: Try)(given Context): List[CaseDef] = self.cases + def Try_finalizer(self: Try)(given Context): Option[Term] = optional(self.finalizer) - def Try_apply(expr: Term, cases: List[CaseDef], finalizer: Option[Term]) given Context: Try = + def Try_apply(expr: Term, cases: List[CaseDef], finalizer: Option[Term])(given Context): Try = withDefaultPos(tpd.Try(expr, cases, finalizer.getOrElse(tpd.EmptyTree))) - def Try_copy(original: Tree)(expr: Term, cases: List[CaseDef], finalizer: Option[Term]) given Context: Try = + def Try_copy(original: Tree)(expr: Term, cases: List[CaseDef], finalizer: Option[Term])(given Context): Try = tpd.cpy.Try(original)(expr, cases, finalizer.getOrElse(tpd.EmptyTree)) type Return = tpd.Return - def matchReturn(x: Term) given Context: Option[Return] = x match { + def matchReturn(x: Term)(given Context): Option[Return] = x match { case x: tpd.Return => Some(x) case _ => None } - def Return_expr(self: Return) given Context: Term = self.expr + def Return_expr(self: Return)(given Context): Term = self.expr def Return_apply(expr: Term) given (ctx: Context): Return = withDefaultPos(tpd.Return(expr, ctx.owner)) @@ -597,23 +597,23 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Repeated = tpd.SeqLiteral - def matchRepeated(x: Term) given Context: Option[Repeated] = x match { + def matchRepeated(x: Term)(given Context): Option[Repeated] = x match { case x: tpd.SeqLiteral => Some(x) case _ => None } - def Repeated_elems(self: Repeated) given Context: List[Term] = self.elems - def Repeated_elemtpt(self: Repeated) given Context: TypeTree = self.elemtpt + def Repeated_elems(self: Repeated)(given Context): List[Term] = self.elems + def Repeated_elemtpt(self: Repeated)(given Context): TypeTree = self.elemtpt - def Repeated_apply(elems: List[Term], elemtpt: TypeTree) given Context: Repeated = + def Repeated_apply(elems: List[Term], elemtpt: TypeTree)(given Context): Repeated = withDefaultPos(tpd.SeqLiteral(elems, elemtpt)) - def Repeated_copy(original: Tree)(elems: List[Term], elemtpt: TypeTree) given Context: Repeated = + def Repeated_copy(original: Tree)(elems: List[Term], elemtpt: TypeTree)(given Context): Repeated = tpd.cpy.SeqLiteral(original)(elems, elemtpt) type SelectOuter = tpd.Select - def matchSelectOuter(x: Term) given Context: Option[SelectOuter] = x match { + def matchSelectOuter(x: Term)(given Context): Option[SelectOuter] = x match { case x: tpd.Select => x.name match { case NameKinds.OuterSelectName(_, _) => Some(x) @@ -622,237 +622,237 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend case _ => None } - def SelectOuter_qualifier(self: SelectOuter) given Context: Term = self.qualifier - def SelectOuter_level(self: SelectOuter) given Context: Int = { + def SelectOuter_qualifier(self: SelectOuter)(given Context): Term = self.qualifier + def SelectOuter_level(self: SelectOuter)(given Context): Int = { val NameKinds.OuterSelectName(_, levels) = self.name levels } - def SelectOuter_tpe(self: SelectOuter) given Context: Type = self.tpe.stripTypeVar + def SelectOuter_tpe(self: SelectOuter)(given Context): Type = self.tpe.stripTypeVar - def SelectOuter_apply(qualifier: Term, name: String, levels: Int) given Context: SelectOuter = + def SelectOuter_apply(qualifier: Term, name: String, levels: Int)(given Context): SelectOuter = withDefaultPos(tpd.Select(qualifier, NameKinds.OuterSelectName(name.toTermName, levels))) - def SelectOuter_copy(original: Tree)(qualifier: Term, name: String, levels: Int) given Context: SelectOuter = + def SelectOuter_copy(original: Tree)(qualifier: Term, name: String, levels: Int)(given Context): SelectOuter = tpd.cpy.Select(original)(qualifier, NameKinds.OuterSelectName(name.toTermName, levels)) type While = tpd.WhileDo - def matchWhile(x: Term) given Context: Option[While] = x match { + def matchWhile(x: Term)(given Context): Option[While] = x match { case x: tpd.WhileDo => Some(x) case _ => None } - def While_cond(self: While) given Context: Term = self.cond - def While_body(self: While) given Context: Term = self.body + def While_cond(self: While)(given Context): Term = self.cond + def While_body(self: While)(given Context): Term = self.body - def While_apply(cond: Term, body: Term) given Context: While = + def While_apply(cond: Term, body: Term)(given Context): While = withDefaultPos(tpd.WhileDo(cond, body)) - def While_copy(original: Tree)(cond: Term, body: Term) given Context: While = + def While_copy(original: Tree)(cond: Term, body: Term)(given Context): While = tpd.cpy.WhileDo(original)(cond, body) type TypeTree = tpd.Tree - def matchTypeTree(x: TypeTree | TypeBoundsTree) given Context: Option[TypeTree] = x match { + def matchTypeTree(x: TypeTree | TypeBoundsTree)(given Context): Option[TypeTree] = x match { case x: tpd.TypeBoundsTree => None case _ => if (x.isType) Some(x) else None } - def TypeTree_pos(self: TypeTree) given Context: Position = self.sourcePos - def TypeTree_symbol(self: TypeTree) given Context: Symbol = self.symbol - def TypeTree_tpe(self: TypeTree) given Context: Type = self.tpe.stripTypeVar + def TypeTree_pos(self: TypeTree)(given Context): Position = self.sourcePos + def TypeTree_symbol(self: TypeTree)(given Context): Symbol = self.symbol + def TypeTree_tpe(self: TypeTree)(given Context): Type = self.tpe.stripTypeVar type Inferred = tpd.TypeTree - def matchInferred(tpt: TypeTree | TypeBoundsTree) given Context: Option[Inferred] = tpt match { + def matchInferred(tpt: TypeTree | TypeBoundsTree)(given Context): Option[Inferred] = tpt match { case tpt: tpd.TypeTree if !tpt.tpe.isInstanceOf[Types.TypeBounds] => Some(tpt) case _ => None } - def Inferred_apply(tpe: Type) given Context: Inferred = withDefaultPos(tpd.TypeTree(tpe)) + def Inferred_apply(tpe: Type)(given Context): Inferred = withDefaultPos(tpd.TypeTree(tpe)) type TypeIdent = tpd.Ident - def matchTypeIdent(tpt: TypeTree | TypeBoundsTree) given Context: Option[TypeIdent] = tpt match { + def matchTypeIdent(tpt: TypeTree | TypeBoundsTree)(given Context): Option[TypeIdent] = tpt match { case tpt: tpd.Ident if tpt.isType => Some(tpt) case _ => None } - def TypeIdent_name(self: TypeIdent) given Context: String = self.name.toString + def TypeIdent_name(self: TypeIdent)(given Context): String = self.name.toString - def TypeIdent_copy(original: TypeIdent)(name: String) given Context: TypeIdent = + def TypeIdent_copy(original: TypeIdent)(name: String)(given Context): TypeIdent = tpd.cpy.Ident(original)(name.toTypeName) type TypeSelect = tpd.Select - def matchTypeSelect(tpt: TypeTree | TypeBoundsTree) given Context: Option[TypeSelect] = tpt match { + def matchTypeSelect(tpt: TypeTree | TypeBoundsTree)(given Context): Option[TypeSelect] = tpt match { case tpt: tpd.Select if tpt.isType && tpt.qualifier.isTerm => Some(tpt) case _ => None } - def TypeSelect_qualifier(self: TypeSelect) given Context: Term = self.qualifier - def TypeSelect_name(self: TypeSelect) given Context: String = self.name.toString + def TypeSelect_qualifier(self: TypeSelect)(given Context): Term = self.qualifier + def TypeSelect_name(self: TypeSelect)(given Context): String = self.name.toString - def TypeSelect_apply(qualifier: Term, name: String) given Context: TypeSelect = + def TypeSelect_apply(qualifier: Term, name: String)(given Context): TypeSelect = withDefaultPos(tpd.Select(qualifier, name.toTypeName)) - def TypeSelect_copy(original: TypeSelect)(qualifier: Term, name: String) given Context: TypeSelect = + def TypeSelect_copy(original: TypeSelect)(qualifier: Term, name: String)(given Context): TypeSelect = tpd.cpy.Select(original)(qualifier, name.toTypeName) type Projection = tpd.Select - def matchProjection(tpt: TypeTree | TypeBoundsTree) given Context: Option[Projection] = tpt match { + def matchProjection(tpt: TypeTree | TypeBoundsTree)(given Context): Option[Projection] = tpt match { case tpt: tpd.Select if tpt.isType && tpt.qualifier.isType => Some(tpt) case _ => None } - def Projection_qualifier(self: Projection) given Context: TypeTree = self.qualifier - def Projection_name(self: Projection) given Context: String = self.name.toString + def Projection_qualifier(self: Projection)(given Context): TypeTree = self.qualifier + def Projection_name(self: Projection)(given Context): String = self.name.toString - def Projection_copy(original: Projection)(qualifier: TypeTree, name: String) given Context: Projection = + def Projection_copy(original: Projection)(qualifier: TypeTree, name: String)(given Context): Projection = tpd.cpy.Select(original)(qualifier, name.toTypeName) type Singleton = tpd.SingletonTypeTree - def matchSingleton(tpt: TypeTree | TypeBoundsTree) given Context: Option[Singleton] = tpt match { + def matchSingleton(tpt: TypeTree | TypeBoundsTree)(given Context): Option[Singleton] = tpt match { case tpt: tpd.SingletonTypeTree => Some(tpt) case _ => None } - def Singleton_ref(self: Singleton) given Context: Term = self.ref + def Singleton_ref(self: Singleton)(given Context): Term = self.ref - def Singleton_apply(ref: Term) given Context: Singleton = + def Singleton_apply(ref: Term)(given Context): Singleton = withDefaultPos(tpd.SingletonTypeTree(ref)) - def Singleton_copy(original: Singleton)(ref: Term) given Context: Singleton = + def Singleton_copy(original: Singleton)(ref: Term)(given Context): Singleton = tpd.cpy.SingletonTypeTree(original)(ref) type Refined = tpd.RefinedTypeTree - def matchRefined(tpt: TypeTree | TypeBoundsTree) given Context: Option[Refined] = tpt match { + def matchRefined(tpt: TypeTree | TypeBoundsTree)(given Context): Option[Refined] = tpt match { case tpt: tpd.RefinedTypeTree => Some(tpt) case _ => None } - def Refined_tpt(self: Refined) given Context: TypeTree = self.tpt - def Refined_refinements(self: Refined) given Context: List[Definition] = self.refinements + def Refined_tpt(self: Refined)(given Context): TypeTree = self.tpt + def Refined_refinements(self: Refined)(given Context): List[Definition] = self.refinements - def Refined_copy(original: Refined)(tpt: TypeTree, refinements: List[Definition]) given Context: Refined = + def Refined_copy(original: Refined)(tpt: TypeTree, refinements: List[Definition])(given Context): Refined = tpd.cpy.RefinedTypeTree(original)(tpt, refinements) type Applied = tpd.AppliedTypeTree - def matchApplied(tpt: TypeTree | TypeBoundsTree) given Context: Option[Applied] = tpt match { + def matchApplied(tpt: TypeTree | TypeBoundsTree)(given Context): Option[Applied] = tpt match { case tpt: tpd.AppliedTypeTree => Some(tpt) case _ => None } - def Applied_tpt(self: Applied) given Context: TypeTree = self.tpt - def Applied_args(self: Applied) given Context: List[TypeTree | TypeBoundsTree] = self.args + def Applied_tpt(self: Applied)(given Context): TypeTree = self.tpt + def Applied_args(self: Applied)(given Context): List[TypeTree | TypeBoundsTree] = self.args - def Applied_apply(tpt: TypeTree, args: List[TypeTree | TypeBoundsTree]) given Context: Applied = + def Applied_apply(tpt: TypeTree, args: List[TypeTree | TypeBoundsTree])(given Context): Applied = withDefaultPos(tpd.AppliedTypeTree(tpt, args)) - def Applied_copy(original: Applied)(tpt: TypeTree, args: List[TypeTree | TypeBoundsTree]) given Context: Applied = + def Applied_copy(original: Applied)(tpt: TypeTree, args: List[TypeTree | TypeBoundsTree])(given Context): Applied = tpd.cpy.AppliedTypeTree(original)(tpt, args) type Annotated = tpd.Annotated - def matchAnnotated(tpt: TypeTree | TypeBoundsTree) given Context: Option[Annotated] = tpt match { + def matchAnnotated(tpt: TypeTree | TypeBoundsTree)(given Context): Option[Annotated] = tpt match { case tpt: tpd.Annotated => Some(tpt) case _ => None } - def Annotated_arg(self: Annotated) given Context: TypeTree = self.arg - def Annotated_annotation(self: Annotated) given Context: Term = self.annot + def Annotated_arg(self: Annotated)(given Context): TypeTree = self.arg + def Annotated_annotation(self: Annotated)(given Context): Term = self.annot - def Annotated_apply(arg: TypeTree, annotation: Term) given Context: Annotated = + def Annotated_apply(arg: TypeTree, annotation: Term)(given Context): Annotated = withDefaultPos(tpd.Annotated(arg, annotation)) - def Annotated_copy(original: Annotated)(arg: TypeTree, annotation: Term) given Context: Annotated = + def Annotated_copy(original: Annotated)(arg: TypeTree, annotation: Term)(given Context): Annotated = tpd.cpy.Annotated(original)(arg, annotation) type MatchTypeTree = tpd.MatchTypeTree - def matchMatchTypeTree(tpt: TypeTree | TypeBoundsTree) given Context: Option[MatchTypeTree] = tpt match { + def matchMatchTypeTree(tpt: TypeTree | TypeBoundsTree)(given Context): Option[MatchTypeTree] = tpt match { case tpt: tpd.MatchTypeTree => Some(tpt) case _ => None } - def MatchTypeTree_bound(self: MatchTypeTree) given Context: Option[TypeTree] = if (self.bound == tpd.EmptyTree) None else Some(self.bound) - def MatchTypeTree_selector(self: MatchTypeTree) given Context: TypeTree = self.selector - def MatchTypeTree_cases(self: MatchTypeTree) given Context: List[CaseDef] = self.cases + def MatchTypeTree_bound(self: MatchTypeTree)(given Context): Option[TypeTree] = if (self.bound == tpd.EmptyTree) None else Some(self.bound) + def MatchTypeTree_selector(self: MatchTypeTree)(given Context): TypeTree = self.selector + def MatchTypeTree_cases(self: MatchTypeTree)(given Context): List[CaseDef] = self.cases - def MatchTypeTree_apply(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef]) given Context: MatchTypeTree = + def MatchTypeTree_apply(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef])(given Context): MatchTypeTree = withDefaultPos(tpd.MatchTypeTree(bound.getOrElse(tpd.EmptyTree), selector, cases)) - def MatchTypeTree_copy(original: MatchTypeTree)(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef]) given Context: MatchTypeTree = + def MatchTypeTree_copy(original: MatchTypeTree)(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef])(given Context): MatchTypeTree = tpd.cpy.MatchTypeTree(original)(bound.getOrElse(tpd.EmptyTree), selector, cases) type ByName = tpd.ByNameTypeTree - def matchByName(tpt: TypeTree | TypeBoundsTree) given Context: Option[ByName] = tpt match { + def matchByName(tpt: TypeTree | TypeBoundsTree)(given Context): Option[ByName] = tpt match { case tpt: tpd.ByNameTypeTree => Some(tpt) case _ => None } - def ByName_result(self: ByName) given Context: TypeTree = self.result + def ByName_result(self: ByName)(given Context): TypeTree = self.result - def ByName_apply(result: TypeTree) given Context: ByName = + def ByName_apply(result: TypeTree)(given Context): ByName = withDefaultPos(tpd.ByNameTypeTree(result)) - def ByName_copy(original: ByName)(result: TypeTree) given Context: ByName = + def ByName_copy(original: ByName)(result: TypeTree)(given Context): ByName = tpd.cpy.ByNameTypeTree(original)(result) type LambdaTypeTree = tpd.LambdaTypeTree - def matchLambdaTypeTree(tpt: TypeTree | TypeBoundsTree) given Context: Option[LambdaTypeTree] = tpt match { + def matchLambdaTypeTree(tpt: TypeTree | TypeBoundsTree)(given Context): Option[LambdaTypeTree] = tpt match { case tpt: tpd.LambdaTypeTree => Some(tpt) case _ => None } - def Lambdatparams(self: LambdaTypeTree) given Context: List[TypeDef] = self.tparams - def Lambdabody(self: LambdaTypeTree) given Context: TypeTree | TypeBoundsTree = self.body + def Lambdatparams(self: LambdaTypeTree)(given Context): List[TypeDef] = self.tparams + def Lambdabody(self: LambdaTypeTree)(given Context): TypeTree | TypeBoundsTree = self.body - def Lambdaapply(tparams: List[TypeDef], body: TypeTree | TypeBoundsTree) given Context: LambdaTypeTree = + def Lambdaapply(tparams: List[TypeDef], body: TypeTree | TypeBoundsTree)(given Context): LambdaTypeTree = withDefaultPos(tpd.LambdaTypeTree(tparams, body)) - def Lambdacopy(original: LambdaTypeTree)(tparams: List[TypeDef], body: TypeTree | TypeBoundsTree) given Context: LambdaTypeTree = + def Lambdacopy(original: LambdaTypeTree)(tparams: List[TypeDef], body: TypeTree | TypeBoundsTree)(given Context): LambdaTypeTree = tpd.cpy.LambdaTypeTree(original)(tparams, body) type TypeBind = tpd.Bind - def matchTypeBind(tpt: TypeTree | TypeBoundsTree) given Context: Option[TypeBind] = tpt match { + def matchTypeBind(tpt: TypeTree | TypeBoundsTree)(given Context): Option[TypeBind] = tpt match { case tpt: tpd.Bind if tpt.name.isTypeName => Some(tpt) case _ => None } - def TypeBind_name(self: TypeBind) given Context: String = self.name.toString - def TypeBind_body(self: TypeBind) given Context: TypeTree | TypeBoundsTree = self.body + def TypeBind_name(self: TypeBind)(given Context): String = self.name.toString + def TypeBind_body(self: TypeBind)(given Context): TypeTree | TypeBoundsTree = self.body - def TypeBind_copy(original: TypeBind)(name: String, tpt: TypeTree | TypeBoundsTree) given Context: TypeBind = + def TypeBind_copy(original: TypeBind)(name: String, tpt: TypeTree | TypeBoundsTree)(given Context): TypeBind = tpd.cpy.Bind(original)(name.toTypeName, tpt) type TypeBlock = tpd.Block - def matchTypeBlock(tpt: TypeTree | TypeBoundsTree) given Context: Option[TypeBlock] = tpt match { + def matchTypeBlock(tpt: TypeTree | TypeBoundsTree)(given Context): Option[TypeBlock] = tpt match { case tpt: tpd.Block => Some(tpt) case _ => None } - def TypeBlock_aliases(self: TypeBlock) given Context: List[TypeDef] = self.stats.map { case alias: TypeDef => alias } - def TypeBlock_tpt(self: TypeBlock) given Context: TypeTree = self.expr + def TypeBlock_aliases(self: TypeBlock)(given Context): List[TypeDef] = self.stats.map { case alias: TypeDef => alias } + def TypeBlock_tpt(self: TypeBlock)(given Context): TypeTree = self.expr - def TypeBlock_apply(aliases: List[TypeDef], tpt: TypeTree) given Context: TypeBlock = + def TypeBlock_apply(aliases: List[TypeDef], tpt: TypeTree)(given Context): TypeBlock = withDefaultPos(tpd.Block(aliases, tpt)) - def TypeBlock_copy(original: TypeBlock)(aliases: List[TypeDef], tpt: TypeTree) given Context: TypeBlock = + def TypeBlock_copy(original: TypeBlock)(aliases: List[TypeDef], tpt: TypeTree)(given Context): TypeBlock = tpd.cpy.Block(original)(aliases, tpt) type TypeBoundsTree = tpd.TypeBoundsTree - def matchTypeBoundsTree(x: TypeTree | TypeBoundsTree) given Context: Option[TypeBoundsTree] = x match { + def matchTypeBoundsTree(x: TypeTree | TypeBoundsTree)(given Context): Option[TypeBoundsTree] = x match { case x: tpd.TypeBoundsTree => Some(x) case x @ Trees.TypeTree() => // TODO only enums generate this kind of type bounds. Is this possible without enums? If not generate tpd.TypeBoundsTree for enums instead @@ -864,50 +864,50 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend case _ => None } - def TypeBoundsTree_tpe(self: TypeBoundsTree) given Context: TypeBounds = self.tpe.asInstanceOf[Types.TypeBounds] - def TypeBoundsTree_low(self: TypeBoundsTree) given Context: TypeTree = self.lo - def TypeBoundsTree_hi(self: TypeBoundsTree) given Context: TypeTree = self.hi + def TypeBoundsTree_tpe(self: TypeBoundsTree)(given Context): TypeBounds = self.tpe.asInstanceOf[Types.TypeBounds] + def TypeBoundsTree_low(self: TypeBoundsTree)(given Context): TypeTree = self.lo + def TypeBoundsTree_hi(self: TypeBoundsTree)(given Context): TypeTree = self.hi type WildcardTypeTree = tpd.Ident - def matchWildcardTypeTree(x: TypeTree | TypeBoundsTree) given Context: Option[WildcardTypeTree] = x match { + def matchWildcardTypeTree(x: TypeTree | TypeBoundsTree)(given Context): Option[WildcardTypeTree] = x match { case x @ Trees.Ident(nme.WILDCARD) => Some(x) case _ => None } - def WildcardTypeTree_tpe(self: WildcardTypeTree) given Context: TypeOrBounds = self.tpe.stripTypeVar + def WildcardTypeTree_tpe(self: WildcardTypeTree)(given Context): TypeOrBounds = self.tpe.stripTypeVar type CaseDef = tpd.CaseDef - def matchCaseDef(tree: Tree) given Context: Option[CaseDef] = tree match { + def matchCaseDef(tree: Tree)(given Context): Option[CaseDef] = tree match { case tree: tpd.CaseDef if tree.body.isTerm => Some(tree) case _ => None } - def CaseDef_pattern(self: CaseDef) given Context: Pattern = self.pat - def CaseDef_guard(self: CaseDef) given Context: Option[Term] = optional(self.guard) - def CaseDef_rhs(self: CaseDef) given Context: Term = self.body + def CaseDef_pattern(self: CaseDef)(given Context): Pattern = self.pat + def CaseDef_guard(self: CaseDef)(given Context): Option[Term] = optional(self.guard) + def CaseDef_rhs(self: CaseDef)(given Context): Term = self.body - def CaseDef_module_apply(pattern: Pattern, guard: Option[Term], body: Term) given Context: CaseDef = + def CaseDef_module_apply(pattern: Pattern, guard: Option[Term], body: Term)(given Context): CaseDef = tpd.CaseDef(pattern, guard.getOrElse(tpd.EmptyTree), body) - def CaseDef_module_copy(original: CaseDef)(pattern: Pattern, guard: Option[Term], body: Term) given Context: CaseDef = + def CaseDef_module_copy(original: CaseDef)(pattern: Pattern, guard: Option[Term], body: Term)(given Context): CaseDef = tpd.cpy.CaseDef(original)(pattern, guard.getOrElse(tpd.EmptyTree), body) type TypeCaseDef = tpd.CaseDef - def matchTypeCaseDef(tree: Tree) given Context: Option[TypeCaseDef] = tree match { + def matchTypeCaseDef(tree: Tree)(given Context): Option[TypeCaseDef] = tree match { case tree: tpd.CaseDef if tree.body.isType => Some(tree) case _ => None } - def TypeCaseDef_pattern(self: TypeCaseDef) given Context: TypeTree = self.pat - def TypeCaseDef_rhs(self: TypeCaseDef) given Context: TypeTree = self.body + def TypeCaseDef_pattern(self: TypeCaseDef)(given Context): TypeTree = self.pat + def TypeCaseDef_rhs(self: TypeCaseDef)(given Context): TypeTree = self.body - def TypeCaseDef_module_apply(pattern: TypeTree, body: TypeTree) given Context: TypeCaseDef = + def TypeCaseDef_module_apply(pattern: TypeTree, body: TypeTree)(given Context): TypeCaseDef = tpd.CaseDef(pattern, tpd.EmptyTree, body) - def TypeCaseDef_module_copy(original: TypeCaseDef)(pattern: TypeTree, body: TypeTree) given Context: TypeCaseDef = + def TypeCaseDef_module_copy(original: TypeCaseDef)(pattern: TypeTree, body: TypeTree)(given Context): TypeCaseDef = tpd.cpy.CaseDef(original)(pattern, tpd.EmptyTree, body) // @@ -916,9 +916,9 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Pattern = tpd.Tree - def Pattern_pos(self: Pattern) given Context: Position = self.sourcePos - def Pattern_tpe(self: Pattern) given Context: Type = self.tpe.stripTypeVar - def Pattern_symbol(self: Pattern) given Context: Symbol = self.symbol + def Pattern_pos(self: Pattern)(given Context): Position = self.sourcePos + def Pattern_tpe(self: Pattern)(given Context): Type = self.tpe.stripTypeVar + def Pattern_symbol(self: Pattern)(given Context): Symbol = self.symbol type Value = tpd.Tree @@ -929,14 +929,14 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend case _ => None } - def Pattern_Value_value(self: Value) given Context: Term = self + def Pattern_Value_value(self: Value)(given Context): Term = self - def Pattern_Value_module_apply(term: Term) given Context: Value = term match { + def Pattern_Value_module_apply(term: Term)(given Context): Value = term match { case lit: tpd.Literal => lit case ref: tpd.RefTree if ref.isTerm => ref case ths: tpd.This => ths } - def Pattern_Value_module_copy(original: Value)(term: Term) given Context: Value = term match { + def Pattern_Value_module_copy(original: Value)(term: Term)(given Context): Value = term match { case lit: tpd.Literal => tpd.cpy.Literal(original)(lit.const) case ref: tpd.RefTree if ref.isTerm => tpd.cpy.Ref(original.asInstanceOf[tpd.RefTree])(ref.name) case ths: tpd.This => tpd.cpy.This(original)(ths.qual) @@ -944,31 +944,31 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Bind = tpd.Bind - def matchPattern_Bind(x: Pattern) given Context: Option[Bind] = x match { + def matchPattern_Bind(x: Pattern)(given Context): Option[Bind] = x match { case x: tpd.Bind if x.name.isTermName => Some(x) case _ => None } - def Pattern_Bind_name(self: Bind) given Context: String = self.name.toString + def Pattern_Bind_name(self: Bind)(given Context): String = self.name.toString - def Pattern_Bind_pattern(self: Bind) given Context: Pattern = self.body + def Pattern_Bind_pattern(self: Bind)(given Context): Pattern = self.body - def Pattern_Bind_module_copy(original: Bind)(name: String, pattern: Pattern) given Context: Bind = + def Pattern_Bind_module_copy(original: Bind)(name: String, pattern: Pattern)(given Context): Bind = withDefaultPos(tpd.cpy.Bind(original)(name.toTermName, pattern)) type Unapply = tpd.UnApply - def matchPattern_Unapply(pattern: Pattern) given Context: Option[Unapply] = pattern match { + def matchPattern_Unapply(pattern: Pattern)(given Context): Option[Unapply] = pattern match { case pattern @ Trees.UnApply(_, _, _) => Some(pattern) case Trees.Typed(pattern @ Trees.UnApply(_, _, _), _) => Some(pattern) case _ => None } - def Pattern_Unapply_fun(self: Unapply) given Context: Term = self.fun - def Pattern_Unapply_implicits(self: Unapply) given Context: List[Term] = self.implicits - def Pattern_Unapply_patterns(self: Unapply) given Context: List[Pattern] = effectivePatterns(self.patterns) + def Pattern_Unapply_fun(self: Unapply)(given Context): Term = self.fun + def Pattern_Unapply_implicits(self: Unapply)(given Context): List[Term] = self.implicits + def Pattern_Unapply_patterns(self: Unapply)(given Context): List[Pattern] = effectivePatterns(self.patterns) - def Pattern_Unapply_module_copy(original: Unapply)(fun: Term, implicits: List[Term], patterns: List[Pattern]) given Context: Unapply = + def Pattern_Unapply_module_copy(original: Unapply)(fun: Term, implicits: List[Term], patterns: List[Pattern])(given Context): Unapply = withDefaultPos(tpd.cpy.UnApply(original)(fun, implicits, patterns)) private def effectivePatterns(patterns: List[Pattern]): List[Pattern] = patterns match { @@ -978,44 +978,44 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Alternatives = tpd.Alternative - def matchPattern_Alternatives(pattern: Pattern) given Context: Option[Alternatives] = pattern match { + def matchPattern_Alternatives(pattern: Pattern)(given Context): Option[Alternatives] = pattern match { case pattern: tpd.Alternative => Some(pattern) case _ => None } - def Pattern_Alternatives_patterns(self: Alternatives) given Context: List[Pattern] = self.trees + def Pattern_Alternatives_patterns(self: Alternatives)(given Context): List[Pattern] = self.trees - def Pattern_Alternatives_module_apply(patterns: List[Pattern]) given Context: Alternatives = + def Pattern_Alternatives_module_apply(patterns: List[Pattern])(given Context): Alternatives = withDefaultPos(tpd.Alternative(patterns)) - def Pattern_Alternatives_module_copy(original: Alternatives)(patterns: List[Pattern]) given Context: Alternatives = + def Pattern_Alternatives_module_copy(original: Alternatives)(patterns: List[Pattern])(given Context): Alternatives = tpd.cpy.Alternative(original)(patterns) type TypeTest = tpd.Typed - def matchPattern_TypeTest(pattern: Pattern) given Context: Option[TypeTest] = pattern match { + def matchPattern_TypeTest(pattern: Pattern)(given Context): Option[TypeTest] = pattern match { case Trees.Typed(_: tpd.UnApply, _) => None case pattern: tpd.Typed => Some(pattern) case _ => None } - def Pattern_TypeTest_tpt(self: TypeTest) given Context: TypeTree = self.tpt + def Pattern_TypeTest_tpt(self: TypeTest)(given Context): TypeTree = self.tpt def Pattern_TypeTest_module_apply(tpt: TypeTree) given (ctx: Context): TypeTest = withDefaultPos(tpd.Typed(untpd.Ident(nme.WILDCARD)(ctx.source).withType(tpt.tpe), tpt)) - def Pattern_TypeTest_module_copy(original: TypeTest)(tpt: TypeTree) given Context: TypeTest = + def Pattern_TypeTest_module_copy(original: TypeTest)(tpt: TypeTree)(given Context): TypeTest = tpd.cpy.Typed(original)(untpd.Ident(nme.WILDCARD).withSpan(original.span).withType(tpt.tpe), tpt) type WildcardPattern = tpd.Ident - def matchPattern_WildcardPattern(pattern: Pattern) given Context: Option[WildcardPattern] = + def matchPattern_WildcardPattern(pattern: Pattern)(given Context): Option[WildcardPattern] = pattern match { case pattern: tpd.Ident if tpd.isWildcardArg(pattern) => Some(pattern) case _ => None } - def Pattern_WildcardPattern_module_apply(tpe: TypeOrBounds) given Context: WildcardPattern = + def Pattern_WildcardPattern_module_apply(tpe: TypeOrBounds)(given Context): WildcardPattern = untpd.Ident(nme.WILDCARD).withType(tpe) // @@ -1026,22 +1026,22 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type NoPrefix = Types.NoPrefix.type - def matchNoPrefix(x: TypeOrBounds) given Context: Option[NoPrefix] = + def matchNoPrefix(x: TypeOrBounds)(given Context): Option[NoPrefix] = if (x == Types.NoPrefix) Some(Types.NoPrefix) else None type TypeBounds = Types.TypeBounds - def matchTypeBounds(x: TypeOrBounds) given Context: Option[TypeBounds] = x match { + def matchTypeBounds(x: TypeOrBounds)(given Context): Option[TypeBounds] = x match { case x: Types.TypeBounds => Some(x) case _ => None } - def TypeBounds_low(self: TypeBounds) given Context: Type = self.lo - def TypeBounds_hi(self: TypeBounds) given Context: Type = self.hi + def TypeBounds_low(self: TypeBounds)(given Context): Type = self.lo + def TypeBounds_hi(self: TypeBounds)(given Context): Type = self.hi type Type = Types.Type - def matchType(x: TypeOrBounds) given Context: Option[Type] = x match { + def matchType(x: TypeOrBounds)(given Context): Option[Type] = x match { case x: TypeBounds => None case x if x == Types.NoPrefix => None case _ => Some(x) @@ -1069,9 +1069,9 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend } else ctx.getClassIfDefined(clazz.getCanonicalName).typeRef - def `Type_=:=`(self: Type)(that: Type) given Context: Boolean = self =:= that + def `Type_=:=`(self: Type)(that: Type)(given Context): Boolean = self =:= that - def `Type_<:<`(self: Type)(that: Type) given Context: Boolean = self <:< that + def `Type_<:<`(self: Type)(that: Type)(given Context): Boolean = self <:< that /** Widen from singleton type to its underlying non-singleton * base type by applying one or more `underlying` dereferences, @@ -1082,78 +1082,78 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend * def o: Outer * .widen = o.C */ - def Type_widen(self: Type) given Context: Type = self.widen + def Type_widen(self: Type)(given Context): Type = self.widen - def Type_dealias(self: Type) given Context: Type = self.dealias + def Type_dealias(self: Type)(given Context): Type = self.dealias - def Type_simplified(self: Type) given Context: Type = self.simplified + def Type_simplified(self: Type)(given Context): Type = self.simplified - def Type_classSymbol(self: Type) given Context: Option[ClassDefSymbol] = + def Type_classSymbol(self: Type)(given Context): Option[ClassDefSymbol] = if (self.classSymbol.exists) Some(self.classSymbol.asClass) else None - def Type_typeSymbol(self: Type) given Context: Symbol = self.typeSymbol + def Type_typeSymbol(self: Type)(given Context): Symbol = self.typeSymbol - def Type_termSymbol(self: Type) given Context: Symbol = self.termSymbol + def Type_termSymbol(self: Type)(given Context): Symbol = self.termSymbol - def Type_isSingleton(self: Type) given Context: Boolean = self.isSingleton + def Type_isSingleton(self: Type)(given Context): Boolean = self.isSingleton - def Type_memberType(self: Type)(member: Symbol) given Context: Type = + def Type_memberType(self: Type)(member: Symbol)(given Context): Type = member.info.asSeenFrom(self, member.owner) - def Type_derivesFrom(self: Type)(cls: ClassDefSymbol) given Context: Boolean = + def Type_derivesFrom(self: Type)(cls: ClassDefSymbol)(given Context): Boolean = self.derivesFrom(cls) - def Type_isFunctionType(self: Type) given Context: Boolean = + def Type_isFunctionType(self: Type)(given Context): Boolean = defn.isFunctionType(self) - def Type_isImplicitFunctionType(self: Type) given Context: Boolean = + def Type_isImplicitFunctionType(self: Type)(given Context): Boolean = defn.isImplicitFunctionType(self) - def Type_isErasedFunctionType(self: Type) given Context: Boolean = + def Type_isErasedFunctionType(self: Type)(given Context): Boolean = defn.isErasedFunctionType(self) - def Type_isDependentFunctionType(self: Type) given Context: Boolean = { + def Type_isDependentFunctionType(self: Type)(given Context): Boolean = { val tpNoRefinement = self.dropDependentRefinement tpNoRefinement != self && defn.isNonRefinedFunction(tpNoRefinement) } type ConstantType = Types.ConstantType - def matchConstantType(tpe: TypeOrBounds) given Context: Option[ConstantType] = tpe match { + def matchConstantType(tpe: TypeOrBounds)(given Context): Option[ConstantType] = tpe match { case tpe: Types.ConstantType => Some(tpe) case _ => None } - def ConstantType_constant(self: ConstantType) given Context: Constant = self.value + def ConstantType_constant(self: ConstantType)(given Context): Constant = self.value type TermRef = Types.NamedType - def matchTermRef(tpe: TypeOrBounds) given Context: Option[TermRef] = tpe match { + def matchTermRef(tpe: TypeOrBounds)(given Context): Option[TermRef] = tpe match { case tp: Types.TermRef => Some(tp) case _ => None } - def TermRef_apply(qual: TypeOrBounds, name: String) given Context: TermRef = + def TermRef_apply(qual: TypeOrBounds, name: String)(given Context): TermRef = Types.TermRef(qual, name.toTermName) - def TermRef_qualifier(self: TermRef) given Context: TypeOrBounds = self.prefix + def TermRef_qualifier(self: TermRef)(given Context): TypeOrBounds = self.prefix - def TermRef_name(self: TermRef) given Context: String = self.name.toString + def TermRef_name(self: TermRef)(given Context): String = self.name.toString type TypeRef = Types.NamedType - def matchTypeRef(tpe: TypeOrBounds) given Context: Option[TypeRef] = tpe match { + def matchTypeRef(tpe: TypeOrBounds)(given Context): Option[TypeRef] = tpe match { case tp: Types.TypeRef => Some(tp) case _ => None } - def TypeRef_qualifier(self: TypeRef) given Context: TypeOrBounds = self.prefix + def TypeRef_qualifier(self: TypeRef)(given Context): TypeOrBounds = self.prefix - def TypeRef_name(self: TypeRef) given Context: String = self.name.toString + def TypeRef_name(self: TypeRef)(given Context): String = self.name.toString type NamedTermRef = Types.NamedType - def matchNamedTermRef(tpe: TypeOrBounds) given Context: Option[NamedTermRef] = tpe match { + def matchNamedTermRef(tpe: TypeOrBounds)(given Context): Option[NamedTermRef] = tpe match { case tpe: Types.NamedType => tpe.designator match { case name: Names.TermName => Some(tpe) @@ -1162,167 +1162,167 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend case _ => None } - def NamedTermRef_name(self: NamedTermRef) given Context: String = self.name.toString - def NamedTermRef_qualifier(self: NamedTermRef) given Context: TypeOrBounds = self.prefix + def NamedTermRef_name(self: NamedTermRef)(given Context): String = self.name.toString + def NamedTermRef_qualifier(self: NamedTermRef)(given Context): TypeOrBounds = self.prefix type SuperType = Types.SuperType - def matchSuperType(tpe: TypeOrBounds) given Context: Option[SuperType] = tpe match { + def matchSuperType(tpe: TypeOrBounds)(given Context): Option[SuperType] = tpe match { case tpe: Types.SuperType => Some(tpe) case _ => None } - def SuperType_thistpe(self: SuperType) given Context: Type = self.thistpe - def SuperType_supertpe(self: SuperType) given Context: Type = self.supertpe + def SuperType_thistpe(self: SuperType)(given Context): Type = self.thistpe + def SuperType_supertpe(self: SuperType)(given Context): Type = self.supertpe type Refinement = Types.RefinedType - def matchRefinement(tpe: TypeOrBounds) given Context: Option[Refinement] = tpe match { + def matchRefinement(tpe: TypeOrBounds)(given Context): Option[Refinement] = tpe match { case tpe: Types.RefinedType => Some(tpe) case _ => None } - def Refinement_parent(self: Refinement) given Context: Type = self.parent - def Refinement_name(self: Refinement) given Context: String = self.refinedName.toString - def Refinement_info(self: Refinement) given Context: TypeOrBounds = self.refinedInfo + def Refinement_parent(self: Refinement)(given Context): Type = self.parent + def Refinement_name(self: Refinement)(given Context): String = self.refinedName.toString + def Refinement_info(self: Refinement)(given Context): TypeOrBounds = self.refinedInfo type AppliedType = Types.AppliedType - def matchAppliedType(tpe: TypeOrBounds) given Context: Option[AppliedType] = tpe match { + def matchAppliedType(tpe: TypeOrBounds)(given Context): Option[AppliedType] = tpe match { case tpe: Types.AppliedType => Some(tpe) case _ => None } - def AppliedType_tycon(self: AppliedType) given Context: Type = self.tycon - def AppliedType_args(self: AppliedType) given Context: List[TypeOrBounds] = self.args + def AppliedType_tycon(self: AppliedType)(given Context): Type = self.tycon + def AppliedType_args(self: AppliedType)(given Context): List[TypeOrBounds] = self.args - def AppliedType_apply(tycon: Type, args: List[TypeOrBounds]) given Context: AppliedType = Types.AppliedType(tycon, args) + def AppliedType_apply(tycon: Type, args: List[TypeOrBounds])(given Context): AppliedType = Types.AppliedType(tycon, args) type AnnotatedType = Types.AnnotatedType - def matchAnnotatedType(tpe: TypeOrBounds) given Context: Option[AnnotatedType] = tpe match { + def matchAnnotatedType(tpe: TypeOrBounds)(given Context): Option[AnnotatedType] = tpe match { case tpe: Types.AnnotatedType => Some(tpe) case _ => None } - def AnnotatedType_underlying(self: AnnotatedType) given Context: Type = self.underlying.stripTypeVar - def AnnotatedType_annot(self: AnnotatedType) given Context: Term = self.annot.tree + def AnnotatedType_underlying(self: AnnotatedType)(given Context): Type = self.underlying.stripTypeVar + def AnnotatedType_annot(self: AnnotatedType)(given Context): Term = self.annot.tree type AndType = Types.AndType - def matchAndType(tpe: TypeOrBounds) given Context: Option[AndType] = tpe match { + def matchAndType(tpe: TypeOrBounds)(given Context): Option[AndType] = tpe match { case tpe: Types.AndType => Some(tpe) case _ => None } - def AndType_left(self: AndType) given Context: Type = self.tp1.stripTypeVar - def AndType_right(self: AndType) given Context: Type = self.tp2.stripTypeVar + def AndType_left(self: AndType)(given Context): Type = self.tp1.stripTypeVar + def AndType_right(self: AndType)(given Context): Type = self.tp2.stripTypeVar type OrType = Types.OrType - def matchOrType(tpe: TypeOrBounds) given Context: Option[OrType] = tpe match { + def matchOrType(tpe: TypeOrBounds)(given Context): Option[OrType] = tpe match { case tpe: Types.OrType => Some(tpe) case _ => None } - def OrType_left(self: OrType) given Context: Type = self.tp1.stripTypeVar - def OrType_right(self: OrType) given Context: Type = self.tp2.stripTypeVar + def OrType_left(self: OrType)(given Context): Type = self.tp1.stripTypeVar + def OrType_right(self: OrType)(given Context): Type = self.tp2.stripTypeVar type MatchType = Types.MatchType - def matchMatchType(tpe: TypeOrBounds) given Context: Option[MatchType] = tpe match { + def matchMatchType(tpe: TypeOrBounds)(given Context): Option[MatchType] = tpe match { case tpe: Types.MatchType => Some(tpe) case _ => None } - def MatchType_bound(self: MatchType) given Context: Type = self.bound - def MatchType_scrutinee(self: MatchType) given Context: Type = self.scrutinee - def MatchType_cases(self: MatchType) given Context: List[Type] = self.cases + def MatchType_bound(self: MatchType)(given Context): Type = self.bound + def MatchType_scrutinee(self: MatchType)(given Context): Type = self.scrutinee + def MatchType_cases(self: MatchType)(given Context): List[Type] = self.cases type ByNameType = Types.ExprType - def matchByNameType(tpe: TypeOrBounds) given Context: Option[ByNameType] = tpe match { + def matchByNameType(tpe: TypeOrBounds)(given Context): Option[ByNameType] = tpe match { case tpe: Types.ExprType => Some(tpe) case _ => None } - def ByNameType_underlying(self: ByNameType) given Context: Type = self.resType.stripTypeVar + def ByNameType_underlying(self: ByNameType)(given Context): Type = self.resType.stripTypeVar type ParamRef = Types.ParamRef - def matchParamRef(tpe: TypeOrBounds) given Context: Option[ParamRef] = tpe match { + def matchParamRef(tpe: TypeOrBounds)(given Context): Option[ParamRef] = tpe match { case tpe: Types.TypeParamRef => Some(tpe) case tpe: Types.TermParamRef => Some(tpe) case _ => None } - def ParamRef_binder(self: ParamRef) given Context: LambdaType[TypeOrBounds] = + def ParamRef_binder(self: ParamRef)(given Context): LambdaType[TypeOrBounds] = self.binder.asInstanceOf[LambdaType[TypeOrBounds]] // Cast to tpd - def ParamRef_paramNum(self: ParamRef) given Context: Int = self.paramNum + def ParamRef_paramNum(self: ParamRef)(given Context): Int = self.paramNum type ThisType = Types.ThisType - def matchThisType(tpe: TypeOrBounds) given Context: Option[ThisType] = tpe match { + def matchThisType(tpe: TypeOrBounds)(given Context): Option[ThisType] = tpe match { case tpe: Types.ThisType => Some(tpe) case _ => None } - def ThisType_tref(self: ThisType) given Context: Type = self.tref + def ThisType_tref(self: ThisType)(given Context): Type = self.tref type RecursiveThis = Types.RecThis - def matchRecursiveThis(tpe: TypeOrBounds) given Context: Option[RecursiveThis] = tpe match { + def matchRecursiveThis(tpe: TypeOrBounds)(given Context): Option[RecursiveThis] = tpe match { case tpe: Types.RecThis => Some(tpe) case _ => None } - def RecursiveThis_binder(self: RecursiveThis) given Context: RecursiveType = self.binder + def RecursiveThis_binder(self: RecursiveThis)(given Context): RecursiveType = self.binder type RecursiveType = Types.RecType - def matchRecursiveType(tpe: TypeOrBounds) given Context: Option[RecursiveType] = tpe match { + def matchRecursiveType(tpe: TypeOrBounds)(given Context): Option[RecursiveType] = tpe match { case tpe: Types.RecType => Some(tpe) case _ => None } - def RecursiveType_underlying(self: RecursiveType) given Context: Type = self.underlying.stripTypeVar + def RecursiveType_underlying(self: RecursiveType)(given Context): Type = self.underlying.stripTypeVar type LambdaType[ParamInfo] = Types.LambdaType { type PInfo = ParamInfo } type MethodType = Types.MethodType - def matchMethodType(tpe: TypeOrBounds) given Context: Option[MethodType] = tpe match { + def matchMethodType(tpe: TypeOrBounds)(given Context): Option[MethodType] = tpe match { case tpe: Types.MethodType => Some(tpe) case _ => None } def MethodType_isErased(self: MethodType): Boolean = self.isErasedMethod def MethodType_isImplicit(self: MethodType): Boolean = self.isImplicitMethod - def MethodType_paramNames(self: MethodType) given Context: List[String] = self.paramNames.map(_.toString) - def MethodType_paramTypes(self: MethodType) given Context: List[Type] = self.paramInfos - def MethodType_resType(self: MethodType) given Context: Type = self.resType + def MethodType_paramNames(self: MethodType)(given Context): List[String] = self.paramNames.map(_.toString) + def MethodType_paramTypes(self: MethodType)(given Context): List[Type] = self.paramInfos + def MethodType_resType(self: MethodType)(given Context): Type = self.resType type PolyType = Types.PolyType - def matchPolyType(tpe: TypeOrBounds) given Context: Option[PolyType] = tpe match { + def matchPolyType(tpe: TypeOrBounds)(given Context): Option[PolyType] = tpe match { case tpe: Types.PolyType => Some(tpe) case _ => None } - def PolyType_paramNames(self: PolyType) given Context: List[String] = self.paramNames.map(_.toString) - def PolyType_paramBounds(self: PolyType) given Context: List[TypeBounds] = self.paramInfos - def PolyType_resType(self: PolyType) given Context: Type = self.resType + def PolyType_paramNames(self: PolyType)(given Context): List[String] = self.paramNames.map(_.toString) + def PolyType_paramBounds(self: PolyType)(given Context): List[TypeBounds] = self.paramInfos + def PolyType_resType(self: PolyType)(given Context): Type = self.resType type TypeLambda = Types.TypeLambda - def matchTypeLambda(tpe: TypeOrBounds) given Context: Option[TypeLambda] = tpe match { + def matchTypeLambda(tpe: TypeOrBounds)(given Context): Option[TypeLambda] = tpe match { case tpe: Types.TypeLambda => Some(tpe) case _ => None } - def TypeLambda_paramNames(self: TypeLambda) given Context: List[String] = self.paramNames.map(_.toString) - def TypeLambda_paramBounds(self: TypeLambda) given Context: List[TypeBounds] = self.paramInfos - def TypeLambda_resType(self: TypeLambda) given Context: Type = self.resType + def TypeLambda_paramNames(self: TypeLambda)(given Context): List[String] = self.paramNames.map(_.toString) + def TypeLambda_paramBounds(self: TypeLambda)(given Context): List[TypeBounds] = self.paramInfos + def TypeLambda_resType(self: TypeLambda)(given Context): Type = self.resType // // IMPORT SELECTORS @@ -1332,29 +1332,29 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type SimpleSelector = untpd.ImportSelector - def matchSimpleSelector(self: ImportSelector) given Context: Option[SimpleSelector] = + def matchSimpleSelector(self: ImportSelector)(given Context): Option[SimpleSelector] = if self.renamed.isEmpty then Some(self) else None // TODO: handle import bounds - def SimpleSelector_selection(self: SimpleSelector) given Context: Id = self.imported + def SimpleSelector_selection(self: SimpleSelector)(given Context): Id = self.imported type RenameSelector = untpd.ImportSelector - def matchRenameSelector(self: ImportSelector) given Context: Option[RenameSelector] = + def matchRenameSelector(self: ImportSelector)(given Context): Option[RenameSelector] = if self.renamed.isEmpty then None else Some(self) - def RenameSelector_from(self: RenameSelector) given Context: Id = + def RenameSelector_from(self: RenameSelector)(given Context): Id = self.imported - def RenameSelector_to(self: RenameSelector) given Context: Id = + def RenameSelector_to(self: RenameSelector)(given Context): Id = self.renamed.asInstanceOf[untpd.Ident] type OmitSelector = untpd.ImportSelector - def matchOmitSelector(self: ImportSelector) given Context: Option[OmitSelector] = + def matchOmitSelector(self: ImportSelector)(given Context): Option[OmitSelector] = self.renamed match case Trees.Ident(nme.WILDCARD) => Some(self) case _ => None - def SimpleSelector_omitted(self: OmitSelector) given Context: Id = + def SimpleSelector_omitted(self: OmitSelector)(given Context): Id = self.imported // @@ -1363,9 +1363,9 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Id = untpd.Ident - def Id_pos(self: Id) given Context: Position = self.sourcePos + def Id_pos(self: Id)(given Context): Position = self.sourcePos - def Id_name(self: Id) given Context: String = self.name.toString + def Id_name(self: Id)(given Context): String = self.name.toString // // SIGNATURES @@ -1454,27 +1454,27 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Symbol = core.Symbols.Symbol - def Symbol_owner(self: Symbol) given Context: Symbol = self.owner + def Symbol_owner(self: Symbol)(given Context): Symbol = self.owner - def Symbol_flags(self: Symbol) given Context: Flags = self.flags + def Symbol_flags(self: Symbol)(given Context): Flags = self.flags - def Symbol_privateWithin(self: Symbol) given Context: Option[Type] = { + def Symbol_privateWithin(self: Symbol)(given Context): Option[Type] = { val within = self.privateWithin if (within.exists && !self.is(core.Flags.Protected)) Some(within.typeRef) else None } - def Symbol_protectedWithin(self: Symbol) given Context: Option[Type] = { + def Symbol_protectedWithin(self: Symbol)(given Context): Option[Type] = { val within = self.privateWithin if (within.exists && self.is(core.Flags.Protected)) Some(within.typeRef) else None } - def Symbol_name(self: Symbol) given Context: String = self.name.toString + def Symbol_name(self: Symbol)(given Context): String = self.name.toString - def Symbol_fullName(self: Symbol) given Context: String = self.fullName.toString + def Symbol_fullName(self: Symbol)(given Context): String = self.fullName.toString - def Symbol_pos(self: Symbol) given Context: Position = self.sourcePos + def Symbol_pos(self: Symbol)(given Context): Position = self.sourcePos def Symbol_localContext(self: Symbol) given (ctx: Context): Context = if (self.exists) ctx.withOwner(self) @@ -1489,165 +1489,165 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend } docCtx.docstring(self) } - def Symbol_annots(self: Symbol) given Context: List[Term] = + def Symbol_annots(self: Symbol)(given Context): List[Term] = self.annotations.flatMap { case _: core.Annotations.LazyBodyAnnotation => Nil case annot => annot.tree :: Nil } - def Symbol_isDefinedInCurrentRun(self: Symbol) given Context: Boolean = + def Symbol_isDefinedInCurrentRun(self: Symbol)(given Context): Boolean = self.topLevelClass.asClass.isDefinedInCurrentRun - def Symbol_isLocalDummy(self: Symbol) given Context: Boolean = self.isLocalDummy - def Symbol_isRefinementClass(self: Symbol) given Context: Boolean = self.isRefinementClass - def Symbol_isAliasType(self: Symbol) given Context: Boolean = self.isAliasType - def Symbol_isAnonymousClass(self: Symbol) given Context: Boolean = self.isAnonymousClass - def Symbol_isAnonymousFunction(self: Symbol) given Context: Boolean = self.isAnonymousFunction - def Symbol_isAbstractType(self: Symbol) given Context: Boolean = self.isAbstractType - def Symbol_isClassConstructor(self: Symbol) given Context: Boolean = self.isClassConstructor + def Symbol_isLocalDummy(self: Symbol)(given Context): Boolean = self.isLocalDummy + def Symbol_isRefinementClass(self: Symbol)(given Context): Boolean = self.isRefinementClass + def Symbol_isAliasType(self: Symbol)(given Context): Boolean = self.isAliasType + def Symbol_isAnonymousClass(self: Symbol)(given Context): Boolean = self.isAnonymousClass + def Symbol_isAnonymousFunction(self: Symbol)(given Context): Boolean = self.isAnonymousFunction + def Symbol_isAbstractType(self: Symbol)(given Context): Boolean = self.isAbstractType + def Symbol_isClassConstructor(self: Symbol)(given Context): Boolean = self.isClassConstructor type PackageDefSymbol = core.Symbols.Symbol - def matchPackageDefSymbol(symbol: Symbol) given Context: Option[PackageDefSymbol] = + def matchPackageDefSymbol(symbol: Symbol)(given Context): Option[PackageDefSymbol] = if (symbol.is(core.Flags.Package)) Some(symbol) else None - def PackageDefSymbol_tree(self: PackageDefSymbol) given Context: PackageDef = + def PackageDefSymbol_tree(self: PackageDefSymbol)(given Context): PackageDef = FromSymbol.packageDefFromSym(self) type TypeSymbol = core.Symbols.TypeSymbol - def matchTypeSymbol(symbol: Symbol) given Context: Option[TypeSymbol] = + def matchTypeSymbol(symbol: Symbol)(given Context): Option[TypeSymbol] = if (symbol.isType) Some(symbol.asType) else None type ClassDefSymbol = core.Symbols.ClassSymbol - def matchClassDefSymbol(symbol: Symbol) given Context: Option[ClassDefSymbol] = + def matchClassDefSymbol(symbol: Symbol)(given Context): Option[ClassDefSymbol] = if (symbol.isClass) Some(symbol.asClass) else None - def ClassDefSymbol_tree(self: ClassDefSymbol) given Context: ClassDef = + def ClassDefSymbol_tree(self: ClassDefSymbol)(given Context): ClassDef = FromSymbol.classDef(self) - def ClassDefSymbol_fields(self: Symbol) given Context: List[Symbol] = + def ClassDefSymbol_fields(self: Symbol)(given Context): List[Symbol] = self.unforcedDecls.filter(isField) - def ClassDefSymbol_field(self: Symbol)(name: String) given Context: Option[Symbol] = { + def ClassDefSymbol_field(self: Symbol)(name: String)(given Context): Option[Symbol] = { val sym = self.unforcedDecls.find(sym => sym.name == name.toTermName) if (sym.exists && isField(sym)) Some(sym) else None } - def ClassDefSymbol_classMethod(self: Symbol)(name: String) given Context: List[DefDefSymbol] = + def ClassDefSymbol_classMethod(self: Symbol)(name: String)(given Context): List[DefDefSymbol] = self.typeRef.decls.iterator.collect { case sym if isMethod(sym) && sym.name.toString == name => sym.asTerm }.toList - def ClassDefSymbol_classMethods(self: Symbol) given Context: List[DefDefSymbol] = + def ClassDefSymbol_classMethods(self: Symbol)(given Context): List[DefDefSymbol] = self.typeRef.decls.iterator.collect { case sym if isMethod(sym) => sym.asTerm }.toList private def appliedTypeRef(sym: Symbol): Type = sym.typeRef.appliedTo(sym.typeParams.map(_.typeRef)) - def ClassDefSymbol_method(self: Symbol)(name: String) given Context: List[DefDefSymbol] = + def ClassDefSymbol_method(self: Symbol)(name: String)(given Context): List[DefDefSymbol] = appliedTypeRef(self).allMembers.iterator.map(_.symbol).collect { case sym if isMethod(sym) && sym.name.toString == name => sym.asTerm }.toList - def ClassDefSymbol_methods(self: Symbol) given Context: List[DefDefSymbol] = + def ClassDefSymbol_methods(self: Symbol)(given Context): List[DefDefSymbol] = appliedTypeRef(self).allMembers.iterator.map(_.symbol).collect { case sym if isMethod(sym) => sym.asTerm }.toList - private def isMethod(sym: Symbol) given Context: Boolean = + private def isMethod(sym: Symbol)(given Context): Boolean = sym.isTerm && sym.is(Flags.Method) && !sym.isConstructor - def ClassDefSymbol_caseFields(self: Symbol) given Context: List[ValDefSymbol] = + def ClassDefSymbol_caseFields(self: Symbol)(given Context): List[ValDefSymbol] = if (!self.isClass) Nil else self.asClass.paramAccessors.collect { case sym if sym.is(Flags.CaseAccessor) => sym.asTerm } - def ClassDefSymbol_companionClass(self: Symbol) given Context: Option[ClassDefSymbol] = { + def ClassDefSymbol_companionClass(self: Symbol)(given Context): Option[ClassDefSymbol] = { val sym = self.companionModule.companionClass if (sym.exists) Some(sym.asClass) else None } - def ClassDefSymbol_companionModule(self: Symbol) given Context: Option[ValDefSymbol] = { + def ClassDefSymbol_companionModule(self: Symbol)(given Context): Option[ValDefSymbol] = { val sym = self.companionModule if (sym.exists) Some(sym.asTerm) else None } - def ClassDefSymbol_moduleClass(self: Symbol) given Context: Option[Symbol] = { + def ClassDefSymbol_moduleClass(self: Symbol)(given Context): Option[Symbol] = { val sym = self.moduleClass if (sym.exists) Some(sym.asTerm) else None } - private def isField(sym: Symbol) given Context: Boolean = sym.isTerm && !sym.is(Flags.Method) + private def isField(sym: Symbol)(given Context): Boolean = sym.isTerm && !sym.is(Flags.Method) def ClassDefSymbol_of(fullName: String) given (ctx: Context): ClassDefSymbol = ctx.requiredClass(fullName) type TypeDefSymbol = core.Symbols.TypeSymbol - def matchTypeDefSymbol(symbol: Symbol) given Context: Option[TypeDefSymbol] = + def matchTypeDefSymbol(symbol: Symbol)(given Context): Option[TypeDefSymbol] = if (symbol.isType) Some(symbol.asType) else None - def TypeDefSymbol_tree(self: TypeDefSymbol) given Context: TypeDef = + def TypeDefSymbol_tree(self: TypeDefSymbol)(given Context): TypeDef = FromSymbol.typeDefFromSym(self) - def TypeDefSymbol_isTypeParam(self: TypeDefSymbol) given Context: Boolean = + def TypeDefSymbol_isTypeParam(self: TypeDefSymbol)(given Context): Boolean = self.isTypeParam type TypeBindSymbol = core.Symbols.TypeSymbol - def matchTypeBindSymbol(symbol: Symbol) given Context: Option[TypeBindSymbol] = + def matchTypeBindSymbol(symbol: Symbol)(given Context): Option[TypeBindSymbol] = if (symbol.isType && symbol.is(core.Flags.Case)) Some(symbol.asType) else None - def TypeBindSymbol_tree(self: TypeBindSymbol) given Context: TypeBind = + def TypeBindSymbol_tree(self: TypeBindSymbol)(given Context): TypeBind = FromSymbol.typeBindFromSym(self) type TermSymbol = core.Symbols.TermSymbol - def matchTermSymbol(symbol: Symbol) given Context: Option[TermSymbol] = + def matchTermSymbol(symbol: Symbol)(given Context): Option[TermSymbol] = if (symbol.isTerm) Some(symbol.asTerm) else None type DefDefSymbol = core.Symbols.TermSymbol - def matchDefDefSymbol(symbol: Symbol) given Context: Option[DefDefSymbol] = + def matchDefDefSymbol(symbol: Symbol)(given Context): Option[DefDefSymbol] = if (symbol.isTerm && symbol.is(core.Flags.Method)) Some(symbol.asTerm) else None - def DefDefSymbol_tree(self: DefDefSymbol) given Context: DefDef = + def DefDefSymbol_tree(self: DefDefSymbol)(given Context): DefDef = FromSymbol.defDefFromSym(self) - def DefDefSymbol_signature(self: DefDefSymbol) given Context: Signature = + def DefDefSymbol_signature(self: DefDefSymbol)(given Context): Signature = self.signature type ValDefSymbol = core.Symbols.TermSymbol - def matchValDefSymbol(symbol: Symbol) given Context: Option[ValDefSymbol] = + def matchValDefSymbol(symbol: Symbol)(given Context): Option[ValDefSymbol] = if (symbol.isTerm && !symbol.is(core.Flags.Method) && !symbol.is(core.Flags.Case)) Some(symbol.asTerm) else None - def ValDefSymbol_tree(self: ValDefSymbol) given Context: ValDef = + def ValDefSymbol_tree(self: ValDefSymbol)(given Context): ValDef = FromSymbol.valDefFromSym(self) - def ValDefSymbol_moduleClass(self: ValDefSymbol) given Context: Option[ClassDefSymbol] = { + def ValDefSymbol_moduleClass(self: ValDefSymbol)(given Context): Option[ClassDefSymbol] = { val sym = self.moduleClass if (sym.exists) Some(sym.asClass) else None } - def ValDefSymbol_companionClass(self: ValDefSymbol) given Context: Option[ClassDefSymbol] = { + def ValDefSymbol_companionClass(self: ValDefSymbol)(given Context): Option[ClassDefSymbol] = { val sym = self.companionClass if (sym.exists) Some(sym.asClass) else None } type BindSymbol = core.Symbols.TermSymbol - def matchBindSymbol(symbol: Symbol) given Context: Option[BindSymbol] = + def matchBindSymbol(symbol: Symbol)(given Context): Option[BindSymbol] = if (symbol.isTerm && symbol.is(core.Flags.Case)) Some(symbol.asTerm) else None - def BindSymbol_tree(self: BindSymbol) given Context: Bind = + def BindSymbol_tree(self: BindSymbol)(given Context): Bind = FromSymbol.bindFromSym(self) type NoSymbol = core.Symbols.NoSymbol.type - def matchNoSymbol(symbol: Symbol) given Context: Boolean = symbol eq core.Symbols.NoSymbol + def matchNoSymbol(symbol: Symbol)(given Context): Boolean = symbol eq core.Symbols.NoSymbol // // FLAGS @@ -1705,11 +1705,11 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend // /** View this expression `quoted.Expr[?]` as a `Term` */ - def QuotedExpr_unseal(self: scala.quoted.Expr[?]) given Context: Term = + def QuotedExpr_unseal(self: scala.quoted.Expr[?])(given Context): Term = PickledQuotes.quotedExprToTree(self) /** View this expression `quoted.Type[?]` as a `TypeTree` */ - def QuotedType_unseal(self: scala.quoted.Type[?]) given Context: TypeTree = + def QuotedType_unseal(self: scala.quoted.Type[?])(given Context): TypeTree = PickledQuotes.quotedTypeToTree(self) /** Convert `Term` to an `quoted.Expr[Any]` */ @@ -1836,34 +1836,34 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend ctx.typer.inferImplicitArg(tpe, rootPosition.span) type ImplicitSearchSuccess = Tree - def matchImplicitSearchSuccess(isr: ImplicitSearchResult) given Context: Option[ImplicitSearchSuccess] = isr.tpe match { + def matchImplicitSearchSuccess(isr: ImplicitSearchResult)(given Context): Option[ImplicitSearchSuccess] = isr.tpe match { case _: SearchFailureType => None case _ => Some(isr) } - def ImplicitSearchSuccess_tree(self: ImplicitSearchSuccess) given Context: Term = self + def ImplicitSearchSuccess_tree(self: ImplicitSearchSuccess)(given Context): Term = self type ImplicitSearchFailure = Tree - def matchImplicitSearchFailure(isr: ImplicitSearchResult) given Context: Option[ImplicitSearchFailure] = isr.tpe match { + def matchImplicitSearchFailure(isr: ImplicitSearchResult)(given Context): Option[ImplicitSearchFailure] = isr.tpe match { case _: SearchFailureType => Some(isr) case _ => None } - def ImplicitSearchFailure_explanation(self: ImplicitSearchFailure) given Context: String = + def ImplicitSearchFailure_explanation(self: ImplicitSearchFailure)(given Context): String = self.tpe.asInstanceOf[SearchFailureType].explanation type DivergingImplicit = Tree - def matchDivergingImplicit(isr: ImplicitSearchResult) given Context: Option[DivergingImplicit] = isr.tpe match { + def matchDivergingImplicit(isr: ImplicitSearchResult)(given Context): Option[DivergingImplicit] = isr.tpe match { case _: Implicits.DivergingImplicit => Some(isr) case _ => None } type NoMatchingImplicits = Tree - def matchNoMatchingImplicits(isr: ImplicitSearchResult) given Context: Option[NoMatchingImplicits] = isr.tpe match { + def matchNoMatchingImplicits(isr: ImplicitSearchResult)(given Context): Option[NoMatchingImplicits] = isr.tpe match { case _: Implicits.NoMatchingImplicits => Some(isr) case _ => None } type AmbiguousImplicits = Tree - def matchAmbiguousImplicits(isr: ImplicitSearchResult) given Context: Option[AmbiguousImplicits] = isr.tpe match { + def matchAmbiguousImplicits(isr: ImplicitSearchResult)(given Context): Option[AmbiguousImplicits] = isr.tpe match { case _: Implicits.AmbiguousImplicits => Some(isr) case _ => None } diff --git a/compiler/src/dotty/tools/dotc/transform/CacheAliasImplicits.scala b/compiler/src/dotty/tools/dotc/transform/CacheAliasImplicits.scala index 90e4febf0ff7..2b1ed3efd5cc 100644 --- a/compiler/src/dotty/tools/dotc/transform/CacheAliasImplicits.scala +++ b/compiler/src/dotty/tools/dotc/transform/CacheAliasImplicits.scala @@ -27,7 +27,7 @@ object CacheAliasImplicits { * is cached. It applies to all alias implicits that have neither type parameters * nor a given clause. Example: The alias * - * given a as TC = rhs + * TC = rhs * * is expanded before this phase to: * diff --git a/compiler/src/dotty/tools/dotc/transform/NonLocalReturns.scala b/compiler/src/dotty/tools/dotc/transform/NonLocalReturns.scala index 59bec73819be..289d6b91b501 100644 --- a/compiler/src/dotty/tools/dotc/transform/NonLocalReturns.scala +++ b/compiler/src/dotty/tools/dotc/transform/NonLocalReturns.scala @@ -26,7 +26,7 @@ class NonLocalReturns extends MiniPhase { if (tree.tpe <:< pt) tree else Erasure.Boxing.adaptToType(tree, pt) - private def nonLocalReturnControl given Context = defn.NonLocalReturnControlClass.typeRef + private def nonLocalReturnControl(given Context) = defn.NonLocalReturnControlClass.typeRef /** The type of a non-local return expression with given argument type */ private def nonLocalReturnExceptionType(argtype: Type)(implicit ctx: Context) = diff --git a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala index 23936a1d0816..3094623fb105 100644 --- a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala +++ b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala @@ -210,7 +210,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( levelError(sym, tp, pos, "") } - private def levelError(sym: Symbol, tp: Type, pos: SourcePosition, errMsg: String) given Context = { + private def levelError(sym: Symbol, tp: Type, pos: SourcePosition, errMsg: String)(given Context) = { def symStr = if (!tp.isInstanceOf[ThisType]) sym.show else if (sym.is(ModuleClass)) sym.sourceModule.show diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 70ed4b4143c4..75d95af06182 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -1401,7 +1401,7 @@ trait Applications extends Compatibility { /** Widen the result type of synthetic given methods from the implementation class to the * type that's implemented. Example * - * given I[X] as T { ... } + * given I[X] : T { ... } * * This desugars to * @@ -1411,7 +1411,7 @@ trait Applications extends Compatibility { * To compare specificity we should compare with `T`, not with its implementation `I[X]`. * No such widening is performed for given aliases, which are not synthetic. E.g. * - * given J[X] as T = rhs + * given J[X] : T = rhs * * already has the right result type `T`. Neither is widening performed for given * objects, since these are anyway taken to be more specific than methods diff --git a/compiler/test/dotty/tools/repl/ReplCompilerTests.scala b/compiler/test/dotty/tools/repl/ReplCompilerTests.scala index 5818b559c4f3..5818162121b1 100644 --- a/compiler/test/dotty/tools/repl/ReplCompilerTests.scala +++ b/compiler/test/dotty/tools/repl/ReplCompilerTests.scala @@ -129,7 +129,7 @@ class ReplCompilerTests extends ReplTest { } @Test def i5897 = - fromInitialState { implicit state => run("given as Int = 10") } + fromInitialState { implicit state => run("given Int = 10") } .andThen { implicit state => assertEquals( "def given_Int: Int", @@ -151,7 +151,7 @@ class ReplCompilerTests extends ReplTest { | def (x: T) > (y: T) = compare(x, y) > 0 |} | - |given IntOrd as Ord[Int] { + |given IntOrd : Ord[Int] { | def compare(x: Int, y: Int) = | if (x < y) -1 else if (x > y) +1 else 0 |} diff --git a/docs/blog/_posts/2019-08-30-18th-dotty-milestone-release.md b/docs/blog/_posts/2019-08-30-18th-dotty-milestone-release.md index b18b5f21a94f..7a549d4eecc5 100644 --- a/docs/blog/_posts/2019-08-30-18th-dotty-milestone-release.md +++ b/docs/blog/_posts/2019-08-30-18th-dotty-milestone-release.md @@ -90,7 +90,7 @@ If you run the above with command line arguments "Jack 25", the output will be " ```scala case class Address(city: String, street: String) -given as scala.util.FromString[Address] { +given scala.util.FromString[Address] { /** Can throw java.lang.IllegalArgumentException */ def fromString(s: String): T = s.split(",").toList match { diff --git a/docs/docs/reference/changed-features/implicit-resolution.md b/docs/docs/reference/changed-features/implicit-resolution.md index 00ba944b3d6d..e645e03a63a8 100644 --- a/docs/docs/reference/changed-features/implicit-resolution.md +++ b/docs/docs/reference/changed-features/implicit-resolution.md @@ -43,10 +43,10 @@ affect implicits on the language level. Example: package p - given a as A + given a : A object o { - given b as B + given b : B type C } diff --git a/docs/docs/reference/changed-features/numeric-literals.md b/docs/docs/reference/changed-features/numeric-literals.md index ddf0ba3ca9ae..dc8d6c2abe97 100644 --- a/docs/docs/reference/changed-features/numeric-literals.md +++ b/docs/docs/reference/changed-features/numeric-literals.md @@ -156,7 +156,7 @@ object BigFloat { To accept `BigFloat` literals, all that's needed in addition is a given instance of type `FromDigits.Floating[BigFloat]`: ```scala - given FromDigits as FromDigits.Floating[BigFloat] { + given FromDigits : FromDigits.Floating[BigFloat] { def fromDigits(digits: String) = apply(digits) } } // end BigFloat @@ -189,7 +189,7 @@ object BigFloat { def fromDigits(digits: String) = apply(digits) } - given as FromDigits { + given FromDigits { override inline def fromDigits(digits: String) = ${ fromDigitsImpl('digits) } diff --git a/docs/docs/reference/metaprogramming/macros-spec.md b/docs/docs/reference/metaprogramming/macros-spec.md index 6864a187a0eb..3d2f7a41ffca 100644 --- a/docs/docs/reference/metaprogramming/macros-spec.md +++ b/docs/docs/reference/metaprogramming/macros-spec.md @@ -55,7 +55,7 @@ extends simply-typed lambda calculus with quotes and splices. ### Syntax -The syntax of terms, values, and types is given as follows: +The syntax of terms, values, and types is given follows: Terms t ::= x variable (x: T) => t lambda @@ -190,7 +190,7 @@ With the right extractors, the "AsFunction" conversion that maps expressions over functions to functions over expressions can be implemented in user code: ```scala - given AsFunction1[T, U] as Conversion[Expr[T => U], Expr[T] => Expr[U]] { + given AsFunction1[T, U] : Conversion[Expr[T => U], Expr[T] => Expr[U]] { def apply(f: Expr[T => U]): Expr[T] => Expr[U] = (x: Expr[T]) => f match { case Lambda(g) => g(x) diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index 7fc3d8c7e647..4a9844feb642 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -269,7 +269,7 @@ in the sense that they could all be defined in a user program without knowing anything about the representation of `Expr` trees. For instance, here is a possible instance of `Liftable[Boolean]`: ```scala - given as Liftable[Boolean] { + given Liftable[Boolean] { def toExpr(b: Boolean) given QuoteContext: Expr[Boolean] = if (b) '{ true } else '{ false } } @@ -278,7 +278,7 @@ Once we can lift bits, we can work our way up. For instance, here is a possible implementation of `Liftable[Int]` that does not use the underlying tree machinery: ```scala - given as Liftable[Int] { + given Liftable[Int] { def toExpr(n: Int) given QuoteContext: Expr[Int] = n match { case Int.MinValue => '{ Int.MinValue } case _ if n < 0 => '{ - ${ toExpr(-n) } } @@ -291,7 +291,7 @@ tree machinery: Since `Liftable` is a type class, its instances can be conditional. For example, a `List` is liftable if its element type is: ```scala - given [T: Liftable] as Liftable[List[T]] { + given [T: Liftable] : Liftable[List[T]] { def toExpr(xs: List[T]) given QuoteContext: Expr[List[T]] = xs match { case head :: tail => '{ ${ toExpr(head) } :: ${ toExpr(tail) } } case Nil => '{ Nil: List[T] } diff --git a/docs/docs/reference/metaprogramming/staging.md b/docs/docs/reference/metaprogramming/staging.md index 27f04cd1fbf9..fc22c94167b1 100644 --- a/docs/docs/reference/metaprogramming/staging.md +++ b/docs/docs/reference/metaprogramming/staging.md @@ -86,7 +86,7 @@ It will create a project with the necessary dependencies and some examples. Now take exactly the same example as in [Macros](./macros.md). Assume that we do not want to pass an array statically but generated code at run-time and pass the value, also at run-time. Note, how we make a future-stage function of type -`Expr[Array[Int] => Int]` in line 4 below. Using `run { ... }` we can evaluate an +`Expr[Array[Int] => Int]` in line 4 below. Using `run { ... }` we can evaluate an expression at runtime. Within the scope of `run` we can also invoke `show` on an expression to get a source-like representation of the expression. @@ -94,7 +94,7 @@ to get a source-like representation of the expression. import scala.quoted.staging._ // make available the necessary toolbox for runtime code generation -given as Toolbox = Toolbox.make(getClass.getClassLoader) +given Toolbox = Toolbox.make(getClass.getClassLoader) val f: Array[Int] => Int = run { val stagedSum: Expr[Array[Int] => Int] = '{ (arr: Array[Int]) => ${sum('arr)}} diff --git a/library/src-bootstrapped/scala/quoted/Liftable.scala b/library/src-bootstrapped/scala/quoted/Liftable.scala index ec4d30d4ea37..94c5a12d3763 100644 --- a/library/src-bootstrapped/scala/quoted/Liftable.scala +++ b/library/src-bootstrapped/scala/quoted/Liftable.scala @@ -19,15 +19,15 @@ trait Liftable[T] { */ object Liftable { - given Liftable_Boolean_delegate[T <: Boolean] as Liftable[T] = new PrimitiveLiftable - given Liftable_Byte_delegate[T <: Byte] as Liftable[T] = new PrimitiveLiftable - given Liftable_Short_delegate[T <: Short] as Liftable[T] = new PrimitiveLiftable - given Liftable_Int_delegate[T <: Int] as Liftable[T] = new PrimitiveLiftable - given Liftable_Long_delegate[T <: Long] as Liftable[T] = new PrimitiveLiftable - given Liftable_Float_delegate[T <: Float] as Liftable[T] = new PrimitiveLiftable - given Liftable_Double_delegate[T <: Double] as Liftable[T] = new PrimitiveLiftable - given Liftable_Char_delegate[T <: Char] as Liftable[T] = new PrimitiveLiftable - given Liftable_String_delegate[T <: String] as Liftable[T] = new PrimitiveLiftable + given Liftable_Boolean_delegate[T <: Boolean] : Liftable[T] = new PrimitiveLiftable + given Liftable_Byte_delegate[T <: Byte] : Liftable[T] = new PrimitiveLiftable + given Liftable_Short_delegate[T <: Short] : Liftable[T] = new PrimitiveLiftable + given Liftable_Int_delegate[T <: Int] : Liftable[T] = new PrimitiveLiftable + given Liftable_Long_delegate[T <: Long] : Liftable[T] = new PrimitiveLiftable + given Liftable_Float_delegate[T <: Float] : Liftable[T] = new PrimitiveLiftable + given Liftable_Double_delegate[T <: Double] : Liftable[T] = new PrimitiveLiftable + given Liftable_Char_delegate[T <: Char] : Liftable[T] = new PrimitiveLiftable + given Liftable_String_delegate[T <: String] : Liftable[T] = new PrimitiveLiftable private class PrimitiveLiftable[T <: Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String] extends Liftable[T] { /** Lift a primitive value `n` into `'{ n }` */ @@ -37,7 +37,7 @@ object Liftable { } } - given ClassIsLiftable[T] as Liftable[Class[T]] = new Liftable[Class[T]] { + given ClassIsLiftable[T] : Liftable[Class[T]] = new Liftable[Class[T]] { /** Lift a `Class[T]` into `'{ classOf[T] }` */ def toExpr(x: Class[T]) = (given qctx) => { import qctx.tasty._ @@ -45,59 +45,59 @@ object Liftable { } } - given ClassTagIsLiftable[T: Type] as Liftable[ClassTag[T]] = new Liftable[ClassTag[T]] { + given ClassTagIsLiftable[T: Type] : Liftable[ClassTag[T]] = new Liftable[ClassTag[T]] { def toExpr(ct: ClassTag[T]): (given QuoteContext) => Expr[ClassTag[T]] = '{ ClassTag[T](${ct.runtimeClass.toExpr}) } } - given ArrayIsLiftable[T: Type: Liftable: ClassTag] as Liftable[Array[T]] = new Liftable[Array[T]] { + given ArrayIsLiftable[T: Type: Liftable: ClassTag] : Liftable[Array[T]] = new Liftable[Array[T]] { def toExpr(arr: Array[T]): (given QuoteContext) => Expr[Array[T]] = '{ Array[T](${arr.toSeq.toExpr}: _*)(${summon[ClassTag[T]].toExpr}) } } - given ArrayOfBooleanIsLiftable as Liftable[Array[Boolean]] = new Liftable[Array[Boolean]] { + given ArrayOfBooleanIsLiftable : Liftable[Array[Boolean]] = new Liftable[Array[Boolean]] { def toExpr(array: Array[Boolean]): (given QuoteContext) => Expr[Array[Boolean]] = if (array.length == 0) '{ Array.emptyBooleanArray } else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } } - given ArrayOfByteIsLiftable as Liftable[Array[Byte]] = new Liftable[Array[Byte]] { + given ArrayOfByteIsLiftable : Liftable[Array[Byte]] = new Liftable[Array[Byte]] { def toExpr(array: Array[Byte]): (given QuoteContext) => Expr[Array[Byte]] = if (array.length == 0) '{ Array.emptyByteArray } else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } } - given ArrayOfShortIsLiftable as Liftable[Array[Short]] = new Liftable[Array[Short]] { + given ArrayOfShortIsLiftable : Liftable[Array[Short]] = new Liftable[Array[Short]] { def toExpr(array: Array[Short]): (given QuoteContext) => Expr[Array[Short]] = if (array.length == 0) '{ Array.emptyShortArray } else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } } - given ArrayOfCharIsLiftable as Liftable[Array[Char]] = new Liftable[Array[Char]] { + given ArrayOfCharIsLiftable : Liftable[Array[Char]] = new Liftable[Array[Char]] { def toExpr(array: Array[Char]): (given QuoteContext) => Expr[Array[Char]] = if (array.length == 0) '{ Array.emptyCharArray } else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } } - given ArrayOfIntIsLiftable as Liftable[Array[Int]] = new Liftable[Array[Int]] { + given ArrayOfIntIsLiftable : Liftable[Array[Int]] = new Liftable[Array[Int]] { def toExpr(array: Array[Int]): (given QuoteContext) => Expr[Array[Int]] = if (array.length == 0) '{ Array.emptyIntArray } else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } } - given ArrayOfLongIsLiftable as Liftable[Array[Long]] = new Liftable[Array[Long]] { + given ArrayOfLongIsLiftable : Liftable[Array[Long]] = new Liftable[Array[Long]] { def toExpr(array: Array[Long]): (given QuoteContext) => Expr[Array[Long]] = if (array.length == 0) '{ Array.emptyLongArray } else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } } - given ArrayOfFloatIsLiftable as Liftable[Array[Float]] = new Liftable[Array[Float]] { + given ArrayOfFloatIsLiftable : Liftable[Array[Float]] = new Liftable[Array[Float]] { def toExpr(array: Array[Float]): (given QuoteContext) => Expr[Array[Float]] = if (array.length == 0) '{ Array.emptyFloatArray } else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } } - given ArrayOfDoubleIsLiftable as Liftable[Array[Double]] = new Liftable[Array[Double]] { + given ArrayOfDoubleIsLiftable : Liftable[Array[Double]] = new Liftable[Array[Double]] { def toExpr(array: Array[Double]): (given QuoteContext) => Expr[Array[Double]] = if (array.length == 0) '{ Array.emptyDoubleArray } else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } @@ -108,199 +108,199 @@ object Liftable { '{ ${ltArray.toExpr(iarray.asInstanceOf[Array[T]])}.asInstanceOf[IArray[T]] } } - given [T: Type: Liftable] as Liftable[Seq[T]] = new Liftable[Seq[T]] { + given [T: Type: Liftable] : Liftable[Seq[T]] = new Liftable[Seq[T]] { def toExpr(xs: Seq[T]): (given QuoteContext) => Expr[Seq[T]] = xs.map(summon[Liftable[T]].toExpr).toExprOfSeq } - given [T: Type: Liftable] as Liftable[List[T]] = new Liftable[List[T]] { + given [T: Type: Liftable] : Liftable[List[T]] = new Liftable[List[T]] { def toExpr(xs: List[T]): (given QuoteContext) => Expr[List[T]] = xs.map(summon[Liftable[T]].toExpr).toExprOfList } - given [T: Type: Liftable] as Liftable[Set[T]] = new Liftable[Set[T]] { + given [T: Type: Liftable] : Liftable[Set[T]] = new Liftable[Set[T]] { def toExpr(set: Set[T]): (given QuoteContext) => Expr[Set[T]] = '{ Set(${set.toSeq.toExpr}: _*) } } - given [T: Type: Liftable, U: Type: Liftable] as Liftable[Map[T, U]] = new Liftable[Map[T, U]] { + given [T: Type: Liftable, U: Type: Liftable] : Liftable[Map[T, U]] = new Liftable[Map[T, U]] { def toExpr(map: Map[T, U]): (given QuoteContext) => Expr[Map[T, U]] = '{ Map(${map.toSeq.toExpr}: _*) } } - given [T: Type: Liftable] as Liftable[Option[T]] = new Liftable[Option[T]] { + given [T: Type: Liftable] : Liftable[Option[T]] = new Liftable[Option[T]] { def toExpr(x: Option[T]): (given QuoteContext) => Expr[Option[T]] = x match { case Some(x) => '{ Some[T](${x.toExpr}) } case None => '{ None: Option[T] } } } - given [L: Type: Liftable, R: Type: Liftable] as Liftable[Either[L, R]] = new Liftable[Either[L, R]] { + given [L: Type: Liftable, R: Type: Liftable] : Liftable[Either[L, R]] = new Liftable[Either[L, R]] { def toExpr(x: Either[L, R]): (given QuoteContext) => Expr[Either[L, R]] = x match { case Left(x) => '{ Left[L, R](${x.toExpr}) } case Right(x) => '{ Right[L, R](${x.toExpr}) } } } - given [T1: Type: Liftable] as Liftable[Tuple1[T1]] = new { + given [T1: Type: Liftable] : Liftable[Tuple1[T1]] = new { def toExpr(tup: Tuple1[T1]) = '{ Tuple1(${tup._1.toExpr}) } } - given [T1: Type: Liftable, T2: Type: Liftable] as Liftable[Tuple2[T1, T2]] = new { + given [T1: Type: Liftable, T2: Type: Liftable] : Liftable[Tuple2[T1, T2]] = new { def toExpr(tup: Tuple2[T1, T2]) = '{ (${tup._1.toExpr}, ${tup._2.toExpr}) } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable] as Liftable[Tuple3[T1, T2, T3]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable] : Liftable[Tuple3[T1, T2, T3]] = new { def toExpr(tup: Tuple3[T1, T2, T3]) = '{ (${tup._1.toExpr}, ${tup._2.toExpr}, ${tup._3.toExpr}) } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable] as Liftable[Tuple4[T1, T2, T3, T4]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable] : Liftable[Tuple4[T1, T2, T3, T4]] = new { def toExpr(tup: Tuple4[T1, T2, T3, T4]) = '{ (${tup._1.toExpr}, ${tup._2.toExpr}, ${tup._3.toExpr}, ${tup._4.toExpr}) } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable] as Liftable[Tuple5[T1, T2, T3, T4, T5]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable] : Liftable[Tuple5[T1, T2, T3, T4, T5]] = new { def toExpr(tup: Tuple5[T1, T2, T3, T4, T5]) = { val (x1, x2, x3, x4, x5) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable] as Liftable[Tuple6[T1, T2, T3, T4, T5, T6]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable] : Liftable[Tuple6[T1, T2, T3, T4, T5, T6]] = new { def toExpr(tup: Tuple6[T1, T2, T3, T4, T5, T6]) = { val (x1, x2, x3, x4, x5, x6) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable] as Liftable[Tuple7[T1, T2, T3, T4, T5, T6, T7]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable] : Liftable[Tuple7[T1, T2, T3, T4, T5, T6, T7]] = new { def toExpr(tup: Tuple7[T1, T2, T3, T4, T5, T6, T7]) = { val (x1, x2, x3, x4, x5, x6, x7) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable] as Liftable[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable] : Liftable[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]] = new { def toExpr(tup: Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]) = { val (x1, x2, x3, x4, x5, x6, x7, x8) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable] as Liftable[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable] : Liftable[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]] = new { def toExpr(tup: Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable] as Liftable[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable] : Liftable[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]] = new { def toExpr(tup: Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable] as Liftable[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable] : Liftable[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]] = new { def toExpr(tup: Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable] as Liftable[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable] : Liftable[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]] = new { def toExpr(tup: Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable] as Liftable[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable] : Liftable[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]] = new { def toExpr(tup: Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable] as Liftable[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable] : Liftable[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]] = new { def toExpr(tup: Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable] as Liftable[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable] : Liftable[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]] = new { def toExpr(tup: Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable] as Liftable[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable] : Liftable[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]] = new { def toExpr(tup: Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable] as Liftable[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable] : Liftable[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]] = new { def toExpr(tup: Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable] as Liftable[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable] : Liftable[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]] = new { def toExpr(tup: Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}, ${x18.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable] as Liftable[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable] : Liftable[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]] = new { def toExpr(tup: Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}, ${x18.toExpr}, ${x19.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable] as Liftable[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable] : Liftable[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]] = new { def toExpr(tup: Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}, ${x18.toExpr}, ${x19.toExpr}, ${x20.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable, T21: Type: Liftable] as Liftable[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable, T21: Type: Liftable] : Liftable[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]] = new { def toExpr(tup: Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}, ${x18.toExpr}, ${x19.toExpr}, ${x20.toExpr}, ${x21.toExpr}) } } } - given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable, T21: Type: Liftable, T22: Type: Liftable] as Liftable[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable, T21: Type: Liftable, T22: Type: Liftable] : Liftable[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]] = new { def toExpr(tup: Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22) = tup '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}, ${x18.toExpr}, ${x19.toExpr}, ${x20.toExpr}, ${x21.toExpr}, ${x22.toExpr}) } } } - given [H: Type: Liftable, T <: Tuple: Type: Liftable] as Liftable[H *: T] = new { + given [H: Type: Liftable, T <: Tuple: Type: Liftable] : Liftable[H *: T] = new { def toExpr(tup: H *: T): (given QuoteContext) => Expr[H *: T] = '{ ${summon[Liftable[H]].toExpr(tup.head)} *: ${summon[Liftable[T]].toExpr(tup.tail)} } // '{ ${tup.head.toExpr} *: ${tup.tail.toExpr} } // TODO figure out why this fails during CI documentation } - given as Liftable[BigInt] = new Liftable[BigInt] { + given Liftable[BigInt] = new Liftable[BigInt] { def toExpr(x: BigInt): (given QuoteContext) => Expr[BigInt] = '{ BigInt(${x.toByteArray.toExpr}) } } /** Lift a BigDecimal using the default MathContext */ - given as Liftable[BigDecimal] = new Liftable[BigDecimal] { + given Liftable[BigDecimal] = new Liftable[BigDecimal] { def toExpr(x: BigDecimal): (given QuoteContext) => Expr[BigDecimal] = '{ BigDecimal(${x.toString.toExpr}) } } diff --git a/library/src-bootstrapped/scala/tasty/reflect/TreeUtils.scala b/library/src-bootstrapped/scala/tasty/reflect/TreeUtils.scala index c33ffa15520d..074bf33cb6c0 100644 --- a/library/src-bootstrapped/scala/tasty/reflect/TreeUtils.scala +++ b/library/src-bootstrapped/scala/tasty/reflect/TreeUtils.scala @@ -286,7 +286,7 @@ trait TreeUtils /** Bind the `rhs` to a `val` and use it in `body` */ def let(rhs: Term)(body: Ident => Term): Term = { import scala.quoted.QuoteContext - given as QuoteContext = new QuoteContext(this) + given QuoteContext = new QuoteContext(this) val expr = (rhs.seal: @unchecked) match { case '{ $rhsExpr: $t } => '{ diff --git a/library/src/scala/internal/quoted/Matcher.scala b/library/src/scala/internal/quoted/Matcher.scala index 776c27d8afd0..57f4f0f9598b 100644 --- a/library/src/scala/internal/quoted/Matcher.scala +++ b/library/src/scala/internal/quoted/Matcher.scala @@ -89,7 +89,7 @@ private[quoted] object Matcher { private given /*TreeListOps*/ { /** Check that all trees match with =?= and concatenate the results with && */ - def (scrutinees: List[Tree]) =?= (patterns: List[Tree]) given Context, Env: Matching = + def (scrutinees: List[Tree]) =?= (patterns: List[Tree])(given Context, Env): Matching = matchLists(scrutinees, patterns)(_ =?= _) } @@ -104,7 +104,7 @@ private[quoted] object Matcher { * @param `the[Env]` Set of tuples containing pairs of symbols (s, p) where s defines a symbol in `scrutinee` which corresponds to symbol p in `pattern`. * @return `None` if it did not match or `Some(tup: Tuple)` if it matched where `tup` contains the contents of the holes. */ - def (scrutinee0: Tree) =?= (pattern0: Tree) given Context, Env: Matching = { + def (scrutinee0: Tree) =?= (pattern0: Tree)(given Context, Env): Matching = { /** Normalize the tree */ def normalize(tree: Tree): Tree = tree match { @@ -277,7 +277,7 @@ private[quoted] object Matcher { } } - private def treeOptMatches(scrutinee: Option[Tree], pattern: Option[Tree]) given Context, Env: Matching = { + private def treeOptMatches(scrutinee: Option[Tree], pattern: Option[Tree])(given Context, Env): Matching = { (scrutinee, pattern) match { case (Some(x), Some(y)) => x =?= y case (None, None) => matched @@ -285,7 +285,7 @@ private[quoted] object Matcher { } } - private def caseMatches(scrutinee: CaseDef, pattern: CaseDef) given Context, Env: Matching = { + private def caseMatches(scrutinee: CaseDef, pattern: CaseDef)(given Context, Env): Matching = { val (caseEnv, patternMatch) = scrutinee.pattern =?= pattern.pattern withEnv(caseEnv) { patternMatch && @@ -306,7 +306,7 @@ private[quoted] object Matcher { * @return The new environment containing the bindings defined in this pattern tuppled with * `None` if it did not match or `Some(tup: Tuple)` if it matched where `tup` contains the contents of the holes. */ - def (scrutinee: Pattern) =?= (pattern: Pattern) given Context, Env: (Env, Matching) = (scrutinee, pattern) match { + def (scrutinee: Pattern) =?= (pattern: Pattern)(given Context, Env): (Env, Matching) = (scrutinee, pattern) match { case (Pattern.Value(v1), Pattern.Unapply(TypeApply(Select(patternHole @ Ident("patternHole"), "unapply"), List(tpt)), Nil, Nil)) if patternHole.symbol.owner.fullName == "scala.runtime.quoted.Matcher$" => (the[Env], matched(v1.seal)) @@ -354,7 +354,7 @@ private[quoted] object Matcher { } - private def foldPatterns(patterns1: List[Pattern], patterns2: List[Pattern]) given Context, Env: (Env, Matching) = { + private def foldPatterns(patterns1: List[Pattern], patterns2: List[Pattern])(given Context, Env): (Env, Matching) = { if (patterns1.size != patterns2.size) (the[Env], notMatched) else patterns1.zip(patterns2).foldLeft((the[Env], matched)) { (acc, x) => val (env, res) = (x._1 =?= x._2) given (the[Context], acc._1) diff --git a/library/src/scala/quoted/Type.scala b/library/src/scala/quoted/Type.scala index 049e9a97da3b..c3b396dde516 100644 --- a/library/src/scala/quoted/Type.scala +++ b/library/src/scala/quoted/Type.scala @@ -17,47 +17,47 @@ package quoted { /** Some basic type tags, currently incomplete */ object Type { - given UnitTag as Type[Unit] given (qctx: QuoteContext) = { + given UnitTag(given qctx: QuoteContext): Type[Unit] = { import qctx.tasty._ defn.UnitType.seal.asInstanceOf[quoted.Type[Unit]] } - given BooleanTag as Type[Boolean] given (qctx: QuoteContext) = { + given BooleanTag(given qctx: QuoteContext): Type[Boolean] = { import qctx.tasty._ defn.BooleanType.seal.asInstanceOf[quoted.Type[Boolean]] } - given ByteTag as Type[Byte] given (qctx: QuoteContext) = { + given ByteTag(given qctx: QuoteContext): Type[Byte] = { import qctx.tasty._ defn.ByteType.seal.asInstanceOf[quoted.Type[Byte]] } - given CharTag as Type[Char] given (qctx: QuoteContext) = { + given CharTag(given qctx: QuoteContext): Type[Char] = { import qctx.tasty._ defn.CharType.seal.asInstanceOf[quoted.Type[Char]] } - given ShortTag as Type[Short] given (qctx: QuoteContext) = { + given ShortTag(given qctx: QuoteContext): Type[Short] = { import qctx.tasty._ defn.ShortType.seal.asInstanceOf[quoted.Type[Short]] } - given IntTag as Type[Int] given (qctx: QuoteContext) = { + given IntTag(given qctx: QuoteContext): Type[Int] = { import qctx.tasty._ defn.IntType.seal.asInstanceOf[quoted.Type[Int]] } - given LongTag as Type[Long] given (qctx: QuoteContext) = { + given LongTag(given qctx: QuoteContext): Type[Long] = { import qctx.tasty._ defn.LongType.seal.asInstanceOf[quoted.Type[Long]] } - given FloatTag as Type[Float] given (qctx: QuoteContext) = { + given FloatTag(given qctx: QuoteContext): Type[Float] = { import qctx.tasty._ defn.FloatType.seal.asInstanceOf[quoted.Type[Float]] } - given DoubleTag as Type[Double] given (qctx: QuoteContext) = { + given DoubleTag(given qctx: QuoteContext): Type[Double] = { import qctx.tasty._ defn.DoubleType.seal.asInstanceOf[quoted.Type[Double]] } diff --git a/library/src/scala/tasty/reflect/CompilerInterface.scala b/library/src/scala/tasty/reflect/CompilerInterface.scala index 0ff9c45e164d..5ca8514c1252 100644 --- a/library/src/scala/tasty/reflect/CompilerInterface.scala +++ b/library/src/scala/tasty/reflect/CompilerInterface.scala @@ -933,7 +933,7 @@ trait CompilerInterface { def matchTypeRef(tpe: TypeOrBounds) given (ctx: Context): Option[TypeRef] def TypeRef_qualifier(self: TypeRef) given (ctx: Context): TypeOrBounds - def TypeRef_name(self: TypeRef) given Context: String + def TypeRef_name(self: TypeRef)(given Context): String /** Type of a `super` refernce */ type SuperType <: Type diff --git a/library/src/scala/util/FromDigits.scala b/library/src/scala/util/FromDigits.scala index 62e9843c56bd..39c66136f8e0 100644 --- a/library/src/scala/util/FromDigits.scala +++ b/library/src/scala/util/FromDigits.scala @@ -154,11 +154,11 @@ object FromDigits { x } - given BigIntFromDigits as FromDigits.WithRadix[BigInt] { + given BigIntFromDigits : FromDigits.WithRadix[BigInt] { def fromDigits(digits: String, radix: Int): BigInt = BigInt(digits, radix) } - given BigDecimalFromDigits as FromDigits.Decimal[BigDecimal] { + given BigDecimalFromDigits : FromDigits.Decimal[BigDecimal] { def fromDigits(digits: String): BigDecimal = BigDecimal(digits) } } diff --git a/library/src/scala/util/FromString.scala b/library/src/scala/util/FromString.scala index 8da6484efa60..943bdf656471 100644 --- a/library/src/scala/util/FromString.scala +++ b/library/src/scala/util/FromString.scala @@ -13,35 +13,35 @@ trait FromString[T] { object FromString { - given as FromString[String] { + given FromString[String] { def fromString(s: String) = s } - given as FromString[Boolean] { + given FromString[Boolean] { def fromString(s: String) = s.toBoolean } - given as FromString[Byte] { + given FromString[Byte] { def fromString(s: String) = s.toByte } - given as FromString[Short] { + given FromString[Short] { def fromString(s: String) = s.toShort } - given as FromString[Int] { + given FromString[Int] { def fromString(s: String) = s.toInt } - given as FromString[Long] { + given FromString[Long] { def fromString(s: String) = s.toLong } - given as FromString[Float] { + given FromString[Float] { def fromString(s: String) = s.toFloat } - given as FromString[Double] { + given FromString[Double] { def fromString(s: String) = s.toDouble } } diff --git a/library/src/scalaShadowing/language.scala b/library/src/scalaShadowing/language.scala index c3d521bc4708..e761b5115d7c 100644 --- a/library/src/scalaShadowing/language.scala +++ b/library/src/scalaShadowing/language.scala @@ -119,10 +119,10 @@ object language { * class A * class B * object B { - * given a2b as Conversion[A, B] { ... } + * given a2b : Conversion[A, B] { ... } * } * object C { - * given b2a as Conversion[B, A] { ... } + * given b2a : Conversion[B, A] { ... } * } * import given B._ * import given C._ diff --git a/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala b/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala index 33e64afb763b..0113c8ace079 100644 --- a/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala +++ b/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala @@ -6,7 +6,7 @@ import scala.quoted.staging.{run, Toolbox} object Main { - given as Toolbox = Toolbox.make(getClass.getClassLoader) + given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = { diff --git a/staging/src/scala/quoted/staging/Toolbox.scala b/staging/src/scala/quoted/staging/Toolbox.scala index 350f2ad8666a..3081b239a06d 100644 --- a/staging/src/scala/quoted/staging/Toolbox.scala +++ b/staging/src/scala/quoted/staging/Toolbox.scala @@ -3,7 +3,7 @@ package staging import scala.annotation.implicitNotFound -@implicitNotFound("Could not find implicit scala.quoted.staging.Toolbox.\n\nDefault toolbox can be instantiated with:\n `delegate for scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)`\n\n") +@implicitNotFound("Could not find implicit scala.quoted.staging.Toolbox.\n\nDefault toolbox can be instantiated with:\n `given scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)`\n\n") trait Toolbox { def run[T](expr: QuoteContext => Expr[T]): T } @@ -15,7 +15,7 @@ object Toolbox { * Usuage: * ``` * import scala.quoted.staging._ - * delegate for Toolbox = Toolbox.make(getClass.getClassLoader) + * given Toolbox = Toolbox.make(getClass.getClassLoader) * ``` * * @param appClassloader classloader of the application that generated the quotes diff --git a/tests/neg-macros/i6976/Macro_1.scala b/tests/neg-macros/i6976/Macro_1.scala index 9c79b16b7863..f8df371e9032 100644 --- a/tests/neg-macros/i6976/Macro_1.scala +++ b/tests/neg-macros/i6976/Macro_1.scala @@ -1,7 +1,7 @@ package playground import scala.quoted._, scala.quoted.matching._ -import delegate scala.quoted._ +import scala.quoted.given import scala.tasty._ object macros { diff --git a/tests/pos-macros/i7011/Macros_1.scala b/tests/pos-macros/i7011/Macros_1.scala index 00c7a3b5be77..21c0730bb85a 100644 --- a/tests/pos-macros/i7011/Macros_1.scala +++ b/tests/pos-macros/i7011/Macros_1.scala @@ -1,5 +1,5 @@ import scala.quoted._, scala.quoted.matching._ -import delegate scala.quoted._ +import scala.quoted.given inline def mcr(body: => Any): Unit = ${mcrImpl('body)} diff --git a/tests/pos/i5978.scala b/tests/pos/i5978.scala index e412214a2763..9ab194405469 100644 --- a/tests/pos/i5978.scala +++ b/tests/pos/i5978.scala @@ -10,7 +10,7 @@ package p1 { given TP : TokenParser[Char, Position[CharSequence]] {} def f - given TokenParser[Char, Position[CharSequence]] = ??? + (given TokenParser[Char, Position[CharSequence]]) = ??? given FromCharToken(given T: TokenParser[Char, Position[CharSequence]]) : Conversion[Char, Position[CharSequence]] = ??? diff --git a/tests/run-macros/i6765-c/Macro_1.scala b/tests/run-macros/i6765-c/Macro_1.scala index 64139fee3337..9b4273465023 100644 --- a/tests/run-macros/i6765-c/Macro_1.scala +++ b/tests/run-macros/i6765-c/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ -import delegate scala.quoted._ +import scala.quoted.given inline def foo(inline n: Int) = ${fooImpl(n)} diff --git a/tests/run-macros/i7008/macro_1.scala b/tests/run-macros/i7008/macro_1.scala index c230df51d273..25de0bbf008e 100644 --- a/tests/run-macros/i7008/macro_1.scala +++ b/tests/run-macros/i7008/macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._, scala.quoted.matching._ -import delegate scala.quoted._ +import scala.quoted.given import scala.tasty._ case class Box[T](v: T) diff --git a/tests/run-macros/quote-toExprOfSeq/Macro_1.scala b/tests/run-macros/quote-toExprOfSeq/Macro_1.scala index f869cbdbc470..860d48ce9805 100644 --- a/tests/run-macros/quote-toExprOfSeq/Macro_1.scala +++ b/tests/run-macros/quote-toExprOfSeq/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ -import delegate scala.quoted._ +import scala.quoted.given inline def seq = ${fooImpl} diff --git a/tests/run-staging/i6992/Macro_1.scala b/tests/run-staging/i6992/Macro_1.scala index 7f7dd3606af1..dbeb964edc38 100644 --- a/tests/run-staging/i6992/Macro_1.scala +++ b/tests/run-staging/i6992/Macro_1.scala @@ -1,7 +1,7 @@ import scala.quoted._, scala.quoted.matching._ import scala.quoted.staging._ -import delegate scala.quoted._ +import scala.quoted.given given Toolbox = Toolbox.make(getClass.getClassLoader) From 0b27321d71f33789d1dcaaf7d21ec25895a0b23c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 17 Sep 2019 23:19:47 +0200 Subject: [PATCH 05/20] Fixes to erased and others --- .../dotty/tools/dotc/core/Definitions.scala | 4 +- .../tools/dotc/core/tasty/TastyFormat.scala | 2 +- .../dotty/tools/dotc/parsing/Parsers.scala | 145 ++++-------------- compiler/test-resources/repl/erased | 4 +- compiler/test-resources/repl/erased-implicit | 4 +- docs/docs/internals/syntax.md | 4 +- .../metaprogramming/erased-terms-spec.md | 24 +-- .../reference/metaprogramming/erased-terms.md | 14 +- ...6217aaf5e71195b85b12ca59245f35152885.scala | 2 +- tests/generic-java-signatures/erased.scala | 2 +- tests/neg/erased-1.scala | 4 +- tests/neg/erased-2.scala | 4 +- tests/neg/erased-24.scala | 4 +- tests/neg/erased-3.scala | 4 +- tests/neg/erased-4.scala | 2 +- tests/neg/erased-assign.scala | 2 +- tests/neg/erased-case-class.scala | 2 +- tests/neg/erased-def-rhs.scala | 2 +- tests/neg/erased-if-else.scala | 2 +- tests/neg/erased-match.scala | 2 +- tests/neg/erased-pathdep-1.scala | 6 +- tests/neg/erased-pathdep-2.scala | 2 +- tests/neg/erased-return.scala | 2 +- tests/neg/erased-try.scala | 4 +- tests/neg/erased-val-rhs.scala | 2 +- tests/neg/erased-value-class.scala | 2 +- tests/neg/i4060.scala | 4 +- tests/neg/parser-stability-25.scala | 2 +- tests/neg/tupled-function-instances.scala | 96 ++++++------ tests/new/test.scala | 18 --- tests/pos/erased-args-lifted.scala | 2 +- tests/pos/erased-asInstanceOf.scala | 2 +- tests/pos/erased-deep-context.scala | 6 +- tests/pos/erased-extension-method.scala | 2 +- tests/run-macros/erased-arg-macro/1.scala | 16 +- tests/run/config.scala | 4 +- tests/run/erased-1.scala | 2 +- tests/run/erased-10.scala | 2 +- tests/run/erased-11.scala | 6 +- tests/run/erased-12.scala | 2 +- tests/run/erased-13.scala | 2 +- tests/run/erased-15.scala | 2 +- tests/run/erased-16.scala | 4 +- tests/run/erased-2.scala | 2 +- tests/run/erased-20.scala | 2 +- tests/run/erased-21.scala | 2 +- tests/run/erased-25.scala | 2 +- tests/run/erased-26.scala | 2 +- tests/run/erased-27.scala | 2 +- tests/run/erased-28.scala | 4 +- tests/run/erased-3.scala | 2 +- tests/run/erased-4.scala | 4 +- tests/run/erased-5.scala | 4 +- tests/run/erased-6.scala | 2 +- tests/run/erased-7.scala | 4 +- tests/run/erased-8.scala | 4 +- tests/run/erased-9.scala | 2 +- tests/run/erased-poly-ref.scala | 4 +- tests/run/erased-select-prefix.scala | 2 +- tests/run/erased-value-class.scala | 2 +- 60 files changed, 187 insertions(+), 282 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index ccb7b8bb1fde..7162b67e6691 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -98,13 +98,13 @@ class Definitions { * ErasedFunctionN traits follow this template: * * trait ErasedFunctionN[T0,...,T{N-1}, R] extends Object { - * def apply erased ($x0: T0, ..., $x{N_1}: T{N-1}): R + * def apply(erased $x0: T0, ..., $x{N_1}: T{N-1}): R * } * * ErasedImplicitFunctionN traits follow this template: * * trait ErasedImplicitFunctionN[T0,...,T{N-1}, R] extends Object { - * def apply given erased ($x0: T0, ..., $x{N_1}: T{N-1}): R + * def apply (given erased $x0: T0, ..., $x{N_1}: T{N-1}): R * } * * ErasedFunctionN and ErasedImplicitFunctionN erase to Function0. diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala index fa3d8031839d..cd742dd52790 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala @@ -167,7 +167,7 @@ Standard-Section: "ASTs" TopLevelStat* METHODtype Length result_Type NamesTypes -- A method type `(NamesTypes)result`, needed for refinements ERASEDMETHODtype Length result_Type NamesTypes -- A method type `erased (NamesTypes)result`, needed for refinements GIVENMETHODtype Length result_Type NamesTypes -- A method type `given (NamesTypes)result`, needed for refinements - ERASEDGIVENMETHODtype Length result_Type NamesTypes -- A method type `given erased (NamesTypes)result`, needed for refinements + ERASEDGIVENMETHODtype Length result_Type NamesTypes -- A method type `given(erased NamesTypes)result`, needed for refinements IMPLICITMETHODtype Length result_Type NamesTypes -- A method type `(implicit NamesTypes)result`, needed for refinements // TODO: remove ERASEDIMPLICITMETHODtype TYPELAMBDAtype Length result_Type NamesTypes -- A type lambda `[NamesTypes] => result`, variance encoded using VARIANT names diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 8065e6815e9f..ebe24cdaa395 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -33,9 +33,6 @@ object Parsers { import reporting.diagnostic.Message import reporting.diagnostic.messages._ - private inline val allowOldGiven = true - private inline val allowOldExtension = true - case class OpInfo(operand: Tree, operator: Ident, offset: Offset) class ParensCounters { @@ -210,8 +207,7 @@ object Parsers { } && !in.isSoftModifierInModifierPosition def isExprIntro: Boolean = - if (in.token == GIVEN) false - else canStartExpressionTokens.contains(in.token) && !in.isSoftModifierInModifierPosition + canStartExpressionTokens.contains(in.token) && !in.isSoftModifierInModifierPosition def isDefIntro(allowedMods: BitSet, excludedSoftModifiers: Set[TermName] = Set.empty): Boolean = in.token == AT || @@ -928,11 +924,6 @@ object Parsers { } else recur(operand()) } - else if (in.token == GIVEN && allowOldGiven && !isType) { - val top1 = reduceStack(base, top, minInfixPrec, leftAssoc = true, nme.WITHkw, isType) - assert(opStack `eq` base) - recur(applyGiven(top1, operand)) - } else reduceStack(base, top, minPrec, leftAssoc = true, in.name, isType) recur(first) @@ -1652,14 +1643,14 @@ object Parsers { t } - /** Expr ::= [ClosureMods] FunParams =>' Expr + /** Expr ::= [`implicit'] FunParams =>' Expr * | Expr1 * FunParams ::= Bindings * | id * | `_' * ExprInParens ::= PostfixExpr `:' Type * | Expr - * BlockResult ::= [ClosureMods] FunParams =>' Block + * BlockResult ::= [‘implicit’] FunParams =>' Block * | Expr1 * Expr1 ::= [‘inline’] `if' `(' Expr `)' {nl} Expr [[semi] else Expr] * | [‘inline’] `if' Expr `then' Expr [[semi] else Expr] @@ -1689,10 +1680,10 @@ object Parsers { def expr(location: Location.Value): Tree = { val start = in.offset - if closureMods.contains(in.token) && allowOldGiven then - implicitClosure(start, location, modifiers(closureMods)) + if in.token == IMPLICIT then + closure(start, location, modifiers(BitSet(IMPLICIT))) else if in.token == LPAREN && in.lookaheadIn(funTypeArgMods) then - implicitClosure(start, location, modifiers()) + closure(start, location, Modifiers()) else { val saved = placeholderParams placeholderParams = Nil @@ -1951,10 +1942,10 @@ object Parsers { } else ident() - /** Expr ::= ClosureMods FunParams `=>' Expr + /** Expr ::= [‘implicit’] FunParams `=>' Expr * BlockResult ::= implicit id [`:' InfixType] `=>' Block // Scala2 only */ - def implicitClosure(start: Int, location: Location.Value, implicitMods: Modifiers): Tree = + def closure(start: Int, location: Location.Value, implicitMods: Modifiers): Tree = closureRest(start, location, funParams(implicitMods, location)) def closureRest(start: Int, location: Location.Value, params: List[Tree]): Tree = @@ -2615,15 +2606,6 @@ object Parsers { normalize(loop(start)) } - /** ClosureMods ::= { ‘implicit’ | ‘erased’ | ‘given’} - * FunTypeMods ::= { ‘erased’ | ‘given’} - */ - val closureMods: BitSet = - if allowOldGiven then BitSet(GIVEN, IMPLICIT, ERASED) - else BitSet(IMPLICIT, ERASED) - - val funTypeMods: BitSet = BitSet(ERASED) - val funTypeArgMods: BitSet = BitSet(GIVEN, ERASED) /** Wrap annotation or constructor in New(...). */ @@ -2735,9 +2717,9 @@ object Parsers { ofClass: Boolean = false, // owner is a class ofCaseClass: Boolean = false, // owner is a case class prefix: Boolean = false, // clause precedes name of an extension method - firstClause: Boolean = false, // clause is the first in regular list of clauses - initialMods: Modifiers = EmptyModifiers): List[ValDef] = { - var impliedMods: Modifiers = initialMods + firstClause: Boolean = false // clause is the first in regular list of clauses + ): List[ValDef] = { + var impliedMods: Modifiers = EmptyModifiers def impliedModOpt(token: Token, mod: () => Mod): Boolean = if in.token == token then @@ -2826,47 +2808,35 @@ object Parsers { */ def paramClauses(ofClass: Boolean = false, ofCaseClass: Boolean = false, - ofInstance: Boolean = false): List[List[ValDef]] = { + ofInstance: Boolean = false): List[List[ValDef]] = - def recur(firstClause: Boolean, nparams: Int, contextualOnly: Boolean): List[List[ValDef]] = { - var initialMods = EmptyModifiers - val isNewLine = in.token == NEWLINE - newLineOptWhenFollowedBy(LPAREN) - if (in.token == GIVEN && allowOldGiven) { - in.nextToken() - initialMods |= Given - } - if (in.token == ERASED && allowOldGiven) { - in.nextToken() - initialMods |= Erased - } - var isGiven = initialMods.is(Given) + def recur(firstClause: Boolean, nparams: Int, contextualOnly: Boolean): List[List[ValDef]] = newLineOptWhenFollowedBy(LPAREN) - if in.token == LPAREN && (!isGiven || followingIsParamOrGivenType()) then + if in.token == LPAREN then val paramsStart = in.offset val params = paramClause( nparams, ofClass = ofClass, ofCaseClass = ofCaseClass, - firstClause = firstClause, - initialMods = initialMods) - params match - case param :: _ if param.mods.flags.is(Given) => isGiven = true + firstClause = firstClause) + val isGiven = params match + case param :: _ if param.mods.flags.is(Given) => true case _ => if contextualOnly then syntaxError( if ofInstance then em"parameters of instance definitions must be `given' clauses" else em"normal parameters cannot come after `given' clauses", paramsStart) + false val lastClause = params.nonEmpty && params.head.mods.flags.is(Implicit) - params :: (if (lastClause) Nil else recur(firstClause = false, nparams + params.length, isGiven)) - else if isGiven then - val params = givenTypes(false, nparams, ofClass) - params :: recur(firstClause = false, nparams + params.length, isGiven) + params :: ( + if lastClause then Nil + else recur(firstClause = false, nparams + params.length, isGiven)) else Nil - } + end recur + recur(firstClause = true, 0, ofInstance) - } + end paramClauses /* -------- DEFS ------------------------------------------- */ @@ -2880,9 +2850,7 @@ object Parsers { */ def importClause(leading: Token, mkTree: ImportConstr): List[Tree] = { val offset = accept(leading) - val importGiven = allowOldGiven && in.token == GIVEN - if (importGiven) in.nextToken() - commaSeparated(importExpr(importGiven, mkTree)) match { + commaSeparated(importExpr(mkTree)) match { case t :: rest => // The first import should start at the start offset of the keyword. val firstPos = @@ -2899,12 +2867,12 @@ object Parsers { * | ‘given’ * | ‘{’ ImportSelectors) ‘}’ */ - def importExpr(importGiven: Boolean, mkTree: ImportConstr): () => Tree = { + def importExpr(mkTree: ImportConstr): () => Tree = { /** '_' | 'given' */ def wildcardSelectorId() = - val name = if importGiven || in.token == GIVEN then nme.EMPTY else nme.WILDCARD + val name = if in.token == GIVEN then nme.EMPTY else nme.WILDCARD atSpan(in.skipToken()) { Ident(name) } /** ImportSelectors ::= id [‘=>’ id | ‘=>’ ‘_’] [‘,’ ImportSelectors] @@ -3404,37 +3372,9 @@ object Parsers { /** SimpleConstrApp ::= AnnotType {ParArgumentExprs} */ val constrApp: () => Tree = () => { - - def isAnnotType(t: Tree) = t match { - case _: Ident - | _: Select - | _: AppliedTypeTree - | _: Tuple - | _: Parens - | _: RefinedTypeTree - | _: SingletonTypeTree - | _: TypSplice - | _: Annotated => true - case _ => false - } - - def givenArgs(t: Tree): Tree = - if (in.token == GIVEN) givenArgs(applyGiven(t, prefixExpr)) else t - - if (allowOldGiven && in.token == LPAREN) - inParens { - val t = toplevelTyp() - if (isAnnotType(t)) - if (in.token == LPAREN) givenArgs(parArgumentExprss(wrapNew(t))) - else if (in.token == GIVEN) givenArgs(wrapNew(t)) - else t - else Parens(t) - } - else { - 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) parArgumentExprss(wrapNew(t)) else t - } + 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 then parArgumentExprss(wrapNew(t)) else t } /** ConstrApps ::= ConstrApp {‘with’ ConstrApp} (to be deprecated in 3.1) @@ -3682,29 +3622,12 @@ object Parsers { setLastStatOffset() if (in.token == IMPORT) stats ++= importClause(IMPORT, Import) - else if (in.token == GIVEN) { - val start = in.offset - val mods = modifiers(closureMods) - mods.mods match { - case givenMod :: Nil if !isBindingIntro => - stats += instanceDef(start, EmptyModifiers, Mod.Given().withSpan(givenMod.span)) - case _ => - stats += implicitClosure(in.offset, Location.InBlock, mods) - } - } else if (isExprIntro) stats += expr(Location.InBlock) - else if (isDefIntro(localModifierTokens, excludedSoftModifiers = Set(nme.`opaque`))) - if (closureMods.contains(in.token)) { - val start = in.offset - var imods = modifiers(closureMods) - if (isBindingIntro) - stats += implicitClosure(start, Location.InBlock, imods) - else - stats +++= localDef(start, imods) - } - else - stats +++= localDef(in.offset) + else if in.token == IMPLICIT && !in.inModifierPosition() then + stats += closure(in.offset, Location.InBlock, modifiers(BitSet(IMPLICIT))) + else if isDefIntro(localModifierTokens, excludedSoftModifiers = Set(nme.`opaque`)) then + stats +++= localDef(in.offset) else if (!isStatSep && (in.token != CASE)) { exitOnError = mustStartStat syntaxErrorOrIncomplete(IllegalStartOfStatement(isModifier)) diff --git a/compiler/test-resources/repl/erased b/compiler/test-resources/repl/erased index 878b99dce1a5..9a67c1963769 100644 --- a/compiler/test-resources/repl/erased +++ b/compiler/test-resources/repl/erased @@ -1,2 +1,2 @@ -scala> def f erased (a: Int): Int = ??? -def f erased (a: Int): Int +scala> def f(erased a: Int): Int = ??? +def f(erased a: Int): Int diff --git a/compiler/test-resources/repl/erased-implicit b/compiler/test-resources/repl/erased-implicit index 05252ff91aed..ffaba6595a79 100644 --- a/compiler/test-resources/repl/erased-implicit +++ b/compiler/test-resources/repl/erased-implicit @@ -1,2 +1,2 @@ -scala> def f given erased (a: Int): Int = ??? -def f given erased (a: Int): Int +scala> def f(given erased a: Int): Int = ??? +def f(given erased a: Int): Int diff --git a/docs/docs/internals/syntax.md b/docs/docs/internals/syntax.md index f499a95d6d3d..3019c37d925b 100644 --- a/docs/docs/internals/syntax.md +++ b/docs/docs/internals/syntax.md @@ -180,9 +180,9 @@ TypeParamBounds ::= SubtypeBounds {‘:’ Type} ### Expressions ```ebnf -Expr ::= [ClosureMods] FunParams ‘=>’ Expr Function(args, expr), Function(ValDef([implicit], id, TypeTree(), EmptyTree), expr) +Expr ::= [‘implicit’] FunParams ‘=>’ Expr Function(args, expr), Function(ValDef([implicit], id, TypeTree(), EmptyTree), expr) | Expr1 -BlockResult ::= [ClosureMods] FunParams ‘=>’ Block +BlockResult ::= [‘implicit’] FunParams ‘=>’ Block | Expr1 FunParams ::= Bindings | id diff --git a/docs/docs/reference/metaprogramming/erased-terms-spec.md b/docs/docs/reference/metaprogramming/erased-terms-spec.md index 7a5f1202a756..921f1664acf2 100644 --- a/docs/docs/reference/metaprogramming/erased-terms-spec.md +++ b/docs/docs/reference/metaprogramming/erased-terms-spec.md @@ -16,12 +16,12 @@ title: "Erased Terms Spec" erased val x = ... erased def f = ... - def g erased (x: Int) = ... + def g(erased x: Int) = ... - erased (x: Int) => ... - def h(x: erased Int => Int) = ... + (erased x: Int) => ... + def h(x: (erased Int) => Int) = ... - class K erased (x: Int) { ... } + class K(erased x: Int) { ... } ``` @@ -31,25 +31,25 @@ title: "Erased Terms Spec" 3. Functions - * `erased (x1: T1, x2: T2, ..., xN: TN) => y : erased (T1, T2, ..., TN) => R` - * `given erased (x1: T1, x2: T2, ..., xN: TN) => y : given erased (T1, T2, ..., TN) => R` - * `given erased T1 => R <:< erased T1 => R` - * `given erased (T1, T2) => R <:< erased (T1, T2) => R` + * `(erased x1: T1, x2: T2, ..., xN: TN) => y : (erased T1, T2, ..., TN) => R` + * `(given erased x1: T1, x2: T2, ..., xN: TN) => y : (given erased T1, T2, ..., TN) => R` + * `(given erased T1) => R <:< erased T1 => R` + * `(given erased T1, T2) => R <:< (erased T1, T2) => R` * ... - Note that there is no subtype relation between `erased T => R` and `T => R` (or `given erased T => R` and `given T => R`) + Note that there is no subtype relation between `(erased T) => R` and `T => R` (or `(given erased T) => R` and `(given T) => R`) 4. Eta expansion - if `def f erased (x: T): U` then `f: erased (T) => U`. + if `def f(erased x: T): U` then `f: (erased T) => U`. 5. Erasure Semantics * All `erased` parameters are removed from the function * All argument to `erased` parameters are not passed to the function * All `erased` definitions are removed - * All ` erased (T1, T2, ..., TN) => R` and `(given erased T1, T2, ..., TN) => R` become `() => R` + * All `(erased T1, T2, ..., TN) => R` and `(given erased T1, T2, ..., TN) => R` become `() => R` 6. Overloading @@ -59,5 +59,5 @@ title: "Erased Terms Spec" 7. Overriding * Member definitions overriding each other must both be `erased` or not be `erased` - * `def foo(x: T): U` cannot be overridden by `def foo erased (x: T): U` an vice-versa + * `def foo(x: T): U` cannot be overridden by `def foo(erased x: T): U` an vice-versa diff --git a/docs/docs/reference/metaprogramming/erased-terms.md b/docs/docs/reference/metaprogramming/erased-terms.md index ffcead174d98..643a581aa91d 100644 --- a/docs/docs/reference/metaprogramming/erased-terms.md +++ b/docs/docs/reference/metaprogramming/erased-terms.md @@ -50,20 +50,20 @@ Parameters of methods and functions can be declared as erased, placing `erased` in front of a parameter list (like `given`). ```scala -def methodWithErasedEv erased (ev: Ev): Int = 42 +def methodWithErasedEv(erased ev: Ev): Int = 42 val lambdaWithErasedEv: erased Ev => Int = - erased (ev: Ev) => 42 + (erased ev: Ev) => 42 ``` `erased` parameters will not be usable for computations, though they can be used as arguments to other `erased` parameters. ```scala -def methodWithErasedInt1 erased (i: Int): Int = +def methodWithErasedInt1(erased i: Int): Int = i + 42 // ERROR: can not use i -def methodWithErasedInt2 erased (i: Int): Int = +def methodWithErasedInt2(erased i: Int): Int = methodWithErasedInt1(i) // OK ``` @@ -83,7 +83,7 @@ erased. ```scala // becomes def methodWithErasedEv(): Int at runtime -def methodWithErasedEv erased (ev: Ev): Int = ... +def methodWithErasedEv(erased ev: Ev): Int = ... def evidence1: Ev = ... erased def erasedEvidence2: Ev = ... // does not exist at runtime @@ -134,8 +134,8 @@ object IsOn { class Machine[S <: State] private { // ev will disappear from both functions - def turnedOn given erased (ev: IsOff[S]): Machine[On] = new Machine[On] - def turnedOff given erased (ev: IsOn[S]): Machine[Off] = new Machine[Off] + def turnedOn(given erased ev: IsOff[S]): Machine[On] = new Machine[On] + def turnedOff(given erased ev: IsOn[S]): Machine[Off] = new Machine[Off] } object Machine { diff --git a/tests/fuzzy/5d506217aaf5e71195b85b12ca59245f35152885.scala b/tests/fuzzy/5d506217aaf5e71195b85b12ca59245f35152885.scala index 193a1d5558fc..2b12dffd735e 100644 --- a/tests/fuzzy/5d506217aaf5e71195b85b12ca59245f35152885.scala +++ b/tests/fuzzy/5d506217aaf5e71195b85b12ca59245f35152885.scala @@ -24,7 +24,7 @@ case List(i4: Int) => } } trait i5 { -def i3 erased (i2: Int): Int = 0 +def i3(erased i2: Int): Int = 0 def i2() = { class i3 } match { case i4 @ i5 => 1 case i6: i7 => i5 _ extends i5 => diff --git a/tests/generic-java-signatures/erased.scala b/tests/generic-java-signatures/erased.scala index f22b6dc4699f..a9731cc748fb 100644 --- a/tests/generic-java-signatures/erased.scala +++ b/tests/generic-java-signatures/erased.scala @@ -1,5 +1,5 @@ object MyErased { - def f1[U] erased (a: Int): Int = 0 + def f1[U](erased a: Int): Int = 0 } object Test { diff --git a/tests/neg/erased-1.scala b/tests/neg/erased-1.scala index 7bb4cb95d826..552d2cc7e086 100644 --- a/tests/neg/erased-1.scala +++ b/tests/neg/erased-1.scala @@ -1,6 +1,6 @@ object Test { def foo0(a: Int): Int = a - def foo1 erased (a: Int): Int = { + def foo1(erased a: Int): Int = { foo0( a // error ) @@ -24,7 +24,7 @@ object Test { foo3(a) // OK a // OK } - erased def foo3 erased (a: Int): Int = { + erased def foo3(erased a: Int): Int = { foo0(a) // OK foo1(a) // OK foo2(a) // OK diff --git a/tests/neg/erased-2.scala b/tests/neg/erased-2.scala index db7b46f34cec..bab269061899 100644 --- a/tests/neg/erased-2.scala +++ b/tests/neg/erased-2.scala @@ -1,6 +1,6 @@ object Test { def foo0(a: Int): Int = a - def foo1 erased (a: Int): Int = { + def foo1(erased a: Int): Int = { foo0( u // error ) @@ -22,7 +22,7 @@ object Test { u // warn u // OK } - erased def foo3 erased (a: Int): Int = { + erased def foo3(erased a: Int): Int = { foo0(u) // OK foo1(u) // OK foo2(u) // OK diff --git a/tests/neg/erased-24.scala b/tests/neg/erased-24.scala index 3042ef29604e..dc39d4f9b653 100644 --- a/tests/neg/erased-24.scala +++ b/tests/neg/erased-24.scala @@ -6,11 +6,11 @@ object Test { println(fun(new Bar)) } - def fun erased (foo: Foo): foo.X = { // ok + def fun(erased foo: Foo): foo.X = { // ok null.asInstanceOf[foo.X] // ok } - def fun2 erased (foo: Foo) erased (bar: foo.B): bar.X = { // error + def fun2(erased foo: Foo)(erased bar: foo.B): bar.X = { // error null.asInstanceOf[bar.X] // error } } diff --git a/tests/neg/erased-3.scala b/tests/neg/erased-3.scala index 9654b91cca03..16e18b320dc5 100644 --- a/tests/neg/erased-3.scala +++ b/tests/neg/erased-3.scala @@ -1,6 +1,6 @@ object Test { def foo0(a: Int): Int = a - def foo1 erased (a: Int): Int = { + def foo1(erased a: Int): Int = { foo0( u() // error ) @@ -22,7 +22,7 @@ object Test { u() // warn u() // OK } - erased def foo3 erased (a: Int): Int = { + erased def foo3(erased a: Int): Int = { foo0(u()) // OK foo1(u()) // OK foo2(u()) // OK diff --git a/tests/neg/erased-4.scala b/tests/neg/erased-4.scala index 0efc1a92b904..1583c5297cd1 100644 --- a/tests/neg/erased-4.scala +++ b/tests/neg/erased-4.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { - def foo erased (i: Int) = 0 + def foo (erased i: Int) = 0 val f: (erased Int) => Int = (erased x: Int) => { diff --git a/tests/neg/erased-assign.scala b/tests/neg/erased-assign.scala index 28b4a242ae81..5f1bd9250e84 100644 --- a/tests/neg/erased-assign.scala +++ b/tests/neg/erased-assign.scala @@ -1,6 +1,6 @@ object Test { var i: Int = 1 - def foo erased (a: Int): Int = { + def foo(erased a: Int): Int = { i = a // error erased def r = { i = a diff --git a/tests/neg/erased-case-class.scala b/tests/neg/erased-case-class.scala index 1d1458b7453d..692534d772b6 100644 --- a/tests/neg/erased-case-class.scala +++ b/tests/neg/erased-case-class.scala @@ -1 +1 @@ -case class Foo1 erased (x: Int) // error // error +case class Foo1(erased x: Int) // error // error diff --git a/tests/neg/erased-def-rhs.scala b/tests/neg/erased-def-rhs.scala index 8afaa5a72c44..23417583f860 100644 --- a/tests/neg/erased-def-rhs.scala +++ b/tests/neg/erased-def-rhs.scala @@ -1,5 +1,5 @@ object Test { - def f erased (i: Int) = { + def f(erased i: Int) = { def j: Int = i // error j } diff --git a/tests/neg/erased-if-else.scala b/tests/neg/erased-if-else.scala index 032b8d735802..503dfc0bd1e3 100644 --- a/tests/neg/erased-if-else.scala +++ b/tests/neg/erased-if-else.scala @@ -1,6 +1,6 @@ object Test { var b = true - def foo erased (a: Boolean): Boolean = { + def foo(erased a: Boolean): Boolean = { if (a) // error true else diff --git a/tests/neg/erased-match.scala b/tests/neg/erased-match.scala index 668ba905703d..2d8057519bfc 100644 --- a/tests/neg/erased-match.scala +++ b/tests/neg/erased-match.scala @@ -1,6 +1,6 @@ object Test { var b = true - def foo erased (a: Int): Int = { + def foo(erased a: Int): Int = { a match { // error case _ => } diff --git a/tests/neg/erased-pathdep-1.scala b/tests/neg/erased-pathdep-1.scala index a930ff2f18db..027a08e29582 100644 --- a/tests/neg/erased-pathdep-1.scala +++ b/tests/neg/erased-pathdep-1.scala @@ -6,9 +6,9 @@ object Test { fun2(new Bar) fun3(new Bar) - def fun1[F >: Bar <: Foo] erased (f: F): f.X = null.asInstanceOf[f.X] // error // error - def fun2[F >: Bar <: Foo] erased (f: F) erased (bar: f.B): f.B = null.asInstanceOf[f.B] // error // error // error - def fun3[F >: Bar <: Foo] erased (f: F) erased (b: f.B): b.X = null.asInstanceOf[b.X] // error // error // error + def fun1[F >: Bar <: Foo](erased f: F): f.X = null.asInstanceOf[f.X] // error // error + def fun2[F >: Bar <: Foo](erased f: F)(erased bar: f.B): f.B = null.asInstanceOf[f.B] // error // error // error + def fun3[F >: Bar <: Foo](erased f: F)(erased b: f.B): b.X = null.asInstanceOf[b.X] // error // error // error } class Foo { diff --git a/tests/neg/erased-pathdep-2.scala b/tests/neg/erased-pathdep-2.scala index 0c8c5afbaa70..29dcf216b32e 100644 --- a/tests/neg/erased-pathdep-2.scala +++ b/tests/neg/erased-pathdep-2.scala @@ -4,7 +4,7 @@ object Test { type F >: Bar <: Foo - class A erased (val f: F) { + class A(erased val f: F) { type F1 <: f.X // error type F2[Z <: f.X] // error } diff --git a/tests/neg/erased-return.scala b/tests/neg/erased-return.scala index b87394d4a7c8..f7cf15a079be 100644 --- a/tests/neg/erased-return.scala +++ b/tests/neg/erased-return.scala @@ -1,6 +1,6 @@ object Test { var b = true - def foo erased (a: Int): Int = { + def foo(erased a: Int): Int = { if (b) return a // error else diff --git a/tests/neg/erased-try.scala b/tests/neg/erased-try.scala index 7f748a685664..3e9aae8ab9a4 100644 --- a/tests/neg/erased-try.scala +++ b/tests/neg/erased-try.scala @@ -1,12 +1,12 @@ object Test { - def foo erased (a: Int): Int = { + def foo(erased a: Int): Int = { try { a // error } catch { case _ => 42 } } - def foo2 erased (a: Int): Int = { + def foo2(erased a: Int): Int = { try { 42 } catch { diff --git a/tests/neg/erased-val-rhs.scala b/tests/neg/erased-val-rhs.scala index afc65789b664..1b904c671478 100644 --- a/tests/neg/erased-val-rhs.scala +++ b/tests/neg/erased-val-rhs.scala @@ -1,5 +1,5 @@ object Test { - def f erased (i: Int) = { + def f(erased i: Int) = { val j: Int = i // error () } diff --git a/tests/neg/erased-value-class.scala b/tests/neg/erased-value-class.scala index 95d707bd34c0..65cd3e2f961b 100644 --- a/tests/neg/erased-value-class.scala +++ b/tests/neg/erased-value-class.scala @@ -1,4 +1,4 @@ -class Foo erased (x: Int) extends AnyVal // error +class Foo(erased x: Int) extends AnyVal // error class Bar(x: Int)(y: Int) extends AnyVal // error diff --git a/tests/neg/i4060.scala b/tests/neg/i4060.scala index 0e2664e51ec4..3d5c180b5d7b 100644 --- a/tests/neg/i4060.scala +++ b/tests/neg/i4060.scala @@ -1,12 +1,12 @@ class X { type R } -class T erased (val a: X)(val value: a.R) +class T(erased val a: X)(val value: a.R) object App { def coerce[U, V](u: U): V = { trait X { type R >: U } trait Y { type R = V } - class T[A <: X] erased (val a: A)(val value: a.R) // error + class T[A <: X](erased val a: A)(val value: a.R) // error object O { lazy val x : Y & X = ??? } diff --git a/tests/neg/parser-stability-25.scala b/tests/neg/parser-stability-25.scala index 68fa28a9d9e1..23db4498af0e 100644 --- a/tests/neg/parser-stability-25.scala +++ b/tests/neg/parser-stability-25.scala @@ -11,5 +11,5 @@ class D extends (Int => 1) { } class Wrap(x: Int) -class E extends (Wrap)( // error // error +class E extends (Wrap)( // error // error \ No newline at end of file diff --git a/tests/neg/tupled-function-instances.scala b/tests/neg/tupled-function-instances.scala index 0929fc6566e1..0d401f417eb2 100644 --- a/tests/neg/tupled-function-instances.scala +++ b/tests/neg/tupled-function-instances.scala @@ -20,55 +20,55 @@ object Test { summon[TupledFunction[(given T, T, T) => R, ((T, T, T)) =>R]] // error summon[TupledFunction[(erased T) => R, erased Tuple1[T] => R]] // error - summon[TupledFunction[erased (T, T) => R, erased ((T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T) => R, erased ((T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T) => R, erased ((T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T) => R, erased ((T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, erased ((T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T) => R,(erased (T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T) => R,(erased (T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T) => R,(erased (T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T) => R,(erased (T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R,(erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error summon[TupledFunction[(given erased T) => R, (given erased Tuple1[T]) => R]] // error - summon[TupledFunction[(given erased T, T) => R, (given erased (T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T) => R, (given erased (T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T) => R, (given erased (T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T) => R, (given erased (T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error - summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) => R]] // error + summon[TupledFunction[(given erased T, T) => R, (given erased T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T) => R, (given erased T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T) => R, (given erased T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T) => R, (given erased T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error + summon[TupledFunction[(given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R, (given erased T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) => R]] // error } } \ No newline at end of file diff --git a/tests/new/test.scala b/tests/new/test.scala index 33676a6ecbe0..c42aaf364300 100644 --- a/tests/new/test.scala +++ b/tests/new/test.scala @@ -1,21 +1,3 @@ trait T { object O - - type U = (given Int) => Int - type V = (given Int) => Int - - val v = given (x: Int) => x - val w = (given x: Int) => x - val w2: V = (given x) => x - - class C[T] - - given t2[T](given C[T]): C[T] - - try ??? : List[Int] match - case Nil => 1 - case x :: xs => 2 - catch - case java.io.IOException => 3 - case java.lang.Error => 4 } diff --git a/tests/pos/erased-args-lifted.scala b/tests/pos/erased-args-lifted.scala index 03b78ec84a1f..faa07cdcb0b5 100644 --- a/tests/pos/erased-args-lifted.scala +++ b/tests/pos/erased-args-lifted.scala @@ -1,5 +1,5 @@ object Test { - def foo erased (a: Int)(b: Int, c: Int) = 42 + def foo(erased a: Int)(b: Int, c: Int) = 42 def bar(i: Int): Int = { println(1) 42 diff --git a/tests/pos/erased-asInstanceOf.scala b/tests/pos/erased-asInstanceOf.scala index 57996aab961e..956e325646d9 100644 --- a/tests/pos/erased-asInstanceOf.scala +++ b/tests/pos/erased-asInstanceOf.scala @@ -1,6 +1,6 @@ trait Dataset { - def select erased (c: Column): Unit = () + def select(erased c: Column): Unit = () } class Column diff --git a/tests/pos/erased-deep-context.scala b/tests/pos/erased-deep-context.scala index 93b971456713..049bf14c2e4f 100644 --- a/tests/pos/erased-deep-context.scala +++ b/tests/pos/erased-deep-context.scala @@ -1,12 +1,12 @@ object Test { def outer1(): Int = { - def inner erased (a: Int): Int = 0 + def inner(erased a: Int): Int = 0 inner(42) } def outer2(): Int = { - def inner erased (b: Int): Int = { - def inner2 erased (a: Int): Int = 0 + def inner(erased b: Int): Int = { + def inner2(erased a: Int): Int = 0 inner2(b) } inner(42) diff --git a/tests/pos/erased-extension-method.scala b/tests/pos/erased-extension-method.scala index 6b56f5ee46dc..7ef14d65e4a4 100644 --- a/tests/pos/erased-extension-method.scala +++ b/tests/pos/erased-extension-method.scala @@ -1,3 +1,3 @@ class IntDeco(x: Int) extends AnyVal { - def foo erased (y: Int) = x + def foo(erased y: Int) = x } diff --git a/tests/run-macros/erased-arg-macro/1.scala b/tests/run-macros/erased-arg-macro/1.scala index 1277ec6d9425..b17b422e505f 100644 --- a/tests/run-macros/erased-arg-macro/1.scala +++ b/tests/run-macros/erased-arg-macro/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])(given QuoteContext): Expr[Int] = '{ 0 } - def case2 (i: Int) erased (j: Expr[Int])(given QuoteContext): Expr[Int] = '{ 0 } - def case3 erased (i: Expr[Int]) (j: Int)(given QuoteContext): Expr[Int] = '{ 0 } - def case4 (h: Int) erased (i: Expr[Int], j: Expr[Int])(given QuoteContext): Expr[Int] = '{ 0 } - def case5 erased (i: Expr[Int], j: Expr[Int]) (h: Int)(given QuoteContext): Expr[Int] = '{ 0 } - def case6 (h: Int) erased (i: Expr[Int]) erased (j: Expr[Int])(given QuoteContext): Expr[Int] = '{ 0 } - def case7 erased (i: Expr[Int]) (h: Int) erased (j: Expr[Int])(given QuoteContext): Expr[Int] = '{ 0 } - def case8 erased (i: Expr[Int]) erased (j: Expr[Int]) (h: Int)(given QuoteContext): Expr[Int] = '{ 0 } + def case1(erased i: Expr[Int])(given QuoteContext): Expr[Int] = '{ 0 } + def case2 (i: Int)(erased j: Expr[Int])(given QuoteContext): Expr[Int] = '{ 0 } + def case3(erased i: Expr[Int]) (j: Int)(given QuoteContext): Expr[Int] = '{ 0 } + def case4 (h: Int)(erased i: Expr[Int], j: Expr[Int])(given QuoteContext): Expr[Int] = '{ 0 } + def case5(erased i: Expr[Int], j: Expr[Int]) (h: Int)(given QuoteContext): Expr[Int] = '{ 0 } + def case6 (h: Int)(erased i: Expr[Int])(erased j: Expr[Int])(given QuoteContext): Expr[Int] = '{ 0 } + def case7(erased i: Expr[Int]) (h: Int)(erased j: Expr[Int])(given QuoteContext): Expr[Int] = '{ 0 } + def case8(erased i: Expr[Int])(erased j: Expr[Int]) (h: Int)(given QuoteContext): Expr[Int] = '{ 0 } } diff --git a/tests/run/config.scala b/tests/run/config.scala index aeeb1e734310..efc516ebaae4 100644 --- a/tests/run/config.scala +++ b/tests/run/config.scala @@ -85,8 +85,8 @@ object Test extends App { val config1 = Config("John Doe", 20) val config2 = Config("Incognito", 99) - println(readPerson given config1) - println(readPerson given config2) + println(readPerson(given config1)) + println(readPerson(given config2)) } object OptionTest extends App { diff --git a/tests/run/erased-1.scala b/tests/run/erased-1.scala index f1f62cdd3706..acb8ce68f9bf 100644 --- a/tests/run/erased-1.scala +++ b/tests/run/erased-1.scala @@ -8,7 +8,7 @@ object Test { println("foo") 42 } - def fun erased (boo: Int): Unit = { + def fun(erased boo: Int): Unit = { println("fun") } } diff --git a/tests/run/erased-10.scala b/tests/run/erased-10.scala index 78a55cc058ef..25c86c0267c8 100644 --- a/tests/run/erased-10.scala +++ b/tests/run/erased-10.scala @@ -4,7 +4,7 @@ object Test { fun2.pacFun4(inky) } - def pacFun4 erased (clyde: Int) = { + def pacFun4(erased clyde: Int) = { println("pacFun4") } diff --git a/tests/run/erased-11.scala b/tests/run/erased-11.scala index 1419cd381f08..36a8d08f8d7f 100644 --- a/tests/run/erased-11.scala +++ b/tests/run/erased-11.scala @@ -8,17 +8,17 @@ object Test { (new Fun2().fun)({ println("z1"); boo })({ println("z2"); boo }) } - def fun erased (x1: Int) erased (x2: Int) = { + def fun(erased x1: Int)(erased x2: Int) = { println("fun") } - class Fun erased (y1: Int) erased (y2: Int) { + class Fun(erased y1: Int)(erased y2: Int) { println("Fun") } class Fun2 { println("Fun2") - def fun erased (z1: Int) erased (z2: Int) = { + def fun(erased z1: Int)(erased z2: Int) = { println("Fun2fun") } } diff --git a/tests/run/erased-12.scala b/tests/run/erased-12.scala index 202eba7232c2..cde677050dd6 100644 --- a/tests/run/erased-12.scala +++ b/tests/run/erased-12.scala @@ -12,6 +12,6 @@ object Test { } -case class Foo(a: Int) erased (b: Int) { +case class Foo(a: Int)(erased b: Int) { println("Foo") } diff --git a/tests/run/erased-13.scala b/tests/run/erased-13.scala index c6687f886ccf..442a3eab4c01 100644 --- a/tests/run/erased-13.scala +++ b/tests/run/erased-13.scala @@ -8,7 +8,7 @@ object Test { foo(x) } - def foo erased (a: Int) = { + def foo(erased a: Int) = { println("foo") } diff --git a/tests/run/erased-15.scala b/tests/run/erased-15.scala index a850e9b5cc7b..b879ee4c54d8 100644 --- a/tests/run/erased-15.scala +++ b/tests/run/erased-15.scala @@ -11,7 +11,7 @@ object Test { } class Foo extends ErasedFunction1[Int, Int] { - def apply erased (x: Int): Int = { + def apply(erased x: Int): Int = { println("Foo.apply") 42 } diff --git a/tests/run/erased-16.scala b/tests/run/erased-16.scala index f38f13244dd2..879af76765b7 100644 --- a/tests/run/erased-16.scala +++ b/tests/run/erased-16.scala @@ -11,11 +11,11 @@ object Test { } class Foo { - def foo erased (x: Int): Int = 42 + def foo(erased x: Int): Int = 42 } class Bar extends Foo { - override def foo erased (x: Int): Int = { + override def foo(erased x: Int): Int = { println("Bar.foo") 42 } diff --git a/tests/run/erased-2.scala b/tests/run/erased-2.scala index b0f550790d14..20d89990b362 100644 --- a/tests/run/erased-2.scala +++ b/tests/run/erased-2.scala @@ -12,7 +12,7 @@ object Test { } } - def fun erased (bottom: Nothing): Unit = { + def fun(erased bottom: Nothing): Unit = { println("fun") } } diff --git a/tests/run/erased-20.scala b/tests/run/erased-20.scala index bfae456373a3..f54fd417eb83 100644 --- a/tests/run/erased-20.scala +++ b/tests/run/erased-20.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { - fun { erased (x: Int) => + fun {(erased x: Int) => println("lambda") "abc" } diff --git a/tests/run/erased-21.scala b/tests/run/erased-21.scala index ba3270d08b29..a85c6ea62f98 100644 --- a/tests/run/erased-21.scala +++ b/tests/run/erased-21.scala @@ -3,7 +3,7 @@ object Test { type UU[T] = (erased T) => Int def main(args: Array[String]): Unit = { - fun { erased x => + fun { (erased x) => println("lambda") 42 } diff --git a/tests/run/erased-25.scala b/tests/run/erased-25.scala index 9bc7e4d08063..97a85dd1460d 100644 --- a/tests/run/erased-25.scala +++ b/tests/run/erased-25.scala @@ -6,5 +6,5 @@ object Test { } class Dataset { - def select[A] erased (c: Boolean): String = "abc" + def select[A](erased c: Boolean): String = "abc" } diff --git a/tests/run/erased-26.scala b/tests/run/erased-26.scala index b95ce5036449..eed903ac2753 100644 --- a/tests/run/erased-26.scala +++ b/tests/run/erased-26.scala @@ -2,5 +2,5 @@ object Test { def main(args: Array[String]): Unit = { col("abc")(true) } - def col[S](s: String) erased (ev: Boolean): Unit = println(s) + def col[S](s: String)(erased ev: Boolean): Unit = println(s) } diff --git a/tests/run/erased-27.scala b/tests/run/erased-27.scala index 4371190c49e3..68b551520daa 100644 --- a/tests/run/erased-27.scala +++ b/tests/run/erased-27.scala @@ -5,7 +5,7 @@ object Test { foo })(x) } - def foo erased (a: Int): Unit = { + def foo(erased a: Int): Unit = { println("foo") } def x: Int = { diff --git a/tests/run/erased-28.scala b/tests/run/erased-28.scala index d8ba2ea19a9a..8b916b810dff 100644 --- a/tests/run/erased-28.scala +++ b/tests/run/erased-28.scala @@ -5,10 +5,10 @@ object Test { a = false (if (a) foo else bar)(x) } - def foo erased (a: Int): Unit = { + def foo(erased a: Int): Unit = { println("foo") } - def bar erased (a: Int): Unit = { + def bar(erased a: Int): Unit = { println("bar") } def x: Int = { diff --git a/tests/run/erased-3.scala b/tests/run/erased-3.scala index 10143311a956..68d2f8b629c2 100644 --- a/tests/run/erased-3.scala +++ b/tests/run/erased-3.scala @@ -14,7 +14,7 @@ object Test { "abc" } - def fun erased (a: Int) erased (b: String): Unit = { + def fun(erased a: Int)(erased b: String): Unit = { println("fun") } diff --git a/tests/run/erased-4.scala b/tests/run/erased-4.scala index c2c5e9c00000..8725a7ebc00f 100644 --- a/tests/run/erased-4.scala +++ b/tests/run/erased-4.scala @@ -15,11 +15,11 @@ object Test { "abc" } - def fun(a: Int) erased (b: String): Unit = { + def fun(a: Int)(erased b: String): Unit = { println("fun " + a) } - def fun2 erased (a: Int)(b: String): Unit = { + def fun2(erased a: Int)(b: String): Unit = { println("fun2 " + b) } } diff --git a/tests/run/erased-5.scala b/tests/run/erased-5.scala index 24d26718e8cf..043d1a4781a7 100644 --- a/tests/run/erased-5.scala +++ b/tests/run/erased-5.scala @@ -10,11 +10,11 @@ object Test { i } - def fun(a: Int) erased (b: Int)(c: Int) erased (d: Int): Unit = { + def fun(a: Int)(erased b: Int)(c: Int)(erased d: Int): Unit = { println("fun " + a + " " + c) } - def fun2 erased (a2: Int)(b2: Int) erased (c2: Int)(d2: Int): Unit = { + def fun2(erased a2: Int)(b2: Int)(erased c2: Int)(d2: Int): Unit = { println("fun2 " + b2 + " " + d2) } } diff --git a/tests/run/erased-6.scala b/tests/run/erased-6.scala index 40ae3fa28bcd..ec113fbb426b 100644 --- a/tests/run/erased-6.scala +++ b/tests/run/erased-6.scala @@ -11,6 +11,6 @@ object Test { } -class Foo erased (a: Int) { +class Foo(erased a: Int) { println("Foo") } diff --git a/tests/run/erased-7.scala b/tests/run/erased-7.scala index 49a0d9cdf544..6027c2e1572c 100644 --- a/tests/run/erased-7.scala +++ b/tests/run/erased-7.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { - def f erased (i: Int) = { + def f(erased i: Int) = { new Foo(i)(foo) } f(5) @@ -14,6 +14,6 @@ object Test { } -class Foo erased (a: Int)(b: Int) { +class Foo(erased a: Int)(b: Int) { println("Foo") } diff --git a/tests/run/erased-8.scala b/tests/run/erased-8.scala index 040fadded893..afa637e709ef 100644 --- a/tests/run/erased-8.scala +++ b/tests/run/erased-8.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { - def f erased (i: Int) = { + def f(erased i: Int) = { new Foo(foo)(i) } f(foo) @@ -14,6 +14,6 @@ object Test { } -class Foo(a: Int) erased (b: Int) { +class Foo(a: Int)(erased b: Int) { println("Foo") } diff --git a/tests/run/erased-9.scala b/tests/run/erased-9.scala index 81e856437191..a989bce068a2 100644 --- a/tests/run/erased-9.scala +++ b/tests/run/erased-9.scala @@ -9,7 +9,7 @@ object Test { 42 } - def fun[T] erased (x: T): Unit = { + def fun[T](erased x: T): Unit = { println("fun") } } diff --git a/tests/run/erased-poly-ref.scala b/tests/run/erased-poly-ref.scala index fb43a72ef2b1..9f0d3c38d417 100644 --- a/tests/run/erased-poly-ref.scala +++ b/tests/run/erased-poly-ref.scala @@ -4,9 +4,9 @@ object Test { fun(foo(bar(5))(bar(6))) } - def fun erased (a: Int): Unit = println("fun") + def fun(erased a: Int): Unit = println("fun") - def foo[P] erased (x: Int) erased (y: Int): Int = 0 + def foo[P](erased x: Int)(erased y: Int): Int = 0 def bar(x: Int) = { println(x) diff --git a/tests/run/erased-select-prefix.scala b/tests/run/erased-select-prefix.scala index 985f6c8258f2..718779ccdcfb 100644 --- a/tests/run/erased-select-prefix.scala +++ b/tests/run/erased-select-prefix.scala @@ -25,7 +25,7 @@ object Test { () } - def bar erased (i: Int): Unit = () + def bar(erased i: Int): Unit = () erased def foo0: Int = 0 erased def foo1(): Int = 1 diff --git a/tests/run/erased-value-class.scala b/tests/run/erased-value-class.scala index ce07dd1d9a90..a87b0e8bf4af 100644 --- a/tests/run/erased-value-class.scala +++ b/tests/run/erased-value-class.scala @@ -11,6 +11,6 @@ object Test { } } -class Bar(x: Int) erased (y: Int) extends AnyVal { +class Bar(x: Int)(erased y: Int) extends AnyVal { def foo() = x } From 24dc2de468da7215fa678104525c85265a3c5978 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 17 Sep 2019 23:26:47 +0200 Subject: [PATCH 06/20] Adapt xml interpolator to new given syntax --- community-build/community-projects/xml-interpolator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index 716a099edab5..e7e12e4a5451 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit 716a099edab57dc25408404439250b2eb535e839 +Subproject commit e7e12e4a54512142101bd2ebf6e4bd55e2282b93 From 4f437ae6c5e0e6891fd6aff368c90ceeb2b436ef Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 18 Sep 2019 00:07:26 +0200 Subject: [PATCH 07/20] More fixes in code and tests --- .../dotty/tools/backend/jvm/GenBCode.scala | 4 +- .../src/dotty/tools/dotc/ast/Desugar.scala | 2 +- .../dotty/tools/dotc/ast/MainProxies.scala | 2 +- .../dotty/tools/dotc/core/Annotations.scala | 6 +- .../dotty/tools/dotc/core/Decorators.scala | 2 +- .../src/dotty/tools/dotc/core/Periods.scala | 2 +- .../src/dotty/tools/dotc/core/Phases.scala | 2 +- .../src/dotty/tools/dotc/core/Signature.scala | 4 +- .../dotty/tools/dotc/core/TypeComparer.scala | 4 +- .../dotty/tools/dotc/core/TyperState.scala | 4 +- .../tools/dotc/core/tasty/TreeUnpickler.scala | 4 +- .../core/unpickleScala2/Scala2Unpickler.scala | 2 +- .../tools/dotc/interactive/Interactive.scala | 2 +- .../tools/dotc/printing/Formatting.scala | 2 +- .../tools/dotc/printing/RefinedPrinter.scala | 5 +- .../tools/dotc/quoted/QuoteContext.scala | 4 +- .../dotty/tools/dotc/reporting/Reporter.scala | 2 +- .../dotty/tools/dotc/rewrites/Rewrites.scala | 2 +- .../ReflectionCompilerInterface.scala | 36 +- .../dotc/tastyreflect/ReflectionImpl.scala | 2 +- .../dotty/tools/dotc/transform/CtxLazy.scala | 2 +- .../dotc/transform/PCPCheckAndHeal.scala | 4 +- .../tools/dotc/transform/ReifyQuotes.scala | 2 +- .../dotty/tools/dotc/transform/Splicer.scala | 22 +- .../tools/dotc/transform/ValueClasses.scala | 2 +- .../src/dotty/tools/dotc/typer/Checking.scala | 4 +- .../dotty/tools/dotc/typer/ImportInfo.scala | 2 +- .../src/dotty/tools/dotc/typer/Inliner.scala | 2 +- .../src/dotty/tools/dotc/typer/Typer.scala | 10 +- compiler/src/dotty/tools/package.scala | 2 +- compiler/test-resources/repl-macros/i5551 | 4 +- compiler/test-resources/repl/defs | 2 +- .../tools/backend/jvm/ArrayApplyOptTest.scala | 2 +- .../reference/contextual/given-clauses.md | 2 +- docs/docs/reference/metaprogramming/macros.md | 10 +- .../docs/reference/metaprogramming/staging.md | 4 +- .../metaprogramming/tasty-reflect.md | 6 +- .../other-new-features/quoted-pattern-spec.md | 8 +- .../dotty/internal/StringContextMacro.scala | 8 +- library/src-bootstrapped/scala/IArray.scala | 2 +- .../scala/quoted/util/Var.scala | 10 +- .../scala/tasty/reflect/TreeUtils.scala | 60 +- library/src/dotty/DottyPredef.scala | 4 +- library/src/scala/Tuple.scala | 2 +- .../src/scala/internal/quoted/Matcher.scala | 52 +- library/src/scala/quoted/Expr.scala | 14 +- library/src/scala/quoted/QuoteContext.scala | 8 +- library/src/scala/quoted/ValueOfExpr.scala | 4 +- library/src/scala/quoted/matching/Bind.scala | 2 +- library/src/scala/quoted/matching/Const.scala | 2 +- .../src/scala/quoted/matching/ConstSeq.scala | 2 +- .../src/scala/quoted/matching/ExprSeq.scala | 2 +- .../src/scala/quoted/matching/package.scala | 2 +- .../src/scala/runtime/quoted/Unpickler.scala | 4 +- .../tasty/reflect/CompilerInterface.scala | 838 +++++++++--------- .../src/scala/tasty/reflect/ConstantOps.scala | 2 +- library/src/scala/tasty/reflect/IdOps.scala | 6 +- .../scala/tasty/reflect/ImplicitsOps.scala | 16 +- .../tasty/reflect/ImportSelectorOps.scala | 14 +- .../src/scala/tasty/reflect/PatternOps.scala | 68 +- .../src/scala/tasty/reflect/Printers.scala | 150 ++-- .../src/scala/tasty/reflect/QuotedOps.scala | 10 +- .../scala/tasty/reflect/ReportingOps.scala | 8 +- .../scala/tasty/reflect/SignatureOps.scala | 2 +- .../src/scala/tasty/reflect/SymbolOps.scala | 128 +-- library/src/scala/tasty/reflect/TreeOps.scala | 606 ++++++------- .../scala/tasty/reflect/TypeOrBoundsOps.scala | 192 ++-- .../src/scala/util/CommandLineParser.scala | 6 +- .../scala/util/control/NonLocalReturns.scala | 4 +- .../src/main/scala/hello/Hello.scala | 2 +- .../src/scala/quoted/staging/staging.scala | 8 +- staging/test-resources/repl-staging/i6007 | 2 +- tests/neg-macros/quote-this.scala | 4 +- tests/neg/i4044a.scala | 4 +- tests/neg/i4044b.scala | 6 +- tests/neg/i7052b.scala | 2 +- tests/neg/quote-0.scala | 2 +- tests/patmat/i6255.scala | 2 +- tests/pos/i4380b.scala | 2 +- tests/pos/i4414.scala | 2 +- tests/pos/quote-1.scala | 2 +- tests/pos/quote-lift.scala | 2 +- tests/pos/quote-liftable.scala | 2 +- tests/pos/quoted-inline-quote.scala | 2 +- .../tasty-macro-positions/quoted_1.scala | 2 +- 85 files changed, 1226 insertions(+), 1231 deletions(-) diff --git a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala index 1f5c35c1db20..9c97e7747721 100644 --- a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala +++ b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala @@ -161,10 +161,10 @@ class GenBCodePipeline(val int: DottyBackendInterface)(implicit val ctx: Context val same = classSymbol.effectiveName.toString == dupClassSym.effectiveName.toString ctx.atPhase(ctx.typerPhase) { if (same) - the[Context].warning( // FIXME: This should really be an error, but then FromTasty tests fail + summon[Context].warning( // FIXME: This should really be an error, but then FromTasty tests fail s"${cl1.show} and ${cl2.showLocated} produce classes that overwrite one another", cl1.sourcePos) else - the[Context].warning(s"${cl1.show} differs only in case from ${cl2.showLocated}. " + + summon[Context].warning(s"${cl1.show} differs only in case from ${cl2.showLocated}. " + "Such classes will overwrite one another on case-insensitive filesystems.", cl1.sourcePos) } } diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 63331aa69c5f..c9ace1ebd559 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -893,7 +893,7 @@ object desugar { * If the given member `mdef` is not of this form, flag it as an error. */ - def makeExtensionDef(mdef: Tree, tparams: List[TypeDef], leadingParams: List[ValDef]) given (ctx: Context): Tree = { + def makeExtensionDef(mdef: Tree, tparams: List[TypeDef], leadingParams: List[ValDef])(given ctx: Context): Tree = { val allowed = "allowed here, since collective parameters are given" mdef match { case mdef: DefDef => diff --git a/compiler/src/dotty/tools/dotc/ast/MainProxies.scala b/compiler/src/dotty/tools/dotc/ast/MainProxies.scala index a2181e78a05e..92427c4586de 100644 --- a/compiler/src/dotty/tools/dotc/ast/MainProxies.scala +++ b/compiler/src/dotty/tools/dotc/ast/MainProxies.scala @@ -40,7 +40,7 @@ object MainProxies { } import untpd._ - def mainProxy(mainFun: Symbol) given (ctx: Context): List[TypeDef] = { + def mainProxy(mainFun: Symbol)(given ctx: Context): List[TypeDef] = { val mainAnnotSpan = mainFun.getAnnotation(defn.MainAnnot).get.tree.span def pos = mainFun.sourcePos val argsRef = Ident(nme.args) diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index 976134ff0517..c0fa628b10fd 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -121,7 +121,7 @@ object Annotations { def deferred(sym: Symbol)(treeFn: ImplicitFunction1[Context, Tree])(implicit ctx: Context): Annotation = new LazyAnnotation { override def symbol(implicit ctx: Context): Symbol = sym - def complete(implicit ctx: Context) = treeFn given ctx + def complete(implicit ctx: Context) = treeFn(given ctx) } /** Create an annotation where the symbol and the tree are computed lazily. */ @@ -131,12 +131,12 @@ object Annotations { override def symbol(implicit ctx: Context): Symbol = { if (mySym == null || mySym.defRunId != ctx.runId) { - mySym = symf given ctx + mySym = symf(given ctx) assert(mySym != null) } mySym } - def complete(implicit ctx: Context) = treeFn given ctx + def complete(implicit ctx: Context) = treeFn(given ctx) } def deferred(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation = diff --git a/compiler/src/dotty/tools/dotc/core/Decorators.scala b/compiler/src/dotty/tools/dotc/core/Decorators.scala index 478c30f14dec..61e4ccbee8c8 100644 --- a/compiler/src/dotty/tools/dotc/core/Decorators.scala +++ b/compiler/src/dotty/tools/dotc/core/Decorators.scala @@ -174,7 +174,7 @@ object Decorators { def (x: T) reporting[T]( op: ImplicitFunction1[WrappedResult[T], String], printer: config.Printers.Printer = config.Printers.default): T = { - printer.println(op given WrappedResult(x)) + printer.println(op(given WrappedResult(x))) x } } diff --git a/compiler/src/dotty/tools/dotc/core/Periods.scala b/compiler/src/dotty/tools/dotc/core/Periods.scala index a06c713a65d0..752271288c90 100644 --- a/compiler/src/dotty/tools/dotc/core/Periods.scala +++ b/compiler/src/dotty/tools/dotc/core/Periods.scala @@ -22,7 +22,7 @@ abstract class Periods { self: Context => /** Execute `op` at given phase id */ def atPhase[T](pid: PhaseId)(op: ImplicitFunction1[Context, T]): T = - op given ctx.withPhase(pid) + op(given ctx.withPhase(pid)) /** The period containing the current period where denotations do not change. * We compute this by taking as first phase the first phase less or equal to diff --git a/compiler/src/dotty/tools/dotc/core/Phases.scala b/compiler/src/dotty/tools/dotc/core/Phases.scala index 6aa56aff94fc..87e69e8285f4 100644 --- a/compiler/src/dotty/tools/dotc/core/Phases.scala +++ b/compiler/src/dotty/tools/dotc/core/Phases.scala @@ -37,7 +37,7 @@ trait Phases { def atNextPhase[T](op: ImplicitFunction1[Context, T]): T = atPhase(phase.next)(op) def atPhaseNotLaterThan[T](limit: Phase)(op: ImplicitFunction1[Context, T]): T = - if (!limit.exists || phase <= limit) op given this else atPhase(limit)(op) + if (!limit.exists || phase <= limit) op(given this) else atPhase(limit)(op) def isAfterTyper: Boolean = base.isAfterTyper(phase) } diff --git a/compiler/src/dotty/tools/dotc/core/Signature.scala b/compiler/src/dotty/tools/dotc/core/Signature.scala index 2b6de325ffcd..7303fa44a4db 100644 --- a/compiler/src/dotty/tools/dotc/core/Signature.scala +++ b/compiler/src/dotty/tools/dotc/core/Signature.scala @@ -167,7 +167,7 @@ object Signature { y match { case y: TypeName => // `Ordering[TypeName]` doesn't work due to `Ordering` still being invariant - the[Ordering[Name]].compare(x, y) + summon[Ordering[Name]].compare(x, y) case y: Int => 1 } @@ -184,7 +184,7 @@ object Signature { import scala.math.Ordering.Implicits.seqOrdering val paramsOrdering = seqOrdering(paramSigOrdering).compare(x.paramsSig, y.paramsSig) if (paramsOrdering != 0) paramsOrdering - else the[Ordering[Name]].compare(x.resSig, y.resSig) + else summon[Ordering[Name]].compare(x.resSig, y.resSig) } } } diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 72653c24f520..c06410d234e0 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -195,7 +195,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w //} assert(!ctx.settings.YnoDeepSubtypes.value) if (Config.traceDeepSubTypeRecursions && !this.isInstanceOf[ExplainingTypeComparer]) - ctx.log(TypeComparer.explained(the[Context].typeComparer.isSubType(tp1, tp2, approx))) + ctx.log(TypeComparer.explained(summon[Context].typeComparer.isSubType(tp1, tp2, approx))) } // Eliminate LazyRefs before checking whether we have seen a type before val normalize = new TypeMap { @@ -2309,7 +2309,7 @@ object TypeComparer { /** Show trace of comparison operations when performing `op` */ def explaining[T](say: String => Unit)(op: ImplicitFunction1[Context, T])(implicit ctx: Context): T = { val nestedCtx = ctx.fresh.setTypeComparerFn(new ExplainingTypeComparer(_)) - val res = try { op given nestedCtx } finally { say(nestedCtx.typeComparer.lastTrace()) } + val res = try { op(given nestedCtx) } finally { say(nestedCtx.typeComparer.lastTrace()) } res } diff --git a/compiler/src/dotty/tools/dotc/core/TyperState.scala b/compiler/src/dotty/tools/dotc/core/TyperState.scala index 58e73d463e7a..8ec2fc9f514f 100644 --- a/compiler/src/dotty/tools/dotc/core/TyperState.scala +++ b/compiler/src/dotty/tools/dotc/core/TyperState.scala @@ -98,7 +98,7 @@ class TyperState(private val previous: TyperState /* | Null */) { */ def test[T](op: ImplicitFunction1[Context, T])(implicit ctx: Context): T = if (isShared) - op given ctx.fresh.setExploreTyperState() + op(given ctx.fresh.setExploreTyperState()) else { val savedConstraint = myConstraint val savedReporter = myReporter @@ -113,7 +113,7 @@ class TyperState(private val previous: TyperState /* | Null */) { testReporter.inUse = true testReporter } - try op given ctx + try op(given ctx) finally { testReporter.inUse = false resetConstraintTo(savedConstraint) diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index e7ad5e2163ba..9c12d03615c5 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -1271,7 +1271,7 @@ class TreeUnpickler(reader: TastyReader, val args = until(end)(readTerm()) val splice = splices(idx) def wrap(arg: Tree) = - if (arg.isTerm) given (qctx: scala.quoted.QuoteContext) => new TastyTreeExpr(arg, QuoteContext.scopeId) + if (arg.isTerm) (given qctx: scala.quoted.QuoteContext) => new TastyTreeExpr(arg, QuoteContext.scopeId) else new TreeType(arg, QuoteContext.scopeId) val reifiedArgs = args.map(wrap) val filled = if (isType) { @@ -1280,7 +1280,7 @@ class TreeUnpickler(reader: TastyReader, } else { val splice1 = splice.asInstanceOf[Seq[Any] => ImplicitFunction1[scala.quoted.QuoteContext, quoted.Expr[?]]] - val quotedExpr = splice1(reifiedArgs) given dotty.tools.dotc.quoted.QuoteContext() + val quotedExpr = splice1(reifiedArgs)(given dotty.tools.dotc.quoted.QuoteContext()) PickledQuotes.quotedExprToTree(quotedExpr) } // We need to make sure a hole is created with the source file of the surrounding context, even if diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 7b3e5dbfc566..4bfcd1b5236d 100644 --- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -979,7 +979,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas val atp = readTypeRef() val phase = ctx.phase Annotation.deferred(atp.typeSymbol)( - atReadPos(start, () => readAnnotationContents(end)(the[Context].withPhase(phase)))) + atReadPos(start, () => readAnnotationContents(end)(summon[Context].withPhase(phase)))) } /* Read an abstract syntax tree */ diff --git a/compiler/src/dotty/tools/dotc/interactive/Interactive.scala b/compiler/src/dotty/tools/dotc/interactive/Interactive.scala index 725660b84485..5124062b3d28 100644 --- a/compiler/src/dotty/tools/dotc/interactive/Interactive.scala +++ b/compiler/src/dotty/tools/dotc/interactive/Interactive.scala @@ -379,7 +379,7 @@ object Interactive { def localize(symbol: Symbol, sourceDriver: InteractiveDriver, targetDriver: InteractiveDriver): Symbol = { def in[T](driver: InteractiveDriver)(fn: ImplicitFunction1[Context, T]): T = - fn given driver.currentCtx + fn(given driver.currentCtx) if (sourceDriver == targetDriver) symbol else { diff --git a/compiler/src/dotty/tools/dotc/printing/Formatting.scala b/compiler/src/dotty/tools/dotc/printing/Formatting.scala index 6be06e98bb41..8bf39c4e321a 100644 --- a/compiler/src/dotty/tools/dotc/printing/Formatting.scala +++ b/compiler/src/dotty/tools/dotc/printing/Formatting.scala @@ -254,7 +254,7 @@ object Formatting { */ def explained(op: ImplicitFunction1[Context, String])(implicit ctx: Context): String = { val seen = new Seen - val msg = op given explainCtx(seen) + val msg = op(given explainCtx(seen)) val addendum = explanations(seen) if (addendum.isEmpty) msg else msg ++ "\n\n" ++ addendum } diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index c0f7a3ebf96e..4610ab003499 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -764,10 +764,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { "[" ~ toText(params, ", ") ~ "]" provided params.nonEmpty def addVparamssText[T >: Untyped](leading: Text, vparamss: List[List[ValDef[T]]]): Text = - vparamss.foldLeft(leading)((txt, params) => - txt ~ - (Str(" given ") provided params.nonEmpty && params.head.mods.is(Given)) ~ - paramsText(params)) + vparamss.foldLeft(leading)((txt, params) => txt ~ paramsText(params)) protected def valDefToText[T >: Untyped](tree: ValDef[T]): Text = { import untpd.{modsDeco => _} diff --git a/compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala b/compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala index e13f475c4772..4ba056389d26 100644 --- a/compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala +++ b/compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala @@ -6,7 +6,7 @@ import dotty.tools.dotc.tastyreflect.ReflectionImpl object QuoteContext { def apply()(given Context): scala.quoted.QuoteContext = - new scala.quoted.QuoteContext(ReflectionImpl(the[Context])) + new scala.quoted.QuoteContext(ReflectionImpl(summon[Context])) type ScopeId = Int @@ -17,5 +17,5 @@ object QuoteContext { // TODO Explore more fine grained scope ids. // This id can only differentiate scope extrusion from one compiler instance to another. private[dotty] def scopeId(given Context): ScopeId = - the[Context].outersIterator.toList.last.hashCode() + summon[Context].outersIterator.toList.last.hashCode() } diff --git a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala index b1393fe58c56..e7363ca0e9c9 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala @@ -252,7 +252,7 @@ abstract class Reporter extends interfaces.ReporterResult { /** Run `op` and return `true` if errors were reported by this reporter. */ - def reportsErrorsFor(op: Context => Unit) given (ctx: Context): Boolean = { + def reportsErrorsFor(op: Context => Unit)(given ctx: Context): Boolean = { val initial = errorCount op(ctx) errorCount > initial diff --git a/compiler/src/dotty/tools/dotc/rewrites/Rewrites.scala b/compiler/src/dotty/tools/dotc/rewrites/Rewrites.scala index bb7e92890b7d..20d28bd35f71 100644 --- a/compiler/src/dotty/tools/dotc/rewrites/Rewrites.scala +++ b/compiler/src/dotty/tools/dotc/rewrites/Rewrites.scala @@ -75,7 +75,7 @@ object Rewrites { patch(ctx.compilationUnit.source, span, replacement) /** Does `span` overlap with a patch region of `source`? */ - def overlapsPatch(source: SourceFile, span: Span) given (ctx: Context): Boolean = + def overlapsPatch(source: SourceFile, span: Span)(given ctx: Context): Boolean = ctx.settings.rewrite.value.exists(rewrites => rewrites.patched.get(source).exists(patches => patches.pbuf.exists(patch => patch.span.overlaps(span)))) diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala index dc3923e86ffd..fa851d75b8b6 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala @@ -61,16 +61,16 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend // REPORTING // - def error(msg: => String, pos: Position) given (ctx: Context): Unit = + def error(msg: => String, pos: Position)(given ctx: Context): Unit = ctx.error(msg, pos) - def error(msg: => String, sourceFile: SourceFile, start: Int, end: Int) given (ctx: Context): Unit = + def error(msg: => String, sourceFile: SourceFile, start: Int, end: Int)(given ctx: Context): Unit = ctx.error(msg, util.SourcePosition(sourceFile, util.Spans.Span(start, end))) - def warning(msg: => String, pos: Position) given (ctx: Context): Unit = + def warning(msg: => String, pos: Position)(given ctx: Context): Unit = ctx.warning(msg, pos) - def warning(msg: => String, sourceFile: SourceFile, start: Int, end: Int) given (ctx: Context): Unit = + def warning(msg: => String, sourceFile: SourceFile, start: Int, end: Int)(given ctx: Context): Unit = ctx.error(msg, util.SourcePosition(sourceFile, util.Spans.Span(start, end))) // @@ -589,10 +589,10 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend def Return_expr(self: Return)(given Context): Term = self.expr - def Return_apply(expr: Term) given (ctx: Context): Return = + def Return_apply(expr: Term)(given ctx: Context): Return = withDefaultPos(tpd.Return(expr, ctx.owner)) - def Return_copy(original: Tree)(expr: Term) given (ctx: Context): Return = + def Return_copy(original: Tree)(expr: Term)(given ctx: Context): Return = tpd.cpy.Return(original)(expr, tpd.ref(ctx.owner)) type Repeated = tpd.SeqLiteral @@ -1001,7 +1001,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend def Pattern_TypeTest_tpt(self: TypeTest)(given Context): TypeTree = self.tpt - def Pattern_TypeTest_module_apply(tpt: TypeTree) given (ctx: Context): TypeTest = + def Pattern_TypeTest_module_apply(tpt: TypeTree)(given ctx: Context): TypeTest = withDefaultPos(tpd.Typed(untpd.Ident(nme.WILDCARD)(ctx.source).withType(tpt.tpe), tpt)) def Pattern_TypeTest_module_copy(original: TypeTest)(tpt: TypeTree)(given Context): TypeTest = @@ -1047,7 +1047,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend case _ => Some(x) } - def Type_apply(clazz: Class[?]) given (ctx: Context): Type = + def Type_apply(clazz: Class[?])(given ctx: Context): Type = if (clazz.isPrimitive) if (clazz == classOf[Boolean]) defn.BooleanType else if (clazz == classOf[Byte]) defn.ByteType @@ -1476,11 +1476,11 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend def Symbol_pos(self: Symbol)(given Context): Position = self.sourcePos - def Symbol_localContext(self: Symbol) given (ctx: Context): Context = + def Symbol_localContext(self: Symbol)(given ctx: Context): Context = if (self.exists) ctx.withOwner(self) else ctx - def Symbol_comment(self: Symbol) given (ctx: Context): Option[Comment] = { + def Symbol_comment(self: Symbol)(given ctx: Context): Option[Comment] = { import dotty.tools.dotc.core.Comments.CommentsContext val docCtx = ctx.docCtx.getOrElse { throw new RuntimeException( @@ -1583,7 +1583,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend private def isField(sym: Symbol)(given Context): Boolean = sym.isTerm && !sym.is(Flags.Method) - def ClassDefSymbol_of(fullName: String) given (ctx: Context): ClassDefSymbol = ctx.requiredClass(fullName) + def ClassDefSymbol_of(fullName: String)(given ctx: Context): ClassDefSymbol = ctx.requiredClass(fullName) type TypeDefSymbol = core.Symbols.TypeSymbol @@ -1713,7 +1713,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend PickledQuotes.quotedTypeToTree(self) /** Convert `Term` to an `quoted.Expr[Any]` */ - def QuotedExpr_seal(self: Term) given (ctx: Context): scala.quoted.Expr[Any] = { + def QuotedExpr_seal(self: Term)(given ctx: Context): scala.quoted.Expr[Any] = { def etaExpand(term: Term): Term = term.tpe.widen match { case mtpe: Types.MethodType if !mtpe.isParamDependent => val closureResType = mtpe.resType match { @@ -1729,7 +1729,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend } /** Checked cast to a `quoted.Expr[U]` */ - def QuotedExpr_cast[U](self: scala.quoted.Expr[?]) given (tp: scala.quoted.Type[U], ctx: Context): scala.quoted.Expr[U] = { + def QuotedExpr_cast[U](self: scala.quoted.Expr[?])(given tp: scala.quoted.Type[U], ctx: Context): scala.quoted.Expr[U] = { val tree = QuotedExpr_unseal(self) val expectedType = QuotedType_unseal(tp).tpe if (tree.tpe <:< expectedType) @@ -1743,7 +1743,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend } /** Convert `Type` to an `quoted.Type[?]` */ - def QuotedType_seal(self: Type) given (ctx: Context): scala.quoted.Type[?] = { + def QuotedType_seal(self: Type)(given ctx: Context): scala.quoted.Type[?] = { val dummySpan = ctx.owner.span // FIXME new scala.internal.quoted.TreeType(tpd.TypeTree(self).withSpan(dummySpan), compilerId) } @@ -1832,7 +1832,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type ImplicitSearchResult = Tree - def searchImplicit(tpe: Type) given (ctx: Context): ImplicitSearchResult = + def searchImplicit(tpe: Type)(given ctx: Context): ImplicitSearchResult = ctx.typer.inferImplicitArg(tpe, rootPosition.span) type ImplicitSearchSuccess = Tree @@ -1868,7 +1868,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend case _ => None } - def betaReduce(fn: Term, args: List[Term]) given (ctx: Context): Term = { + def betaReduce(fn: Term, args: List[Term])(given ctx: Context): Term = { val (argVals0, argRefs0) = args.foldLeft((List.empty[ValDef], List.empty[Tree])) { case ((acc1, acc2), arg) => arg.tpe match { case tpe: SingletonType if isIdempotentExpr(arg) => (acc1, arg :: acc2) case _ => @@ -1904,8 +1904,8 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend private def optional[T <: Trees.Tree[?]](tree: T): Option[tree.type] = if (tree.isEmpty) None else Some(tree) - private def withDefaultPos[T <: Tree](fn: ImplicitFunction1[Context, T]) given (ctx: Context): T = - (fn given ctx.withSource(rootPosition.source)).withSpan(rootPosition.span) + private def withDefaultPos[T <: Tree](fn: ImplicitFunction1[Context, T])(given ctx: Context): T = + (fn(given ctx.withSource(rootPosition.source)).withSpan(rootPosition.span)) private def compilerId: Int = rootContext.outersIterator.toList.last.hashCode() } diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala index decd795b46a5..4c468a26e5cf 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala @@ -18,7 +18,7 @@ object ReflectionImpl { val syntaxHighlight = if (ctx.settings.color.value == "always") SyntaxHighlight.ANSI else SyntaxHighlight.plain - new refl.SourceCodePrinter(syntaxHighlight).showTree(reflTree) given reflCtx + new refl.SourceCodePrinter(syntaxHighlight).showTree(reflTree)(given reflCtx) } } diff --git a/compiler/src/dotty/tools/dotc/transform/CtxLazy.scala b/compiler/src/dotty/tools/dotc/transform/CtxLazy.scala index 2f0cb084b54f..ca7544505beb 100644 --- a/compiler/src/dotty/tools/dotc/transform/CtxLazy.scala +++ b/compiler/src/dotty/tools/dotc/transform/CtxLazy.scala @@ -16,7 +16,7 @@ class CtxLazy[T](expr: ImplicitFunction1[Context, T]) { private[this] var forced = false def apply()(implicit ctx: Context): T = { if (!forced) { - myValue = expr given ctx + myValue = expr(given ctx) forced = true } myValue diff --git a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala index 3094623fb105..c7293330d7e2 100644 --- a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala +++ b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala @@ -40,7 +40,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( case tree: DefDef if tree.symbol.is(Inline) && level > 0 => EmptyTree case tree: DefTree => for (annot <- tree.symbol.annotations) - transform(annot.tree) given ctx.withOwner(tree.symbol) + transform(annot.tree)(given ctx.withOwner(tree.symbol)) checkLevel(super.transform(tree)) case _ => checkLevel(super.transform(tree)) } @@ -215,7 +215,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( if (!tp.isInstanceOf[ThisType]) sym.show else if (sym.is(ModuleClass)) sym.sourceModule.show else i"${sym.name}.this" - the[Context].error( + summon[Context].error( em"""access to $symStr from wrong staging level: | - the definition is at level ${levelOf(sym).getOrElse(0)}, | - but the access is at level $level.$errMsg""", pos) diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index bbfc39bf603f..8aa8fd7f0542 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -405,7 +405,7 @@ class ReifyQuotes extends MacroTransform { case tree: DefTree if level >= 1 => val newAnnotations = tree.symbol.annotations.mapconserve { annot => - val newAnnotTree = transform(annot.tree) given ctx.withOwner(tree.symbol) + val newAnnotTree = transform(annot.tree)(given ctx.withOwner(tree.symbol)) if (annot.tree == newAnnotTree) annot else ConcreteAnnotation(newAnnotTree) } diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index da78698056c5..bd988422541f 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -72,18 +72,18 @@ object Splicer { case _ => type Env = Set[Symbol] - def checkValidStat(tree: Tree) given Env: Env = tree match { + def checkValidStat(tree: Tree)(given Env): Env = tree match { case tree: ValDef if tree.symbol.is(Synthetic) => // Check val from `foo(j = x, i = y)` which it is expanded to // `val j$1 = x; val i$1 = y; foo(i = i$1, j = j$1)` checkIfValidArgument(tree.rhs) - the[Env] + tree.symbol + summon[Env] + tree.symbol case _ => ctx.error("Macro should not have statements", tree.sourcePos) - the[Env] + summon[Env] } - def checkIfValidArgument(tree: Tree) given Env: Unit = tree match { + def checkIfValidArgument(tree: Tree)(given Env): Unit = tree match { case Block(Nil, expr) => checkIfValidArgument(expr) case Typed(expr, _) => checkIfValidArgument(expr) @@ -111,7 +111,7 @@ object Splicer { case SeqLiteral(elems, _) => elems.foreach(checkIfValidArgument) - case tree: Ident if tree.symbol.is(Inline) || the[Env].contains(tree.symbol) => + case tree: Ident if tree.symbol.is(Inline) || summon[Env].contains(tree.symbol) => // OK case _ => @@ -125,13 +125,13 @@ object Splicer { |""".stripMargin, tree.sourcePos) } - def checkIfValidStaticCall(tree: Tree) given Env: Unit = tree match { + def checkIfValidStaticCall(tree: Tree)(given Env): Unit = tree match { case closureDef(ddef @ DefDef(_, Nil, (ev :: Nil) :: Nil, _, _)) if ddef.symbol.info.isContextualMethod => - checkIfValidStaticCall(ddef.rhs) given (the[Env] + ev.symbol) + checkIfValidStaticCall(ddef.rhs)(given summon[Env] + ev.symbol) case Block(stats, expr) => - val newEnv = stats.foldLeft(the[Env])((env, stat) => checkValidStat(stat) given env) - checkIfValidStaticCall(expr) given newEnv + val newEnv = stats.foldLeft(summon[Env])((env, stat) => checkValidStat(stat)(given env)) + checkIfValidStaticCall(expr)(given newEnv) case Typed(expr, _) => checkIfValidStaticCall(expr) @@ -152,7 +152,7 @@ object Splicer { |""".stripMargin, tree.sourcePos) } - checkIfValidStaticCall(tree) given Set.empty + checkIfValidStaticCall(tree)(given Set.empty) } /** Tree interpreter that evaluates the tree */ @@ -217,7 +217,7 @@ object Splicer { unexpectedTree(tree) case closureDef((ddef @ DefDef(_, _, (arg :: Nil) :: Nil, _, _))) => - (obj: AnyRef) => interpretTree(ddef.rhs) given env.updated(arg.symbol, obj) + (obj: AnyRef) => interpretTree(ddef.rhs)(given env.updated(arg.symbol, obj)) // Interpret `foo(j = x, i = y)` which it is expanded to // `val j$1 = x; val i$1 = y; foo(i = i$1, j = j$1)` diff --git a/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala b/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala index c2f81b8dcde3..ae91791060ed 100644 --- a/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala +++ b/compiler/src/dotty/tools/dotc/transform/ValueClasses.scala @@ -24,7 +24,7 @@ object ValueClasses { def isMethodWithExtension(sym: Symbol)(implicit ctx: Context): Boolean = ctx.atPhaseNotLaterThan(ctx.extensionMethodsPhase) { val d = sym.denot - d.validFor.containsPhaseId(the[Context].phaseId) && + d.validFor.containsPhaseId(summon[Context].phaseId) && d.isRealMethod && isDerivedValueClass(d.owner) && !d.isConstructor && diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 7acb4d71e782..d50f662d7652 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -1131,7 +1131,7 @@ trait Checking { } /** check that annotation `annot` is applicable to symbol `sym` */ - def checkAnnotApplicable(annot: Tree, sym: Symbol) given (ctx: Context): Boolean = + def checkAnnotApplicable(annot: Tree, sym: Symbol)(given ctx: Context): Boolean = !ctx.reporter.reportsErrorsFor { implicit ctx => val annotCls = Annotations.annotClass(annot) val pos = annot.sourcePos @@ -1165,7 +1165,7 @@ trait ReChecking extends Checking { override def checkEnum(cdef: untpd.TypeDef, cls: Symbol, firstParent: Symbol)(implicit ctx: Context): Unit = () override def checkRefsLegal(tree: tpd.Tree, badOwner: Symbol, allowed: (Name, Symbol) => Boolean, where: String)(implicit ctx: Context): Unit = () override def checkEnumCaseRefsLegal(cdef: TypeDef, enumCtx: Context)(implicit ctx: Context): Unit = () - override def checkAnnotApplicable(annot: Tree, sym: Symbol) given (ctx: Context): Boolean = true + override def checkAnnotApplicable(annot: Tree, sym: Symbol)(given ctx: Context): Boolean = true } trait NoChecking extends ReChecking { diff --git a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala index 99989acfa059..f9b1ad72592c 100644 --- a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala +++ b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala @@ -52,7 +52,7 @@ class ImportInfo(symf: ImplicitFunction1[Context, Symbol], // that we cannot use one for `DottyPredefModuleRef`. def sym(implicit ctx: Context): Symbol = { if (mySym == null) { - mySym = symf given ctx + mySym = symf(given ctx) assert(mySym != null) } mySym diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 0ff79a9ab558..64af560f8847 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -1125,7 +1125,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) { override def newLikeThis: Typer = new InlineTyper(initialErrorCount) /** Suppress further inlining if this inline typer has already issued errors */ - override def suppressInline given (ctx: Context) = + override def suppressInline(given ctx: Context) = ctx.reporter.errorCount > initialErrorCount || super.suppressInline } diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 93df227921af..54738b63a113 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -759,7 +759,7 @@ class Typer extends Namer def typedBlock(tree: untpd.Block, pt: Type)(implicit ctx: Context): Tree = { val localCtx = ctx.retractMode(Mode.Pattern) - val (exprCtx, stats1) = typedBlockStats(tree.stats) given localCtx + val (exprCtx, stats1) = typedBlockStats(tree.stats)(given localCtx) val expr1 = typedExpr(tree.expr, pt.dropIfProto)(exprCtx) ensureNoLocalRefs( cpy.Block(tree)(stats1, expr1).withType(expr1.tpe), pt, localSyms(stats1)) @@ -2246,7 +2246,7 @@ class Typer extends Namer def tryEither[T](op: ImplicitFunction1[Context, T])(fallBack: (T, TyperState) => T)(implicit ctx: Context): T = { val nestedCtx = ctx.fresh.setNewTyperState() - val result = op given nestedCtx + val result = op(given nestedCtx) if (nestedCtx.reporter.hasErrors && !nestedCtx.reporter.hasStickyErrors) { record("tryEither.fallBack") fallBack(result, nestedCtx.typerState) @@ -2288,7 +2288,7 @@ class Typer extends Namer def tryWithType(tpt: untpd.Tree): Tree = tryEither { val tycon = typed(tpt) - if (the[Context].reporter.hasErrors) + if (summon[Context].reporter.hasErrors) EmptyTree // signal that we should return the error in fallBack else { def recur(tpt: Tree, pt: Type): Tree = pt.revealIgnored match { @@ -2403,7 +2403,7 @@ class Typer extends Namer val qualProto = SelectionProto(name, pt, NoViewsAllowed, privateOK = false) tryEither { val qual1 = adapt(qual, qualProto, locked) - if ((qual eq qual1) || the[Context].reporter.hasErrors) None + if ((qual eq qual1) || summon[Context].reporter.hasErrors) None else Some(typed(cpy.Select(tree)(untpd.TypedSplice(qual1), name), pt, locked)) } { (_, _) => None } @@ -3050,7 +3050,7 @@ class Typer extends Namer } // Overridden in InlineTyper - def suppressInline given (ctx: Context): Boolean = ctx.isAfterTyper + def suppressInline(given ctx: Context): Boolean = ctx.isAfterTyper /** Does the "contextuality" of the method type `methType` match the one of the prototype `pt`? * This is the case if diff --git a/compiler/src/dotty/tools/package.scala b/compiler/src/dotty/tools/package.scala index 416504d40aa4..870148fcd5d4 100644 --- a/compiler/src/dotty/tools/package.scala +++ b/compiler/src/dotty/tools/package.scala @@ -31,5 +31,5 @@ package object tools { } type WrappedResult[T] = resultWrapper.WrappedResult[T] def WrappedResult[T](x: T) = resultWrapper.wrap(x) - def result[T] given (x: WrappedResult[T]): T = resultWrapper.unwrap(x) + def result[T](given x: WrappedResult[T]): T = resultWrapper.unwrap(x) } diff --git a/compiler/test-resources/repl-macros/i5551 b/compiler/test-resources/repl-macros/i5551 index 8de4a387bda1..d3c7539a64ee 100644 --- a/compiler/test-resources/repl-macros/i5551 +++ b/compiler/test-resources/repl-macros/i5551 @@ -1,8 +1,8 @@ scala> import scala.quoted._ -scala> def assertImpl(expr: Expr[Boolean]) given (qctx: QuoteContext) = '{ if !($expr) then throw new AssertionError("failed assertion")} +scala> def assertImpl(expr: Expr[Boolean])(given qctx: QuoteContext) = '{ if !($expr) then throw new AssertionError("failed assertion")} def assertImpl (expr: quoted.Expr[Boolean]) - given (qctx: quoted.QuoteContext): quoted.Expr[Unit] + (given qctx: quoted.QuoteContext): quoted.Expr[Unit] scala> inline def assert(expr: => Boolean): Unit = ${ assertImpl('{expr}) } def assert(expr: => Boolean): Unit diff --git a/compiler/test-resources/repl/defs b/compiler/test-resources/repl/defs index a42438dfc100..40d0de8458ca 100644 --- a/compiler/test-resources/repl/defs +++ b/compiler/test-resources/repl/defs @@ -10,5 +10,5 @@ scala> def id(x: 4): 4 = x def id(x: 4): 4 scala> id(4) val res0: Int = 4 -scala> def f given Int = 1 +scala> def f(given Int) = 1 def f given (x$1: Int): Int diff --git a/compiler/test/dotty/tools/backend/jvm/ArrayApplyOptTest.scala b/compiler/test/dotty/tools/backend/jvm/ArrayApplyOptTest.scala index f4aba02c453d..502edbd8b170 100644 --- a/compiler/test/dotty/tools/backend/jvm/ArrayApplyOptTest.scala +++ b/compiler/test/dotty/tools/backend/jvm/ArrayApplyOptTest.scala @@ -127,7 +127,7 @@ class ArrayApplyOptTest extends DottyBytecodeTest { @Test def testArrayInlined3 = test( """{ - | inline def array[T](xs: =>T*) given (ct: =>scala.reflect.ClassTag[T]): Array[T] = Array(xs: _*) + | inline def array[T](xs: =>T*)(given ct: =>scala.reflect.ClassTag[T]): Array[T] = Array(xs: _*) | array(1, 2) |}""".stripMargin, newArray2Opcodes(T_INT, List(Op(DUP), Op(ICONST_0), Op(ICONST_1), Op(IASTORE), Op(DUP), Op(ICONST_1), Op(ICONST_2), Op(IASTORE), TypeOp(CHECKCAST, "[I"))) diff --git a/docs/docs/reference/contextual/given-clauses.md b/docs/docs/reference/contextual/given-clauses.md index de1c8804df5e..d87a3d91e196 100644 --- a/docs/docs/reference/contextual/given-clauses.md +++ b/docs/docs/reference/contextual/given-clauses.md @@ -85,7 +85,7 @@ Then the following calls are all valid (and normalize to the last one) ```scala f (f given global) -(f given global) given ctx +(f given global)(given ctx) ``` But `f given ctx` would give a type error. diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index 4a9844feb642..953052f10163 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -252,7 +252,7 @@ The `toExpr` extension method is defined in package `quoted`: package quoted given { - def (x: T) toExpr[T: Liftable] given QuoteContext: Expr[T] = summon[Liftable[T]].toExpr(x) + def (x: T) toExpr[T: Liftable](given QuoteContext): Expr[T] = summon[Liftable[T]].toExpr(x) ... } ``` @@ -270,7 +270,7 @@ knowing anything about the representation of `Expr` trees. For instance, here is a possible instance of `Liftable[Boolean]`: ```scala given Liftable[Boolean] { - def toExpr(b: Boolean) given QuoteContext: Expr[Boolean] = + def toExpr(b: Boolean)(given QuoteContext): Expr[Boolean] = if (b) '{ true } else '{ false } } ``` @@ -279,7 +279,7 @@ possible implementation of `Liftable[Int]` that does not use the underlying tree machinery: ```scala given Liftable[Int] { - def toExpr(n: Int) given QuoteContext: Expr[Int] = n match { + def toExpr(n: Int)(given QuoteContext): Expr[Int] = n match { case Int.MinValue => '{ Int.MinValue } case _ if n < 0 => '{ - ${ toExpr(-n) } } case 0 => '{ 0 } @@ -292,7 +292,7 @@ Since `Liftable` is a type class, its instances can be conditional. For example, a `List` is liftable if its element type is: ```scala given [T: Liftable] : Liftable[List[T]] { - def toExpr(xs: List[T]) given QuoteContext: Expr[List[T]] = xs match { + def toExpr(xs: List[T])(given QuoteContext): Expr[List[T]] = xs match { case head :: tail => '{ ${ toExpr(head) } :: ${ toExpr(tail) } } case Nil => '{ Nil: List[T] } } @@ -577,7 +577,7 @@ in a quote context. For this we simply provide `scala.quoted.matching.searchImpl ```scala inline def setFor[T]: Set[T] = ${ setForExpr[T] } -def setForExpr[T: Type] given QuoteContext: Expr[Set[T]] = { +def setForExpr[T: Type](given QuoteContext): Expr[Set[T]] = { searchImplicitExpr[Ordering[T]] match { case Some(ord) => '{ new TreeSet[T]()($ord) } case _ => '{ new HashSet[T] } diff --git a/docs/docs/reference/metaprogramming/staging.md b/docs/docs/reference/metaprogramming/staging.md index fc22c94167b1..0fa1dc79bddb 100644 --- a/docs/docs/reference/metaprogramming/staging.md +++ b/docs/docs/reference/metaprogramming/staging.md @@ -66,9 +66,9 @@ On the other hand `withQuoteContext` provides a `QuoteContext` without evauating ```scala package scala.quoted.staging -def run[T](expr: given QuoteContext => Expr[T]) given (toolbox: Toolbox): T = ... +def run[T](expr:(given QuoteContext) => Expr[T])(given toolbox: Toolbox): T = ... -def withQuoteContext[T](thunk: given QuoteContext => T) given (toolbox: Toolbox): T = ... +def withQuoteContext[T](thunk:(given QuoteContext) => T)(given toolbox: Toolbox): T = ... ``` ## Create a new Dotty project with staging enabled diff --git a/docs/docs/reference/metaprogramming/tasty-reflect.md b/docs/docs/reference/metaprogramming/tasty-reflect.md index 327df5fae888..1bc2cca74570 100644 --- a/docs/docs/reference/metaprogramming/tasty-reflect.md +++ b/docs/docs/reference/metaprogramming/tasty-reflect.md @@ -28,7 +28,7 @@ import scala.quoted._ inline def natConst(x: => Int): Int = ${natConstImpl('{x})} -def natConstImpl(x: Expr[Int]) given (qctx: QuoteContext): Expr[Int] = { +def natConstImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[Int] = { import qctx.tasty._ ... } @@ -43,7 +43,7 @@ respectively. It will also import all extractors and methods on TASTy Reflect trees. For example the `Literal(_)` extractor used below. ```scala -def natConstImpl(x: Expr[Int]) given (qctx: QuoteContext): Expr[Int] = { +def natConstImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[Int] = { import qctx.tasty._ val xTree: Term = x.unseal xTree match { @@ -80,7 +80,7 @@ operation expression passed while calling the `macro` below. ```scala inline def macro(param: => Boolean): Unit = ${ macroImpl('param) } -def macroImpl(param: Expr[Boolean]) given (qctx: QuoteContext): Expr[Unit] = { +def macroImpl(param: Expr[Boolean])(given qctx: QuoteContext): Expr[Unit] = { import qctx.tasty._ import util._ diff --git a/docs/docs/reference/other-new-features/quoted-pattern-spec.md b/docs/docs/reference/other-new-features/quoted-pattern-spec.md index 46f40edbb2e5..07712dad0ce6 100644 --- a/docs/docs/reference/other-new-features/quoted-pattern-spec.md +++ b/docs/docs/reference/other-new-features/quoted-pattern-spec.md @@ -47,14 +47,14 @@ def notMatched = None def matched = Some(()) // aka Some(Tuple0()) def matched[T](x: T) = Some(Tuple1(x)) def (x: Matching) && (y: Matching) = if (x == None || y == None) None else Some(x.get ++ y.get) -def fold[T](m: Mattching*) given Env: Matching = m.fold(matched)(_ && _) +def fold[T](m: Mattching*)(given Env): Matching = m.fold(matched)(_ && _) // `a =#= b` stands for `a` matches `b` -def (scrutinee: Tree) =#= pattern: Tree) given Env: Matching // described by cases in the tables below +def (scrutinee: Tree) =#= pattern: Tree)(given Env): Matching // described by cases in the tables below -def envWith(equiv: (Symbol, Symbol)*) given Env: Env // Adds to the current environment the fact that s1 from the scrutinee is equivalent to s2 in the pattern +def envWith(equiv: (Symbol, Symbol)*)(given Env): Env // Adds to the current environment the fact that s1 from the scrutinee is equivalent to s2 in the pattern -def equivalent(s1: Symbol, s2: Symbol) given Env: Env +def equivalent(s1: Symbol, s2: Symbol)(given Env): Env ``` The implementation of `=#=` diff --git a/library/src-bootstrapped/dotty/internal/StringContextMacro.scala b/library/src-bootstrapped/dotty/internal/StringContextMacro.scala index 1303451853fb..851dd26c6934 100644 --- a/library/src-bootstrapped/dotty/internal/StringContextMacro.scala +++ b/library/src-bootstrapped/dotty/internal/StringContextMacro.scala @@ -59,7 +59,7 @@ object StringContextMacro { * @return a list of Expr containing Strings, each corresponding to one parts of the given StringContext * quotes an error if the given Expr does not correspond to a StringContext */ - def getPartsExprs(strCtxExpr : Expr[scala.StringContext]) given (qctx: QuoteContext): Option[(List[Expr[String]], List[String])] = { + def getPartsExprs(strCtxExpr: Expr[scala.StringContext])(given qctx: QuoteContext): Option[(List[Expr[String]], List[String])] = { def notStatic = { qctx.error("Expected statically known String Context", strCtxExpr) None @@ -81,7 +81,7 @@ object StringContextMacro { * @return a list of Expr containing arguments * quotes an error if the given Expr does not contain a list of arguments */ - def getArgsExprs(argsExpr: Expr[Seq[Any]]) given (qctx: QuoteContext): Option[List[Expr[Any]]] = { + def getArgsExprs(argsExpr: Expr[Seq[Any]])(given qctx: QuoteContext): Option[List[Expr[Any]]] = { import qctx.tasty._ argsExpr.unseal.underlyingArgument match { case Typed(Repeated(args, _), _) => @@ -98,7 +98,7 @@ object StringContextMacro { * @param args the Expr that holds the sequence of arguments to interpolate to the String in the correct format * @return the Expr containing the formatted and interpolated String or an error/warning if the parameters are not correct */ - private def interpolate(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]]) given (qctx: QuoteContext): Expr[String] = { + private def interpolate(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(given qctx: QuoteContext): Expr[String] = { import qctx.tasty._ val sourceFile = strCtxExpr.unseal.pos.sourceFile @@ -164,7 +164,7 @@ object StringContextMacro { * @param reporter the reporter to return any error/warning when a problem is encountered * @return the Expr containing the formatted and interpolated String or an error/warning report if the parameters are not correct */ - def interpolate(parts0 : List[String], args : List[Expr[Any]], argsExpr: Expr[Seq[Any]], reporter : Reporter) given (qctx: QuoteContext) : Expr[String] = { + def interpolate(parts0 : List[String], args : List[Expr[Any]], argsExpr: Expr[Seq[Any]], reporter : Reporter)(given qctx: QuoteContext) : Expr[String] = { import qctx.tasty._ /** Checks if the number of arguments are the same as the number of formatting strings diff --git a/library/src-bootstrapped/scala/IArray.scala b/library/src-bootstrapped/scala/IArray.scala index 63833f754739..47aa3739a7f9 100644 --- a/library/src-bootstrapped/scala/IArray.scala +++ b/library/src-bootstrapped/scala/IArray.scala @@ -60,7 +60,7 @@ object IArray { /** An immutable array with given elements. */ - inline def apply[T](xs: =>T*) given (ct: =>ClassTag[T]): IArray[T] = Array(xs: _*).asInstanceOf + inline def apply[T](xs: =>T*)(given ct: => ClassTag[T]): IArray[T] = Array(xs: _*).asInstanceOf inline def apply(x: Boolean, xs: =>Boolean*): IArray[Boolean] = Array(x, xs: _*).asInstanceOf inline def apply(x: Byte, xs: =>Byte*): IArray[Byte] = Array(x, xs: _*).asInstanceOf inline def apply(x: Short, xs: =>Short*): IArray[Short] = Array(x, xs: _*).asInstanceOf diff --git a/library/src-bootstrapped/scala/quoted/util/Var.scala b/library/src-bootstrapped/scala/quoted/util/Var.scala index e5085aa7edaa..a80de966aedd 100644 --- a/library/src-bootstrapped/scala/quoted/util/Var.scala +++ b/library/src-bootstrapped/scala/quoted/util/Var.scala @@ -7,10 +7,10 @@ package util sealed trait Var[T] { // Retrieves the value of the variable - def get given QuoteContext: Expr[T] + def get(given QuoteContext): Expr[T] // Update the variable with the expression of a value (`e` corresponds to the RHS of variable assignment `x = e`) - def update(e: Expr[T]) given QuoteContext: Expr[Unit] + def update(e: Expr[T])(given QuoteContext): Expr[Unit] } object Var { @@ -34,13 +34,13 @@ object Var { * x * } */ - def apply[T: Type, U: Type](init: Expr[T])(body: Var[T] => Expr[U]) given QuoteContext: Expr[U] = '{ + def apply[T: Type, U: Type](init: Expr[T])(body: Var[T] => Expr[U])(given QuoteContext): Expr[U] = '{ var x = $init ${ body( new Var[T] { - def get given QuoteContext: Expr[T] = 'x - def update(e: Expr[T]) given QuoteContext: Expr[Unit] = '{ x = $e } + def get(given QuoteContext): Expr[T] = 'x + def update(e: Expr[T])(given QuoteContext): Expr[Unit] = '{ x = $e } } ) } diff --git a/library/src-bootstrapped/scala/tasty/reflect/TreeUtils.scala b/library/src-bootstrapped/scala/tasty/reflect/TreeUtils.scala index 074bf33cb6c0..f3c5e7c44030 100644 --- a/library/src-bootstrapped/scala/tasty/reflect/TreeUtils.scala +++ b/library/src-bootstrapped/scala/tasty/reflect/TreeUtils.scala @@ -11,13 +11,13 @@ trait TreeUtils abstract class TreeAccumulator[X] { // Ties the knot of the traversal: call `foldOver(x, tree))` to dive in the `tree` node. - def foldTree(x: X, tree: Tree) given (ctx: Context): X - def foldPattern(x: X, tree: Pattern) given (ctx: Context): X + def foldTree(x: X, tree: Tree)(given ctx: Context): X + def foldPattern(x: X, tree: Pattern)(given ctx: Context): X - def foldTrees(x: X, trees: Iterable[Tree]) given (ctx: Context): X = trees.foldLeft(x)(foldTree) - def foldPatterns(x: X, trees: Iterable[Pattern]) given (ctx: Context): X = trees.foldLeft(x)(foldPattern) + def foldTrees(x: X, trees: Iterable[Tree])(given ctx: Context): X = trees.foldLeft(x)(foldTree) + def foldPatterns(x: X, trees: Iterable[Pattern])(given ctx: Context): X = trees.foldLeft(x)(foldPattern) - def foldOverTree(x: X, tree: Tree) given (ctx: Context): X = { + def foldOverTree(x: X, tree: Tree)(given ctx: Context): X = { def localCtx(definition: Definition): Context = definition.symbol.localContext tree match { case Ident(_) => @@ -75,7 +75,7 @@ trait TreeUtils case Import(expr, _) => foldTree(x, expr) case IsPackageClause(clause @ PackageClause(pid, stats)) => - foldTrees(foldTree(x, pid), stats) given clause.symbol.localContext + foldTrees(foldTree(x, pid), stats)(given clause.symbol.localContext) case Inferred() => x case TypeIdent(_) => x case TypeSelect(qualifier, _) => foldTree(x, qualifier) @@ -97,7 +97,7 @@ trait TreeUtils } } - def foldOverPattern(x: X, tree: Pattern) given (ctx: Context): X = tree match { + def foldOverPattern(x: X, tree: Pattern)(given ctx: Context): X = tree match { case Pattern.Value(v) => foldTree(x, v) case Pattern.Bind(_, body) => foldPattern(x, body) case Pattern.Unapply(fun, implicits, patterns) => foldPatterns(foldTrees(foldTree(x, fun), implicits), patterns) @@ -110,23 +110,23 @@ trait TreeUtils abstract class TreeTraverser extends TreeAccumulator[Unit] { - def traverseTree(tree: Tree) given (ctx: Context): Unit = traverseTreeChildren(tree) - def traversePattern(tree: Pattern) given (ctx: Context): Unit = traversePatternChildren(tree) + def traverseTree(tree: Tree)(given ctx: Context): Unit = traverseTreeChildren(tree) + def traversePattern(tree: Pattern)(given ctx: Context): Unit = traversePatternChildren(tree) - def foldTree(x: Unit, tree: Tree) given (ctx: Context): Unit = traverseTree(tree) - def foldPattern(x: Unit, tree: Pattern) given (ctx: Context) = traversePattern(tree) + def foldTree(x: Unit, tree: Tree)(given ctx: Context): Unit = traverseTree(tree) + def foldPattern(x: Unit, tree: Pattern)(given ctx: Context) = traversePattern(tree) - protected def traverseTreeChildren(tree: Tree) given (ctx: Context): Unit = foldOverTree((), tree) - protected def traversePatternChildren(tree: Pattern) given (ctx: Context): Unit = foldOverPattern((), tree) + protected def traverseTreeChildren(tree: Tree)(given ctx: Context): Unit = foldOverTree((), tree) + protected def traversePatternChildren(tree: Pattern)(given ctx: Context): Unit = foldOverPattern((), tree) } abstract class TreeMap { self => - def transformTree(tree: Tree) given (ctx: Context): Tree = { + def transformTree(tree: Tree)(given ctx: Context): Tree = { tree match { case IsPackageClause(tree) => - PackageClause.copy(tree)(transformTerm(tree.pid).asInstanceOf[Ref], transformTrees(tree.stats) given tree.symbol.localContext) + PackageClause.copy(tree)(transformTerm(tree.pid).asInstanceOf[Ref], transformTrees(tree.stats)(given tree.symbol.localContext)) case IsImport(tree) => Import.copy(tree)(transformTerm(tree.expr), tree.selectors) case IsStatement(tree) => @@ -141,7 +141,7 @@ trait TreeUtils } } - def transformStatement(tree: Statement) given (ctx: Context): Statement = { + def transformStatement(tree: Statement)(given ctx: Context): Statement = { def localCtx(definition: Definition): Context = definition.symbol.localContext tree match { case IsTerm(tree) => @@ -164,7 +164,7 @@ trait TreeUtils } } - def transformTerm(tree: Term) given (ctx: Context): Term = { + def transformTerm(tree: Term)(given ctx: Context): Term = { tree match { case Ident(name) => tree @@ -209,7 +209,7 @@ trait TreeUtils } } - def transformTypeTree(tree: TypeTree) given (ctx: Context): TypeTree = tree match { + def transformTypeTree(tree: TypeTree)(given ctx: Context): TypeTree = tree match { case Inferred() => tree case IsTypeIdent(tree) => tree case IsTypeSelect(tree) => @@ -229,22 +229,22 @@ trait TreeUtils case IsByName(tree) => ByName.copy(tree)(transformTypeTree(tree.result)) case IsLambdaTypeTree(tree) => - LambdaTypeTree.copy(tree)(transformSubTrees(tree.tparams), transformTree(tree.body)) given tree.symbol.localContext + LambdaTypeTree.copy(tree)(transformSubTrees(tree.tparams), transformTree(tree.body))(given tree.symbol.localContext) case IsTypeBind(tree) => TypeBind.copy(tree)(tree.name, tree.body) case IsTypeBlock(tree) => TypeBlock.copy(tree)(tree.aliases, tree.tpt) } - def transformCaseDef(tree: CaseDef) given (ctx: Context): CaseDef = { + def transformCaseDef(tree: CaseDef)(given ctx: Context): CaseDef = { CaseDef.copy(tree)(transformPattern(tree.pattern), tree.guard.map(transformTerm), transformTerm(tree.rhs)) } - def transformTypeCaseDef(tree: TypeCaseDef) given (ctx: Context): TypeCaseDef = { + def transformTypeCaseDef(tree: TypeCaseDef)(given ctx: Context): TypeCaseDef = { TypeCaseDef.copy(tree)(transformTypeTree(tree.pattern), transformTypeTree(tree.rhs)) } - def transformPattern(pattern: Pattern) given (ctx: Context): Pattern = pattern match { + def transformPattern(pattern: Pattern)(given ctx: Context): Pattern = pattern match { case Pattern.Value(_) | Pattern.WildcardPattern() => pattern case Pattern.IsTypeTest(pattern) => @@ -257,28 +257,28 @@ trait TreeUtils Pattern.Bind.copy(pattern)(pattern.name, transformPattern(pattern.pattern)) } - def transformStats(trees: List[Statement]) given (ctx: Context): List[Statement] = + def transformStats(trees: List[Statement])(given ctx: Context): List[Statement] = trees mapConserve (transformStatement(_)) - def transformTrees(trees: List[Tree]) given (ctx: Context): List[Tree] = + def transformTrees(trees: List[Tree])(given ctx: Context): List[Tree] = trees mapConserve (transformTree(_)) - def transformTerms(trees: List[Term]) given (ctx: Context): List[Term] = + def transformTerms(trees: List[Term])(given ctx: Context): List[Term] = trees mapConserve (transformTerm(_)) - def transformTypeTrees(trees: List[TypeTree]) given (ctx: Context): List[TypeTree] = + def transformTypeTrees(trees: List[TypeTree])(given ctx: Context): List[TypeTree] = trees mapConserve (transformTypeTree(_)) - def transformCaseDefs(trees: List[CaseDef]) given (ctx: Context): List[CaseDef] = + def transformCaseDefs(trees: List[CaseDef])(given ctx: Context): List[CaseDef] = trees mapConserve (transformCaseDef(_)) - def transformTypeCaseDefs(trees: List[TypeCaseDef]) given (ctx: Context): List[TypeCaseDef] = + def transformTypeCaseDefs(trees: List[TypeCaseDef])(given ctx: Context): List[TypeCaseDef] = trees mapConserve (transformTypeCaseDef(_)) - def transformPatterns(trees: List[Pattern]) given (ctx: Context): List[Pattern] = + def transformPatterns(trees: List[Pattern])(given ctx: Context): List[Pattern] = trees mapConserve (transformPattern(_)) - def transformSubTrees[Tr <: Tree](trees: List[Tr]) given (ctx: Context): List[Tr] = + def transformSubTrees[Tr <: Tree](trees: List[Tr])(given ctx: Context): List[Tr] = transformTrees(trees).asInstanceOf[List[Tr]] } diff --git a/library/src/dotty/DottyPredef.scala b/library/src/dotty/DottyPredef.scala index 367148244881..18b16a0283e6 100644 --- a/library/src/dotty/DottyPredef.scala +++ b/library/src/dotty/DottyPredef.scala @@ -37,7 +37,5 @@ object DottyPredef { case ev: ValueOf[T] => ev.value } - inline def summon[T] given (x: T): x.type = x - - inline def the[T] given (x: T): x.type = x + inline def summon[T](given x: T): x.type = x } diff --git a/library/src/scala/Tuple.scala b/library/src/scala/Tuple.scala index dea576cadb64..a3e3e4911a3f 100644 --- a/library/src/scala/Tuple.scala +++ b/library/src/scala/Tuple.scala @@ -140,7 +140,7 @@ object Tuple { def fromProduct(product: Product): Tuple = runtime.DynamicTuple.dynamicFromProduct[Tuple](product) - def fromProductTyped[P <: Product](p: P) given (m: scala.deriving.Mirror.ProductOf[P]): m.MirroredElemTypes = + def fromProductTyped[P <: Product](p: P)(given m: scala.deriving.Mirror.ProductOf[P]): m.MirroredElemTypes = Tuple.fromArray(p.productIterator.toArray).asInstanceOf[m.MirroredElemTypes] // TODO use toIArray of Object to avoid double/triple array copy } diff --git a/library/src/scala/internal/quoted/Matcher.scala b/library/src/scala/internal/quoted/Matcher.scala index 57f4f0f9598b..c400984ddfc8 100644 --- a/library/src/scala/internal/quoted/Matcher.scala +++ b/library/src/scala/internal/quoted/Matcher.scala @@ -7,7 +7,7 @@ import scala.quoted.matching.Bind private[quoted] object Matcher { - class QuoteMatcher[QCtx <: QuoteContext & Singleton] given (val qctx: QCtx) { + class QuoteMatcher[QCtx <: QuoteContext & Singleton](given val qctx: QCtx) { // TODO improve performance private final val debug = false @@ -17,7 +17,7 @@ private[quoted] object Matcher { private type Env = Set[(Symbol, Symbol)] - inline private def withEnv[T](env: Env)(body: => ImplicitFunction1[Env, T]): T = body given env + inline private def withEnv[T](env: Env)(body: => ImplicitFunction1[Env, T]): T = body(given env) class SymBinding(val sym: Symbol, val fromAbove: Boolean) @@ -30,7 +30,7 @@ private[quoted] object Matcher { // that we have found and seal them in a quoted.Type matchings.asOptionOfTuple.map { tup => Tuple.fromArray(tup.toArray.map { // TODO improve performace - case x: SymBinding => internal.Context_GADT_approximation(the[Context])(x.sym, !x.fromAbove).seal + case x: SymBinding => internal.Context_GADT_approximation(summon[Context])(x.sym, !x.fromAbove).seal case x => x }) } @@ -50,7 +50,7 @@ private[quoted] object Matcher { // that we have found and seal them in a quoted.Type matchings.asOptionOfTuple.map { tup => Tuple.fromArray(tup.toArray.map { // TODO improve performace - case x: SymBinding => internal.Context_GADT_approximation(the[Context])(x.sym, !x.fromAbove).seal + case x: SymBinding => internal.Context_GADT_approximation(summon[Context])(x.sym, !x.fromAbove).seal case x => x }) } @@ -86,7 +86,7 @@ private[quoted] object Matcher { case _ => notMatched } - private given /*TreeListOps*/ { + private given treeListOps: { /** Check that all trees match with =?= and concatenate the results with && */ def (scrutinees: List[Tree]) =?= (patterns: List[Tree])(given Context, Env): Matching = @@ -94,14 +94,14 @@ private[quoted] object Matcher { } - private given /*TreeOps*/ { + private given treeOps: { /** Check that the trees match and return the contents from the pattern holes. * Return None if the trees do not match otherwise return Some of a tuple containing all the contents in the holes. * * @param scrutinee The tree beeing matched * @param pattern The pattern tree that the scrutinee should match. Contains `patternHole` holes. - * @param `the[Env]` Set of tuples containing pairs of symbols (s, p) where s defines a symbol in `scrutinee` which corresponds to symbol p in `pattern`. + * @param `summon[Env]` Set of tuples containing pairs of symbols (s, p) where s defines a symbol in `scrutinee` which corresponds to symbol p in `pattern`. * @return `None` if it did not match or `Some(tup: Tuple)` if it matched where `tup` contains the contents of the holes. */ def (scrutinee0: Tree) =?= (pattern0: Tree)(given Context, Env): Matching = { @@ -156,7 +156,7 @@ private[quoted] object Matcher { case (scrutinee, Typed(expr2, _)) => scrutinee =?= expr2 - case (Ident(_), Ident(_)) if scrutinee.symbol == pattern.symbol || the[Env].apply((scrutinee.symbol, pattern.symbol)) => + case (Ident(_), Ident(_)) if scrutinee.symbol == pattern.symbol || summon[Env].apply((scrutinee.symbol, pattern.symbol)) => matched case (Select(qual1, _), Select(qual2, _)) if scrutinee.symbol == pattern.symbol => @@ -172,17 +172,17 @@ private[quoted] object Matcher { fn1 =?= fn2 && args1 =?= args2 case (Block(stats1, expr1), Block(binding :: stats2, expr2)) if isTypeBinding(binding) => - qctx.tasty.internal.Context_GADT_addToConstraint(the[Context])(binding.symbol :: Nil) + qctx.tasty.internal.Context_GADT_addToConstraint(summon[Context])(binding.symbol :: Nil) matched(new SymBinding(binding.symbol, hasFromAboveAnnotation(binding.symbol))) && Block(stats1, expr1) =?= Block(stats2, expr2) case (Block(stat1 :: stats1, expr1), Block(stat2 :: stats2, expr2)) => - withEnv(the[Env] + (stat1.symbol -> stat2.symbol)) { + withEnv(summon[Env] + (stat1.symbol -> stat2.symbol)) { stat1 =?= stat2 && Block(stats1, expr1) =?= Block(stats2, expr2) } case (scrutinee, Block(typeBindings, expr2)) if typeBindings.forall(isTypeBinding) => val bindingSymbols = typeBindings.map(_.symbol) - qctx.tasty.internal.Context_GADT_addToConstraint(the[Context])(bindingSymbols) + qctx.tasty.internal.Context_GADT_addToConstraint(summon[Context])(bindingSymbols) bindingSymbols.foldRight(scrutinee =?= expr2)((x, acc) => matched(new SymBinding(x, hasFromAboveAnnotation(x))) && acc) case (If(cond1, thenp1, elsep1), If(cond2, thenp2, elsep2)) => @@ -219,15 +219,15 @@ private[quoted] object Matcher { val bindMatch = if (hasBindAnnotation(pattern.symbol) || hasBindTypeAnnotation(tpt2)) bindingMatch(scrutinee.symbol) else matched - def rhsEnv = the[Env] + (scrutinee.symbol -> pattern.symbol) - bindMatch && tpt1 =?= tpt2 && (treeOptMatches(rhs1, rhs2) given (the[Context], rhsEnv)) + def rhsEnv = summon[Env] + (scrutinee.symbol -> pattern.symbol) + bindMatch && tpt1 =?= tpt2 && treeOptMatches(rhs1, rhs2)(given summon[Context], rhsEnv) case (DefDef(_, typeParams1, paramss1, tpt1, Some(rhs1)), DefDef(_, typeParams2, paramss2, tpt2, Some(rhs2))) => val bindMatch = if (hasBindAnnotation(pattern.symbol)) bindingMatch(scrutinee.symbol) else matched def rhsEnv = - the[Env] + (scrutinee.symbol -> pattern.symbol) ++ + summon[Env] + (scrutinee.symbol -> pattern.symbol) ++ typeParams1.zip(typeParams2).map((tparam1, tparam2) => tparam1.symbol -> tparam2.symbol) ++ paramss1.flatten.zip(paramss2.flatten).map((param1, param2) => param1.symbol -> param2.symbol) @@ -294,7 +294,7 @@ private[quoted] object Matcher { } } - private given /*PatternOps*/ { + private given patternOps: { /** Check that the pattern trees match and return the contents from the pattern holes. * Return a tuple with the new environment containing the bindings defined in this pattern and a matching. @@ -302,21 +302,21 @@ private[quoted] object Matcher { * * @param scrutinee The pattern tree beeing matched * @param pattern The pattern tree that the scrutinee should match. Contains `patternHole` holes. - * @param `the[Env]` Set of tuples containing pairs of symbols (s, p) where s defines a symbol in `scrutinee` which corresponds to symbol p in `pattern`. + * @param `summon[Env]` Set of tuples containing pairs of symbols (s, p) where s defines a symbol in `scrutinee` which corresponds to symbol p in `pattern`. * @return The new environment containing the bindings defined in this pattern tuppled with * `None` if it did not match or `Some(tup: Tuple)` if it matched where `tup` contains the contents of the holes. */ def (scrutinee: Pattern) =?= (pattern: Pattern)(given Context, Env): (Env, Matching) = (scrutinee, pattern) match { case (Pattern.Value(v1), Pattern.Unapply(TypeApply(Select(patternHole @ Ident("patternHole"), "unapply"), List(tpt)), Nil, Nil)) if patternHole.symbol.owner.fullName == "scala.runtime.quoted.Matcher$" => - (the[Env], matched(v1.seal)) + (summon[Env], matched(v1.seal)) case (Pattern.Value(v1), Pattern.Value(v2)) => - (the[Env], v1 =?= v2) + (summon[Env], v1 =?= v2) case (Pattern.Bind(name1, body1), Pattern.Bind(name2, body2)) => - val bindEnv = the[Env] + (scrutinee.symbol -> pattern.symbol) - (body1 =?= body2) given (the[Context], bindEnv) + val bindEnv = summon[Env] + (scrutinee.symbol -> pattern.symbol) + (body1 =?= body2)(given summon[Context], bindEnv) case (Pattern.Unapply(fun1, implicits1, patterns1), Pattern.Unapply(fun2, implicits2, patterns2)) => val (patEnv, patternsMatch) = foldPatterns(patterns1, patterns2) @@ -326,10 +326,10 @@ private[quoted] object Matcher { foldPatterns(patterns1, patterns2) case (Pattern.TypeTest(tpt1), Pattern.TypeTest(tpt2)) => - (the[Env], tpt1 =?= tpt2) + (summon[Env], tpt1 =?= tpt2) case (Pattern.WildcardPattern(), Pattern.WildcardPattern()) => - (the[Env], matched) + (summon[Env], matched) case _ => if (debug) @@ -349,15 +349,15 @@ private[quoted] object Matcher { | | |""".stripMargin) - (the[Env], notMatched) + (summon[Env], notMatched) } } private def foldPatterns(patterns1: List[Pattern], patterns2: List[Pattern])(given Context, Env): (Env, Matching) = { - if (patterns1.size != patterns2.size) (the[Env], notMatched) - else patterns1.zip(patterns2).foldLeft((the[Env], matched)) { (acc, x) => - val (env, res) = (x._1 =?= x._2) given (the[Context], acc._1) + if (patterns1.size != patterns2.size) (summon[Env], notMatched) + else patterns1.zip(patterns2).foldLeft((summon[Env], matched)) { (acc, x) => + val (env, res) = (x._1 =?= x._2)(given summon[Context], acc._1) (env, acc._2 && res) } } diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index 76479b3ea27e..30a41afabefa 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -17,7 +17,7 @@ package quoted { * Returns `None` if the expression does not contain a value or contains side effects. * Otherwise returns the `Some` of the value. */ - final def getValue[U >: T] given (qctx: QuoteContext, valueOf: ValueOfExpr[U]): Option[U] = valueOf(this) + final def getValue[U >: T](given qctx: QuoteContext, valueOf: ValueOfExpr[U]): Option[U] = valueOf(this) } @@ -28,30 +28,30 @@ package quoted { /** Converts a tuple `(T1, ..., Tn)` to `(Expr[T1], ..., Expr[Tn])` */ type TupleOfExpr[Tup <: Tuple] = Tuple.Map[Tup, [X] =>> ImplicitFunction1[QuoteContext, Expr[X]]] - implicit class AsFunction[F, Args <: Tuple, R](f: Expr[F]) given (tf: TupledFunction[F, Args => R], qctx: QuoteContext) { + implicit class AsFunction[F, Args <: Tuple, R](f: Expr[F])(given tf: TupledFunction[F, Args => R], qctx: QuoteContext) { /** Beta-reduces the function appication. Generates the an expression only containing the body of the function */ - def apply[G] given (tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]]): G = { + def apply[G](given tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]]): G = { import qctx.tasty._ tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) } } - implicit class AsContextualFunction[F, Args <: Tuple, R](f: Expr[F]) given (tf: TupledFunction[F, ImplicitFunction1[Args, R]], qctx: QuoteContext) { + implicit class AsContextualFunction[F, Args <: Tuple, R](f: Expr[F])(given tf: TupledFunction[F, ImplicitFunction1[Args, R]], qctx: QuoteContext) { /** Beta-reduces the function appication. Generates the an expression only containing the body of the function */ - def apply[G] given (tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]]): G = { + def apply[G](given tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]]): G = { import qctx.tasty._ tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) } } /** Returns a null expresssion equivalent to `'{null}` */ - def nullExpr: ImplicitFunction1[QuoteContext, Expr[Null]] = given qctx => { + def nullExpr: ImplicitFunction1[QuoteContext, Expr[Null]] = (given qctx) => { import qctx.tasty._ Literal(Constant(null)).seal.asInstanceOf[Expr[Null]] } /** Returns a unit expresssion equivalent to `'{}` or `'{()}` */ - def unitExpr: ImplicitFunction1[QuoteContext, Expr[Unit]] = given qctx => { + def unitExpr: ImplicitFunction1[QuoteContext, Expr[Unit]] = (given qctx) => { import qctx.tasty._ Literal(Constant(())).seal.asInstanceOf[Expr[Unit]] } diff --git a/library/src/scala/quoted/QuoteContext.scala b/library/src/scala/quoted/QuoteContext.scala index 8fa3eb403f33..3f81928678d6 100644 --- a/library/src/scala/quoted/QuoteContext.scala +++ b/library/src/scala/quoted/QuoteContext.scala @@ -25,25 +25,25 @@ class QuoteContext(val tasty: scala.tasty.Reflection) { /** Report an error */ def error(msg: => String): Unit = { import tasty._ - tasty.error(msg, rootPosition) given rootContext + tasty.error(msg, rootPosition)(given rootContext) } /** Report an error at the on the position of `expr` */ def error(msg: => String, expr: Expr[_]): Unit = { import tasty._ - tasty.error(msg, expr.unseal.pos) given rootContext + tasty.error(msg, expr.unseal.pos)(given rootContext) } /** Report a warning */ def warning(msg: => String): Unit = { import tasty._ - tasty.warning(msg, rootPosition) given rootContext + tasty.warning(msg, rootPosition)(given rootContext) } /** Report a warning at the on the position of `expr` */ def warning(msg: => String, expr: Expr[_]): Unit = { import tasty._ - tasty.warning(msg, expr.unseal.pos) given rootContext + tasty.warning(msg, expr.unseal.pos)(given rootContext) } } diff --git a/library/src/scala/quoted/ValueOfExpr.scala b/library/src/scala/quoted/ValueOfExpr.scala index 32d27feb5246..a248fdafea9c 100644 --- a/library/src/scala/quoted/ValueOfExpr.scala +++ b/library/src/scala/quoted/ValueOfExpr.scala @@ -8,7 +8,7 @@ trait ValueOfExpr[T] { * Returns `None` if the expression does not contain a value or contains side effects. * Otherwise returns the `Some` of the value. */ - def apply(x: Expr[T]) given QuoteContext: Option[T] + def apply(x: Expr[T])(given QuoteContext): Option[T] } @@ -27,7 +27,7 @@ object ValueOfExpr { private class PrimitiveValueOfExpr[T <: Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String] extends ValueOfExpr[T] { /** Lift a quoted primitive value `'{ n }` into `n` */ - def apply(x: Expr[T]) given QuoteContext: Option[T] = matching.Const.unapply(x) + def apply(x: Expr[T])(given QuoteContext): Option[T] = matching.Const.unapply(x) } } diff --git a/library/src/scala/quoted/matching/Bind.scala b/library/src/scala/quoted/matching/Bind.scala index 024810a8b8b4..e28688014aca 100644 --- a/library/src/scala/quoted/matching/Bind.scala +++ b/library/src/scala/quoted/matching/Bind.scala @@ -19,7 +19,7 @@ class Bind[T <: AnyKind] private[scala](val name: String, private[Bind] val id: object Bind { - def unapply[T](expr: Expr[T]) given (qctx: QuoteContext): Option[Bind[T]] = { + def unapply[T](expr: Expr[T])(given qctx: QuoteContext): Option[Bind[T]] = { import qctx.tasty.{Bind => BindPattern, _} expr.unseal match { case IsIdent(ref) => diff --git a/library/src/scala/quoted/matching/Const.scala b/library/src/scala/quoted/matching/Const.scala index 7ac829eee4cd..e7b790a08041 100644 --- a/library/src/scala/quoted/matching/Const.scala +++ b/library/src/scala/quoted/matching/Const.scala @@ -14,7 +14,7 @@ package matching */ object Const { - def unapply[T](expr: Expr[T]) given (qctx: QuoteContext): Option[T] = { + def unapply[T](expr: Expr[T])(given qctx: QuoteContext): Option[T] = { import qctx.tasty._ def rec(tree: Term): Option[T] = tree match { case Literal(c) => Some(c.value.asInstanceOf[T]) diff --git a/library/src/scala/quoted/matching/ConstSeq.scala b/library/src/scala/quoted/matching/ConstSeq.scala index 1d343e8bee61..742773ec9007 100644 --- a/library/src/scala/quoted/matching/ConstSeq.scala +++ b/library/src/scala/quoted/matching/ConstSeq.scala @@ -5,7 +5,7 @@ package matching object ConstSeq { /** Matches literal sequence of literal constant value expressions */ - def unapply[T](expr: Expr[Seq[T]]) given (qctx: QuoteContext): Option[Seq[T]] = expr match { + def unapply[T](expr: Expr[Seq[T]])(given qctx: QuoteContext): Option[Seq[T]] = expr match { case ExprSeq(elems) => elems.foldRight(Option(List.empty[T])) { (elem, acc) => (elem, acc) match { diff --git a/library/src/scala/quoted/matching/ExprSeq.scala b/library/src/scala/quoted/matching/ExprSeq.scala index 2f15640e9900..d80e8146dcd4 100644 --- a/library/src/scala/quoted/matching/ExprSeq.scala +++ b/library/src/scala/quoted/matching/ExprSeq.scala @@ -5,7 +5,7 @@ package matching object ExprSeq { /** Matches a literal sequence of expressions */ - def unapply[T](expr: Expr[Seq[T]]) given (qctx: QuoteContext): Option[Seq[Expr[T]]] = { + def unapply[T](expr: Expr[Seq[T]])(given qctx: QuoteContext): Option[Seq[Expr[T]]] = { import qctx.tasty._ def rec(tree: Term): Option[Seq[Expr[T]]] = tree match { case Typed(Repeated(elems, _), _) => Some(elems.map(x => x.seal.asInstanceOf[Expr[T]])) diff --git a/library/src/scala/quoted/matching/package.scala b/library/src/scala/quoted/matching/package.scala index cae5def95dfb..eee039991097 100644 --- a/library/src/scala/quoted/matching/package.scala +++ b/library/src/scala/quoted/matching/package.scala @@ -10,7 +10,7 @@ package object matching { * @param tpe quoted type of the implicit parameter * @param qctx current context */ - def searchImplicitExpr[T] given (tpe: Type[T], qctx: QuoteContext): Option[Expr[T]] = { + def searchImplicitExpr[T](given tpe: Type[T], qctx: QuoteContext): Option[Expr[T]] = { import qctx.tasty._ searchImplicit(tpe.unseal.tpe) match { case IsImplicitSearchSuccess(iss) => Some(iss.tree.seal.asInstanceOf[Expr[T]]) diff --git a/library/src/scala/runtime/quoted/Unpickler.scala b/library/src/scala/runtime/quoted/Unpickler.scala index 16b3a1fbeff6..fc8a2c8229bc 100644 --- a/library/src/scala/runtime/quoted/Unpickler.scala +++ b/library/src/scala/runtime/quoted/Unpickler.scala @@ -13,13 +13,13 @@ object Unpickler { * replacing splice nodes with `args` */ def unpickleExpr[T](repr: PickledQuote, args: PickledExprArgs): ImplicitFunction1[QuoteContext, Expr[T]] = - the[QuoteContext].tasty.internal.unpickleExpr(repr, args).asInstanceOf[Expr[T]] + summon[QuoteContext].tasty.internal.unpickleExpr(repr, args).asInstanceOf[Expr[T]] /** Unpickle `repr` which represents a pickled `Type` tree, * replacing splice nodes with `args` */ def unpickleType[T](repr: PickledQuote, args: PickledTypeArgs): ImplicitFunction1[QuoteContext, Type[T]] = - the[QuoteContext].tasty.internal.unpickleType(repr, args).asInstanceOf[Type[T]] + summon[QuoteContext].tasty.internal.unpickleType(repr, args).asInstanceOf[Type[T]] } diff --git a/library/src/scala/tasty/reflect/CompilerInterface.scala b/library/src/scala/tasty/reflect/CompilerInterface.scala index 5ca8514c1252..34fdd1d8df8f 100644 --- a/library/src/scala/tasty/reflect/CompilerInterface.scala +++ b/library/src/scala/tasty/reflect/CompilerInterface.scala @@ -166,16 +166,16 @@ trait CompilerInterface { // /** Report a compilation error with the given message at the given position */ - def error(msg: => String, pos: Position) given (ctx: Context): Unit + def error(msg: => String, pos: Position)(given ctx: Context): Unit /** Report a compilation error with the given message at the given position range */ - def error(msg: => String, source: SourceFile, start: Int, end: Int) given (ctx: Context): Unit + def error(msg: => String, source: SourceFile, start: Int, end: Int)(given ctx: Context): Unit /** Report a compilation warning with the given message at the given position */ - def warning(msg: => String, pos: Position) given (ctx: Context): Unit + def warning(msg: => String, pos: Position)(given ctx: Context): Unit /** Report a compilation warning with the given message at the given position range */ - def warning(msg: => String, source: SourceFile, start: Int, end: Int) given (ctx: Context): Unit + def warning(msg: => String, source: SourceFile, start: Int, end: Int)(given ctx: Context): Unit // // Settings @@ -193,254 +193,254 @@ trait CompilerInterface { /** Tree representing code written in the source */ type Tree <: AnyRef - def Tree_pos(self: Tree) given (ctx: Context): Position - def Tree_symbol(self: Tree) given (ctx: Context): Symbol + def Tree_pos(self: Tree)(given ctx: Context): Position + def Tree_symbol(self: Tree)(given ctx: Context): Symbol /** Tree representing a pacakage clause in the source code */ type PackageClause <: Tree - def matchPackageClause(tree: Tree) given (ctx: Context): Option[PackageClause] + def matchPackageClause(tree: Tree)(given ctx: Context): Option[PackageClause] - def PackageClause_pid(self: PackageClause) given (ctx: Context): Ref - def PackageClause_stats(self: PackageClause) given (ctx: Context): List[Tree] + def PackageClause_pid(self: PackageClause)(given ctx: Context): Ref + def PackageClause_stats(self: PackageClause)(given ctx: Context): List[Tree] - def PackageClause_apply(pid: Ref, stats: List[Tree]) given (ctx: Context): PackageClause + def PackageClause_apply(pid: Ref, stats: List[Tree])(given ctx: Context): PackageClause - def PackageClause_copy(original: PackageClause)(pid: Ref, stats: List[Tree]) given (ctx: Context): PackageClause + def PackageClause_copy(original: PackageClause)(pid: Ref, stats: List[Tree])(given ctx: Context): PackageClause /** Tree representing a statement in the source code */ type Statement <: Tree - def matchStatement(tree: Tree) given (ctx: Context): Option[Statement] + def matchStatement(tree: Tree)(given ctx: Context): Option[Statement] /** Tree representing an import in the source code */ type Import <: Statement - def matchImport(tree: Tree) given (ctx: Context): Option[Import] + def matchImport(tree: Tree)(given ctx: Context): Option[Import] def Import_implied(self: Import): Boolean - def Import_expr(self: Import) given (ctx: Context): Term - def Import_selectors(self: Import) given (ctx: Context): List[ImportSelector] + def Import_expr(self: Import)(given ctx: Context): Term + def Import_selectors(self: Import)(given ctx: Context): List[ImportSelector] - def Import_apply(iexpr: Term, selectors: List[ImportSelector]) given (ctx: Context): Import + def Import_apply(iexpr: Term, selectors: List[ImportSelector])(given ctx: Context): Import - def Import_copy(original: Import)(expr: Term, selectors: List[ImportSelector]) given (ctx: Context): Import + def Import_copy(original: Import)(expr: Term, selectors: List[ImportSelector])(given ctx: Context): Import /** Tree representing a definition in the source code. It can be `PackageDef`, `ClassDef`, `TypeDef`, `DefDef` or `ValDef` */ type Definition <: Statement - def matchDefinition(tree: Tree) given (ctx: Context): Option[Definition] + def matchDefinition(tree: Tree)(given ctx: Context): Option[Definition] - def Definition_name(self: Definition) given (ctx: Context): String + def Definition_name(self: Definition)(given ctx: Context): String /** Tree representing a package definition. This includes definitions in all source files */ type PackageDef <: Definition - def matchPackageDef(tree: Tree) given (ctx: Context): Option[PackageDef] + def matchPackageDef(tree: Tree)(given ctx: Context): Option[PackageDef] - def PackageDef_owner(self: PackageDef) given (ctx: Context): PackageDef - def PackageDef_members(self: PackageDef) given (ctx: Context): List[Statement] - def PackageDef_symbol(self: PackageDef) given (ctx: Context): PackageDefSymbol + def PackageDef_owner(self: PackageDef)(given ctx: Context): PackageDef + def PackageDef_members(self: PackageDef)(given ctx: Context): List[Statement] + def PackageDef_symbol(self: PackageDef)(given ctx: Context): PackageDefSymbol /** Tree representing a class definition. This includes annonymus class definitions and the class of a module object */ type ClassDef <: Definition - def matchClassDef(tree: Tree) given (ctx: Context): Option[ClassDef] + def matchClassDef(tree: Tree)(given ctx: Context): Option[ClassDef] - def ClassDef_constructor(self: ClassDef) given (ctx: Context): DefDef - def ClassDef_parents(self: ClassDef) given (ctx: Context): List[Tree/* Term | TypeTree */] - def ClassDef_derived(self: ClassDef) given (ctx: Context): List[TypeTree] - def ClassDef_self(self: ClassDef) given (ctx: Context): Option[ValDef] - def ClassDef_body(self: ClassDef) given (ctx: Context): List[Statement] - def ClassDef_symbol(self: ClassDef) given (ctx: Context): ClassDefSymbol + def ClassDef_constructor(self: ClassDef)(given ctx: Context): DefDef + def ClassDef_parents(self: ClassDef)(given ctx: Context): List[Tree/* Term | TypeTree */] + def ClassDef_derived(self: ClassDef)(given ctx: Context): List[TypeTree] + def ClassDef_self(self: ClassDef)(given ctx: Context): Option[ValDef] + def ClassDef_body(self: ClassDef)(given ctx: Context): List[Statement] + def ClassDef_symbol(self: ClassDef)(given ctx: Context): ClassDefSymbol - def ClassDef_copy(original: ClassDef)(name: String, constr: DefDef, parents: List[Tree/* Term | TypeTree */], derived: List[TypeTree], selfOpt: Option[ValDef], body: List[Statement]) given (ctx: Context): ClassDef + def ClassDef_copy(original: ClassDef)(name: String, constr: DefDef, parents: List[Tree/* Term | TypeTree */], derived: List[TypeTree], selfOpt: Option[ValDef], body: List[Statement])(given ctx: Context): ClassDef /** Tree representing a type (paramter or member) definition in the source code */ type TypeDef <: Definition - def matchTypeDef(tree: Tree) given (ctx: Context): Option[TypeDef] + def matchTypeDef(tree: Tree)(given ctx: Context): Option[TypeDef] - def TypeDef_rhs(self: TypeDef) given (ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ - def TypeDef_symbol(self: TypeDef) given (ctx: Context): TypeDefSymbol + def TypeDef_rhs(self: TypeDef)(given ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ + def TypeDef_symbol(self: TypeDef)(given ctx: Context): TypeDefSymbol - def TypeDef_apply(symbol: TypeDefSymbol) given (ctx: Context): TypeDef - def TypeDef_copy(original: TypeDef)(name: String, rhs: Tree /*TypeTree | TypeBoundsTree*/) given (ctx: Context): TypeDef + def TypeDef_apply(symbol: TypeDefSymbol)(given ctx: Context): TypeDef + def TypeDef_copy(original: TypeDef)(name: String, rhs: Tree /*TypeTree | TypeBoundsTree*/)(given ctx: Context): TypeDef /** Tree representing a method definition in the source code */ type DefDef <: Definition - def matchDefDef(tree: Tree) given (ctx: Context): Option[DefDef] + def matchDefDef(tree: Tree)(given ctx: Context): Option[DefDef] - def DefDef_typeParams(self: DefDef) given (ctx: Context): List[TypeDef] - def DefDef_paramss(self: DefDef) given (ctx: Context): List[List[ValDef]] - def DefDef_returnTpt(self: DefDef) given (ctx: Context): TypeTree - def DefDef_rhs(self: DefDef) given (ctx: Context): Option[Term] - def DefDef_symbol(self: DefDef) given (ctx: Context): DefDefSymbol + def DefDef_typeParams(self: DefDef)(given ctx: Context): List[TypeDef] + def DefDef_paramss(self: DefDef)(given ctx: Context): List[List[ValDef]] + def DefDef_returnTpt(self: DefDef)(given ctx: Context): TypeTree + def DefDef_rhs(self: DefDef)(given ctx: Context): Option[Term] + def DefDef_symbol(self: DefDef)(given ctx: Context): DefDefSymbol - def DefDef_apply(symbol: DefDefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term]) given (ctx: Context): DefDef - def DefDef_copy(original: DefDef)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term]) given (ctx: Context): DefDef + def DefDef_apply(symbol: DefDefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(given ctx: Context): DefDef + def DefDef_copy(original: DefDef)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term])(given ctx: Context): DefDef /** Tree representing a value definition in the source code This inclues `val`, `lazy val`, `var`, `object` and parameter definitions. */ type ValDef <: Definition - def matchValDef(tree: Tree) given (ctx: Context): Option[ValDef] + def matchValDef(tree: Tree)(given ctx: Context): Option[ValDef] - def ValDef_tpt(self: ValDef) given (ctx: Context): TypeTree - def ValDef_rhs(self: ValDef) given (ctx: Context): Option[Term] - def ValDef_symbol(self: ValDef) given (ctx: Context): ValDefSymbol + def ValDef_tpt(self: ValDef)(given ctx: Context): TypeTree + def ValDef_rhs(self: ValDef)(given ctx: Context): Option[Term] + def ValDef_symbol(self: ValDef)(given ctx: Context): ValDefSymbol - def ValDef_apply(symbol: ValDefSymbol, rhs: Option[Term]) given (ctx: Context): ValDef - def ValDef_copy(original: ValDef)(name: String, tpt: TypeTree, rhs: Option[Term]) given (ctx: Context): ValDef + def ValDef_apply(symbol: ValDefSymbol, rhs: Option[Term])(given ctx: Context): ValDef + def ValDef_copy(original: ValDef)(name: String, tpt: TypeTree, rhs: Option[Term])(given ctx: Context): ValDef /** Tree representing an expression in the source code */ type Term <: Statement - def matchTerm(tree: Tree) given (ctx: Context): Option[Term] + def matchTerm(tree: Tree)(given ctx: Context): Option[Term] - def Term_pos(self: Term) given (ctx: Context): Position - def Term_tpe(self: Term) given (ctx: Context): Type - def Term_underlyingArgument(self: Term) given (ctx: Context): Term - def Term_underlying(self: Term) given (ctx: Context): Term + def Term_pos(self: Term)(given ctx: Context): Position + def Term_tpe(self: Term)(given ctx: Context): Type + def Term_underlyingArgument(self: Term)(given ctx: Context): Term + def Term_underlying(self: Term)(given ctx: Context): Term /** Tree representing a reference to definition */ type Ref <: Term - def matchRef(tree: Tree) given (ctx: Context): Option[Ref] + def matchRef(tree: Tree)(given ctx: Context): Option[Ref] - def Ref_apply(sym: Symbol) given (ctx: Context): Ref + def Ref_apply(sym: Symbol)(given ctx: Context): Ref /** Tree representing a reference to definition with a given name */ type Ident <: Ref - def matchIdent(tree: Tree) given (ctx: Context): Option[Ident] + def matchIdent(tree: Tree)(given ctx: Context): Option[Ident] - def Ident_name(self: Ident) given (ctx: Context): String + def Ident_name(self: Ident)(given ctx: Context): String - def Ident_apply(tmref: TermRef) given (ctx: Context): Term - def Ident_copy(original: Tree)(name: String) given (ctx: Context): Ident + def Ident_apply(tmref: TermRef)(given ctx: Context): Term + def Ident_copy(original: Tree)(name: String)(given ctx: Context): Ident /** Tree representing a selection of definition with a given name on a given prefix */ type Select <: Ref - def matchSelect(tree: Tree) given (ctx: Context): Option[Select] + def matchSelect(tree: Tree)(given ctx: Context): Option[Select] - def Select_qualifier(self: Select) given (ctx: Context): Term - def Select_name(self: Select) given (ctx: Context): String - def Select_signature(self: Select) given (ctx: Context): Option[Signature] + def Select_qualifier(self: Select)(given ctx: Context): Term + def Select_name(self: Select)(given ctx: Context): String + def Select_signature(self: Select)(given ctx: Context): Option[Signature] - def Select_apply(qualifier: Term, symbol: Symbol) given (ctx: Context): Select - def Select_unique(qualifier: Term, name: String) given (ctx: Context): Select + def Select_apply(qualifier: Term, symbol: Symbol)(given ctx: Context): Select + def Select_unique(qualifier: Term, name: String)(given ctx: Context): Select // TODO rename, this returns an Apply and not a Select - def Select_overloaded(qualifier: Term, name: String, targs: List[Type], args: List[Term]) given (ctx: Context): Apply - def Select_copy(original: Tree)(qualifier: Term, name: String) given (ctx: Context): Select + def Select_overloaded(qualifier: Term, name: String, targs: List[Type], args: List[Term])(given ctx: Context): Apply + def Select_copy(original: Tree)(qualifier: Term, name: String)(given ctx: Context): Select /** Tree representing a literal value in the source code */ type Literal <: Term - def matchLiteral(tree: Tree) given (ctx: Context): Option[Literal] + def matchLiteral(tree: Tree)(given ctx: Context): Option[Literal] - def Literal_constant(self: Literal) given (ctx: Context): Constant + def Literal_constant(self: Literal)(given ctx: Context): Constant - def Literal_apply(constant: Constant) given (ctx: Context): Literal - def Literal_copy(original: Tree)(constant: Constant) given (ctx: Context): Literal + def Literal_apply(constant: Constant)(given ctx: Context): Literal + def Literal_copy(original: Tree)(constant: Constant)(given ctx: Context): Literal /** Tree representing `this` in the source code */ type This <: Term - def matchThis(tree: Tree) given (ctx: Context): Option[This] + def matchThis(tree: Tree)(given ctx: Context): Option[This] - def This_id(self: This) given (ctx: Context): Option[Id] + def This_id(self: This)(given ctx: Context): Option[Id] - def This_apply(cls: ClassDefSymbol) given (ctx: Context): This - def This_copy(original: Tree)(qual: Option[Id]) given (ctx: Context): This + def This_apply(cls: ClassDefSymbol)(given ctx: Context): This + def This_copy(original: Tree)(qual: Option[Id])(given ctx: Context): This /** Tree representing `new` in the source code */ type New <: Term - def matchNew(tree: Tree) given (ctx: Context): Option[New] + def matchNew(tree: Tree)(given ctx: Context): Option[New] - def New_tpt(self: New) given (ctx: Context): TypeTree + def New_tpt(self: New)(given ctx: Context): TypeTree - def New_apply(tpt: TypeTree) given (ctx: Context): New - def New_copy(original: Tree)(tpt: TypeTree) given (ctx: Context): New + def New_apply(tpt: TypeTree)(given ctx: Context): New + def New_copy(original: Tree)(tpt: TypeTree)(given ctx: Context): New /** Tree representing an argument passed with an explicit name. Such as `arg1 = x` in `foo(arg1 = x)` */ type NamedArg <: Term - def matchNamedArg(tree: Tree) given (ctx: Context): Option[NamedArg] + def matchNamedArg(tree: Tree)(given ctx: Context): Option[NamedArg] - def NamedArg_name(self: NamedArg) given (ctx: Context): String - def NamedArg_value(self: NamedArg) given (ctx: Context): Term + def NamedArg_name(self: NamedArg)(given ctx: Context): String + def NamedArg_value(self: NamedArg)(given ctx: Context): Term - def NamedArg_apply(name: String, arg: Term) given (ctx: Context): NamedArg - def NamedArg_copy(tree: NamedArg)(name: String, arg: Term) given (ctx: Context): NamedArg + def NamedArg_apply(name: String, arg: Term)(given ctx: Context): NamedArg + def NamedArg_copy(tree: NamedArg)(name: String, arg: Term)(given ctx: Context): NamedArg /** Tree an application of arguments. It represents a single list of arguments, multiple argument lists will have nested `Apply`s */ type Apply <: Term - def matchApply(tree: Tree) given (ctx: Context): Option[Apply] + def matchApply(tree: Tree)(given ctx: Context): Option[Apply] - def Apply_fun(self: Apply) given (ctx: Context): Term - def Apply_args(self: Apply) given (ctx: Context): List[Term] + def Apply_fun(self: Apply)(given ctx: Context): Term + def Apply_args(self: Apply)(given ctx: Context): List[Term] - def Apply_apply(fn: Term, args: List[Term]) given (ctx: Context): Apply - def Apply_copy(original: Tree)(fun: Term, args: List[Term]) given (ctx: Context): Apply + def Apply_apply(fn: Term, args: List[Term])(given ctx: Context): Apply + def Apply_copy(original: Tree)(fun: Term, args: List[Term])(given ctx: Context): Apply /** Tree an application of type arguments */ type TypeApply <: Term - def matchTypeApply(tree: Tree) given (ctx: Context): Option[TypeApply] + def matchTypeApply(tree: Tree)(given ctx: Context): Option[TypeApply] - def TypeApply_fun(self: TypeApply) given (ctx: Context): Term - def TypeApply_args(self: TypeApply) given (ctx: Context): List[TypeTree] + def TypeApply_fun(self: TypeApply)(given ctx: Context): Term + def TypeApply_args(self: TypeApply)(given ctx: Context): List[TypeTree] - def TypeApply_apply(fn: Term, args: List[TypeTree]) given (ctx: Context): TypeApply - def TypeApply_copy(original: Tree)(fun: Term, args: List[TypeTree]) given (ctx: Context): TypeApply + def TypeApply_apply(fn: Term, args: List[TypeTree])(given ctx: Context): TypeApply + def TypeApply_copy(original: Tree)(fun: Term, args: List[TypeTree])(given ctx: Context): TypeApply /** Tree representing `super` in the source code */ type Super <: Term - def matchSuper(tree: Tree) given (ctx: Context): Option[Super] + def matchSuper(tree: Tree)(given ctx: Context): Option[Super] - def Super_qualifier(self: Super) given (ctx: Context): Term - def Super_id(self: Super) given (ctx: Context): Option[Id] + def Super_qualifier(self: Super)(given ctx: Context): Term + def Super_id(self: Super)(given ctx: Context): Option[Id] - def Super_apply(qual: Term, mix: Option[Id]) given (ctx: Context): Super - def Super_copy(original: Tree)(qual: Term, mix: Option[Id]) given (ctx: Context): Super + def Super_apply(qual: Term, mix: Option[Id])(given ctx: Context): Super + def Super_copy(original: Tree)(qual: Term, mix: Option[Id])(given ctx: Context): Super /** Tree representing a type ascription `x: T` in the source code */ type Typed <: Term - def matchTyped(tree: Tree) given (ctx: Context): Option[Typed] + def matchTyped(tree: Tree)(given ctx: Context): Option[Typed] - def Typed_expr(self: Typed) given (ctx: Context): Term - def Typed_tpt(self: Typed) given (ctx: Context): TypeTree + def Typed_expr(self: Typed)(given ctx: Context): Term + def Typed_tpt(self: Typed)(given ctx: Context): TypeTree - def Typed_apply(expr: Term, tpt: TypeTree) given (ctx: Context): Typed - def Typed_copy(original: Tree)(expr: Term, tpt: TypeTree) given (ctx: Context): Typed + def Typed_apply(expr: Term, tpt: TypeTree)(given ctx: Context): Typed + def Typed_copy(original: Tree)(expr: Term, tpt: TypeTree)(given ctx: Context): Typed /** Tree representing an assignment `x = y` in the source code */ type Assign <: Term - def matchAssign(tree: Tree) given (ctx: Context): Option[Assign] + def matchAssign(tree: Tree)(given ctx: Context): Option[Assign] - def Assign_lhs(self: Assign) given (ctx: Context): Term - def Assign_rhs(self: Assign) given (ctx: Context): Term + def Assign_lhs(self: Assign)(given ctx: Context): Term + def Assign_rhs(self: Assign)(given ctx: Context): Term - def Assign_apply(lhs: Term, rhs: Term) given (ctx: Context): Assign - def Assign_copy(original: Tree)(lhs: Term, rhs: Term) given (ctx: Context): Assign + def Assign_apply(lhs: Term, rhs: Term)(given ctx: Context): Assign + def Assign_copy(original: Tree)(lhs: Term, rhs: Term)(given ctx: Context): Assign /** Tree representing a block `{ ... }` in the source code */ type Block <: Term - def matchBlock(tree: Tree) given (ctx: Context): Option[Block] + def matchBlock(tree: Tree)(given ctx: Context): Option[Block] - def Block_statements(self: Block) given (ctx: Context): List[Statement] - def Block_expr(self: Block) given (ctx: Context): Term + def Block_statements(self: Block)(given ctx: Context): List[Statement] + def Block_expr(self: Block)(given ctx: Context): Term - def Block_apply(stats: List[Statement], expr: Term) given (ctx: Context): Block - def Block_copy(original: Tree)(stats: List[Statement], expr: Term) given (ctx: Context): Block + def Block_apply(stats: List[Statement], expr: Term)(given ctx: Context): Block + def Block_copy(original: Tree)(stats: List[Statement], expr: Term)(given ctx: Context): Block /** A lambda `(...) => ...` in the source code is represented as * a local method and a closure: @@ -453,265 +453,265 @@ trait CompilerInterface { */ type Closure <: Term - def matchClosure(tree: Tree) given (ctx: Context): Option[Closure] + def matchClosure(tree: Tree)(given ctx: Context): Option[Closure] - def Closure_meth(self: Closure) given (ctx: Context): Term - def Closure_tpeOpt(self: Closure) given (ctx: Context): Option[Type] + def Closure_meth(self: Closure)(given ctx: Context): Term + def Closure_tpeOpt(self: Closure)(given ctx: Context): Option[Type] - def Closure_apply(meth: Term, tpe: Option[Type]) given (ctx: Context): Closure - def Closure_copy(original: Tree)(meth: Tree, tpe: Option[Type]) given (ctx: Context): Closure + def Closure_apply(meth: Term, tpe: Option[Type])(given ctx: Context): Closure + def Closure_copy(original: Tree)(meth: Tree, tpe: Option[Type])(given ctx: Context): Closure /** Tree representing an if/then/else `if (...) ... else ...` in the source code */ type If <: Term - def matchIf(tree: Tree) given (ctx: Context): Option[If] + def matchIf(tree: Tree)(given ctx: Context): Option[If] - def If_cond(self: If) given (ctx: Context): Term - def If_thenp(self: If) given (ctx: Context): Term - def If_elsep(self: If) given (ctx: Context): Term + def If_cond(self: If)(given ctx: Context): Term + def If_thenp(self: If)(given ctx: Context): Term + def If_elsep(self: If)(given ctx: Context): Term - def If_apply(cond: Term, thenp: Term, elsep: Term) given (ctx: Context): If - def If_copy(original: Tree)(cond: Term, thenp: Term, elsep: Term) given (ctx: Context): If + def If_apply(cond: Term, thenp: Term, elsep: Term)(given ctx: Context): If + def If_copy(original: Tree)(cond: Term, thenp: Term, elsep: Term)(given ctx: Context): If /** Tree representing a pattern match `x match { ... }` in the source code */ type Match <: Term - def matchMatch(tree: Tree) given (ctx: Context): Option[Match] + def matchMatch(tree: Tree)(given ctx: Context): Option[Match] - def Match_scrutinee(self: Match) given (ctx: Context): Term - def Match_cases(self: Match) given (ctx: Context): List[CaseDef] + def Match_scrutinee(self: Match)(given ctx: Context): Term + def Match_cases(self: Match)(given ctx: Context): List[CaseDef] - def Match_apply(selector: Term, cases: List[CaseDef]) given (ctx: Context): Match - def Match_copy(original: Tree)(selector: Term, cases: List[CaseDef]) given (ctx: Context): Match + def Match_apply(selector: Term, cases: List[CaseDef])(given ctx: Context): Match + def Match_copy(original: Tree)(selector: Term, cases: List[CaseDef])(given ctx: Context): Match /** Tree representing a pattern match `delegate match { ... }` in the source code */ type ImpliedMatch <: Term - def matchImplicitMatch(tree: Tree) given (ctx: Context): Option[ImpliedMatch] + def matchImplicitMatch(tree: Tree)(given ctx: Context): Option[ImpliedMatch] - def ImplicitMatch_cases(self: ImpliedMatch) given (ctx: Context): List[CaseDef] + def ImplicitMatch_cases(self: ImpliedMatch)(given ctx: Context): List[CaseDef] - def ImplicitMatch_apply(cases: List[CaseDef]) given (ctx: Context): ImpliedMatch - def ImplicitMatch_copy(original: Tree)(cases: List[CaseDef]) given (ctx: Context): ImpliedMatch + def ImplicitMatch_apply(cases: List[CaseDef])(given ctx: Context): ImpliedMatch + def ImplicitMatch_copy(original: Tree)(cases: List[CaseDef])(given ctx: Context): ImpliedMatch /** Tree representing a tyr catch `try x catch { ... } finally { ... }` in the source code */ type Try <: Term - def matchTry(tree: Tree) given (ctx: Context): Option[Try] + def matchTry(tree: Tree)(given ctx: Context): Option[Try] - def Try_body(self: Try) given (ctx: Context): Term - def Try_cases(self: Try) given (ctx: Context): List[CaseDef] - def Try_finalizer(self: Try) given (ctx: Context): Option[Term] + def Try_body(self: Try)(given ctx: Context): Term + def Try_cases(self: Try)(given ctx: Context): List[CaseDef] + def Try_finalizer(self: Try)(given ctx: Context): Option[Term] - def Try_apply(expr: Term, cases: List[CaseDef], finalizer: Option[Term]) given (ctx: Context): Try - def Try_copy(original: Tree)(expr: Term, cases: List[CaseDef], finalizer: Option[Term]) given (ctx: Context): Try + def Try_apply(expr: Term, cases: List[CaseDef], finalizer: Option[Term])(given ctx: Context): Try + def Try_copy(original: Tree)(expr: Term, cases: List[CaseDef], finalizer: Option[Term])(given ctx: Context): Try /** Tree representing a `return` in the source code */ type Return <: Term - def matchReturn(tree: Tree) given (ctx: Context): Option[Return] + def matchReturn(tree: Tree)(given ctx: Context): Option[Return] - def Return_expr(self: Return) given (ctx: Context): Term + def Return_expr(self: Return)(given ctx: Context): Term - def Return_apply(expr: Term) given (ctx: Context): Return - def Return_copy(original: Tree)(expr: Term) given (ctx: Context): Return + def Return_apply(expr: Term)(given ctx: Context): Return + def Return_copy(original: Tree)(expr: Term)(given ctx: Context): Return /** Tree representing a variable argument list in the source code */ type Repeated <: Term - def matchRepeated(tree: Tree) given (ctx: Context): Option[Repeated] + def matchRepeated(tree: Tree)(given ctx: Context): Option[Repeated] - def Repeated_elems(self: Repeated) given (ctx: Context): List[Term] - def Repeated_elemtpt(self: Repeated) given (ctx: Context): TypeTree + def Repeated_elems(self: Repeated)(given ctx: Context): List[Term] + def Repeated_elemtpt(self: Repeated)(given ctx: Context): TypeTree - def Repeated_apply(elems: List[Term], elemtpt: TypeTree) given (ctx: Context): Repeated - def Repeated_copy(original: Tree)(elems: List[Term], elemtpt: TypeTree) given (ctx: Context): Repeated + def Repeated_apply(elems: List[Term], elemtpt: TypeTree)(given ctx: Context): Repeated + def Repeated_copy(original: Tree)(elems: List[Term], elemtpt: TypeTree)(given ctx: Context): Repeated /** Tree representing the scope of an inlined tree */ type Inlined <: Term - def matchInlined(tree: Tree) given (ctx: Context): Option[Inlined] + def matchInlined(tree: Tree)(given ctx: Context): Option[Inlined] - def Inlined_call(self: Inlined) given (ctx: Context): Option[Tree/* Term | TypeTree */] - def Inlined_bindings(self: Inlined) given (ctx: Context): List[Definition] - def Inlined_body(self: Inlined) given (ctx: Context): Term + def Inlined_call(self: Inlined)(given ctx: Context): Option[Tree/* Term | TypeTree */] + def Inlined_bindings(self: Inlined)(given ctx: Context): List[Definition] + def Inlined_body(self: Inlined)(given ctx: Context): Term - def Inlined_apply(call: Option[Tree/* Term | TypeTree */], bindings: List[Definition], expansion: Term) given (ctx: Context): Inlined - def Inlined_copy(original: Tree)(call: Option[Tree/* Term | TypeTree */], bindings: List[Definition], expansion: Term) given (ctx: Context): Inlined + def Inlined_apply(call: Option[Tree/* Term | TypeTree */], bindings: List[Definition], expansion: Term)(given ctx: Context): Inlined + def Inlined_copy(original: Tree)(call: Option[Tree/* Term | TypeTree */], bindings: List[Definition], expansion: Term)(given ctx: Context): Inlined /** Tree representing a selection of definition with a given name on a given prefix and number of nested scopes of inlined trees */ type SelectOuter <: Term - def matchSelectOuter(tree: Tree) given (ctx: Context): Option[SelectOuter] + def matchSelectOuter(tree: Tree)(given ctx: Context): Option[SelectOuter] - def SelectOuter_qualifier(self: SelectOuter) given (ctx: Context): Term - def SelectOuter_level(self: SelectOuter) given (ctx: Context): Int - def SelectOuter_tpe(self: SelectOuter) given (ctx: Context): Type + def SelectOuter_qualifier(self: SelectOuter)(given ctx: Context): Term + def SelectOuter_level(self: SelectOuter)(given ctx: Context): Int + def SelectOuter_tpe(self: SelectOuter)(given ctx: Context): Type - def SelectOuter_apply(qualifier: Term, name: String, levels: Int) given (ctx: Context): SelectOuter - def SelectOuter_copy(original: Tree)(qualifier: Term, name: String, levels: Int) given (ctx: Context): SelectOuter + def SelectOuter_apply(qualifier: Term, name: String, levels: Int)(given ctx: Context): SelectOuter + def SelectOuter_copy(original: Tree)(qualifier: Term, name: String, levels: Int)(given ctx: Context): SelectOuter /** Tree representing a while loop */ type While <: Term - def matchWhile(tree: Tree) given (ctx: Context): Option[While] + def matchWhile(tree: Tree)(given ctx: Context): Option[While] - def While_cond(self: While) given (ctx: Context): Term - def While_body(self: While) given (ctx: Context): Term + def While_cond(self: While)(given ctx: Context): Term + def While_body(self: While)(given ctx: Context): Term - def While_apply(cond: Term, body: Term) given (ctx: Context): While - def While_copy(original: Tree)(cond: Term, body: Term) given (ctx: Context): While + def While_apply(cond: Term, body: Term)(given ctx: Context): While + def While_copy(original: Tree)(cond: Term, body: Term)(given ctx: Context): While /** Type tree representing a type written in the source */ type TypeTree <: Tree - def matchTypeTree(tree: Tree) given (ctx: Context): Option[TypeTree] + def matchTypeTree(tree: Tree)(given ctx: Context): Option[TypeTree] - def TypeTree_pos(self: TypeTree) given (ctx: Context): Position - def TypeTree_symbol(self: TypeTree) given (ctx: Context): Symbol - def TypeTree_tpe(self: TypeTree) given (ctx: Context): Type + def TypeTree_pos(self: TypeTree)(given ctx: Context): Position + def TypeTree_symbol(self: TypeTree)(given ctx: Context): Symbol + def TypeTree_tpe(self: TypeTree)(given ctx: Context): Type /** Type tree representing an inferred type */ type Inferred <: TypeTree - def matchInferred(tree: Tree) given (ctx: Context): Option[Inferred] + def matchInferred(tree: Tree)(given ctx: Context): Option[Inferred] - def Inferred_apply(tpe: Type) given (ctx: Context): Inferred + def Inferred_apply(tpe: Type)(given ctx: Context): Inferred /** Type tree representing a reference to definition with a given name */ type TypeIdent <: TypeTree - def matchTypeIdent(tree: Tree) given (ctx: Context): Option[TypeIdent] + def matchTypeIdent(tree: Tree)(given ctx: Context): Option[TypeIdent] - def TypeIdent_name(self: TypeIdent) given (ctx: Context): String + def TypeIdent_name(self: TypeIdent)(given ctx: Context): String - def TypeIdent_copy(original: TypeIdent)(name: String) given (ctx: Context): TypeIdent + def TypeIdent_copy(original: TypeIdent)(name: String)(given ctx: Context): TypeIdent /** Type tree representing a selection of definition with a given name on a given term prefix */ type TypeSelect <: TypeTree - def matchTypeSelect(tree: Tree) given (ctx: Context): Option[TypeSelect] + def matchTypeSelect(tree: Tree)(given ctx: Context): Option[TypeSelect] - def TypeSelect_qualifier(self: TypeSelect) given (ctx: Context): Term - def TypeSelect_name(self: TypeSelect) given (ctx: Context): String + def TypeSelect_qualifier(self: TypeSelect)(given ctx: Context): Term + def TypeSelect_name(self: TypeSelect)(given ctx: Context): String - def TypeSelect_apply(qualifier: Term, name: String) given (ctx: Context): TypeSelect - def TypeSelect_copy(original: TypeSelect)(qualifier: Term, name: String) given (ctx: Context): TypeSelect + def TypeSelect_apply(qualifier: Term, name: String)(given ctx: Context): TypeSelect + def TypeSelect_copy(original: TypeSelect)(qualifier: Term, name: String)(given ctx: Context): TypeSelect /** Type tree representing a selection of definition with a given name on a given type prefix */ type Projection <: TypeTree - def matchProjection(tree: Tree) given (ctx: Context): Option[Projection] + def matchProjection(tree: Tree)(given ctx: Context): Option[Projection] - def Projection_qualifier(self: Projection) given (ctx: Context): TypeTree - def Projection_name(self: Projection) given (ctx: Context): String + def Projection_qualifier(self: Projection)(given ctx: Context): TypeTree + def Projection_name(self: Projection)(given ctx: Context): String - def Projection_copy(original: Projection)(qualifier: TypeTree, name: String) given (ctx: Context): Projection + def Projection_copy(original: Projection)(qualifier: TypeTree, name: String)(given ctx: Context): Projection /** Type tree representing a singleton type */ type Singleton <: TypeTree - def matchSingleton(tree: Tree) given (ctx: Context): Option[Singleton] + def matchSingleton(tree: Tree)(given ctx: Context): Option[Singleton] - def Singleton_ref(self: Singleton) given (ctx: Context): Term + def Singleton_ref(self: Singleton)(given ctx: Context): Term - def Singleton_apply(ref: Term) given (ctx: Context): Singleton - def Singleton_copy(original: Singleton)(ref: Term) given (ctx: Context): Singleton + def Singleton_apply(ref: Term)(given ctx: Context): Singleton + def Singleton_copy(original: Singleton)(ref: Term)(given ctx: Context): Singleton /** Type tree representing a type refinement */ type Refined <: TypeTree - def matchRefined(tree: Tree) given (ctx: Context): Option[Refined] + def matchRefined(tree: Tree)(given ctx: Context): Option[Refined] - def Refined_tpt(self: Refined) given (ctx: Context): TypeTree - def Refined_refinements(self: Refined) given (ctx: Context): List[Definition] + def Refined_tpt(self: Refined)(given ctx: Context): TypeTree + def Refined_refinements(self: Refined)(given ctx: Context): List[Definition] - def Refined_copy(original: Refined)(tpt: TypeTree, refinements: List[Definition]) given (ctx: Context): Refined + def Refined_copy(original: Refined)(tpt: TypeTree, refinements: List[Definition])(given ctx: Context): Refined /** Type tree representing a type application */ type Applied <: TypeTree - def matchApplied(tree: Tree) given (ctx: Context): Option[Applied] + def matchApplied(tree: Tree)(given ctx: Context): Option[Applied] - def Applied_tpt(self: Applied) given (ctx: Context): TypeTree - def Applied_args(self: Applied) given (ctx: Context): List[Tree /*TypeTree | TypeBoundsTree*/] + def Applied_tpt(self: Applied)(given ctx: Context): TypeTree + def Applied_args(self: Applied)(given ctx: Context): List[Tree /*TypeTree | TypeBoundsTree*/] - def Applied_apply(tpt: TypeTree, args: List[Tree /*TypeTree | TypeBoundsTree*/]) given (ctx: Context): Applied - def Applied_copy(original: Applied)(tpt: TypeTree, args: List[Tree /*TypeTree | TypeBoundsTree*/]) given (ctx: Context): Applied + def Applied_apply(tpt: TypeTree, args: List[Tree /*TypeTree | TypeBoundsTree*/])(given ctx: Context): Applied + def Applied_copy(original: Applied)(tpt: TypeTree, args: List[Tree /*TypeTree | TypeBoundsTree*/])(given ctx: Context): Applied /** Type tree representing an annotated type */ type Annotated <: TypeTree - def matchAnnotated(tree: Tree) given (ctx: Context): Option[Annotated] + def matchAnnotated(tree: Tree)(given ctx: Context): Option[Annotated] - def Annotated_arg(self: Annotated) given (ctx: Context): TypeTree - def Annotated_annotation(self: Annotated) given (ctx: Context): Term + def Annotated_arg(self: Annotated)(given ctx: Context): TypeTree + def Annotated_annotation(self: Annotated)(given ctx: Context): Term - def Annotated_apply(arg: TypeTree, annotation: Term) given (ctx: Context): Annotated - def Annotated_copy(original: Annotated)(arg: TypeTree, annotation: Term) given (ctx: Context): Annotated + def Annotated_apply(arg: TypeTree, annotation: Term)(given ctx: Context): Annotated + def Annotated_copy(original: Annotated)(arg: TypeTree, annotation: Term)(given ctx: Context): Annotated /** Type tree representing a type match */ type MatchTypeTree <: TypeTree - def matchMatchTypeTree(tree: Tree) given (ctx: Context): Option[MatchTypeTree] + def matchMatchTypeTree(tree: Tree)(given ctx: Context): Option[MatchTypeTree] - def MatchTypeTree_bound(self: MatchTypeTree) given (ctx: Context): Option[TypeTree] - def MatchTypeTree_selector(self: MatchTypeTree) given (ctx: Context): TypeTree - def MatchTypeTree_cases(self: MatchTypeTree) given (ctx: Context): List[TypeCaseDef] + def MatchTypeTree_bound(self: MatchTypeTree)(given ctx: Context): Option[TypeTree] + def MatchTypeTree_selector(self: MatchTypeTree)(given ctx: Context): TypeTree + def MatchTypeTree_cases(self: MatchTypeTree)(given ctx: Context): List[TypeCaseDef] - def MatchTypeTree_apply(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef]) given (ctx: Context): MatchTypeTree - def MatchTypeTree_copy(original: MatchTypeTree)(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef]) given (ctx: Context): MatchTypeTree + def MatchTypeTree_apply(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef])(given ctx: Context): MatchTypeTree + def MatchTypeTree_copy(original: MatchTypeTree)(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef])(given ctx: Context): MatchTypeTree /** Type tree representing a by name parameter */ type ByName <: TypeTree - def ByName_result(self: ByName) given (ctx: Context): TypeTree + def ByName_result(self: ByName)(given ctx: Context): TypeTree - def matchByName(tree: Tree) given (ctx: Context): Option[ByName] + def matchByName(tree: Tree)(given ctx: Context): Option[ByName] - def ByName_apply(result: TypeTree) given (ctx: Context): ByName - def ByName_copy(original: ByName)(result: TypeTree) given (ctx: Context): ByName + def ByName_apply(result: TypeTree)(given ctx: Context): ByName + def ByName_copy(original: ByName)(result: TypeTree)(given ctx: Context): ByName /** Type tree representing a lambda abstraction type */ type LambdaTypeTree <: TypeTree - def matchLambdaTypeTree(tree: Tree) given (ctx: Context): Option[LambdaTypeTree] + def matchLambdaTypeTree(tree: Tree)(given ctx: Context): Option[LambdaTypeTree] - def Lambdatparams(self: LambdaTypeTree) given (ctx: Context): List[TypeDef] - def Lambdabody(self: LambdaTypeTree) given (ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ + def Lambdatparams(self: LambdaTypeTree)(given ctx: Context): List[TypeDef] + def Lambdabody(self: LambdaTypeTree)(given ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ - def Lambdaapply(tparams: List[TypeDef], body: Tree /*TypeTree | TypeBoundsTree*/) given (ctx: Context): LambdaTypeTree - def Lambdacopy(original: LambdaTypeTree)(tparams: List[TypeDef], body: Tree /*TypeTree | TypeBoundsTree*/) given (ctx: Context): LambdaTypeTree + def Lambdaapply(tparams: List[TypeDef], body: Tree /*TypeTree | TypeBoundsTree*/)(given ctx: Context): LambdaTypeTree + def Lambdacopy(original: LambdaTypeTree)(tparams: List[TypeDef], body: Tree /*TypeTree | TypeBoundsTree*/)(given ctx: Context): LambdaTypeTree /** Type tree representing a type binding */ type TypeBind <: TypeTree - def matchTypeBind(tree: Tree) given (ctx: Context): Option[TypeBind] + def matchTypeBind(tree: Tree)(given ctx: Context): Option[TypeBind] - def TypeBind_name(self: TypeBind) given (ctx: Context): String - def TypeBind_body(self: TypeBind) given (ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ + def TypeBind_name(self: TypeBind)(given ctx: Context): String + def TypeBind_body(self: TypeBind)(given ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ - def TypeBind_copy(original: TypeBind)(name: String, tpt: Tree /*TypeTree | TypeBoundsTree*/) given (ctx: Context): TypeBind + def TypeBind_copy(original: TypeBind)(name: String, tpt: Tree /*TypeTree | TypeBoundsTree*/)(given ctx: Context): TypeBind /** Type tree within a block with aliases `{ type U1 = ... ; T[U1, U2] }` */ type TypeBlock <: TypeTree - def matchTypeBlock(tree: Tree) given (ctx: Context): Option[TypeBlock] + def matchTypeBlock(tree: Tree)(given ctx: Context): Option[TypeBlock] - def TypeBlock_aliases(self: TypeBlock) given (ctx: Context): List[TypeDef] - def TypeBlock_tpt(self: TypeBlock) given (ctx: Context): TypeTree + def TypeBlock_aliases(self: TypeBlock)(given ctx: Context): List[TypeDef] + def TypeBlock_tpt(self: TypeBlock)(given ctx: Context): TypeTree - def TypeBlock_apply(aliases: List[TypeDef], tpt: TypeTree) given (ctx: Context): TypeBlock - def TypeBlock_copy(original: TypeBlock)(aliases: List[TypeDef], tpt: TypeTree) given (ctx: Context): TypeBlock + def TypeBlock_apply(aliases: List[TypeDef], tpt: TypeTree)(given ctx: Context): TypeBlock + def TypeBlock_copy(original: TypeBlock)(aliases: List[TypeDef], tpt: TypeTree)(given ctx: Context): TypeBlock /** Type tree representing a type bound written in the source */ type TypeBoundsTree <: Tree /*TypeTree | TypeBoundsTree*/ - def matchTypeBoundsTree(tree: Tree) given (ctx: Context): Option[TypeBoundsTree] + def matchTypeBoundsTree(tree: Tree)(given ctx: Context): Option[TypeBoundsTree] - def TypeBoundsTree_tpe(self: TypeBoundsTree) given (ctx: Context): TypeBounds - def TypeBoundsTree_low(self: TypeBoundsTree) given (ctx: Context): TypeTree - def TypeBoundsTree_hi(self: TypeBoundsTree) given (ctx: Context): TypeTree + def TypeBoundsTree_tpe(self: TypeBoundsTree)(given ctx: Context): TypeBounds + def TypeBoundsTree_low(self: TypeBoundsTree)(given ctx: Context): TypeTree + def TypeBoundsTree_hi(self: TypeBoundsTree)(given ctx: Context): TypeTree /** Type tree representing wildcard type bounds written in the source. * The wildcard type `_` (for example in in `List[_]`) will be a type tree that @@ -719,32 +719,32 @@ trait CompilerInterface { */ type WildcardTypeTree <: Tree - def matchWildcardTypeTree(tree: Tree) given (ctx: Context): Option[WildcardTypeTree] + def matchWildcardTypeTree(tree: Tree)(given ctx: Context): Option[WildcardTypeTree] - def WildcardTypeTree_tpe(self: WildcardTypeTree) given (ctx: Context): TypeOrBounds + def WildcardTypeTree_tpe(self: WildcardTypeTree)(given ctx: Context): TypeOrBounds /** Branch of a pattern match or catch clause */ type CaseDef <: Tree - def matchCaseDef(tree: Tree) given (ctx: Context): Option[CaseDef] + def matchCaseDef(tree: Tree)(given ctx: Context): Option[CaseDef] - def CaseDef_pattern(self: CaseDef) given (ctx: Context): Pattern - def CaseDef_guard(self: CaseDef) given (ctx: Context): Option[Term] - def CaseDef_rhs(self: CaseDef) given (ctx: Context): Term + def CaseDef_pattern(self: CaseDef)(given ctx: Context): Pattern + def CaseDef_guard(self: CaseDef)(given ctx: Context): Option[Term] + def CaseDef_rhs(self: CaseDef)(given ctx: Context): Term - def CaseDef_module_apply(pattern: Pattern, guard: Option[Term], body: Term) given (ctx: Context): CaseDef - def CaseDef_module_copy(original: CaseDef)(pattern: Pattern, guard: Option[Term], body: Term) given (ctx: Context): CaseDef + def CaseDef_module_apply(pattern: Pattern, guard: Option[Term], body: Term)(given ctx: Context): CaseDef + def CaseDef_module_copy(original: CaseDef)(pattern: Pattern, guard: Option[Term], body: Term)(given ctx: Context): CaseDef /** Branch of a type pattern match */ type TypeCaseDef <: Tree - def matchTypeCaseDef(tree: Tree) given (ctx: Context): Option[TypeCaseDef] + def matchTypeCaseDef(tree: Tree)(given ctx: Context): Option[TypeCaseDef] - def TypeCaseDef_pattern(self: TypeCaseDef) given (ctx: Context): TypeTree - def TypeCaseDef_rhs(self: TypeCaseDef) given (ctx: Context): TypeTree + def TypeCaseDef_pattern(self: TypeCaseDef)(given ctx: Context): TypeTree + def TypeCaseDef_rhs(self: TypeCaseDef)(given ctx: Context): TypeTree - def TypeCaseDef_module_apply(pattern: TypeTree, body: TypeTree) given (ctx: Context): TypeCaseDef - def TypeCaseDef_module_copy(original: TypeCaseDef)(pattern: TypeTree, body: TypeTree) given (ctx: Context): TypeCaseDef + def TypeCaseDef_module_apply(pattern: TypeTree, body: TypeTree)(given ctx: Context): TypeCaseDef + def TypeCaseDef_module_copy(original: TypeCaseDef)(pattern: TypeTree, body: TypeTree)(given ctx: Context): TypeCaseDef // // PATTERNS @@ -753,70 +753,70 @@ trait CompilerInterface { /** Pattern tree of the pattern part of a CaseDef */ type Pattern <: AnyRef - def Pattern_pos(self: Pattern) given (ctx: Context): Position - def Pattern_tpe(self: Pattern) given (ctx: Context): Type - def Pattern_symbol(self: Pattern) given (ctx: Context): Symbol + def Pattern_pos(self: Pattern)(given ctx: Context): Position + def Pattern_tpe(self: Pattern)(given ctx: Context): Type + def Pattern_symbol(self: Pattern)(given ctx: Context): Symbol /** Pattern representing a value. This includes `1`, ```x``` and `_` */ type Value <: Pattern def matchPattern_Value(pattern: Pattern): Option[Value] - def Pattern_Value_value(self: Value) given (ctx: Context): Term + def Pattern_Value_value(self: Value)(given ctx: Context): Term - def Pattern_Value_module_apply(term: Term) given (ctx: Context): Value - def Pattern_Value_module_copy(original: Value)(term: Term) given (ctx: Context): Value + def Pattern_Value_module_apply(term: Term)(given ctx: Context): Value + def Pattern_Value_module_copy(original: Value)(term: Term)(given ctx: Context): Value /** Pattern representing a `_ @ _` binding. */ type Bind <: Pattern - def matchPattern_Bind(x: Pattern) given (ctx: Context): Option[Bind] + def matchPattern_Bind(x: Pattern)(given ctx: Context): Option[Bind] - def Pattern_Bind_name(self: Bind) given (ctx: Context): String + def Pattern_Bind_name(self: Bind)(given ctx: Context): String - def Pattern_Bind_pattern(self: Bind) given (ctx: Context): Pattern + def Pattern_Bind_pattern(self: Bind)(given ctx: Context): Pattern - def Pattern_Bind_module_copy(original: Bind)(name: String, pattern: Pattern) given (ctx: Context): Bind + def Pattern_Bind_module_copy(original: Bind)(name: String, pattern: Pattern)(given ctx: Context): Bind /** Pattern representing a `Xyz(...)` unapply. */ type Unapply <: Pattern - def matchPattern_Unapply(pattern: Pattern) given (ctx: Context): Option[Unapply] + def matchPattern_Unapply(pattern: Pattern)(given ctx: Context): Option[Unapply] - def Pattern_Unapply_fun(self: Unapply) given (ctx: Context): Term + def Pattern_Unapply_fun(self: Unapply)(given ctx: Context): Term - def Pattern_Unapply_implicits(self: Unapply) given (ctx: Context): List[Term] + def Pattern_Unapply_implicits(self: Unapply)(given ctx: Context): List[Term] - def Pattern_Unapply_patterns(self: Unapply) given (ctx: Context): List[Pattern] + def Pattern_Unapply_patterns(self: Unapply)(given ctx: Context): List[Pattern] - def Pattern_Unapply_module_copy(original: Unapply)(fun: Term, implicits: List[Term], patterns: List[Pattern]) given (ctx: Context): Unapply + def Pattern_Unapply_module_copy(original: Unapply)(fun: Term, implicits: List[Term], patterns: List[Pattern])(given ctx: Context): Unapply /** Pattern representing `X | Y | ...` alternatives. */ type Alternatives <: Pattern - def matchPattern_Alternatives(pattern: Pattern) given (ctx: Context): Option[Alternatives] + def matchPattern_Alternatives(pattern: Pattern)(given ctx: Context): Option[Alternatives] - def Pattern_Alternatives_patterns(self: Alternatives) given (ctx: Context): List[Pattern] + def Pattern_Alternatives_patterns(self: Alternatives)(given ctx: Context): List[Pattern] - def Pattern_Alternatives_module_apply(patterns: List[Pattern]) given (ctx: Context): Alternatives - def Pattern_Alternatives_module_copy(original: Alternatives)(patterns: List[Pattern]) given (ctx: Context): Alternatives + def Pattern_Alternatives_module_apply(patterns: List[Pattern])(given ctx: Context): Alternatives + def Pattern_Alternatives_module_copy(original: Alternatives)(patterns: List[Pattern])(given ctx: Context): Alternatives /** Pattern representing a `x: Y` type test. */ type TypeTest <: Pattern - def matchPattern_TypeTest(pattern: Pattern) given (ctx: Context): Option[TypeTest] + def matchPattern_TypeTest(pattern: Pattern)(given ctx: Context): Option[TypeTest] - def Pattern_TypeTest_tpt(self: TypeTest) given (ctx: Context): TypeTree + def Pattern_TypeTest_tpt(self: TypeTest)(given ctx: Context): TypeTree - def Pattern_TypeTest_module_apply(tpt: TypeTree) given (ctx: Context): TypeTest - def Pattern_TypeTest_module_copy(original: TypeTest)(tpt: TypeTree) given (ctx: Context): TypeTest + def Pattern_TypeTest_module_apply(tpt: TypeTree)(given ctx: Context): TypeTest + def Pattern_TypeTest_module_copy(original: TypeTest)(tpt: TypeTree)(given ctx: Context): TypeTest /** Pattern representing a `_` pattern */ type WildcardPattern <: Pattern - def matchPattern_WildcardPattern(pattern: Pattern) given (ctx: Context): Option[WildcardPattern] + def matchPattern_WildcardPattern(pattern: Pattern)(given ctx: Context): Option[WildcardPattern] - def Pattern_WildcardPattern_module_apply(tpe: TypeOrBounds) given (ctx: Context): WildcardPattern + def Pattern_WildcardPattern_module_apply(tpe: TypeOrBounds)(given ctx: Context): WildcardPattern // // TYPES @@ -828,25 +828,25 @@ trait CompilerInterface { /** NoPrefix for a type selection */ type NoPrefix <: TypeOrBounds - def matchNoPrefix(x: TypeOrBounds) given (ctx: Context): Option[NoPrefix] + def matchNoPrefix(x: TypeOrBounds)(given ctx: Context): Option[NoPrefix] /** Type bounds */ type TypeBounds <: TypeOrBounds - def matchTypeBounds(x: TypeOrBounds) given (ctx: Context): Option[TypeBounds] + def matchTypeBounds(x: TypeOrBounds)(given ctx: Context): Option[TypeBounds] - def TypeBounds_low(self: TypeBounds) given (ctx: Context): Type - def TypeBounds_hi(self: TypeBounds) given (ctx: Context): Type + def TypeBounds_low(self: TypeBounds)(given ctx: Context): Type + def TypeBounds_hi(self: TypeBounds)(given ctx: Context): Type /** A type */ type Type <: TypeOrBounds - def matchType(x: TypeOrBounds) given (ctx: Context): Option[Type] + def matchType(x: TypeOrBounds)(given ctx: Context): Option[Type] - def Type_apply(clazz: Class[_]) given (ctx: Context): Type + def Type_apply(clazz: Class[_])(given ctx: Context): Type - def `Type_=:=`(self: Type)(that: Type) given (ctx: Context): Boolean - def `Type_<:<`(self: Type)(that: Type) given (ctx: Context): Boolean + def `Type_=:=`(self: Type)(that: Type)(given ctx: Context): Boolean + def `Type_<:<`(self: Type)(that: Type)(given ctx: Context): Boolean /** Widen from singleton type to its underlying non-singleton * base type by applying one or more `underlying` dereferences, @@ -857,28 +857,28 @@ trait CompilerInterface { * def o: Outer * .widen = o.C */ - def Type_widen(self: Type) given (ctx: Context): Type + def Type_widen(self: Type)(given ctx: Context): Type /** Follow aliases and dereferences LazyRefs, annotated types and instantiated * TypeVars until type is no longer alias type, annotated type, LazyRef, * or instantiated type variable. */ - def Type_dealias(self: Type) given (ctx: Context): Type + def Type_dealias(self: Type)(given ctx: Context): Type - def Type_simplified(self: Type) given (ctx: Context): Type + def Type_simplified(self: Type)(given ctx: Context): Type - def Type_classSymbol(self: Type) given (ctx: Context): Option[ClassDefSymbol] // TODO remove Option and use NoSymbol + def Type_classSymbol(self: Type)(given ctx: Context): Option[ClassDefSymbol] // TODO remove Option and use NoSymbol - def Type_typeSymbol(self: Type) given (ctx: Context): Symbol + def Type_typeSymbol(self: Type)(given ctx: Context): Symbol - def Type_termSymbol(self: Type) given (ctx: Context): Symbol + def Type_termSymbol(self: Type)(given ctx: Context): Symbol - def Type_isSingleton(self: Type) given (ctx: Context): Boolean + def Type_isSingleton(self: Type)(given ctx: Context): Boolean - def Type_memberType(self: Type)(member: Symbol) given (ctx: Context): Type + def Type_memberType(self: Type)(member: Symbol)(given ctx: Context): Type /** Is this type an instance of a non-bottom subclass of the given class `cls`? */ - def Type_derivesFrom(self: Type)(cls: ClassDefSymbol) given (ctx: Context): Boolean + def Type_derivesFrom(self: Type)(cls: ClassDefSymbol)(given ctx: Context): Boolean /** Is this type a function type? * @@ -889,147 +889,147 @@ trait CompilerInterface { * - returns true for `given Int => Int` and `erased Int => Int` * - returns false for `List[Int]`, despite that `List[Int] <:< Int => Int`. */ - def Type_isFunctionType(self: Type) given (ctx: Context): Boolean + def Type_isFunctionType(self: Type)(given ctx: Context): Boolean /** Is this type an implicit function type? * * @see `Type_isFunctionType` */ - def Type_isImplicitFunctionType(self: Type) given (ctx: Context): Boolean + def Type_isImplicitFunctionType(self: Type)(given ctx: Context): Boolean /** Is this type an erased function type? * * @see `Type_isFunctionType` */ - def Type_isErasedFunctionType(self: Type) given (ctx: Context): Boolean + def Type_isErasedFunctionType(self: Type)(given ctx: Context): Boolean /** Is this type a dependent function type? * * @see `Type_isFunctionType` */ - def Type_isDependentFunctionType(self: Type) given (ctx: Context): Boolean + def Type_isDependentFunctionType(self: Type)(given ctx: Context): Boolean /** A singleton type representing a known constant value */ type ConstantType <: Type - def matchConstantType(tpe: TypeOrBounds) given (ctx: Context): Option[ConstantType] + def matchConstantType(tpe: TypeOrBounds)(given ctx: Context): Option[ConstantType] - def ConstantType_constant(self: ConstantType) given (ctx: Context): Constant + def ConstantType_constant(self: ConstantType)(given ctx: Context): Constant /** Type of a reference to a term symbol */ type TermRef <: Type - def matchTermRef(tpe: TypeOrBounds) given (ctx: Context): Option[TermRef] + def matchTermRef(tpe: TypeOrBounds)(given ctx: Context): Option[TermRef] - def TermRef_apply(qual: TypeOrBounds, name: String) given (ctx: Context): TermRef + def TermRef_apply(qual: TypeOrBounds, name: String)(given ctx: Context): TermRef - def TermRef_qualifier(self: TermRef) given (ctx: Context): TypeOrBounds - def TermRef_name(self: TermRef) given (ctx: Context): String + def TermRef_qualifier(self: TermRef)(given ctx: Context): TypeOrBounds + def TermRef_name(self: TermRef)(given ctx: Context): String /** Type of a reference to a type symbol */ type TypeRef <: Type - def matchTypeRef(tpe: TypeOrBounds) given (ctx: Context): Option[TypeRef] + def matchTypeRef(tpe: TypeOrBounds)(given ctx: Context): Option[TypeRef] - def TypeRef_qualifier(self: TypeRef) given (ctx: Context): TypeOrBounds + def TypeRef_qualifier(self: TypeRef)(given ctx: Context): TypeOrBounds def TypeRef_name(self: TypeRef)(given Context): String /** Type of a `super` refernce */ type SuperType <: Type - def matchSuperType(tpe: TypeOrBounds) given (ctx: Context): Option[SuperType] + def matchSuperType(tpe: TypeOrBounds)(given ctx: Context): Option[SuperType] - def SuperType_thistpe(self: SuperType) given (ctx: Context): Type - def SuperType_supertpe(self: SuperType) given (ctx: Context): Type + def SuperType_thistpe(self: SuperType)(given ctx: Context): Type + def SuperType_supertpe(self: SuperType)(given ctx: Context): Type /** A type with a type refinement `T { type U }` */ type Refinement <: Type - def matchRefinement(tpe: TypeOrBounds) given (ctx: Context): Option[Refinement] + def matchRefinement(tpe: TypeOrBounds)(given ctx: Context): Option[Refinement] - def Refinement_parent(self: Refinement) given (ctx: Context): Type - def Refinement_name(self: Refinement) given (ctx: Context): String - def Refinement_info(self: Refinement) given (ctx: Context): TypeOrBounds + def Refinement_parent(self: Refinement)(given ctx: Context): Type + def Refinement_name(self: Refinement)(given ctx: Context): String + def Refinement_info(self: Refinement)(given ctx: Context): TypeOrBounds /** A higher kinded type applied to some types `T[U]` */ type AppliedType <: Type - def matchAppliedType(tpe: TypeOrBounds) given (ctx: Context): Option[AppliedType] + def matchAppliedType(tpe: TypeOrBounds)(given ctx: Context): Option[AppliedType] - def AppliedType_tycon(self: AppliedType) given (ctx: Context): Type - def AppliedType_args(self: AppliedType) given (ctx: Context): List[TypeOrBounds] + def AppliedType_tycon(self: AppliedType)(given ctx: Context): Type + def AppliedType_args(self: AppliedType)(given ctx: Context): List[TypeOrBounds] - def AppliedType_apply(tycon: Type, args: List[TypeOrBounds]) given (ctx: Context) : AppliedType + def AppliedType_apply(tycon: Type, args: List[TypeOrBounds])(given ctx: Context) : AppliedType /** A type with an anottation `T @foo` */ type AnnotatedType <: Type - def matchAnnotatedType(tpe: TypeOrBounds) given (ctx: Context): Option[AnnotatedType] + def matchAnnotatedType(tpe: TypeOrBounds)(given ctx: Context): Option[AnnotatedType] - def AnnotatedType_underlying(self: AnnotatedType) given (ctx: Context): Type - def AnnotatedType_annot(self: AnnotatedType) given (ctx: Context): Term + def AnnotatedType_underlying(self: AnnotatedType)(given ctx: Context): Type + def AnnotatedType_annot(self: AnnotatedType)(given ctx: Context): Term /** Intersection type `T & U` */ type AndType <: Type - def matchAndType(tpe: TypeOrBounds) given (ctx: Context): Option[AndType] + def matchAndType(tpe: TypeOrBounds)(given ctx: Context): Option[AndType] - def AndType_left(self: AndType) given (ctx: Context): Type - def AndType_right(self: AndType) given (ctx: Context): Type + def AndType_left(self: AndType)(given ctx: Context): Type + def AndType_right(self: AndType)(given ctx: Context): Type /** Union type `T | U` */ type OrType <: Type - def matchOrType(tpe: TypeOrBounds) given (ctx: Context): Option[OrType] + def matchOrType(tpe: TypeOrBounds)(given ctx: Context): Option[OrType] - def OrType_left(self: OrType) given (ctx: Context): Type - def OrType_right(self: OrType) given (ctx: Context): Type + def OrType_left(self: OrType)(given ctx: Context): Type + def OrType_right(self: OrType)(given ctx: Context): Type /** Type match `T match { case U => ... }` */ type MatchType <: Type - def matchMatchType(tpe: TypeOrBounds) given (ctx: Context): Option[MatchType] + def matchMatchType(tpe: TypeOrBounds)(given ctx: Context): Option[MatchType] - def MatchType_bound(self: MatchType) given (ctx: Context): Type - def MatchType_scrutinee(self: MatchType) given (ctx: Context): Type - def MatchType_cases(self: MatchType) given (ctx: Context): List[Type] + def MatchType_bound(self: MatchType)(given ctx: Context): Type + def MatchType_scrutinee(self: MatchType)(given ctx: Context): Type + def MatchType_cases(self: MatchType)(given ctx: Context): List[Type] /** Type of a by by name parameter */ type ByNameType <: Type - def matchByNameType(tpe: TypeOrBounds) given (ctx: Context): Option[ByNameType] + def matchByNameType(tpe: TypeOrBounds)(given ctx: Context): Option[ByNameType] - def ByNameType_underlying(self: ByNameType) given (ctx: Context): Type + def ByNameType_underlying(self: ByNameType)(given ctx: Context): Type /** Type of a parameter reference */ type ParamRef <: Type - def matchParamRef(tpe: TypeOrBounds) given (ctx: Context): Option[ParamRef] + def matchParamRef(tpe: TypeOrBounds)(given ctx: Context): Option[ParamRef] - def ParamRef_binder(self: ParamRef) given (ctx: Context): LambdaType[TypeOrBounds] - def ParamRef_paramNum(self: ParamRef) given (ctx: Context): Int + def ParamRef_binder(self: ParamRef)(given ctx: Context): LambdaType[TypeOrBounds] + def ParamRef_paramNum(self: ParamRef)(given ctx: Context): Int /** Type of `this` */ type ThisType <: Type - def matchThisType(tpe: TypeOrBounds) given (ctx: Context): Option[ThisType] + def matchThisType(tpe: TypeOrBounds)(given ctx: Context): Option[ThisType] - def ThisType_tref(self: ThisType) given (ctx: Context): Type + def ThisType_tref(self: ThisType)(given ctx: Context): Type /** A type that is recursively defined `this` */ type RecursiveThis <: Type - def matchRecursiveThis(tpe: TypeOrBounds) given (ctx: Context): Option[RecursiveThis] + def matchRecursiveThis(tpe: TypeOrBounds)(given ctx: Context): Option[RecursiveThis] - def RecursiveThis_binder(self: RecursiveThis) given (ctx: Context): RecursiveType + def RecursiveThis_binder(self: RecursiveThis)(given ctx: Context): RecursiveType /** A type that is recursively defined */ type RecursiveType <: Type - def matchRecursiveType(tpe: TypeOrBounds) given (ctx: Context): Option[RecursiveType] + def matchRecursiveType(tpe: TypeOrBounds)(given ctx: Context): Option[RecursiveType] - def RecursiveType_underlying(self: RecursiveType) given (ctx: Context): Type + def RecursiveType_underlying(self: RecursiveType)(given ctx: Context): Type // TODO can we add the bound back without an cake? // TODO is LambdaType really needed? ParamRefExtractor could be split into more precise extractors @@ -1039,31 +1039,31 @@ trait CompilerInterface { /** Type of the definition of a method taking a single list of parameters. It's return type may be a MethodType. */ type MethodType <: LambdaType[Type] - def matchMethodType(tpe: TypeOrBounds) given (ctx: Context): Option[MethodType] + def matchMethodType(tpe: TypeOrBounds)(given ctx: Context): Option[MethodType] def MethodType_isErased(self: MethodType): Boolean def MethodType_isImplicit(self: MethodType): Boolean - def MethodType_paramNames(self: MethodType) given (ctx: Context): List[String] - def MethodType_paramTypes(self: MethodType) given (ctx: Context): List[Type] - def MethodType_resType(self: MethodType) given (ctx: Context): Type + def MethodType_paramNames(self: MethodType)(given ctx: Context): List[String] + def MethodType_paramTypes(self: MethodType)(given ctx: Context): List[Type] + def MethodType_resType(self: MethodType)(given ctx: Context): Type /** Type of the definition of a method taking a list of type parameters. It's return type may be a MethodType. */ type PolyType <: LambdaType[TypeBounds] - def matchPolyType(tpe: TypeOrBounds) given (ctx: Context): Option[PolyType] + def matchPolyType(tpe: TypeOrBounds)(given ctx: Context): Option[PolyType] - def PolyType_paramNames(self: PolyType) given (ctx: Context): List[String] - def PolyType_paramBounds(self: PolyType) given (ctx: Context): List[TypeBounds] - def PolyType_resType(self: PolyType) given (ctx: Context): Type + def PolyType_paramNames(self: PolyType)(given ctx: Context): List[String] + def PolyType_paramBounds(self: PolyType)(given ctx: Context): List[TypeBounds] + def PolyType_resType(self: PolyType)(given ctx: Context): Type /** Type of the definition of a type lambda taking a list of type parameters. It's return type may be a TypeLambda. */ type TypeLambda <: LambdaType[TypeBounds] - def matchTypeLambda(tpe: TypeOrBounds) given (ctx: Context): Option[TypeLambda] + def matchTypeLambda(tpe: TypeOrBounds)(given ctx: Context): Option[TypeLambda] - def TypeLambda_paramNames(self: TypeLambda) given (ctx: Context): List[String] - def TypeLambda_paramBounds(self: TypeLambda) given (ctx: Context): List[TypeBounds] - def TypeLambda_resType(self: TypeLambda) given (ctx: Context): Type + def TypeLambda_paramNames(self: TypeLambda)(given ctx: Context): List[String] + def TypeLambda_paramBounds(self: TypeLambda)(given ctx: Context): List[TypeBounds] + def TypeLambda_resType(self: TypeLambda)(given ctx: Context): Type // // IMPORT SELECTORS @@ -1078,22 +1078,22 @@ trait CompilerInterface { type SimpleSelector <: ImportSelector - def matchSimpleSelector(self: ImportSelector) given (ctx: Context): Option[SimpleSelector] + def matchSimpleSelector(self: ImportSelector)(given ctx: Context): Option[SimpleSelector] - def SimpleSelector_selection(self: SimpleSelector) given (ctx: Context): Id + def SimpleSelector_selection(self: SimpleSelector)(given ctx: Context): Id type RenameSelector <: ImportSelector - def matchRenameSelector(self: ImportSelector) given (ctx: Context): Option[RenameSelector] + def matchRenameSelector(self: ImportSelector)(given ctx: Context): Option[RenameSelector] - def RenameSelector_from(self: RenameSelector) given (ctx: Context): Id - def RenameSelector_to(self: RenameSelector) given (ctx: Context): Id + def RenameSelector_from(self: RenameSelector)(given ctx: Context): Id + def RenameSelector_to(self: RenameSelector)(given ctx: Context): Id type OmitSelector <: ImportSelector - def matchOmitSelector(self: ImportSelector) given (ctx: Context): Option[OmitSelector] + def matchOmitSelector(self: ImportSelector)(given ctx: Context): Option[OmitSelector] - def SimpleSelector_omitted(self: OmitSelector) given (ctx: Context): Id + def SimpleSelector_omitted(self: OmitSelector)(given ctx: Context): Id // // IDENTIFIERS @@ -1103,10 +1103,10 @@ trait CompilerInterface { type Id <: AnyRef /** Position in the source code */ - def Id_pos(self: Id) given (ctx: Context): Position + def Id_pos(self: Id)(given ctx: Context): Position /** Name of the identifier */ - def Id_name(self: Id) given (ctx: Context): String + def Id_name(self: Id)(given ctx: Context): String // // SIGNATURES @@ -1201,159 +1201,159 @@ trait CompilerInterface { type Symbol <: AnyRef /** Owner of this symbol. The owner is the symbol in which this symbol is defined. */ - def Symbol_owner(self: Symbol) given (ctx: Context): Symbol + def Symbol_owner(self: Symbol)(given ctx: Context): Symbol /** Flags of this symbol */ - def Symbol_flags(self: Symbol) given (ctx: Context): Flags + def Symbol_flags(self: Symbol)(given ctx: Context): Flags - def Symbol_isLocalDummy(self: Symbol) given (ctx: Context): Boolean + def Symbol_isLocalDummy(self: Symbol)(given ctx: Context): Boolean - def Symbol_isRefinementClass(self: Symbol) given (ctx: Context): Boolean + def Symbol_isRefinementClass(self: Symbol)(given ctx: Context): Boolean - def Symbol_isAliasType(self: Symbol) given (ctx: Context): Boolean + def Symbol_isAliasType(self: Symbol)(given ctx: Context): Boolean - def Symbol_isAnonymousClass(self: Symbol) given (ctx: Context): Boolean + def Symbol_isAnonymousClass(self: Symbol)(given ctx: Context): Boolean - def Symbol_isAnonymousFunction(self: Symbol) given (ctx: Context): Boolean + def Symbol_isAnonymousFunction(self: Symbol)(given ctx: Context): Boolean - def Symbol_isAbstractType(self: Symbol) given (ctx: Context): Boolean + def Symbol_isAbstractType(self: Symbol)(given ctx: Context): Boolean - def Symbol_isClassConstructor(self: Symbol) given (ctx: Context): Boolean + def Symbol_isClassConstructor(self: Symbol)(given ctx: Context): Boolean /** This symbol is private within the resulting type. */ - def Symbol_privateWithin(self: Symbol) given (ctx: Context): Option[Type] + def Symbol_privateWithin(self: Symbol)(given ctx: Context): Option[Type] /** This symbol is protected within the resulting type. */ - def Symbol_protectedWithin(self: Symbol) given (ctx: Context): Option[Type] + def Symbol_protectedWithin(self: Symbol)(given ctx: Context): Option[Type] /** The name of this symbol. */ - def Symbol_name(self: Symbol) given (ctx: Context): String + def Symbol_name(self: Symbol)(given ctx: Context): String /** The full name of this symbol up to the root package. */ - def Symbol_fullName(self: Symbol) given (ctx: Context): String + def Symbol_fullName(self: Symbol)(given ctx: Context): String /** The position of this symbol */ - def Symbol_pos(self: Symbol) given (ctx: Context): Position + def Symbol_pos(self: Symbol)(given ctx: Context): Position - def Symbol_localContext(self: Symbol) given (ctx: Context): Context + def Symbol_localContext(self: Symbol)(given ctx: Context): Context /** The comment of the symbol */ - def Symbol_comment(self: Symbol) given (ctx: Context): Option[Comment] + def Symbol_comment(self: Symbol)(given ctx: Context): Option[Comment] /** Annotations attached to this symbol */ - def Symbol_annots(self: Symbol) given (ctx: Context): List[Term] + def Symbol_annots(self: Symbol)(given ctx: Context): List[Term] - def Symbol_isDefinedInCurrentRun(self: Symbol) given (ctx: Context): Boolean + def Symbol_isDefinedInCurrentRun(self: Symbol)(given ctx: Context): Boolean /** Symbol of a package definition */ type PackageDefSymbol <: Symbol - def matchPackageDefSymbol(symbol: Symbol) given (ctx: Context): Option[PackageDefSymbol] + def matchPackageDefSymbol(symbol: Symbol)(given ctx: Context): Option[PackageDefSymbol] - def PackageDefSymbol_tree(self: PackageDefSymbol) given (ctx: Context): PackageDef + def PackageDefSymbol_tree(self: PackageDefSymbol)(given ctx: Context): PackageDef type TypeSymbol <: Symbol - def matchTypeSymbol(symbol: Symbol) given (ctx: Context): Option[TypeSymbol] + def matchTypeSymbol(symbol: Symbol)(given ctx: Context): Option[TypeSymbol] /** Symbol of a class definition. This includes anonymous class definitions and the class of a module object. */ type ClassDefSymbol <: TypeSymbol - def matchClassDefSymbol(symbol: Symbol) given (ctx: Context): Option[ClassDefSymbol] + def matchClassDefSymbol(symbol: Symbol)(given ctx: Context): Option[ClassDefSymbol] /** ClassDef tree of this definition */ - def ClassDefSymbol_tree(self: ClassDefSymbol) given (ctx: Context): ClassDef + def ClassDefSymbol_tree(self: ClassDefSymbol)(given ctx: Context): ClassDef /** Fields directly declared in the class */ - def ClassDefSymbol_fields(self: Symbol) given (ctx: Context): List[Symbol] + def ClassDefSymbol_fields(self: Symbol)(given ctx: Context): List[Symbol] /** Field with the given name directly declared in the class */ - def ClassDefSymbol_field(self: Symbol)(name: String) given (ctx: Context): Option[Symbol] + def ClassDefSymbol_field(self: Symbol)(name: String)(given ctx: Context): Option[Symbol] /** Get non-private named methods defined directly inside the class */ - def ClassDefSymbol_classMethod(self: Symbol)(name: String) given (ctx: Context): List[DefDefSymbol] + def ClassDefSymbol_classMethod(self: Symbol)(name: String)(given ctx: Context): List[DefDefSymbol] /** Get all non-private methods defined directly inside the class, excluding constructors */ - def ClassDefSymbol_classMethods(self: Symbol) given (ctx: Context): List[DefDefSymbol] + def ClassDefSymbol_classMethods(self: Symbol)(given ctx: Context): List[DefDefSymbol] /** Get named non-private methods declared or inherited */ - def ClassDefSymbol_method(self: Symbol)(name: String) given (ctx: Context): List[DefDefSymbol] + def ClassDefSymbol_method(self: Symbol)(name: String)(given ctx: Context): List[DefDefSymbol] /** Get all non-private methods declared or inherited */ - def ClassDefSymbol_methods(self: Symbol) given (ctx: Context): List[DefDefSymbol] + def ClassDefSymbol_methods(self: Symbol)(given ctx: Context): List[DefDefSymbol] /** Fields of a case class type -- only the ones declared in primary constructor */ - def ClassDefSymbol_caseFields(self: Symbol) given (ctx: Context): List[ValDefSymbol] + def ClassDefSymbol_caseFields(self: Symbol)(given ctx: Context): List[ValDefSymbol] /** The class symbol of the companion module class */ - def ClassDefSymbol_companionClass(self: Symbol) given (ctx: Context): Option[ClassDefSymbol] + def ClassDefSymbol_companionClass(self: Symbol)(given ctx: Context): Option[ClassDefSymbol] /** The symbol of the companion module */ - def ClassDefSymbol_companionModule(self: Symbol) given (ctx: Context): Option[ValDefSymbol] + def ClassDefSymbol_companionModule(self: Symbol)(given ctx: Context): Option[ValDefSymbol] /** The symbol of the class of the companion module */ - def ClassDefSymbol_moduleClass(self: Symbol) given (ctx: Context): Option[Symbol] + def ClassDefSymbol_moduleClass(self: Symbol)(given ctx: Context): Option[Symbol] - def ClassDefSymbol_of(fullName: String) given (ctx: Context): ClassDefSymbol + def ClassDefSymbol_of(fullName: String)(given ctx: Context): ClassDefSymbol /** Symbol of a type (parameter or member) definition. */ type TypeDefSymbol <: TypeSymbol - def matchTypeDefSymbol(symbol: Symbol) given (ctx: Context): Option[TypeDefSymbol] + def matchTypeDefSymbol(symbol: Symbol)(given ctx: Context): Option[TypeDefSymbol] - def TypeDefSymbol_isTypeParam(self: TypeDefSymbol) given (ctx: Context): Boolean + def TypeDefSymbol_isTypeParam(self: TypeDefSymbol)(given ctx: Context): Boolean /** TypeDef tree of this definition */ - def TypeDefSymbol_tree(self: TypeDefSymbol) given (ctx: Context): TypeDef + def TypeDefSymbol_tree(self: TypeDefSymbol)(given ctx: Context): TypeDef /** Symbol representing a bind definition. */ type TypeBindSymbol <: TypeSymbol - def matchTypeBindSymbol(symbol: Symbol) given (ctx: Context): Option[TypeBindSymbol] + def matchTypeBindSymbol(symbol: Symbol)(given ctx: Context): Option[TypeBindSymbol] /** TypeBind pattern of this definition */ - def TypeBindSymbol_tree(self: TypeBindSymbol) given (ctx: Context): TypeBind + def TypeBindSymbol_tree(self: TypeBindSymbol)(given ctx: Context): TypeBind type TermSymbol <: Symbol - def matchTermSymbol(symbol: Symbol) given (ctx: Context): Option[TermSymbol] + def matchTermSymbol(symbol: Symbol)(given ctx: Context): Option[TermSymbol] /** Symbol representing a method definition. */ type DefDefSymbol <: TermSymbol - def matchDefDefSymbol(symbol: Symbol) given (ctx: Context): Option[DefDefSymbol] + def matchDefDefSymbol(symbol: Symbol)(given ctx: Context): Option[DefDefSymbol] /** DefDef tree of this definition */ - def DefDefSymbol_tree(self: DefDefSymbol) given (ctx: Context): DefDef + def DefDefSymbol_tree(self: DefDefSymbol)(given ctx: Context): DefDef /** Signature of this definition */ - def DefDefSymbol_signature(self: DefDefSymbol) given (ctx: Context): Signature + def DefDefSymbol_signature(self: DefDefSymbol)(given ctx: Context): Signature /** Symbol representing a value definition. This includes `val`, `lazy val`, `var`, `object` and parameter definitions. */ type ValDefSymbol <: TermSymbol - def matchValDefSymbol(symbol: Symbol) given (ctx: Context): Option[ValDefSymbol] + def matchValDefSymbol(symbol: Symbol)(given ctx: Context): Option[ValDefSymbol] /** ValDef tree of this definition */ - def ValDefSymbol_tree(self: ValDefSymbol) given (ctx: Context): ValDef + def ValDefSymbol_tree(self: ValDefSymbol)(given ctx: Context): ValDef /** The class symbol of the companion module class */ - def ValDefSymbol_moduleClass(self: ValDefSymbol) given (ctx: Context): Option[ClassDefSymbol] + def ValDefSymbol_moduleClass(self: ValDefSymbol)(given ctx: Context): Option[ClassDefSymbol] - def ValDefSymbol_companionClass(self: ValDefSymbol) given (ctx: Context): Option[ClassDefSymbol] + def ValDefSymbol_companionClass(self: ValDefSymbol)(given ctx: Context): Option[ClassDefSymbol] /** Symbol representing a bind definition. */ type BindSymbol <: TermSymbol - def matchBindSymbol(symbol: Symbol) given (ctx: Context): Option[BindSymbol] + def matchBindSymbol(symbol: Symbol)(given ctx: Context): Option[BindSymbol] /** Bind pattern of this definition */ - def BindSymbol_tree(self: BindSymbol) given (ctx: Context): Bind + def BindSymbol_tree(self: BindSymbol)(given ctx: Context): Bind /** No symbol available. */ type NoSymbol <: Symbol - def matchNoSymbol(symbol: Symbol) given (ctx: Context): Boolean + def matchNoSymbol(symbol: Symbol)(given ctx: Context): Boolean // // FLAGS @@ -1412,20 +1412,20 @@ trait CompilerInterface { // /** View this expression `quoted.Expr[_]` as a `Term` */ - def QuotedExpr_unseal(self: scala.quoted.Expr[_]) given (ctx: Context): Term + def QuotedExpr_unseal(self: scala.quoted.Expr[_])(given ctx: Context): Term /** Checked cast to a `quoted.Expr[U]` */ - def QuotedExpr_cast[U](self: scala.quoted.Expr[_]) given (tp: scala.quoted.Type[U], ctx: Context): scala.quoted.Expr[U] + def QuotedExpr_cast[U](self: scala.quoted.Expr[_])(given tp: scala.quoted.Type[U], ctx: Context): scala.quoted.Expr[U] /** View this expression `quoted.Type[T]` as a `TypeTree` */ - def QuotedType_unseal(self: scala.quoted.Type[_]) given (ctx: Context): TypeTree + def QuotedType_unseal(self: scala.quoted.Type[_])(given ctx: Context): TypeTree /** Convert `Term` to an `quoted.Expr[Any]` */ - def QuotedExpr_seal(self: Term) given (ctx: Context): scala.quoted.Expr[Any] + def QuotedExpr_seal(self: Term)(given ctx: Context): scala.quoted.Expr[Any] /** Convert `Type` to an `quoted.Type[_]` */ - def QuotedType_seal(self: Type) given (ctx: Context): scala.quoted.Type[_] + def QuotedType_seal(self: Type)(given ctx: Context): scala.quoted.Type[_] // // DEFINITIONS @@ -1514,21 +1514,21 @@ trait CompilerInterface { type ImplicitSearchResult <: AnyRef type ImplicitSearchSuccess <: ImplicitSearchResult - def matchImplicitSearchSuccess(isr: ImplicitSearchResult) given (ctx: Context): Option[ImplicitSearchSuccess] - def ImplicitSearchSuccess_tree(self: ImplicitSearchSuccess) given (ctx: Context): Term + def matchImplicitSearchSuccess(isr: ImplicitSearchResult)(given ctx: Context): Option[ImplicitSearchSuccess] + def ImplicitSearchSuccess_tree(self: ImplicitSearchSuccess)(given ctx: Context): Term type ImplicitSearchFailure <: ImplicitSearchResult - def matchImplicitSearchFailure(isr: ImplicitSearchResult) given (ctx: Context): Option[ImplicitSearchFailure] - def ImplicitSearchFailure_explanation(self: ImplicitSearchFailure) given (ctx: Context): String + def matchImplicitSearchFailure(isr: ImplicitSearchResult)(given ctx: Context): Option[ImplicitSearchFailure] + def ImplicitSearchFailure_explanation(self: ImplicitSearchFailure)(given ctx: Context): String type DivergingImplicit <: ImplicitSearchFailure - def matchDivergingImplicit(isr: ImplicitSearchResult) given (ctx: Context): Option[DivergingImplicit] + def matchDivergingImplicit(isr: ImplicitSearchResult)(given ctx: Context): Option[DivergingImplicit] type NoMatchingImplicits <: ImplicitSearchFailure - def matchNoMatchingImplicits(isr: ImplicitSearchResult) given (ctx: Context): Option[NoMatchingImplicits] + def matchNoMatchingImplicits(isr: ImplicitSearchResult)(given ctx: Context): Option[NoMatchingImplicits] type AmbiguousImplicits <: ImplicitSearchFailure - def matchAmbiguousImplicits(isr: ImplicitSearchResult) given (ctx: Context): Option[AmbiguousImplicits] + def matchAmbiguousImplicits(isr: ImplicitSearchResult)(given ctx: Context): Option[AmbiguousImplicits] /** Find an implicit of type `T` in the current scope given by `ctx`. * Return an `ImplicitSearchResult`. @@ -1536,11 +1536,11 @@ trait CompilerInterface { * @param tpe type of the implicit parameter * @param ctx current context */ - def searchImplicit(tpe: Type) given (ctx: Context): ImplicitSearchResult + def searchImplicit(tpe: Type)(given ctx: Context): ImplicitSearchResult /** Inline fn if it is an explicit closure possibly nested inside the expression of a block. * Otherwise apply the arguments to the closure. */ - def betaReduce(f: Term, args: List[Term]) given (ctx: Context): Term + def betaReduce(f: Term, args: List[Term])(given ctx: Context): Term } diff --git a/library/src/scala/tasty/reflect/ConstantOps.scala b/library/src/scala/tasty/reflect/ConstantOps.scala index eac00149d2de..07ca627a0ea3 100644 --- a/library/src/scala/tasty/reflect/ConstantOps.scala +++ b/library/src/scala/tasty/reflect/ConstantOps.scala @@ -19,7 +19,7 @@ trait ConstantOps extends Core { /** Module of ClassTag literals */ object ClassTag { /** scala.reflect.ClassTag literal */ - def apply[T] given (x: Type): Constant = + def apply[T](given x: Type): Constant = internal.Constant_ClassTag_apply(x) /** Extractor for ClassTag literals */ diff --git a/library/src/scala/tasty/reflect/IdOps.scala b/library/src/scala/tasty/reflect/IdOps.scala index c445504ea659..d1088dfafcc6 100644 --- a/library/src/scala/tasty/reflect/IdOps.scala +++ b/library/src/scala/tasty/reflect/IdOps.scala @@ -6,15 +6,15 @@ trait IdOps extends Core { implicit class IdAPI(id: Id) { /** Position in the source code */ - def pos given (ctx: Context): Position = internal.Id_pos(id) + def pos(given ctx: Context): Position = internal.Id_pos(id) /** Name of the identifier */ - def name given (ctx: Context): String = internal.Id_name(id) + def name(given ctx: Context): String = internal.Id_name(id) } object Id { - def unapply(id: Id) given (ctx: Context): Option[String] = Some(id.name) + def unapply(id: Id)(given ctx: Context): Option[String] = Some(id.name) } } diff --git a/library/src/scala/tasty/reflect/ImplicitsOps.scala b/library/src/scala/tasty/reflect/ImplicitsOps.scala index d547b85c0baa..d8310d2ee0c9 100644 --- a/library/src/scala/tasty/reflect/ImplicitsOps.scala +++ b/library/src/scala/tasty/reflect/ImplicitsOps.scala @@ -2,39 +2,39 @@ package scala.tasty.reflect trait ImplicitsOps extends Core { - def searchImplicit(tpe: Type) given (ctx: Context): ImplicitSearchResult = + def searchImplicit(tpe: Type)(given ctx: Context): ImplicitSearchResult = internal.searchImplicit(tpe) object IsImplicitSearchSuccess { - def unapply(isr: ImplicitSearchResult) given (ctx: Context): Option[ImplicitSearchSuccess] = + def unapply(isr: ImplicitSearchResult)(given ctx: Context): Option[ImplicitSearchSuccess] = internal.matchImplicitSearchSuccess(isr) } implicit class IsImplicitSearchSuccessAPI(self: ImplicitSearchSuccess) { - def tree given (ctx: Context): Term = internal.ImplicitSearchSuccess_tree(self) + def tree(given ctx: Context): Term = internal.ImplicitSearchSuccess_tree(self) } object IsImplicitSearchFailure { - def unapply(isr: ImplicitSearchResult) given (ctx: Context): Option[ImplicitSearchFailure] = + def unapply(isr: ImplicitSearchResult)(given ctx: Context): Option[ImplicitSearchFailure] = internal.matchImplicitSearchFailure(isr) } implicit class ImplicitSearchFailureAPI(self: ImplicitSearchFailure) { - def explanation given (ctx: Context): String = internal.ImplicitSearchFailure_explanation(self) + def explanation(given ctx: Context): String = internal.ImplicitSearchFailure_explanation(self) } object IsDivergingImplicit { - def unapply(isr: ImplicitSearchResult) given (ctx: Context): Option[DivergingImplicit] = + def unapply(isr: ImplicitSearchResult)(given ctx: Context): Option[DivergingImplicit] = internal.matchDivergingImplicit(isr) } object IsNoMatchingImplicits { - def unapply(isr: ImplicitSearchResult) given (ctx: Context): Option[NoMatchingImplicits] = + def unapply(isr: ImplicitSearchResult)(given ctx: Context): Option[NoMatchingImplicits] = internal.matchNoMatchingImplicits(isr) } object IsAmbiguousImplicits { - def unapply(isr: ImplicitSearchResult) given (ctx: Context): Option[AmbiguousImplicits] = + def unapply(isr: ImplicitSearchResult)(given ctx: Context): Option[AmbiguousImplicits] = internal.matchAmbiguousImplicits(isr) } diff --git a/library/src/scala/tasty/reflect/ImportSelectorOps.scala b/library/src/scala/tasty/reflect/ImportSelectorOps.scala index 2b42b71fe989..f9eb0646ec8a 100644 --- a/library/src/scala/tasty/reflect/ImportSelectorOps.scala +++ b/library/src/scala/tasty/reflect/ImportSelectorOps.scala @@ -4,35 +4,35 @@ package reflect trait ImportSelectorOps extends Core { implicit class SimpleSelectorAPI(self: SimpleSelector) { - def selection given (ctx: Context): Id = + def selection(given ctx: Context): Id = internal.SimpleSelector_selection(self) } object SimpleSelector { - def unapply(importSelector: ImportSelector) given (ctx: Context): Option[Id] = + def unapply(importSelector: ImportSelector)(given ctx: Context): Option[Id] = internal.matchSimpleSelector(importSelector).map(_.selection) } implicit class RenameSelectorAPI(self: RenameSelector) { - def from given (ctx: Context): Id = + def from(given ctx: Context): Id = internal.RenameSelector_from(self) - def to given (ctx: Context): Id = + def to(given ctx: Context): Id = internal.RenameSelector_to(self) } object RenameSelector { - def unapply(importSelector: ImportSelector) given (ctx: Context): Option[(Id, Id)] = + def unapply(importSelector: ImportSelector)(given ctx: Context): Option[(Id, Id)] = internal.matchRenameSelector(importSelector).map(x => (x.from, x.to)) } implicit class OmitSelectorAPI(self: OmitSelector) { - def omitted given (ctx: Context): Id = + def omitted(given ctx: Context): Id = internal.SimpleSelector_omitted(self) } object OmitSelector { - def unapply(importSelector: ImportSelector) given (ctx: Context): Option[Id] = + def unapply(importSelector: ImportSelector)(given ctx: Context): Option[Id] = internal.matchOmitSelector(importSelector).map(_.omitted) } diff --git a/library/src/scala/tasty/reflect/PatternOps.scala b/library/src/scala/tasty/reflect/PatternOps.scala index f934f6da70d3..491652ba8465 100644 --- a/library/src/scala/tasty/reflect/PatternOps.scala +++ b/library/src/scala/tasty/reflect/PatternOps.scala @@ -4,116 +4,116 @@ package reflect trait PatternOps extends Core { implicit class ValueAPI(value: Value) { - def value given (ctx: Context): Term = internal.Pattern_Value_value(value) + def value(given ctx: Context): Term = internal.Pattern_Value_value(value) } implicit class BindAPI(bind: Bind) { - def name given (ctx: Context): String = internal.Pattern_Bind_name(bind) - def pattern given (ctx: Context): Pattern = internal.Pattern_Bind_pattern(bind) + def name(given ctx: Context): String = internal.Pattern_Bind_name(bind) + def pattern(given ctx: Context): Pattern = internal.Pattern_Bind_pattern(bind) } implicit class UnapplyAPI(unapply: Unapply) { - def fun given (ctx: Context): Term = internal.Pattern_Unapply_fun(unapply) - def implicits given (ctx: Context): List[Term] = internal.Pattern_Unapply_implicits(unapply) - def patterns given (ctx: Context): List[Pattern] = internal.Pattern_Unapply_patterns(unapply) + def fun(given ctx: Context): Term = internal.Pattern_Unapply_fun(unapply) + def implicits(given ctx: Context): List[Term] = internal.Pattern_Unapply_implicits(unapply) + def patterns(given ctx: Context): List[Pattern] = internal.Pattern_Unapply_patterns(unapply) } implicit class AlternativesAPI(alternatives: Alternatives) { - def patterns given (ctx: Context): List[Pattern] = internal.Pattern_Alternatives_patterns(alternatives) + def patterns(given ctx: Context): List[Pattern] = internal.Pattern_Alternatives_patterns(alternatives) } implicit class TypeTestAPI(typeTest: TypeTest) { - def tpt given (ctx: Context): TypeTree = internal.Pattern_TypeTest_tpt(typeTest) + def tpt(given ctx: Context): TypeTree = internal.Pattern_TypeTest_tpt(typeTest) } implicit class PatternAPI(self: Pattern) { /** Position in the source code */ - def pos given (ctx: Context): Position = internal.Pattern_pos(self) + def pos(given ctx: Context): Position = internal.Pattern_pos(self) - def tpe given (ctx: Context): Type = internal.Pattern_tpe(self) + def tpe(given ctx: Context): Type = internal.Pattern_tpe(self) - def symbol given (ctx: Context): Symbol = internal.Pattern_symbol(self) + def symbol(given ctx: Context): Symbol = internal.Pattern_symbol(self) } object Pattern { object IsValue { - def unapply(pattern: Pattern) given (ctx: Context): Option[Value] = + def unapply(pattern: Pattern)(given ctx: Context): Option[Value] = internal.matchPattern_Value(pattern) } object Value { - def apply(tpt: Term) given (ctx: Context): Value = + def apply(tpt: Term)(given ctx: Context): Value = internal.Pattern_Value_module_apply(tpt) - def copy(original: Value)(tpt: Term) given (ctx: Context): Value = + def copy(original: Value)(tpt: Term)(given ctx: Context): Value = internal.Pattern_Value_module_copy(original)(tpt) - def unapply(pattern: Pattern) given (ctx: Context): Option[Term] = + def unapply(pattern: Pattern)(given ctx: Context): Option[Term] = internal.matchPattern_Value(pattern).map(_.value) } object IsBind { - def unapply(pattern: Pattern) given (ctx: Context): Option[Bind] = + def unapply(pattern: Pattern)(given ctx: Context): Option[Bind] = internal.matchPattern_Bind(pattern) } object Bind { - // TODO def apply(name: String, pattern: Pattern) given (ctx: Context): Bind - def copy(original: Bind)(name: String, pattern: Pattern) given (ctx: Context): Bind = + // TODO def apply(name: String, pattern: Pattern)(given ctx: Context): Bind + def copy(original: Bind)(name: String, pattern: Pattern)(given ctx: Context): Bind = internal.Pattern_Bind_module_copy(original)(name, pattern) - def unapply(pattern: Pattern) given (ctx: Context): Option[(String, Pattern)] = + def unapply(pattern: Pattern)(given ctx: Context): Option[(String, Pattern)] = internal.matchPattern_Bind(pattern).map(x => (x.name, x.pattern)) } object IsUnapply { - def unapply(pattern: Pattern) given (ctx: Context): Option[Unapply] = + def unapply(pattern: Pattern)(given ctx: Context): Option[Unapply] = internal.matchPattern_Unapply(pattern) } object Unapply { - // TODO def apply(fun: Term, implicits: List[Term], patterns: List[Pattern]) given (ctx: Context): Unapply - def copy(original: Unapply)(fun: Term, implicits: List[Term], patterns: List[Pattern]) given (ctx: Context): Unapply = + // TODO def apply(fun: Term, implicits: List[Term], patterns: List[Pattern])(given ctx: Context): Unapply + def copy(original: Unapply)(fun: Term, implicits: List[Term], patterns: List[Pattern])(given ctx: Context): Unapply = internal.Pattern_Unapply_module_copy(original)(fun, implicits, patterns) - def unapply(pattern: Pattern) given (ctx: Context): Option[(Term, List[Term], List[Pattern])] = + def unapply(pattern: Pattern)(given ctx: Context): Option[(Term, List[Term], List[Pattern])] = internal.matchPattern_Unapply(pattern).map(x => (x.fun, x.implicits, x.patterns)) } object IsAlternatives { - def unapply(pattern: Pattern) given (ctx: Context): Option[Alternatives] = + def unapply(pattern: Pattern)(given ctx: Context): Option[Alternatives] = internal.matchPattern_Alternatives(pattern) } object Alternatives { - def apply(patterns: List[Pattern]) given (ctx: Context): Alternatives = + def apply(patterns: List[Pattern])(given ctx: Context): Alternatives = internal.Pattern_Alternatives_module_apply(patterns) - def copy(original: Alternatives)(patterns: List[Pattern]) given (ctx: Context): Alternatives = + def copy(original: Alternatives)(patterns: List[Pattern])(given ctx: Context): Alternatives = internal.Pattern_Alternatives_module_copy(original)(patterns) - def unapply(pattern: Pattern) given (ctx: Context): Option[List[Pattern]] = + def unapply(pattern: Pattern)(given ctx: Context): Option[List[Pattern]] = internal.matchPattern_Alternatives(pattern).map(_.patterns) } object IsTypeTest { - def unapply(pattern: Pattern) given (ctx: Context): Option[TypeTest] = + def unapply(pattern: Pattern)(given ctx: Context): Option[TypeTest] = internal.matchPattern_TypeTest(pattern) } object TypeTest { - def apply(tpt: TypeTree) given (ctx: Context): TypeTest = + def apply(tpt: TypeTree)(given ctx: Context): TypeTest = internal.Pattern_TypeTest_module_apply(tpt) - def copy(original: TypeTest)(tpt: TypeTree) given (ctx: Context): TypeTest = + def copy(original: TypeTest)(tpt: TypeTree)(given ctx: Context): TypeTest = internal.Pattern_TypeTest_module_copy(original)(tpt) - def unapply(pattern: Pattern) given (ctx: Context): Option[TypeTree] = + def unapply(pattern: Pattern)(given ctx: Context): Option[TypeTree] = internal.matchPattern_TypeTest(pattern).map(_.tpt) } object IsWildcardPattern { - def unapply(pattern: Pattern) given (ctx: Context): Option[WildcardPattern] = + def unapply(pattern: Pattern)(given ctx: Context): Option[WildcardPattern] = internal.matchPattern_WildcardPattern(pattern) } object WildcardPattern { - def apply(tpe: TypeOrBounds) given (ctx: Context): WildcardPattern = + def apply(tpe: TypeOrBounds)(given ctx: Context): WildcardPattern = internal.Pattern_WildcardPattern_module_apply(tpe) - def unapply(pattern: Pattern) given (ctx: Context): Boolean = + def unapply(pattern: Pattern)(given ctx: Context): Boolean = internal.matchPattern_WildcardPattern(pattern).isDefined } diff --git a/library/src/scala/tasty/reflect/Printers.scala b/library/src/scala/tasty/reflect/Printers.scala index f1ea5f80b004..e1ce0ae46175 100644 --- a/library/src/scala/tasty/reflect/Printers.scala +++ b/library/src/scala/tasty/reflect/Printers.scala @@ -21,116 +21,116 @@ trait Printers /** Adds `show` as an extension method of a `Tree` */ implicit class TreeShowDeco(tree: Tree) { /** Shows the tree as extractors */ - def showExtractors given (ctx: Context): String = new ExtractorsPrinter().showTree(tree) + def showExtractors(given ctx: Context): String = new ExtractorsPrinter().showTree(tree) /** Shows the tree as fully typed source code */ - def show given (ctx: Context): String = show(SyntaxHighlight.plain) + def show(given ctx: Context): String = show(SyntaxHighlight.plain) /** Shows the tree as fully typed source code */ - def show(syntaxHighlight: SyntaxHighlight) given (ctx: Context): String = + def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = new SourceCodePrinter(syntaxHighlight).showTree(tree) } /** Adds `show` as an extension method of a `TypeOrBounds` */ implicit class TypeOrBoundsShowDeco(tpe: TypeOrBounds) { /** Shows the tree as extractors */ - def showExtractors given (ctx: Context): String = new ExtractorsPrinter().showTypeOrBounds(tpe) + def showExtractors(given ctx: Context): String = new ExtractorsPrinter().showTypeOrBounds(tpe) /** Shows the tree as fully typed source code */ - def show given (ctx: Context): String = show(SyntaxHighlight.plain) + def show(given ctx: Context): String = show(SyntaxHighlight.plain) /** Shows the tree as fully typed source code */ - def show(syntaxHighlight: SyntaxHighlight) given (ctx: Context): String = + def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = new SourceCodePrinter(syntaxHighlight).showTypeOrBounds(tpe) } /** Adds `show` as an extension method of a `Pattern` */ implicit class PatternShowDeco(pattern: Pattern) { /** Shows the tree as extractors */ - def showExtractors given (ctx: Context): String = new ExtractorsPrinter().showPattern(pattern) + def showExtractors(given ctx: Context): String = new ExtractorsPrinter().showPattern(pattern) /** Shows the tree as fully typed source code */ - def show given (ctx: Context): String = show(SyntaxHighlight.plain) + def show(given ctx: Context): String = show(SyntaxHighlight.plain) /** Shows the tree as fully typed source code */ - def show(syntaxHighlight: SyntaxHighlight) given (ctx: Context): String = + def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = new SourceCodePrinter(syntaxHighlight).showPattern(pattern) } /** Adds `show` as an extension method of a `Constant` */ implicit class ConstantShowDeco(const: Constant) { /** Shows the tree as extractors */ - def showExtractors given (ctx: Context): String = new ExtractorsPrinter().showConstant(const) + def showExtractors(given ctx: Context): String = new ExtractorsPrinter().showConstant(const) /** Shows the tree as fully typed source code */ - def show given (ctx: Context): String = show(SyntaxHighlight.plain) + def show(given ctx: Context): String = show(SyntaxHighlight.plain) /** Shows the tree as fully typed source code */ - def show(syntaxHighlight: SyntaxHighlight) given (ctx: Context): String = + def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = new SourceCodePrinter(syntaxHighlight).showConstant(const) } /** Adds `show` as an extension method of a `Symbol` */ implicit class SymbolShowDeco(symbol: Symbol) { /** Shows the tree as extractors */ - def showExtractors given (ctx: Context): String = new ExtractorsPrinter().showSymbol(symbol) + def showExtractors(given ctx: Context): String = new ExtractorsPrinter().showSymbol(symbol) /** Shows the tree as fully typed source code */ - def show given (ctx: Context): String = show(SyntaxHighlight.plain) + def show(given ctx: Context): String = show(SyntaxHighlight.plain) /** Shows the tree as fully typed source code */ - def show(syntaxHighlight: SyntaxHighlight) given (ctx: Context): String = + def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = new SourceCodePrinter(syntaxHighlight).showSymbol(symbol) } /** Adds `show` as an extension method of a `Flags` */ implicit class FlagsShowDeco(flags: Flags) { /** Shows the tree as extractors */ - def showExtractors given (ctx: Context): String = new ExtractorsPrinter().showFlags(flags) + def showExtractors(given ctx: Context): String = new ExtractorsPrinter().showFlags(flags) /** Shows the tree as fully typed source code */ - def show given (ctx: Context): String = show(SyntaxHighlight.plain) + def show(given ctx: Context): String = show(SyntaxHighlight.plain) /** Shows the tree as fully typed source code */ - def show(syntaxHighlight: SyntaxHighlight) given (ctx: Context): String = + def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = new SourceCodePrinter(syntaxHighlight).showFlags(flags) } abstract class Printer { - def showTree(tree: Tree) given (ctx: Context): String + def showTree(tree: Tree)(given ctx: Context): String - def showPattern(pattern: Pattern) given (ctx: Context): String + def showPattern(pattern: Pattern)(given ctx: Context): String - def showTypeOrBounds(tpe: TypeOrBounds) given (ctx: Context): String + def showTypeOrBounds(tpe: TypeOrBounds)(given ctx: Context): String - def showConstant(const: Constant) given (ctx: Context): String + def showConstant(const: Constant)(given ctx: Context): String - def showSymbol(symbol: Symbol) given (ctx: Context): String + def showSymbol(symbol: Symbol)(given ctx: Context): String - def showFlags(flags: Flags) given (ctx: Context): String + def showFlags(flags: Flags)(given ctx: Context): String } class ExtractorsPrinter extends Printer { - def showTree(tree: Tree) given (ctx: Context): String = + def showTree(tree: Tree)(given ctx: Context): String = new Buffer().visitTree(tree).result() - def showPattern(pattern: Pattern) given (ctx: Context): String = + def showPattern(pattern: Pattern)(given ctx: Context): String = new Buffer().visitPattern(pattern).result() - def showTypeOrBounds(tpe: TypeOrBounds) given (ctx: Context): String = + def showTypeOrBounds(tpe: TypeOrBounds)(given ctx: Context): String = new Buffer().visitType(tpe).result() - def showConstant(const: Constant) given (ctx: Context): String = + def showConstant(const: Constant)(given ctx: Context): String = new Buffer().visitConstant(const).result() - def showSymbol(symbol: Symbol) given (ctx: Context): String = + def showSymbol(symbol: Symbol)(given ctx: Context): String = new Buffer().visitSymbol(symbol).result() - def showFlags(flags: Flags) given (ctx: Context): String = { + def showFlags(flags: Flags)(given ctx: Context): String = { val flagList = List.newBuilder[String] if (flags.is(Flags.Private)) flagList += "Flags.Private" if (flags.is(Flags.Protected)) flagList += "Flags.Protected" @@ -168,7 +168,7 @@ trait Printers flagList.result().mkString(" | ") } - private class Buffer given (ctx: Context) { self => + private class Buffer(given ctx: Context) { self => private val sb: StringBuilder = new StringBuilder @@ -457,22 +457,22 @@ trait Printers class SourceCodePrinter(syntaxHighlight: SyntaxHighlight) extends Printer { import syntaxHighlight._ - def showTree(tree: Tree) given (ctx: Context): String = + def showTree(tree: Tree)(given ctx: Context): String = (new Buffer).printTree(tree).result() - def showPattern(pattern: Pattern) given (ctx: Context): String = + def showPattern(pattern: Pattern)(given ctx: Context): String = (new Buffer).printPattern(pattern).result() - def showTypeOrBounds(tpe: TypeOrBounds) given (ctx: Context): String = - ((new Buffer).printTypeOrBound(tpe) given None).result() + def showTypeOrBounds(tpe: TypeOrBounds)(given ctx: Context): String = + (new Buffer).printTypeOrBound(tpe)(given None).result() - def showConstant(const: Constant) given (ctx: Context): String = + def showConstant(const: Constant)(given ctx: Context): String = (new Buffer).printConstant(const).result() - def showSymbol(symbol: Symbol) given (ctx: Context): String = + def showSymbol(symbol: Symbol)(given ctx: Context): String = symbol.fullName - def showFlags(flags: Flags) given (ctx: Context): String = { + def showFlags(flags: Flags)(given ctx: Context): String = { val flagList = List.newBuilder[String] if (flags.is(Flags.Private)) flagList += "private" if (flags.is(Flags.Protected)) flagList += "protected" @@ -510,7 +510,7 @@ trait Printers flagList.result().mkString("/*", " ", "*/") } - private class Buffer given (ctx: Context) { + private class Buffer(given ctx: Context) { private[this] val sb: StringBuilder = new StringBuilder @@ -547,7 +547,7 @@ trait Printers def lineBreak(): String = "\n" + (" " * indent) def doubleLineBreak(): String = "\n\n" + (" " * indent) - def printTree(tree: Tree) given (elideThis: Option[Symbol] = None): Buffer = tree match { + def printTree(tree: Tree)(given elideThis: Option[Symbol] = None): Buffer = tree match { case PackageObject(body)=> printTree(body) // Print package object @@ -612,19 +612,19 @@ trait Printers def printParent(parent: Tree /* Term | TypeTree */, needEmptyParens: Boolean = false): Unit = parent match { case IsTypeTree(parent) => - printTypeTree(parent) given Some(cdef.symbol) + printTypeTree(parent)(given Some(cdef.symbol)) case IsTerm(TypeApply(fun, targs)) => printParent(fun) case IsTerm(Apply(fun@Apply(_,_), args)) => printParent(fun, true) if (!args.isEmpty || needEmptyParens) - inParens(printTrees(args, ", ") given Some(cdef.symbol)) + inParens(printTrees(args, ", ")(given Some(cdef.symbol))) case IsTerm(Apply(fun, args)) => printParent(fun) if (!args.isEmpty || needEmptyParens) - inParens(printTrees(args, ", ") given Some(cdef.symbol)) + inParens(printTrees(args, ", ")(given Some(cdef.symbol))) case IsTerm(Select(IsNew(newTree), _)) => - printType(newTree.tpe) given Some(cdef.symbol) + printType(newTree.tpe)(given Some(cdef.symbol)) case IsTerm(parent) => throw new MatchError(parent.showExtractors) } @@ -676,7 +676,7 @@ trait Printers indented { val name1 = if (name == "_") "this" else name this += " " += highlightValDef(name1) += ": " - printTypeTree(tpt) given Some(cdef.symbol) + printTypeTree(tpt)(given Some(cdef.symbol)) this += " =>" } } @@ -1016,7 +1016,7 @@ trait Printers (flatStats.result(), flatExpr) } - def printFlatBlock(stats: List[Statement], expr: Term) given (elideThis: Option[Symbol]): Buffer = { + def printFlatBlock(stats: List[Statement], expr: Term)(given elideThis: Option[Symbol]): Buffer = { val (stats1, expr1) = flatBlock(stats, expr) val stats2 = stats1.filter { case IsTypeDef(tree) => !tree.symbol.annots.exists(_.symbol.owner.fullName == "scala.internal.Quoted$.quoteTypeTag") @@ -1033,7 +1033,7 @@ trait Printers } } - def printStats(stats: List[Tree], expr: Tree) given (elideThis: Option[Symbol]): Unit = { + def printStats(stats: List[Tree], expr: Tree)(given eliseThis: Option[Symbol]): Unit = { def printSeparator(next: Tree): Unit = { // Avoid accidental application of opening `{` on next line with a double break def rec(next: Tree): Unit = next match { @@ -1081,13 +1081,13 @@ trait Printers this } - def printTrees(trees: List[Tree], sep: String) given (elideThis: Option[Symbol]): Buffer = + def printTrees(trees: List[Tree], sep: String)(given elideThis: Option[Symbol]): Buffer = printList(trees, sep, (t: Tree) => printTree(t)) - def printTypeTrees(trees: List[TypeTree], sep: String) given (elideThis: Option[Symbol] = None): Buffer = + def printTypeTrees(trees: List[TypeTree], sep: String)(given elideThis: Option[Symbol] = None): Buffer = printList(trees, sep, (t: TypeTree) => printTypeTree(t)) - def printTypes(trees: List[Type], sep: String) given (elideThis: Option[Symbol]): Buffer = { + def printTypes(trees: List[Type], sep: String)(given elideThis: Option[Symbol]): Buffer = { def printSeparated(list: List[Type]): Unit = list match { case Nil => case x :: Nil => printType(x) @@ -1153,7 +1153,7 @@ trait Printers this } - def printTypesOrBounds(types: List[TypeOrBounds], sep: String) given (elideThis: Option[Symbol]): Buffer = { + def printTypesOrBounds(types: List[TypeOrBounds], sep: String)(given elideThis: Option[Symbol]): Buffer = { def printSeparated(list: List[TypeOrBounds]): Unit = list match { case Nil => case x :: Nil => printTypeOrBound(x) @@ -1166,7 +1166,7 @@ trait Printers this } - def printTargsDefs(targs: List[(TypeDef, TypeDef)], isDef:Boolean = true) given (elideThis: Option[Symbol]): Unit = { + def printTargsDefs(targs: List[(TypeDef, TypeDef)], isDef:Boolean = true)(given elideThis: Option[Symbol]): Unit = { if (!targs.isEmpty) { def printSeparated(list: List[(TypeDef, TypeDef)]): Unit = list match { case Nil => @@ -1181,7 +1181,7 @@ trait Printers } } - def printTargDef(arg: (TypeDef, TypeDef), isMember: Boolean = false, isDef:Boolean = true) given (elideThis: Option[Symbol]): Buffer = { + def printTargDef(arg: (TypeDef, TypeDef), isMember: Boolean = false, isDef:Boolean = true)(given elideThis: Option[Symbol]): Buffer = { val (argDef, argCons) = arg if (isDef) { @@ -1231,7 +1231,7 @@ trait Printers } } - def printArgsDefs(args: List[ValDef]) given (elideThis: Option[Symbol]): Unit = { + def printArgsDefs(args: List[ValDef])(given elideThis: Option[Symbol]): Unit = { val argFlags = args match { case Nil => Flags.EmptyFlags case arg :: _ => arg.symbol.flags @@ -1257,7 +1257,7 @@ trait Printers } } - def printAnnotations(trees: List[Term]) given (elideThis: Option[Symbol]): Buffer = { + def printAnnotations(trees: List[Term])(given elideThis: Option[Symbol]): Buffer = { def printSeparated(list: List[Term]): Unit = list match { case Nil => case x :: Nil => printAnnotation(x) @@ -1270,7 +1270,7 @@ trait Printers this } - def printParamDef(arg: ValDef) given (elideThis: Option[Symbol]): Unit = { + def printParamDef(arg: ValDef)(given elideThis: Option[Symbol]): Unit = { val name = arg.name arg.symbol.owner match { case IsDefDefSymbol(sym) if sym.name == "" => @@ -1308,7 +1308,7 @@ trait Printers indented { caseDef.rhs match { case Block(stats, expr) => - printStats(stats, expr) given None + printStats(stats, expr)(given None) case body => this += lineBreak() printTree(body) @@ -1390,7 +1390,7 @@ trait Printers inSquare(printType(v)) } - def printTypeOrBoundsTree(tpt: Tree) given (elideThis: Option[Symbol] = None): Buffer = tpt match { + def printTypeOrBoundsTree(tpt: Tree)(given elideThis: Option[Symbol] = None): Buffer = tpt match { case TypeBoundsTree(lo, hi) => this += "_ >: " printTypeTree(lo) @@ -1410,7 +1410,7 @@ trait Printers * Self type annotation and types in parent list should elide current class * prefix `C.this` to avoid type checking errors. */ - def printTypeTree(tree: TypeTree) given (elideThis: Option[Symbol] = None): Buffer = tree match { + def printTypeTree(tree: TypeTree)(given elideThis: Option[Symbol] = None): Buffer = tree match { case Inferred() => // TODO try to move this logic into `printType` def printTypeAndAnnots(tpe: Type): Buffer = tpe match { @@ -1496,7 +1496,7 @@ trait Printers } - def printTypeOrBound(tpe: TypeOrBounds) given (elideThis: Option[Symbol]): Buffer = tpe match { + def printTypeOrBound(tpe: TypeOrBounds)(given elideThis: Option[Symbol]): Buffer = tpe match { case tpe@TypeBounds(lo, hi) => this += "_ >: " printType(lo) @@ -1513,7 +1513,7 @@ trait Printers * Self type annotation and types in parent list should elide current class * prefix `C.this` to avoid type checking errors. */ - def printType(tpe: Type) given (elideThis: Option[Symbol] = None): Buffer = tpe match { + def printType(tpe: Type)(given elideThis: Option[Symbol] = None): Buffer = tpe match { case Type.ConstantType(const) => printConstant(const) @@ -1673,7 +1673,7 @@ trait Printers case PackageDef(name, _) => this += highlightTypeDef(name) } - def printAnnotation(annot: Term) given (elideThis: Option[Symbol]): Buffer = { + def printAnnotation(annot: Term)(given elideThis: Option[Symbol]): Buffer = { val Annotation(ref, args) = annot this += "@" printTypeTree(ref) @@ -1683,7 +1683,7 @@ trait Printers inParens(printTrees(args, ", ")) } - def printDefAnnotations(definition: Definition) given (elideThis: Option[Symbol]): Buffer = { + def printDefAnnotations(definition: Definition)(given elideThis: Option[Symbol]): Buffer = { val annots = definition.symbol.annots.filter { case Annotation(annot, _) => annot.tpe match { @@ -1699,7 +1699,7 @@ trait Printers else this } - def printRefinement(tpe: Type) given (elideThis: Option[Symbol]): Buffer = { + def printRefinement(tpe: Type)(given elideThis: Option[Symbol]): Buffer = { def printMethodicType(tp: TypeOrBounds): Unit = tp match { case tp @ Type.MethodType(paramNames, params, res) => inParens(printMethodicTypeParams(paramNames, params)) @@ -1739,7 +1739,7 @@ trait Printers this += lineBreak() += "}" } - def printMethodicTypeParams(paramNames: List[String], params: List[TypeOrBounds]) given (elideThis: Option[Symbol]): Unit = { + def printMethodicTypeParams(paramNames: List[String], params: List[TypeOrBounds])(given elideThis: Option[Symbol]): Unit = { def printInfo(info: TypeOrBounds) = info match { case IsTypeBounds(info) => printBounds(info) case IsType(info) => @@ -1760,7 +1760,7 @@ trait Printers printSeparated(paramNames.zip(params)) } - def printBoundsTree(bounds: TypeBoundsTree) given (elideThis: Option[Symbol]): Buffer = { + def printBoundsTree(bounds: TypeBoundsTree)(given elideThis: Option[Symbol]): Buffer = { bounds.low match { case Inferred() => case low => @@ -1775,7 +1775,7 @@ trait Printers } } - def printBounds(bounds: TypeBounds) given (elideThis: Option[Symbol]): Buffer = { + def printBounds(bounds: TypeBounds)(given elideThis: Option[Symbol]): Buffer = { this += " >: " printType(bounds.low) this += " <: " @@ -1848,7 +1848,7 @@ trait Printers } private object SpecialOp { - def unapply(arg: Tree) given (ctx: Context): Option[(String, List[Term])] = arg match { + def unapply(arg: Tree)(given ctx: Context): Option[(String, List[Term])] = arg match { case IsTerm(arg @ Apply(fn, args)) => fn.tpe match { case tpe @ Type.TermRef(Type.ThisType(Type.TypeRef(_, name)), name2) if name == "" => @@ -1860,7 +1860,7 @@ trait Printers } private object Annotation { - def unapply(arg: Tree) given (ctx: Context): Option[(TypeTree, List[Term])] = arg match { + def unapply(arg: Tree)(given ctx: Context): Option[(TypeTree, List[Term])] = arg match { case New(annot) => Some((annot, Nil)) case Apply(Select(New(annot), ""), args) => Some((annot, args)) case Apply(TypeApply(Select(New(annot), ""), targs), args) => Some((annot, args)) @@ -1872,14 +1872,14 @@ trait Printers private object Types { object JavaLangObject { - def unapply(tpe: Type) given (ctx: Context): Boolean = tpe match { + def unapply(tpe: Type)(given ctx: Context): Boolean = tpe match { case Type.TypeRef(Type.IsTermRef(prefix), "Object") => prefix.typeSymbol.fullName == "java.lang" case _ => false } } object Sequence { - def unapply(tpe: Type) given (ctx: Context): Option[Type] = tpe match { + def unapply(tpe: Type)(given ctx: Context): Option[Type] = tpe match { case Type.AppliedType(Type.TypeRef(Type.IsTermRef(prefix), "Seq"), IsType(tp) :: Nil) if prefix.termSymbol.fullName == "scala.collection" => Some(tp) case Type.AppliedType(Type.TypeRef(Type.IsTypeRef(prefix), "Seq"), IsType(tp) :: Nil) if prefix.typeSymbol.fullName == "scala.collection" => Some(tp) case _ => None @@ -1887,7 +1887,7 @@ trait Printers } object RepeatedAnnotation { - def unapply(tpe: Type) given (ctx: Context): Boolean = tpe match { + def unapply(tpe: Type)(given ctx: Context): Boolean = tpe match { case Type.TypeRef(Type.IsTermRef(prefix), "Repeated") => prefix.termSymbol.fullName == "scala.annotation.internal" case Type.TypeRef(Type.IsTypeRef(prefix), "Repeated") => prefix.typeSymbol.fullName == "scala.annotation.internal" case _ => false @@ -1895,14 +1895,14 @@ trait Printers } object Repeated { - def unapply(tpe: Type) given (ctx: Context): Option[Type] = tpe match { + def unapply(tpe: Type)(given ctx: Context): Option[Type] = tpe match { case Type.AppliedType(Type.TypeRef(ScalaPackage(), ""), IsType(tp) :: Nil) => Some(tp) case _ => None } } object ScalaPackage { - def unapply(tpe: TypeOrBounds) given (ctx: Context): Boolean = tpe match { + def unapply(tpe: TypeOrBounds)(given ctx: Context): Boolean = tpe match { case Type.IsTermRef(tpe) => tpe.termSymbol == defn.ScalaPackage case _ => false } @@ -1911,7 +1911,7 @@ trait Printers } object PackageObject { - def unapply(tree: Tree) given (ctx: Context): Option[Tree] = tree match { + def unapply(tree: Tree)(given ctx: Context): Option[Tree] = tree match { case PackageClause(_, ValDef("package", _, _) :: body :: Nil) => Some(body) case _ => None } diff --git a/library/src/scala/tasty/reflect/QuotedOps.scala b/library/src/scala/tasty/reflect/QuotedOps.scala index ef0b40c2dfde..651fa3bd2351 100644 --- a/library/src/scala/tasty/reflect/QuotedOps.scala +++ b/library/src/scala/tasty/reflect/QuotedOps.scala @@ -5,29 +5,29 @@ trait QuotedOps extends Core { self: Printers => implicit class QuotedExprAPI[T](expr: scala.quoted.Expr[T]) { /** View this expression `quoted.Expr[T]` as a `Term` */ - def unseal given (ctx: Context): Term = + def unseal(given ctx: Context): Term = internal.QuotedExpr_unseal(expr) /** Checked cast to a `quoted.Expr[U]` */ - def cast[U: scala.quoted.Type] given (ctx: Context): scala.quoted.Expr[U] = + def cast[U: scala.quoted.Type](given ctx: Context): scala.quoted.Expr[U] = internal.QuotedExpr_cast[U](expr) } implicit class QuotedTypeAPI[T <: AnyKind](tpe: scala.quoted.Type[T]) { /** View this expression `quoted.Type[T]` as a `TypeTree` */ - def unseal given (ctx: Context): TypeTree = + def unseal(given ctx: Context): TypeTree = internal.QuotedType_unseal(tpe) } implicit class TermToQuotedAPI(term: Term) { /** Convert `Term` to an `quoted.Expr[Any]` */ - def seal given (ctx: Context): scala.quoted.Expr[Any] = + def seal(given ctx: Context): scala.quoted.Expr[Any] = internal.QuotedExpr_seal(term) } implicit class TypeToQuotedAPI(tpe: Type) { /** Convert `Type` to an `quoted.Type[_]` */ - def seal given (ctx: Context): scala.quoted.Type[_] = + def seal(given ctx: Context): scala.quoted.Type[_] = internal.QuotedType_seal(tpe) } } diff --git a/library/src/scala/tasty/reflect/ReportingOps.scala b/library/src/scala/tasty/reflect/ReportingOps.scala index 11186dc2c3b0..e36ff1faafab 100644 --- a/library/src/scala/tasty/reflect/ReportingOps.scala +++ b/library/src/scala/tasty/reflect/ReportingOps.scala @@ -2,15 +2,15 @@ package scala.tasty.reflect trait ReportingOps extends Core { - def error(msg: => String, pos: Position) given (ctx: Context): Unit = + def error(msg: => String, pos: Position)(given ctx: Context): Unit = internal.error(msg, pos) - def error(msg: => String, source: SourceFile, start: Int, end: Int) given (ctx: Context): Unit = + def error(msg: => String, source: SourceFile, start: Int, end: Int)(given ctx: Context): Unit = internal.error(msg, source, start, end) - def warning(msg: => String, pos: Position) given (ctx: Context): Unit = + def warning(msg: => String, pos: Position)(given ctx: Context): Unit = internal.warning(msg, pos) - def warning(msg: => String, source: SourceFile, start: Int, end: Int) given (ctx: Context): Unit = + def warning(msg: => String, source: SourceFile, start: Int, end: Int)(given ctx: Context): Unit = internal.warning(msg, source, start, end) } diff --git a/library/src/scala/tasty/reflect/SignatureOps.scala b/library/src/scala/tasty/reflect/SignatureOps.scala index bff5d4d894bc..d03026a625a2 100644 --- a/library/src/scala/tasty/reflect/SignatureOps.scala +++ b/library/src/scala/tasty/reflect/SignatureOps.scala @@ -5,7 +5,7 @@ trait SignatureOps extends Core { /** The signature of a method */ object Signature { /** Matches the method signature and returns its parameters and result type. */ - def unapply(sig: Signature) given (ctx: Context): Option[(List[String | Int], String)] = + def unapply(sig: Signature)(given ctx: Context): Option[(List[String | Int], String)] = Some((sig.paramSigs, sig.resultSig)) } diff --git a/library/src/scala/tasty/reflect/SymbolOps.scala b/library/src/scala/tasty/reflect/SymbolOps.scala index 01e071577336..e84f6d84778f 100644 --- a/library/src/scala/tasty/reflect/SymbolOps.scala +++ b/library/src/scala/tasty/reflect/SymbolOps.scala @@ -9,255 +9,255 @@ trait SymbolOps extends Core { implicit class SymbolAPI(self: Symbol) { /** Owner of this symbol. The owner is the symbol in which this symbol is defined */ - def owner given (ctx: Context): Symbol = internal.Symbol_owner(self) + def owner(given ctx: Context): Symbol = internal.Symbol_owner(self) /** Flags of this symbol */ - def flags given (ctx: Context): Flags = internal.Symbol_flags(self) + def flags(given ctx: Context): Flags = internal.Symbol_flags(self) /** This symbol is private within the resulting type */ - def privateWithin given (ctx: Context): Option[Type] = internal.Symbol_privateWithin(self) + def privateWithin(given ctx: Context): Option[Type] = internal.Symbol_privateWithin(self) /** This symbol is protected within the resulting type */ - def protectedWithin given (ctx: Context): Option[Type] = internal.Symbol_protectedWithin(self) + def protectedWithin(given ctx: Context): Option[Type] = internal.Symbol_protectedWithin(self) /** The name of this symbol */ - def name given (ctx: Context): String = internal.Symbol_name(self) + def name(given ctx: Context): String = internal.Symbol_name(self) /** The full name of this symbol up to the root package */ - def fullName given (ctx: Context): String = internal.Symbol_fullName(self) + def fullName(given ctx: Context): String = internal.Symbol_fullName(self) /** The position of this symbol */ - def pos given (ctx: Context): Position = internal.Symbol_pos(self) + def pos(given ctx: Context): Position = internal.Symbol_pos(self) - def localContext given (ctx: Context): Context = internal.Symbol_localContext(self) + def localContext(given ctx: Context): Context = internal.Symbol_localContext(self) /** The comment for this symbol, if any */ - def comment given (ctx: Context): Option[Comment] = internal.Symbol_comment(self) + def comment(given ctx: Context): Option[Comment] = internal.Symbol_comment(self) /** Unsafe cast as to PackageSymbol. Use IsPackageSymbol to safely check and cast to PackageSymbol */ - def asPackageDef given (ctx: Context): PackageDefSymbol = self match { + def asPackageDef(given ctx: Context): PackageDefSymbol = self match { case IsPackageDefSymbol(self) => self case _ => throw new Exception("not a PackageDefSymbol") } /** Unsafe cast as to ClassSymbol. Use IsClassDefSymbol to safely check and cast to ClassSymbol */ - def asClassDef given (ctx: Context): ClassDefSymbol = self match { + def asClassDef(given ctx: Context): ClassDefSymbol = self match { case IsClassDefSymbol(self) => self case _ => throw new Exception("not a ClassDefSymbol") } /** Unsafe cast as to DefSymbol. Use IsDefDefSymbol to safely check and cast to DefSymbol */ - def asDefDef given (ctx: Context): DefDefSymbol = self match { + def asDefDef(given ctx: Context): DefDefSymbol = self match { case IsDefDefSymbol(self) => self case _ => throw new Exception("not a DefDefSymbol") } /** Unsafe cast as to ValSymbol. Use IsValDefSymbol to safely check and cast to ValSymbol */ - def asValDef given (ctx: Context): ValDefSymbol = self match { + def asValDef(given ctx: Context): ValDefSymbol = self match { case IsValDefSymbol(self) => self case _ => throw new Exception("not a ValDefSymbol") } /** Unsafe cast as to TypeSymbol. Use IsTypeDefSymbol to safely check and cast to TypeSymbol */ - def asTypeDef given (ctx: Context): TypeDefSymbol = self match { + def asTypeDef(given ctx: Context): TypeDefSymbol = self match { case IsTypeDefSymbol(self) => self case _ => throw new Exception("not a TypeDefSymbol") } /** Unsafe cast as to BindSymbol. Use IsBindSymbol to safely check and cast to BindSymbol */ - def asBindDef given (ctx: Context): BindSymbol = self match { + def asBindDef(given ctx: Context): BindSymbol = self match { case IsBindSymbol(self) => self case _ => throw new Exception("not a BindSymbol") } /** Annotations attached to this symbol */ - def annots given (ctx: Context): List[Term] = internal.Symbol_annots(self) - - def isDefinedInCurrentRun given (ctx: Context): Boolean = internal.Symbol_isDefinedInCurrentRun(self) - - def isLocalDummy given (ctx: Context): Boolean = internal.Symbol_isLocalDummy(self) - def isRefinementClass given (ctx: Context): Boolean = internal.Symbol_isRefinementClass(self) - def isAliasType given (ctx: Context): Boolean = internal.Symbol_isAliasType(self) - def isAnonymousClass given (ctx: Context): Boolean = internal.Symbol_isAnonymousClass(self) - def isAnonymousFunction given (ctx: Context): Boolean = internal.Symbol_isAnonymousFunction(self) - def isAbstractType given (ctx: Context): Boolean = internal.Symbol_isAbstractType(self) - def isClassConstructor given (ctx: Context): Boolean = internal.Symbol_isClassConstructor(self) - - def isType given (ctx: Context): Boolean = internal.matchTypeSymbol(self).isDefined - def isTerm given (ctx: Context): Boolean = internal.matchTermSymbol(self).isDefined - def isValDef given (ctx: Context): Boolean = internal.matchValDefSymbol(self).isDefined - def isDefDef given (ctx: Context): Boolean = internal.matchDefDefSymbol(self).isDefined - def isClass given (ctx: Context): Boolean = internal.matchClassDefSymbol(self).isDefined + def annots(given ctx: Context): List[Term] = internal.Symbol_annots(self) + + def isDefinedInCurrentRun(given ctx: Context): Boolean = internal.Symbol_isDefinedInCurrentRun(self) + + def isLocalDummy(given ctx: Context): Boolean = internal.Symbol_isLocalDummy(self) + def isRefinementClass(given ctx: Context): Boolean = internal.Symbol_isRefinementClass(self) + def isAliasType(given ctx: Context): Boolean = internal.Symbol_isAliasType(self) + def isAnonymousClass(given ctx: Context): Boolean = internal.Symbol_isAnonymousClass(self) + def isAnonymousFunction(given ctx: Context): Boolean = internal.Symbol_isAnonymousFunction(self) + def isAbstractType(given ctx: Context): Boolean = internal.Symbol_isAbstractType(self) + def isClassConstructor(given ctx: Context): Boolean = internal.Symbol_isClassConstructor(self) + + def isType(given ctx: Context): Boolean = internal.matchTypeSymbol(self).isDefined + def isTerm(given ctx: Context): Boolean = internal.matchTermSymbol(self).isDefined + def isValDef(given ctx: Context): Boolean = internal.matchValDefSymbol(self).isDefined + def isDefDef(given ctx: Context): Boolean = internal.matchDefDefSymbol(self).isDefined + def isClass(given ctx: Context): Boolean = internal.matchClassDefSymbol(self).isDefined } // PackageSymbol object IsPackageDefSymbol { - def unapply(symbol: Symbol) given (ctx: Context): Option[PackageDefSymbol] = + def unapply(symbol: Symbol)(given ctx: Context): Option[PackageDefSymbol] = internal.matchPackageDefSymbol(symbol) } implicit class PackageDefSymbolAPI(self: PackageDefSymbol) { - def tree given (ctx: Context): PackageDef = + def tree(given ctx: Context): PackageDef = internal.PackageDefSymbol_tree(self) } // TypeSymbol object IsTypeSymbol { - def unapply(symbol: Symbol) given (ctx: Context): Option[TypeSymbol] = + def unapply(symbol: Symbol)(given ctx: Context): Option[TypeSymbol] = internal.matchTypeSymbol(symbol) } // ClassSymbol object IsClassDefSymbol { - def unapply(symbol: Symbol) given (ctx: Context): Option[ClassDefSymbol] = + def unapply(symbol: Symbol)(given ctx: Context): Option[ClassDefSymbol] = internal.matchClassDefSymbol(symbol) } object ClassDefSymbol { /** The ClassSymbol of a global class definition */ - def of(fullName: String) given (ctx: Context): ClassDefSymbol = + def of(fullName: String)(given ctx: Context): ClassDefSymbol = internal.ClassDefSymbol_of(fullName) } implicit class ClassDefSymbolAPI(self: ClassDefSymbol) { /** ClassDef tree of this defintion */ - def tree given (ctx: Context): ClassDef = + def tree(given ctx: Context): ClassDef = internal.ClassDefSymbol_tree(self) /** Fields directly declared in the class */ - def fields given (ctx: Context): List[Symbol] = + def fields(given ctx: Context): List[Symbol] = internal.ClassDefSymbol_fields(self) /** Field with the given name directly declared in the class */ - def field(name: String) given (ctx: Context): Option[Symbol] = + def field(name: String)(given ctx: Context): Option[Symbol] = internal.ClassDefSymbol_field(self)(name) /** Get non-private named methods defined directly inside the class */ - def classMethod(name: String) given (ctx: Context): List[DefDefSymbol] = + def classMethod(name: String)(given ctx: Context): List[DefDefSymbol] = internal.ClassDefSymbol_classMethod(self)(name) /** Get all non-private methods defined directly inside the class, exluding constructors */ - def classMethods given (ctx: Context): List[DefDefSymbol] = + def classMethods(given ctx: Context): List[DefDefSymbol] = internal.ClassDefSymbol_classMethods(self) /** Get named non-private methods declared or inherited */ - def method(name: String) given (ctx: Context): List[DefDefSymbol] = + def method(name: String)(given ctx: Context): List[DefDefSymbol] = internal.ClassDefSymbol_method(self)(name) /** Get all non-private methods declared or inherited */ - def methods given (ctx: Context): List[DefDefSymbol] = + def methods(given ctx: Context): List[DefDefSymbol] = internal.ClassDefSymbol_methods(self) /** Fields of a case class type -- only the ones declared in primary constructor */ - def caseFields given (ctx: Context): List[ValDefSymbol] = + def caseFields(given ctx: Context): List[ValDefSymbol] = internal.ClassDefSymbol_caseFields(self) /** The class symbol of the companion module class */ - def companionClass given (ctx: Context): Option[ClassDefSymbol] = + def companionClass(given ctx: Context): Option[ClassDefSymbol] = internal.ClassDefSymbol_companionClass(self) /** The symbol of the companion module */ - def companionModule given (ctx: Context): Option[ValDefSymbol] = + def companionModule(given ctx: Context): Option[ValDefSymbol] = internal.ClassDefSymbol_companionModule(self) /** The symbol of the class of the companion module */ - def moduleClass given (ctx: Context): Option[Symbol] = + def moduleClass(given ctx: Context): Option[Symbol] = internal.ClassDefSymbol_moduleClass(self) } // TypeSymbol object IsTypeDefSymbol { - def unapply(symbol: Symbol) given (ctx: Context): Option[TypeDefSymbol] = + def unapply(symbol: Symbol)(given ctx: Context): Option[TypeDefSymbol] = internal.matchTypeDefSymbol(symbol) } implicit class TypeDefSymbolAPI(self: TypeDefSymbol) { /** TypeDef tree of this definition */ - def tree given (ctx: Context): TypeDef = + def tree(given ctx: Context): TypeDef = internal.TypeDefSymbol_tree(self) - def isTypeParam given (ctx: Context): Boolean = + def isTypeParam(given ctx: Context): Boolean = internal.TypeDefSymbol_isTypeParam(self) } // TypeBindSymbol object IsTypeBindSymbol { - def unapply(symbol: Symbol) given (ctx: Context): Option[TypeBindSymbol] = + def unapply(symbol: Symbol)(given ctx: Context): Option[TypeBindSymbol] = internal.matchTypeBindSymbol(symbol) } implicit class TypeBindSymbolAPI(self: TypeBindSymbol) { /** TypeBind pattern of this definition */ - def tree given (ctx: Context): TypeBind = + def tree(given ctx: Context): TypeBind = internal.TypeBindSymbol_tree(self) } // TermSymbol object IsTermSymbol { - def unapply(symbol: Symbol) given (ctx: Context): Option[TermSymbol] = + def unapply(symbol: Symbol)(given ctx: Context): Option[TermSymbol] = internal.matchTermSymbol(symbol) } // DefSymbol object IsDefDefSymbol { - def unapply(symbol: Symbol) given (ctx: Context): Option[DefDefSymbol] = + def unapply(symbol: Symbol)(given ctx: Context): Option[DefDefSymbol] = internal.matchDefDefSymbol(symbol) } implicit class DefDefSymbolAPI(self: DefDefSymbol) { /** DefDef tree of this defintion */ - def tree given (ctx: Context): DefDef = + def tree(given ctx: Context): DefDef = internal.DefDefSymbol_tree(self) /** Signature of this defintion */ - def signature given (ctx: Context): Signature = + def signature(given ctx: Context): Signature = internal.DefDefSymbol_signature(self) } // ValSymbol object IsValDefSymbol { - def unapply(symbol: Symbol) given (ctx: Context): Option[ValDefSymbol] = + def unapply(symbol: Symbol)(given ctx: Context): Option[ValDefSymbol] = internal.matchValDefSymbol(symbol) } implicit class ValDefSymbolAPI(self: ValDefSymbol) { /** ValDef tree of this defintion */ - def tree given (ctx: Context): ValDef = + def tree(given ctx: Context): ValDef = internal.ValDefSymbol_tree(self) /** The class symbol of the companion module class */ - def moduleClass given (ctx: Context): Option[ClassDefSymbol] = + def moduleClass(given ctx: Context): Option[ClassDefSymbol] = internal.ValDefSymbol_moduleClass(self) - def companionClass given (ctx: Context): Option[ClassDefSymbol] = + def companionClass(given ctx: Context): Option[ClassDefSymbol] = internal.ValDefSymbol_companionClass(self) } // BindSymbol object IsBindSymbol { - def unapply(symbol: Symbol) given (ctx: Context): Option[BindSymbol] = + def unapply(symbol: Symbol)(given ctx: Context): Option[BindSymbol] = internal.matchBindSymbol(symbol) } implicit class BindSymbolAPI(self: BindSymbol) { /** Bind pattern of this definition */ - def tree given (ctx: Context): Bind = + def tree(given ctx: Context): Bind = internal.BindSymbol_tree(self) } // NoSymbol object NoSymbol { - def unapply(symbol: Symbol) given (ctx: Context): Boolean = + def unapply(symbol: Symbol)(given ctx: Context): Boolean = internal.matchNoSymbol(symbol) } } diff --git a/library/src/scala/tasty/reflect/TreeOps.scala b/library/src/scala/tasty/reflect/TreeOps.scala index 7c221dfadc5d..afd76605a157 100644 --- a/library/src/scala/tasty/reflect/TreeOps.scala +++ b/library/src/scala/tasty/reflect/TreeOps.scala @@ -7,268 +7,268 @@ trait TreeOps extends Core { implicit class TreeAPI(self: Tree) { /** Position in the source code */ - def pos given (ctx: Context): Position = internal.Tree_pos(self) + def pos(given ctx: Context): Position = internal.Tree_pos(self) - def symbol given (ctx: Context): Symbol = internal.Tree_symbol(self) + def symbol(given ctx: Context): Symbol = internal.Tree_symbol(self) } object IsPackageClause { - def unapply(tree: Tree) given (ctx: Context): Option[PackageClause] = + def unapply(tree: Tree)(given ctx: Context): Option[PackageClause] = internal.matchPackageClause(tree) } object PackageClause { - def apply(pid: Ref, stats: List[Tree]) given (ctx: Context): PackageClause = + def apply(pid: Ref, stats: List[Tree])(given ctx: Context): PackageClause = internal.PackageClause_apply(pid, stats) - def copy(original: PackageClause)(pid: Ref, stats: List[Tree]) given (ctx: Context): PackageClause = + def copy(original: PackageClause)(pid: Ref, stats: List[Tree])(given ctx: Context): PackageClause = internal.PackageClause_copy(original)(pid, stats) - def unapply(tree: Tree) given (ctx: Context): Option[(Ref, List[Tree])] = + def unapply(tree: Tree)(given ctx: Context): Option[(Ref, List[Tree])] = internal.matchPackageClause(tree).map(x => (x.pid, x.stats)) } implicit class PackageClauseAPI(self: PackageClause) { - def pid given (ctx: Context): Ref = internal.PackageClause_pid(self) - def stats given (ctx: Context): List[Tree] = internal.PackageClause_stats(self) + def pid(given ctx: Context): Ref = internal.PackageClause_pid(self) + def stats(given ctx: Context): List[Tree] = internal.PackageClause_stats(self) } object IsImport { - def unapply(tree: Tree) given (ctx: Context): Option[Import] = + def unapply(tree: Tree)(given ctx: Context): Option[Import] = internal.matchImport(tree) } object Import { - def apply(expr: Term, selectors: List[ImportSelector]) given (ctx: Context): Import = + def apply(expr: Term, selectors: List[ImportSelector])(given ctx: Context): Import = internal.Import_apply(expr, selectors) - def copy(original: Import)(expr: Term, selectors: List[ImportSelector]) given (ctx: Context): Import = + def copy(original: Import)(expr: Term, selectors: List[ImportSelector])(given ctx: Context): Import = internal.Import_copy(original)(expr, selectors) - def unapply(tree: Tree) given (ctx: Context): Option[(Term, List[ImportSelector])] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, List[ImportSelector])] = internal.matchImport(tree).map(x => (x.expr, x.selectors)) } implicit class ImportAPI(self: Import) { - def expr given (ctx: Context): Term = internal.Import_expr(self) - def selectors given (ctx: Context): List[ImportSelector] = + def expr(given ctx: Context): Term = internal.Import_expr(self) + def selectors(given ctx: Context): List[ImportSelector] = internal.Import_selectors(self) } object IsStatement { /** Matches any Statement and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Statement] = internal.matchStatement(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Statement] = internal.matchStatement(tree) } // ----- Definitions ---------------------------------------------- object IsDefinition { - def unapply(tree: Tree) given (ctx: Context): Option[Definition] = internal.matchDefinition(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Definition] = internal.matchDefinition(tree) } implicit class DefinitionAPI(self: Definition) { - def name given (ctx: Context): String = internal.Definition_name(self) + def name(given ctx: Context): String = internal.Definition_name(self) } // ClassDef object IsClassDef { - def unapply(tree: Tree) given (ctx: Context): Option[ClassDef] = internal.matchClassDef(tree) + def unapply(tree: Tree)(given ctx: Context): Option[ClassDef] = internal.matchClassDef(tree) } object ClassDef { - // TODO def apply(name: String, constr: DefDef, parents: List[TermOrTypeTree], selfOpt: Option[ValDef], body: List[Statement]) given (ctx: Context): ClassDef - def copy(original: ClassDef)(name: String, constr: DefDef, parents: List[Tree /* Term | TypeTree */], derived: List[TypeTree], selfOpt: Option[ValDef], body: List[Statement]) given (ctx: Context): ClassDef = + // TODO def apply(name: String, constr: DefDef, parents: List[TermOrTypeTree], selfOpt: Option[ValDef], body: List[Statement])(given ctx: Context): ClassDef + def copy(original: ClassDef)(name: String, constr: DefDef, parents: List[Tree /* Term | TypeTree */], derived: List[TypeTree], selfOpt: Option[ValDef], body: List[Statement])(given ctx: Context): ClassDef = internal.ClassDef_copy(original)(name, constr, parents, derived, selfOpt, body) - def unapply(tree: Tree) given (ctx: Context): Option[(String, DefDef, List[Tree /* Term | TypeTree */], List[TypeTree], Option[ValDef], List[Statement])] = + def unapply(tree: Tree)(given ctx: Context): Option[(String, DefDef, List[Tree /* Term | TypeTree */], List[TypeTree], Option[ValDef], List[Statement])] = internal.matchClassDef(tree).map(x => (x.name, x.constructor, x.parents, x.derived, x.self, x.body)) } implicit class ClassDefAPI(self: ClassDef) { - def constructor given (ctx: Context): DefDef = internal.ClassDef_constructor(self) - def parents given (ctx: Context): List[Tree /* Term | TypeTree */] = internal.ClassDef_parents(self) - def derived given (ctx: Context): List[TypeTree] = internal.ClassDef_derived(self) - def self given (ctx: Context): Option[ValDef] = internal.ClassDef_self(self) - def body given (ctx: Context): List[Statement] = internal.ClassDef_body(self) - def symbol given (ctx: Context): ClassDefSymbol = internal.ClassDef_symbol(self) + def constructor(given ctx: Context): DefDef = internal.ClassDef_constructor(self) + def parents(given ctx: Context): List[Tree /* Term | TypeTree */] = internal.ClassDef_parents(self) + def derived(given ctx: Context): List[TypeTree] = internal.ClassDef_derived(self) + def self(given ctx: Context): Option[ValDef] = internal.ClassDef_self(self) + def body(given ctx: Context): List[Statement] = internal.ClassDef_body(self) + def symbol(given ctx: Context): ClassDefSymbol = internal.ClassDef_symbol(self) } // DefDef object IsDefDef { - def unapply(tree: Tree) given (ctx: Context): Option[DefDef] = internal.matchDefDef(tree) + def unapply(tree: Tree)(given ctx: Context): Option[DefDef] = internal.matchDefDef(tree) } object DefDef { - def apply(symbol: DefDefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term]) given (ctx: Context): DefDef = + def apply(symbol: DefDefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(given ctx: Context): DefDef = internal.DefDef_apply(symbol, rhsFn) - def copy(original: DefDef)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term]) given (ctx: Context): DefDef = + def copy(original: DefDef)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term])(given ctx: Context): DefDef = internal.DefDef_copy(original)(name, typeParams, paramss, tpt, rhs) - def unapply(tree: Tree) given (ctx: Context): Option[(String, List[TypeDef], List[List[ValDef]], TypeTree, Option[Term])] = + def unapply(tree: Tree)(given ctx: Context): Option[(String, List[TypeDef], List[List[ValDef]], TypeTree, Option[Term])] = internal.matchDefDef(tree).map(x => (x.name, x.typeParams, x.paramss, x.returnTpt, x.rhs)) } implicit class DefDefAPI(self: DefDef) { - def typeParams given (ctx: Context): List[TypeDef] = internal.DefDef_typeParams(self) - def paramss given (ctx: Context): List[List[ValDef]] = internal.DefDef_paramss(self) - def returnTpt given (ctx: Context): TypeTree = internal.DefDef_returnTpt(self) // TODO rename to tpt - def rhs given (ctx: Context): Option[Term] = internal.DefDef_rhs(self) - def symbol given (ctx: Context): DefDefSymbol = internal.DefDef_symbol(self) + def typeParams(given ctx: Context): List[TypeDef] = internal.DefDef_typeParams(self) + def paramss(given ctx: Context): List[List[ValDef]] = internal.DefDef_paramss(self) + def returnTpt(given ctx: Context): TypeTree = internal.DefDef_returnTpt(self) // TODO rename to tpt + def rhs(given ctx: Context): Option[Term] = internal.DefDef_rhs(self) + def symbol(given ctx: Context): DefDefSymbol = internal.DefDef_symbol(self) } // ValDef object IsValDef { - def unapply(tree: Tree) given (ctx: Context): Option[ValDef] = internal.matchValDef(tree) + def unapply(tree: Tree)(given ctx: Context): Option[ValDef] = internal.matchValDef(tree) } object ValDef { - def apply(symbol: ValDefSymbol, rhs: Option[Term]) given (ctx: Context): ValDef = + def apply(symbol: ValDefSymbol, rhs: Option[Term])(given ctx: Context): ValDef = internal.ValDef_apply(symbol, rhs) - def copy(original: ValDef)(name: String, tpt: TypeTree, rhs: Option[Term]) given (ctx: Context): ValDef = + def copy(original: ValDef)(name: String, tpt: TypeTree, rhs: Option[Term])(given ctx: Context): ValDef = internal.ValDef_copy(original)(name, tpt, rhs) - def unapply(tree: Tree) given (ctx: Context): Option[(String, TypeTree, Option[Term])] = + def unapply(tree: Tree)(given ctx: Context): Option[(String, TypeTree, Option[Term])] = internal.matchValDef(tree).map(x => (x.name, x.tpt, x.rhs)) } implicit class ValDefAPI(self: ValDef) { - def tpt given (ctx: Context): TypeTree = internal.ValDef_tpt(self) - def rhs given (ctx: Context): Option[Term] = internal.ValDef_rhs(self) - def symbol given (ctx: Context): ValDefSymbol = internal.ValDef_symbol(self) + def tpt(given ctx: Context): TypeTree = internal.ValDef_tpt(self) + def rhs(given ctx: Context): Option[Term] = internal.ValDef_rhs(self) + def symbol(given ctx: Context): ValDefSymbol = internal.ValDef_symbol(self) } // TypeDef object IsTypeDef { - def unapply(tree: Tree) given (ctx: Context): Option[TypeDef] = internal.matchTypeDef(tree) + def unapply(tree: Tree)(given ctx: Context): Option[TypeDef] = internal.matchTypeDef(tree) } object TypeDef { - def apply(symbol: TypeDefSymbol) given (ctx: Context): TypeDef = + def apply(symbol: TypeDefSymbol)(given ctx: Context): TypeDef = internal.TypeDef_apply(symbol) - def copy(original: TypeDef)(name: String, rhs: Tree /*TypeTree | TypeBoundsTree*/) given (ctx: Context): TypeDef = + def copy(original: TypeDef)(name: String, rhs: Tree /*TypeTree | TypeBoundsTree*/)(given ctx: Context): TypeDef = internal.TypeDef_copy(original)(name, rhs) - def unapply(tree: Tree) given (ctx: Context): Option[(String, Tree /*TypeTree | TypeBoundsTree*/ /* TypeTree | TypeBoundsTree */)] = + def unapply(tree: Tree)(given ctx: Context): Option[(String, Tree /*TypeTree | TypeBoundsTree*/ /* TypeTree | TypeBoundsTree */)] = internal.matchTypeDef(tree).map(x => (x.name, x.rhs)) } implicit class TypeDefAPI(self: TypeDef) { - def rhs given (ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = internal.TypeDef_rhs(self) - def symbol given (ctx: Context): TypeDefSymbol = internal.TypeDef_symbol(self) + def rhs(given ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = internal.TypeDef_rhs(self) + def symbol(given ctx: Context): TypeDefSymbol = internal.TypeDef_symbol(self) } // PackageDef object IsPackageDef { - def unapply(tree: Tree) given (ctx: Context): Option[PackageDef] = + def unapply(tree: Tree)(given ctx: Context): Option[PackageDef] = internal.matchPackageDef(tree) } implicit class PackageDefAPI(self: PackageDef) { - def owner given (ctx: Context): PackageDef = internal.PackageDef_owner(self) - def members given (ctx: Context): List[Statement] = internal.PackageDef_members(self) - def symbol given (ctx: Context): PackageDefSymbol = internal.PackageDef_symbol(self) + def owner(given ctx: Context): PackageDef = internal.PackageDef_owner(self) + def members(given ctx: Context): List[Statement] = internal.PackageDef_members(self) + def symbol(given ctx: Context): PackageDefSymbol = internal.PackageDef_symbol(self) } object PackageDef { - def unapply(tree: Tree) given (ctx: Context): Option[(String, PackageDef)] = + def unapply(tree: Tree)(given ctx: Context): Option[(String, PackageDef)] = internal.matchPackageDef(tree).map(x => (x.name, x.owner)) } // ----- Terms ---------------------------------------------------- implicit class TermAPI(self: Term) { - def tpe given (ctx: Context): Type = internal.Term_tpe(self) - def pos given (ctx: Context): Position = internal.Term_pos(self) - def underlyingArgument given (ctx: Context): Term = internal.Term_underlyingArgument(self) - def underlying given (ctx: Context): Term = internal.Term_underlying(self) + def tpe(given ctx: Context): Type = internal.Term_tpe(self) + def pos(given ctx: Context): Position = internal.Term_pos(self) + def underlyingArgument(given ctx: Context): Term = internal.Term_underlyingArgument(self) + def underlying(given ctx: Context): Term = internal.Term_underlying(self) /** A unary apply node with given argument: `tree(arg)` */ - def appliedTo(arg: Term) given (ctx: Context): Term = + def appliedTo(arg: Term)(given ctx: Context): Term = appliedToArgs(arg :: Nil) /** An apply node with given arguments: `tree(arg, args0, ..., argsN)` */ - def appliedTo(arg: Term, args: Term*) given (ctx: Context): Term = + def appliedTo(arg: Term, args: Term*)(given ctx: Context): Term = appliedToArgs(arg :: args.toList) /** An apply node with given argument list `tree(args(0), ..., args(args.length - 1))` */ - def appliedToArgs(args: List[Term]) given (ctx: Context): Apply = + def appliedToArgs(args: List[Term])(given ctx: Context): Apply = Apply(self, args) /** The current tree applied to given argument lists: * `tree (argss(0)) ... (argss(argss.length -1))` */ - def appliedToArgss(argss: List[List[Term]]) given (ctx: Context): Term = + def appliedToArgss(argss: List[List[Term]])(given ctx: Context): Term = argss.foldLeft(self: Term)(Apply(_, _)) /** The current tree applied to (): `tree()` */ - def appliedToNone given (ctx: Context): Apply = appliedToArgs(Nil) + def appliedToNone(given ctx: Context): Apply = appliedToArgs(Nil) /** The current tree applied to given type argument: `tree[targ]` */ - def appliedToType(targ: Type) given (ctx: Context): Term = + def appliedToType(targ: Type)(given ctx: Context): Term = appliedToTypes(targ :: Nil) /** The current tree applied to given type arguments: `tree[targ0, ..., targN]` */ - def appliedToTypes(targs: List[Type]) given (ctx: Context): Term = + def appliedToTypes(targs: List[Type])(given ctx: Context): Term = appliedToTypeTrees(targs map (Inferred(_))) /** The current tree applied to given type argument list: `tree[targs(0), ..., targs(targs.length - 1)]` */ - def appliedToTypeTrees(targs: List[TypeTree]) given (ctx: Context): Term = + def appliedToTypeTrees(targs: List[TypeTree])(given ctx: Context): Term = if (targs.isEmpty) self else TypeApply(self, targs) /** A select node that selects the given symbol. */ - def select(sym: Symbol) given (ctx: Context): Select = Select(self, sym) + def select(sym: Symbol)(given ctx: Context): Select = Select(self, sym) } object IsTerm { /** Matches any term */ - def unapply(tree: Tree) given (ctx: Context): Option[Term] = + def unapply(tree: Tree)(given ctx: Context): Option[Term] = internal.matchTerm(tree) } object IsRef { /** Matches any Ref and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Ref] = internal.matchRef(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Ref] = internal.matchRef(tree) } object Ref { /** Create a reference tree */ - def apply(sym: Symbol) given (ctx: Context): Ref = + def apply(sym: Symbol)(given ctx: Context): Ref = internal.Ref_apply(sym) - // TODO def copy(original: Tree)(name: String) given (ctx: Context): Ref + // TODO def copy(original: Tree)(name: String)(given ctx: Context): Ref } object IsIdent { /** Matches any Ident and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Ident] = internal.matchIdent(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Ident] = internal.matchIdent(tree) } implicit class IdentAPI(self: Ident) { - def name given (ctx: Context): String = internal.Ident_name(self) + def name(given ctx: Context): String = internal.Ident_name(self) } /** Scala term identifier */ object Ident { - def apply(tmref: TermRef) given (ctx: Context): Term = + def apply(tmref: TermRef)(given ctx: Context): Term = internal.Ident_apply(tmref) - def copy(original: Tree)(name: String) given (ctx: Context): Ident = + def copy(original: Tree)(name: String)(given ctx: Context): Ident = internal.Ident_copy(original)(name) /** Matches a term identifier and returns its name */ - def unapply(tree: Tree) given (ctx: Context): Option[String] = + def unapply(tree: Tree)(given ctx: Context): Option[String] = internal.matchIdent(tree).map(_.name) } object IsSelect { /** Matches any Select and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Select] = internal.matchSelect(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Select] = internal.matchSelect(tree) } /** Scala term selection */ object Select { /** Select a term member by symbol */ - def apply(qualifier: Term, symbol: Symbol) given (ctx: Context): Select = + def apply(qualifier: Term, symbol: Symbol)(given ctx: Context): Select = internal.Select_apply(qualifier, symbol) /** Select a field or a non-overloaded method by name @@ -277,155 +277,155 @@ trait TreeOps extends Core { * method is overloaded. The method `overloaded` should be used * in that case. */ - def unique(qualifier: Term, name: String) given (ctx: Context): Select = + def unique(qualifier: Term, name: String)(given ctx: Context): Select = internal.Select_unique(qualifier, name) // TODO rename, this returns an Apply and not a Select /** Call an overloaded method with the given type and term parameters */ - def overloaded(qualifier: Term, name: String, targs: List[Type], args: List[Term]) given (ctx: Context): Apply = + def overloaded(qualifier: Term, name: String, targs: List[Type], args: List[Term])(given ctx: Context): Apply = internal.Select_overloaded(qualifier, name, targs, args) - def copy(original: Tree)(qualifier: Term, name: String) given (ctx: Context): Select = + def copy(original: Tree)(qualifier: Term, name: String)(given ctx: Context): Select = internal.Select_copy(original)(qualifier, name) /** Matches `.` */ - def unapply(tree: Tree) given (ctx: Context): Option[(Term, String)] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, String)] = internal.matchSelect(tree).map(x => (x.qualifier, x.name)) } implicit class SelectAPI(self: Select) { - def qualifier given (ctx: Context): Term = internal.Select_qualifier(self) - def name given (ctx: Context): String = internal.Select_name(self) - def signature given (ctx: Context): Option[Signature] = internal.Select_signature(self) + def qualifier(given ctx: Context): Term = internal.Select_qualifier(self) + def name(given ctx: Context): String = internal.Select_name(self) + def signature(given ctx: Context): Option[Signature] = internal.Select_signature(self) } object IsLiteral { /** Matches any Literal and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Literal] = internal.matchLiteral(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Literal] = internal.matchLiteral(tree) } /** Scala literal constant */ object Literal { /** Create a literal constant */ - def apply(constant: Constant) given (ctx: Context): Literal = + def apply(constant: Constant)(given ctx: Context): Literal = internal.Literal_apply(constant) - def copy(original: Tree)(constant: Constant) given (ctx: Context): Literal = + def copy(original: Tree)(constant: Constant)(given ctx: Context): Literal = internal.Literal_copy(original)(constant) /** Matches a literal constant */ - def unapply(tree: Tree) given (ctx: Context): Option[Constant] = + def unapply(tree: Tree)(given ctx: Context): Option[Constant] = internal.matchLiteral(tree).map(_.constant) } implicit class LiteralAPI(self: Literal) { - def constant given (ctx: Context): Constant = internal.Literal_constant(self) + def constant(given ctx: Context): Constant = internal.Literal_constant(self) } object IsThis { /** Matches any This and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[This] = internal.matchThis(tree) + def unapply(tree: Tree)(given ctx: Context): Option[This] = internal.matchThis(tree) } /** Scala `this` or `this[id]` */ object This { /** Create a `this[` */ - def apply(cls: ClassDefSymbol) given (ctx: Context): This = + def apply(cls: ClassDefSymbol)(given ctx: Context): This = internal.This_apply(cls) - def copy(original: Tree)(qual: Option[Id]) given (ctx: Context): This = + def copy(original: Tree)(qual: Option[Id])(given ctx: Context): This = internal.This_copy(original)(qual) /** Matches `this[` */ - def unapply(tree: Tree) given (ctx: Context): Option[Option[Id]] = + def unapply(tree: Tree)(given ctx: Context): Option[Option[Id]] = internal.matchThis(tree).map(_.id) } implicit class ThisAPI(self: This) { - def id given (ctx: Context): Option[Id] = internal.This_id(self) + def id(given ctx: Context): Option[Id] = internal.This_id(self) } object IsNew { /** Matches any New and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[New] = internal.matchNew(tree) + def unapply(tree: Tree)(given ctx: Context): Option[New] = internal.matchNew(tree) } /** Scala `new` */ object New { /** Create a `new ` */ - def apply(tpt: TypeTree) given (ctx: Context): New = + def apply(tpt: TypeTree)(given ctx: Context): New = internal.New_apply(tpt) - def copy(original: Tree)(tpt: TypeTree) given (ctx: Context): New = + def copy(original: Tree)(tpt: TypeTree)(given ctx: Context): New = internal.New_copy(original)(tpt) /** Matches a `new ` */ - def unapply(tree: Tree) given (ctx: Context): Option[TypeTree] = + def unapply(tree: Tree)(given ctx: Context): Option[TypeTree] = internal.matchNew(tree).map(_.tpt) } implicit class NewAPI(self: New) { - def tpt given (ctx: Context): TypeTree = internal.New_tpt(self) + def tpt(given ctx: Context): TypeTree = internal.New_tpt(self) } object IsNamedArg { /** Matches any NamedArg and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[NamedArg] = internal.matchNamedArg(tree) + def unapply(tree: Tree)(given ctx: Context): Option[NamedArg] = internal.matchNamedArg(tree) } /** Scala named argument `x = y` in argument position */ object NamedArg { /** Create a named argument ` = ` */ - def apply(name: String, arg: Term) given (ctx: Context): NamedArg = + def apply(name: String, arg: Term)(given ctx: Context): NamedArg = internal.NamedArg_apply(name, arg) - def copy(original: NamedArg)(name: String, arg: Term) given (ctx: Context): NamedArg = + def copy(original: NamedArg)(name: String, arg: Term)(given ctx: Context): NamedArg = internal.NamedArg_copy(original)(name, arg) /** Matches a named argument ` = ` */ - def unapply(tree: Tree) given (ctx: Context): Option[(String, Term)] = + def unapply(tree: Tree)(given ctx: Context): Option[(String, Term)] = internal.matchNamedArg(tree).map(x => (x.name, x.value)) } implicit class NamedArgAPI(self: NamedArg) { - def name given (ctx: Context): String = internal.NamedArg_name(self) - def value given (ctx: Context): Term = internal.NamedArg_value(self) + def name(given ctx: Context): String = internal.NamedArg_name(self) + def value(given ctx: Context): Term = internal.NamedArg_value(self) } object IsApply { /** Matches any Apply and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Apply] = internal.matchApply(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Apply] = internal.matchApply(tree) } /** Scala parameter application */ object Apply { /** Create a function application `()` */ - def apply(fun: Term, args: List[Term]) given (ctx: Context): Apply = + def apply(fun: Term, args: List[Term])(given ctx: Context): Apply = internal.Apply_apply(fun, args) - def copy(original: Tree)(fun: Term, args: List[Term]) given (ctx: Context): Apply = + def copy(original: Tree)(fun: Term, args: List[Term])(given ctx: Context): Apply = internal.Apply_copy(original)(fun, args) /** Matches a function application `()` */ - def unapply(tree: Tree) given (ctx: Context): Option[(Term, List[Term])] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, List[Term])] = internal.matchApply(tree).map(x => (x.fun, x.args)) } implicit class ApplyAPI(self: Apply) { - def fun given (ctx: Context): Term = internal.Apply_fun(self) - def args given (ctx: Context): List[Term] = internal.Apply_args(self) + def fun(given ctx: Context): Term = internal.Apply_fun(self) + def args(given ctx: Context): List[Term] = internal.Apply_args(self) } object IsTypeApply { /** Matches any TypeApply and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[TypeApply] = + def unapply(tree: Tree)(given ctx: Context): Option[TypeApply] = internal.matchTypeApply(tree) } @@ -433,144 +433,144 @@ trait TreeOps extends Core { object TypeApply { /** Create a function type application `[]` */ - def apply(fun: Term, args: List[TypeTree]) given (ctx: Context): TypeApply = + def apply(fun: Term, args: List[TypeTree])(given ctx: Context): TypeApply = internal.TypeApply_apply(fun, args) - def copy(original: Tree)(fun: Term, args: List[TypeTree]) given (ctx: Context): TypeApply = + def copy(original: Tree)(fun: Term, args: List[TypeTree])(given ctx: Context): TypeApply = internal.TypeApply_copy(original)(fun, args) /** Matches a function type application `[]` */ - def unapply(tree: Tree) given (ctx: Context): Option[(Term, List[TypeTree])] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, List[TypeTree])] = internal.matchTypeApply(tree).map(x => (x.fun, x.args)) } implicit class TypeApplyAPI(self: TypeApply) { - def fun given (ctx: Context): Term = internal.TypeApply_fun(self) - def args given (ctx: Context): List[TypeTree] = internal.TypeApply_args(self) + def fun(given ctx: Context): Term = internal.TypeApply_fun(self) + def args(given ctx: Context): List[TypeTree] = internal.TypeApply_args(self) } object IsSuper { /** Matches any Super and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Super] = internal.matchSuper(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Super] = internal.matchSuper(tree) } /** Scala `x.super` or `x.super[id]` */ object Super { /** Creates a `.super[` */ - def apply(qual: Term, mix: Option[Id]) given (ctx: Context): Super = + def apply(qual: Term, mix: Option[Id])(given ctx: Context): Super = internal.Super_apply(qual, mix) - def copy(original: Tree)(qual: Term, mix: Option[Id]) given (ctx: Context): Super = + def copy(original: Tree)(qual: Term, mix: Option[Id])(given ctx: Context): Super = internal.Super_copy(original)(qual, mix) /** Matches a `.super[` */ - def unapply(tree: Tree) given (ctx: Context): Option[(Term, Option[Id])] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, Option[Id])] = internal.matchSuper(tree).map(x => (x.qualifier, x.id)) } implicit class SuperAPI(self: Super) { - def qualifier given (ctx: Context): Term = internal.Super_qualifier(self) - def id given (ctx: Context): Option[Id] = internal.Super_id(self) + def qualifier(given ctx: Context): Term = internal.Super_qualifier(self) + def id(given ctx: Context): Option[Id] = internal.Super_id(self) } object IsTyped { /** Matches any Typed and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Typed] = internal.matchTyped(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Typed] = internal.matchTyped(tree) } /** Scala ascription `x: T` */ object Typed { /** Create a type ascription `: ` */ - def apply(expr: Term, tpt: TypeTree) given (ctx: Context): Typed = + def apply(expr: Term, tpt: TypeTree)(given ctx: Context): Typed = internal.Typed_apply(expr, tpt) - def copy(original: Tree)(expr: Term, tpt: TypeTree) given (ctx: Context): Typed = + def copy(original: Tree)(expr: Term, tpt: TypeTree)(given ctx: Context): Typed = internal.Typed_copy(original)(expr, tpt) /** Matches `: ` */ - def unapply(tree: Tree) given (ctx: Context): Option[(Term, TypeTree)] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, TypeTree)] = internal.matchTyped(tree).map(x => (x.expr, x.tpt)) } implicit class TypedAPI(self: Typed) { - def expr given (ctx: Context): Term = internal.Typed_expr(self) - def tpt given (ctx: Context): TypeTree = internal.Typed_tpt(self) + def expr(given ctx: Context): Term = internal.Typed_expr(self) + def tpt(given ctx: Context): TypeTree = internal.Typed_tpt(self) } object IsAssign { /** Matches any Assign and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Assign] = internal.matchAssign(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Assign] = internal.matchAssign(tree) } /** Scala assign `x = y` */ object Assign { /** Create an assignment ` = ` */ - def apply(lhs: Term, rhs: Term) given (ctx: Context): Assign = + def apply(lhs: Term, rhs: Term)(given ctx: Context): Assign = internal.Assign_apply(lhs, rhs) - def copy(original: Tree)(lhs: Term, rhs: Term) given (ctx: Context): Assign = + def copy(original: Tree)(lhs: Term, rhs: Term)(given ctx: Context): Assign = internal.Assign_copy(original)(lhs, rhs) /** Matches an assignment ` = ` */ - def unapply(tree: Tree) given (ctx: Context): Option[(Term, Term)] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, Term)] = internal.matchAssign(tree).map(x => (x.lhs, x.rhs)) } implicit class AssignAPI(self: Assign) { - def lhs given (ctx: Context): Term = internal.Assign_lhs(self) - def rhs given (ctx: Context): Term = internal.Assign_rhs(self) + def lhs(given ctx: Context): Term = internal.Assign_lhs(self) + def rhs(given ctx: Context): Term = internal.Assign_rhs(self) } object IsBlock { /** Matches any Block and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Block] = internal.matchBlock(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Block] = internal.matchBlock(tree) } /** Scala code block `{ stat0; ...; statN; expr }` term */ object Block { /** Creates a block `{ ; }` */ - def apply(stats: List[Statement], expr: Term) given (ctx: Context): Block = + def apply(stats: List[Statement], expr: Term)(given ctx: Context): Block = internal.Block_apply(stats, expr) - def copy(original: Tree)(stats: List[Statement], expr: Term) given (ctx: Context): Block = + def copy(original: Tree)(stats: List[Statement], expr: Term)(given ctx: Context): Block = internal.Block_copy(original)(stats, expr) /** Matches a block `{ ; }` */ - def unapply(tree: Tree) given (ctx: Context): Option[(List[Statement], Term)] = + def unapply(tree: Tree)(given ctx: Context): Option[(List[Statement], Term)] = internal.matchBlock(tree).map(x => (x.statements, x.expr)) } implicit class BlockAPI(self: Block) { - def statements given (ctx: Context): List[Statement] = internal.Block_statements(self) - def expr given (ctx: Context): Term = internal.Block_expr(self) + def statements(given ctx: Context): List[Statement] = internal.Block_statements(self) + def expr(given ctx: Context): Term = internal.Block_expr(self) } object IsClosure { /** Matches any Closure and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Closure] = internal.matchClosure(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Closure] = internal.matchClosure(tree) } object Closure { - def apply(meth: Term, tpt: Option[Type]) given (ctx: Context): Closure = + def apply(meth: Term, tpt: Option[Type])(given ctx: Context): Closure = internal.Closure_apply(meth, tpt) - def copy(original: Tree)(meth: Tree, tpt: Option[Type]) given (ctx: Context): Closure = + def copy(original: Tree)(meth: Tree, tpt: Option[Type])(given ctx: Context): Closure = internal.Closure_copy(original)(meth, tpt) - def unapply(tree: Tree) given (ctx: Context): Option[(Term, Option[Type])] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, Option[Type])] = internal.matchClosure(tree).map(x => (x.meth, x.tpeOpt)) } implicit class ClosureAPI(self: Closure) { - def meth given (ctx: Context): Term = internal.Closure_meth(self) - def tpeOpt given (ctx: Context): Option[Type] = internal.Closure_tpeOpt(self) + def meth(given ctx: Context): Term = internal.Closure_meth(self) + def tpeOpt(given ctx: Context): Option[Type] = internal.Closure_tpeOpt(self) } /** A lambda `(...) => ...` in the source code is represented as @@ -586,7 +586,7 @@ trait TreeOps extends Core { * of `Lambda`. */ object Lambda { - def unapply(tree: Tree) given (ctx: Context): Option[(List[ValDef], Term)] = tree match { + def unapply(tree: Tree)(given ctx: Context): Option[(List[ValDef], Term)] = tree match { case Block((ddef @ DefDef(_, _, params :: Nil, _, Some(body))) :: Nil, Closure(meth, _)) if ddef.symbol == meth.symbol => Some(params, body) @@ -597,573 +597,573 @@ trait TreeOps extends Core { object IsIf { /** Matches any If and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[If] = internal.matchIf(tree) + def unapply(tree: Tree)(given ctx: Context): Option[If] = internal.matchIf(tree) } /** Scala `if`/`else` term */ object If { /** Create an if/then/else `if () else ` */ - def apply(cond: Term, thenp: Term, elsep: Term) given (ctx: Context): If = + def apply(cond: Term, thenp: Term, elsep: Term)(given ctx: Context): If = internal.If_apply(cond, thenp, elsep) - def copy(original: Tree)(cond: Term, thenp: Term, elsep: Term) given (ctx: Context): If = + def copy(original: Tree)(cond: Term, thenp: Term, elsep: Term)(given ctx: Context): If = internal.If_copy(original)(cond, thenp, elsep) /** Matches an if/then/else `if () else ` */ - def unapply(tree: Tree) given (ctx: Context): Option[(Term, Term, Term)] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, Term, Term)] = internal.matchIf(tree).map(x => (x.cond, x.thenp, x.elsep)) } implicit class IfAPI(self: If) { - def cond given (ctx: Context): Term = internal.If_cond(self) - def thenp given (ctx: Context): Term = internal.If_thenp(self) - def elsep given (ctx: Context): Term = internal.If_elsep(self) + def cond(given ctx: Context): Term = internal.If_cond(self) + def thenp(given ctx: Context): Term = internal.If_thenp(self) + def elsep(given ctx: Context): Term = internal.If_elsep(self) } object IsMatch { /** Matches any Match and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Match] = internal.matchMatch(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Match] = internal.matchMatch(tree) } /** Scala `match` term */ object Match { /** Creates a pattern match ` match { }` */ - def apply(selector: Term, cases: List[CaseDef]) given (ctx: Context): Match = + def apply(selector: Term, cases: List[CaseDef])(given ctx: Context): Match = internal.Match_apply(selector, cases) - def copy(original: Tree)(selector: Term, cases: List[CaseDef]) given (ctx: Context): Match = + def copy(original: Tree)(selector: Term, cases: List[CaseDef])(given ctx: Context): Match = internal.Match_copy(original)(selector, cases) /** Matches a pattern match ` match { }` */ - def unapply(tree: Tree) given (ctx: Context): Option[(Term, List[CaseDef])] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, List[CaseDef])] = internal.matchMatch(tree).map(x => (x.scrutinee, x.cases)) } implicit class MatchAPI(self: Match) { - def scrutinee given (ctx: Context): Term = internal.Match_scrutinee(self) - def cases given (ctx: Context): List[CaseDef] = internal.Match_cases(self) + def scrutinee(given ctx: Context): Term = internal.Match_scrutinee(self) + def cases(given ctx: Context): List[CaseDef] = internal.Match_cases(self) } object IsImplicitMatch { /** Matches any ImpliedMatch and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[ImpliedMatch] = internal.matchImplicitMatch(tree) + def unapply(tree: Tree)(given ctx: Context): Option[ImpliedMatch] = internal.matchImplicitMatch(tree) } /** Scala implicit `match` term */ object ImpliedMatch { /** Creates a pattern match `delegate match { }` */ - def apply(cases: List[CaseDef]) given (ctx: Context): ImpliedMatch = + def apply(cases: List[CaseDef])(given ctx: Context): ImpliedMatch = internal.ImplicitMatch_apply(cases) - def copy(original: Tree)(cases: List[CaseDef]) given (ctx: Context): ImpliedMatch = + def copy(original: Tree)(cases: List[CaseDef])(given ctx: Context): ImpliedMatch = internal.ImplicitMatch_copy(original)(cases) /** Matches a pattern match `delegate match { }` */ - def unapply(tree: Tree) given (ctx: Context): Option[List[CaseDef]] = + def unapply(tree: Tree)(given ctx: Context): Option[List[CaseDef]] = internal.matchImplicitMatch(tree).map(_.cases) } implicit class ImplicitMatchAPI(self: ImpliedMatch) { - def cases given (ctx: Context): List[CaseDef] = internal.ImplicitMatch_cases(self) + def cases(given ctx: Context): List[CaseDef] = internal.ImplicitMatch_cases(self) } object IsTry { /** Matches any Try and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Try] = internal.matchTry(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Try] = internal.matchTry(tree) } /** Scala `try`/`catch`/`finally` term */ object Try { /** Create a try/catch `try catch { } finally ` */ - def apply(expr: Term, cases: List[CaseDef], finalizer: Option[Term]) given (ctx: Context): Try = + def apply(expr: Term, cases: List[CaseDef], finalizer: Option[Term])(given ctx: Context): Try = internal.Try_apply(expr, cases, finalizer) - def copy(original: Tree)(expr: Term, cases: List[CaseDef], finalizer: Option[Term]) given (ctx: Context): Try = + def copy(original: Tree)(expr: Term, cases: List[CaseDef], finalizer: Option[Term])(given ctx: Context): Try = internal.Try_copy(original)(expr, cases, finalizer) /** Matches a try/catch `try catch { } finally ` */ - def unapply(tree: Tree) given (ctx: Context): Option[(Term, List[CaseDef], Option[Term])] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, List[CaseDef], Option[Term])] = internal.matchTry(tree).map(x => (x.body, x.cases, x.finalizer)) } implicit class TryAPI(self: Try) { - def body given (ctx: Context): Term = internal.Try_body(self) - def cases given (ctx: Context): List[CaseDef] = internal.Try_cases(self) - def finalizer given (ctx: Context): Option[Term] = internal.Try_finalizer(self) + def body(given ctx: Context): Term = internal.Try_body(self) + def cases(given ctx: Context): List[CaseDef] = internal.Try_cases(self) + def finalizer(given ctx: Context): Option[Term] = internal.Try_finalizer(self) } object IsReturn { /** Matches any Return and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Return] = internal.matchReturn(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Return] = internal.matchReturn(tree) } /** Scala local `return` */ object Return { /** Creates `return ` */ - def apply(expr: Term) given (ctx: Context): Return = + def apply(expr: Term)(given ctx: Context): Return = internal.Return_apply(expr) - def copy(original: Tree)(expr: Term) given (ctx: Context): Return = + def copy(original: Tree)(expr: Term)(given ctx: Context): Return = internal.Return_copy(original)(expr) /** Matches `return ` */ - def unapply(tree: Tree) given (ctx: Context): Option[Term] = + def unapply(tree: Tree)(given ctx: Context): Option[Term] = internal.matchReturn(tree).map(_.expr) } implicit class ReturnAPI(self: Return) { - def expr given (ctx: Context): Term = internal.Return_expr(self) + def expr(given ctx: Context): Term = internal.Return_expr(self) } object IsRepeated { /** Matches any Repeated and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Repeated] = internal.matchRepeated(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Repeated] = internal.matchRepeated(tree) } object Repeated { - def apply(elems: List[Term], tpt: TypeTree) given (ctx: Context): Repeated = + def apply(elems: List[Term], tpt: TypeTree)(given ctx: Context): Repeated = internal.Repeated_apply(elems, tpt) - def copy(original: Tree)(elems: List[Term], tpt: TypeTree) given (ctx: Context): Repeated = + def copy(original: Tree)(elems: List[Term], tpt: TypeTree)(given ctx: Context): Repeated = internal.Repeated_copy(original)(elems, tpt) - def unapply(tree: Tree) given (ctx: Context): Option[(List[Term], TypeTree)] = + def unapply(tree: Tree)(given ctx: Context): Option[(List[Term], TypeTree)] = internal.matchRepeated(tree).map(x => (x.elems, x.elemtpt)) } implicit class RepeatedAPI(self: Repeated) { - def elems given (ctx: Context): List[Term] = internal.Repeated_elems(self) - def elemtpt given (ctx: Context): TypeTree = internal.Repeated_elemtpt(self) + def elems(given ctx: Context): List[Term] = internal.Repeated_elems(self) + def elemtpt(given ctx: Context): TypeTree = internal.Repeated_elemtpt(self) } object IsInlined { /** Matches any Inlined and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Inlined] = internal.matchInlined(tree) + def unapply(tree: Tree)(given ctx: Context): Option[Inlined] = internal.matchInlined(tree) } object Inlined { - def apply(call: Option[Tree /* Term | TypeTree */], bindings: List[Definition], expansion: Term) given (ctx: Context): Inlined = + def apply(call: Option[Tree /* Term | TypeTree */], bindings: List[Definition], expansion: Term)(given ctx: Context): Inlined = internal.Inlined_apply(call, bindings, expansion) - def copy(original: Tree)(call: Option[Tree /* Term | TypeTree */], bindings: List[Definition], expansion: Term) given (ctx: Context): Inlined = + def copy(original: Tree)(call: Option[Tree /* Term | TypeTree */], bindings: List[Definition], expansion: Term)(given ctx: Context): Inlined = internal.Inlined_copy(original)(call, bindings, expansion) - def unapply(tree: Tree) given (ctx: Context): Option[(Option[Tree /* Term | TypeTree */], List[Definition], Term)] = + def unapply(tree: Tree)(given ctx: Context): Option[(Option[Tree /* Term | TypeTree */], List[Definition], Term)] = internal.matchInlined(tree).map(x => (x.call, x.bindings, x.body)) } implicit class InlinedAPI(self: Inlined) { - def call given (ctx: Context): Option[Tree /* Term | TypeTree */] = internal.Inlined_call(self) - def bindings given (ctx: Context): List[Definition] = internal.Inlined_bindings(self) - def body given (ctx: Context): Term = internal.Inlined_body(self) + def call(given ctx: Context): Option[Tree /* Term | TypeTree */] = internal.Inlined_call(self) + def bindings(given ctx: Context): List[Definition] = internal.Inlined_bindings(self) + def body(given ctx: Context): Term = internal.Inlined_body(self) } object IsSelectOuter { /** Matches any SelectOuter and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[SelectOuter] = internal.matchSelectOuter(tree) + def unapply(tree: Tree)(given ctx: Context): Option[SelectOuter] = internal.matchSelectOuter(tree) } object SelectOuter { - def apply(qualifier: Term, name: String, levels: Int) given (ctx: Context): SelectOuter = + def apply(qualifier: Term, name: String, levels: Int)(given ctx: Context): SelectOuter = internal.SelectOuter_apply(qualifier, name, levels) - def copy(original: Tree)(qualifier: Term, name: String, levels: Int) given (ctx: Context): SelectOuter = + def copy(original: Tree)(qualifier: Term, name: String, levels: Int)(given ctx: Context): SelectOuter = internal.SelectOuter_copy(original)(qualifier, name, levels) - def unapply(tree: Tree) given (ctx: Context): Option[(Term, Int, Type)] = // TODO homogenize order of parameters + def unapply(tree: Tree)(given ctx: Context): Option[(Term, Int, Type)] = // TODO homogenize order of parameters internal.matchSelectOuter(tree).map(x => (x.qualifier, x.level, x.tpe)) } implicit class SelectOuterAPI(self: SelectOuter) { - def qualifier given (ctx: Context): Term = internal.SelectOuter_qualifier(self) - def level given (ctx: Context): Int = internal.SelectOuter_level(self) - def tpe given (ctx: Context): Type = internal.SelectOuter_tpe(self) + def qualifier(given ctx: Context): Term = internal.SelectOuter_qualifier(self) + def level(given ctx: Context): Int = internal.SelectOuter_level(self) + def tpe(given ctx: Context): Type = internal.SelectOuter_tpe(self) } object IsWhile { /** Matches any While and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[While] = internal.matchWhile(tree) + def unapply(tree: Tree)(given ctx: Context): Option[While] = internal.matchWhile(tree) } object While { /** Creates a while loop `while () ` and returns (, ) */ - def apply(cond: Term, body: Term) given (ctx: Context): While = + def apply(cond: Term, body: Term)(given ctx: Context): While = internal.While_apply(cond, body) - def copy(original: Tree)(cond: Term, body: Term) given (ctx: Context): While = + def copy(original: Tree)(cond: Term, body: Term)(given ctx: Context): While = internal.While_copy(original)(cond, body) /** Extractor for while loops. Matches `while () ` and returns (, ) */ - def unapply(tree: Tree) given (ctx: Context): Option[(Term, Term)] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, Term)] = internal.matchWhile(tree).map(x => (x.cond, x.body)) } implicit class WhileAPI(self: While) { - def cond given (ctx: Context): Term = internal.While_cond(self) - def body given (ctx: Context): Term = internal.While_body(self) + def cond(given ctx: Context): Term = internal.While_cond(self) + def body(given ctx: Context): Term = internal.While_body(self) } // ----- TypeTrees ------------------------------------------------ implicit class TypeTreeAPI(self: TypeTree) { /** Position in the source code */ - def pos given (ctx: Context): Position = internal.TypeTree_pos(self) + def pos(given ctx: Context): Position = internal.TypeTree_pos(self) /** Type of this type tree */ - def tpe given (ctx: Context): Type = internal.TypeTree_tpe(self) + def tpe(given ctx: Context): Type = internal.TypeTree_tpe(self) /** Symbol of this type tree */ - def symbol given (ctx: Context): Symbol = internal.TypeTree_symbol(self) + def symbol(given ctx: Context): Symbol = internal.TypeTree_symbol(self) } object IsTypeTree { - def unapply(tpt: Tree) given (ctx: Context): Option[TypeTree] = + def unapply(tpt: Tree)(given ctx: Context): Option[TypeTree] = internal.matchTypeTree(tpt) } object IsInferred { /** Matches any Inferred and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Inferred] = + def unapply(tree: Tree)(given ctx: Context): Option[Inferred] = internal.matchInferred(tree) } /** TypeTree containing an inferred type */ object Inferred { - def apply(tpe: Type) given (ctx: Context): Inferred = + def apply(tpe: Type)(given ctx: Context): Inferred = internal.Inferred_apply(tpe) /** Matches a TypeTree containing an inferred type */ - def unapply(tree: Tree) given (ctx: Context): Boolean = + def unapply(tree: Tree)(given ctx: Context): Boolean = internal.matchInferred(tree).isDefined } object IsTypeIdent { /** Matches any TypeIdent and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[TypeIdent] = + def unapply(tree: Tree)(given ctx: Context): Option[TypeIdent] = internal.matchTypeIdent(tree) } implicit class TypeIdentAPI(self: TypeIdent) { - def name given (ctx: Context): String = internal.TypeIdent_name(self) + def name(given ctx: Context): String = internal.TypeIdent_name(self) } object TypeIdent { - // TODO def apply(name: String) given (ctx: Context): TypeIdent - def copy(original: TypeIdent)(name: String) given (ctx: Context): TypeIdent = + // TODO def apply(name: String)(given ctx: Context): TypeIdent + def copy(original: TypeIdent)(name: String)(given ctx: Context): TypeIdent = internal.TypeIdent_copy(original)(name) - def unapply(tree: Tree) given (ctx: Context): Option[String] = + def unapply(tree: Tree)(given ctx: Context): Option[String] = internal.matchTypeIdent(tree).map(_.name) } object IsTypeSelect { /** Matches any TypeSelect and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[TypeSelect] = + def unapply(tree: Tree)(given ctx: Context): Option[TypeSelect] = internal.matchTypeSelect(tree) } object TypeSelect { - def apply(qualifier: Term, name: String) given (ctx: Context): TypeSelect = + def apply(qualifier: Term, name: String)(given ctx: Context): TypeSelect = internal.TypeSelect_apply(qualifier, name) - def copy(original: TypeSelect)(qualifier: Term, name: String) given (ctx: Context): TypeSelect = + def copy(original: TypeSelect)(qualifier: Term, name: String)(given ctx: Context): TypeSelect = internal.TypeSelect_copy(original)(qualifier, name) - def unapply(tree: Tree) given (ctx: Context): Option[(Term, String)] = + def unapply(tree: Tree)(given ctx: Context): Option[(Term, String)] = internal.matchTypeSelect(tree).map(x => (x.qualifier, x.name)) } implicit class TypeSelectAPI(self: TypeSelect) { - def qualifier given (ctx: Context): Term = internal.TypeSelect_qualifier(self) - def name given (ctx: Context): String = internal.TypeSelect_name(self) + def qualifier(given ctx: Context): Term = internal.TypeSelect_qualifier(self) + def name(given ctx: Context): String = internal.TypeSelect_name(self) } object IsProjection { /** Matches any Projection and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Projection] = + def unapply(tree: Tree)(given ctx: Context): Option[Projection] = internal.matchProjection(tree) } object Projection { - // TODO def apply(qualifier: TypeTree, name: String) given (ctx: Context): Project - def copy(original: Projection)(qualifier: TypeTree, name: String) given (ctx: Context): Projection = + // TODO def apply(qualifier: TypeTree, name: String)(given ctx: Context): Project + def copy(original: Projection)(qualifier: TypeTree, name: String)(given ctx: Context): Projection = internal.Projection_copy(original)(qualifier, name) - def unapply(tree: Tree) given (ctx: Context): Option[(TypeTree, String)] = + def unapply(tree: Tree)(given ctx: Context): Option[(TypeTree, String)] = internal.matchProjection(tree).map(x => (x.qualifier, x.name)) } implicit class ProjectionAPI(self: Projection) { - def qualifier given (ctx: Context): TypeTree = internal.Projection_qualifier(self) - def name given (ctx: Context): String = internal.Projection_name(self) + def qualifier(given ctx: Context): TypeTree = internal.Projection_qualifier(self) + def name(given ctx: Context): String = internal.Projection_name(self) } object IsSingleton { /** Matches any Singleton and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Singleton] = + def unapply(tree: Tree)(given ctx: Context): Option[Singleton] = internal.matchSingleton(tree) } object Singleton { - def apply(ref: Term) given (ctx: Context): Singleton = + def apply(ref: Term)(given ctx: Context): Singleton = internal.Singleton_apply(ref) - def copy(original: Singleton)(ref: Term) given (ctx: Context): Singleton = + def copy(original: Singleton)(ref: Term)(given ctx: Context): Singleton = internal.Singleton_copy(original)(ref) - def unapply(tree: Tree) given (ctx: Context): Option[Term] = + def unapply(tree: Tree)(given ctx: Context): Option[Term] = internal.matchSingleton(tree).map(_.ref) } implicit class SingletonAPI(self: Singleton) { - def ref given (ctx: Context): Term = internal.Singleton_ref(self) + def ref(given ctx: Context): Term = internal.Singleton_ref(self) } object IsRefined { /** Matches any Refined and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Refined] = + def unapply(tree: Tree)(given ctx: Context): Option[Refined] = internal.matchRefined(tree) } object Refined { - // TODO def apply(tpt: TypeTree, refinements: List[Definition]) given (ctx: Context): Refined - def copy(original: Refined)(tpt: TypeTree, refinements: List[Definition]) given (ctx: Context): Refined = + // TODO def apply(tpt: TypeTree, refinements: List[Definition])(given ctx: Context): Refined + def copy(original: Refined)(tpt: TypeTree, refinements: List[Definition])(given ctx: Context): Refined = internal.Refined_copy(original)(tpt, refinements) - def unapply(tree: Tree) given (ctx: Context): Option[(TypeTree, List[Definition])] = + def unapply(tree: Tree)(given ctx: Context): Option[(TypeTree, List[Definition])] = internal.matchRefined(tree).map(x => (x.tpt, x.refinements)) } implicit class RefinedAPI(self: Refined) { - def tpt given (ctx: Context): TypeTree = internal.Refined_tpt(self) - def refinements given (ctx: Context): List[Definition] = internal.Refined_refinements(self) + def tpt(given ctx: Context): TypeTree = internal.Refined_tpt(self) + def refinements(given ctx: Context): List[Definition] = internal.Refined_refinements(self) } object IsApplied { /** Matches any Applied and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Applied] = + def unapply(tree: Tree)(given ctx: Context): Option[Applied] = internal.matchApplied(tree) } object Applied { - def apply(tpt: TypeTree, args: List[Tree /*TypeTree | TypeBoundsTree*/]) given (ctx: Context): Applied = + def apply(tpt: TypeTree, args: List[Tree /*TypeTree | TypeBoundsTree*/])(given ctx: Context): Applied = internal.Applied_apply(tpt, args) - def copy(original: Applied)(tpt: TypeTree, args: List[Tree /*TypeTree | TypeBoundsTree*/]) given (ctx: Context): Applied = + def copy(original: Applied)(tpt: TypeTree, args: List[Tree /*TypeTree | TypeBoundsTree*/])(given ctx: Context): Applied = internal.Applied_copy(original)(tpt, args) - def unapply(tree: Tree) given (ctx: Context): Option[(TypeTree, List[Tree /*TypeTree | TypeBoundsTree*/])] = + def unapply(tree: Tree)(given ctx: Context): Option[(TypeTree, List[Tree /*TypeTree | TypeBoundsTree*/])] = internal.matchApplied(tree).map(x => (x.tpt, x.args)) } implicit class AppliedAPI(self: Applied) { - def tpt given (ctx: Context): TypeTree = internal.Applied_tpt(self) - def args given (ctx: Context): List[Tree /*TypeTree | TypeBoundsTree*/] = internal.Applied_args(self) + def tpt(given ctx: Context): TypeTree = internal.Applied_tpt(self) + def args(given ctx: Context): List[Tree /*TypeTree | TypeBoundsTree*/] = internal.Applied_args(self) } object IsAnnotated { /** Matches any Annotated and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[Annotated] = + def unapply(tree: Tree)(given ctx: Context): Option[Annotated] = internal.matchAnnotated(tree) } object Annotated { - def apply(arg: TypeTree, annotation: Term) given (ctx: Context): Annotated = + def apply(arg: TypeTree, annotation: Term)(given ctx: Context): Annotated = internal.Annotated_apply(arg, annotation) - def copy(original: Annotated)(arg: TypeTree, annotation: Term) given (ctx: Context): Annotated = + def copy(original: Annotated)(arg: TypeTree, annotation: Term)(given ctx: Context): Annotated = internal.Annotated_copy(original)(arg, annotation) - def unapply(tree: Tree) given (ctx: Context): Option[(TypeTree, Term)] = + def unapply(tree: Tree)(given ctx: Context): Option[(TypeTree, Term)] = internal.matchAnnotated(tree).map(x => (x.arg, x.annotation)) } implicit class AnnotatedAPI(self: Annotated) { - def arg given (ctx: Context): TypeTree = internal.Annotated_arg(self) - def annotation given (ctx: Context): Term = internal.Annotated_annotation(self) + def arg(given ctx: Context): TypeTree = internal.Annotated_arg(self) + def annotation(given ctx: Context): Term = internal.Annotated_annotation(self) } object IsMatchTypeTree { /** Matches any MatchTypeTree and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[MatchTypeTree] = + def unapply(tree: Tree)(given ctx: Context): Option[MatchTypeTree] = internal.matchMatchTypeTree(tree) } object MatchTypeTree { - def apply(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef]) given (ctx: Context): MatchTypeTree = + def apply(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef])(given ctx: Context): MatchTypeTree = internal.MatchTypeTree_apply(bound, selector, cases) - def copy(original: MatchTypeTree)(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef]) given (ctx: Context): MatchTypeTree = + def copy(original: MatchTypeTree)(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef])(given ctx: Context): MatchTypeTree = internal.MatchTypeTree_copy(original)(bound, selector, cases) - def unapply(tree: Tree) given (ctx: Context): Option[(Option[TypeTree], TypeTree, List[TypeCaseDef])] = + def unapply(tree: Tree)(given ctx: Context): Option[(Option[TypeTree], TypeTree, List[TypeCaseDef])] = internal.matchMatchTypeTree(tree).map(x => (x.bound, x.selector, x.cases)) } implicit class MatchTypeTreeAPI(self: MatchTypeTree) { - def bound given (ctx: Context): Option[TypeTree] = internal.MatchTypeTree_bound(self) - def selector given (ctx: Context): TypeTree = internal.MatchTypeTree_selector(self) - def cases given (ctx: Context): List[TypeCaseDef] = internal.MatchTypeTree_cases(self) + def bound(given ctx: Context): Option[TypeTree] = internal.MatchTypeTree_bound(self) + def selector(given ctx: Context): TypeTree = internal.MatchTypeTree_selector(self) + def cases(given ctx: Context): List[TypeCaseDef] = internal.MatchTypeTree_cases(self) } object IsByName { /** Matches any ByName and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[ByName] = + def unapply(tree: Tree)(given ctx: Context): Option[ByName] = internal.matchByName(tree) } object ByName { - def apply(result: TypeTree) given (ctx: Context): ByName = + def apply(result: TypeTree)(given ctx: Context): ByName = internal.ByName_apply(result) - def copy(original: ByName)(result: TypeTree) given (ctx: Context): ByName = + def copy(original: ByName)(result: TypeTree)(given ctx: Context): ByName = internal.ByName_copy(original)(result) - def unapply(tree: Tree) given (ctx: Context): Option[TypeTree] = + def unapply(tree: Tree)(given ctx: Context): Option[TypeTree] = internal.matchByName(tree).map(_.result) } implicit class ByNameAPI(self: ByName) { - def result given (ctx: Context): TypeTree = internal.ByName_result(self) + def result(given ctx: Context): TypeTree = internal.ByName_result(self) } object IsLambdaTypeTree { /** Matches any LambdaTypeTree and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[LambdaTypeTree] = + def unapply(tree: Tree)(given ctx: Context): Option[LambdaTypeTree] = internal.matchLambdaTypeTree(tree) } object LambdaTypeTree { - def apply(tparams: List[TypeDef], body: Tree /*TypeTree | TypeBoundsTree*/) given (ctx: Context): LambdaTypeTree = + def apply(tparams: List[TypeDef], body: Tree /*TypeTree | TypeBoundsTree*/)(given ctx: Context): LambdaTypeTree = internal.Lambdaapply(tparams, body) - def copy(original: LambdaTypeTree)(tparams: List[TypeDef], body: Tree /*TypeTree | TypeBoundsTree*/) given (ctx: Context): LambdaTypeTree = + def copy(original: LambdaTypeTree)(tparams: List[TypeDef], body: Tree /*TypeTree | TypeBoundsTree*/)(given ctx: Context): LambdaTypeTree = internal.Lambdacopy(original)(tparams, body) - def unapply(tree: Tree) given (ctx: Context): Option[(List[TypeDef], Tree /*TypeTree | TypeBoundsTree*/)] = + def unapply(tree: Tree)(given ctx: Context): Option[(List[TypeDef], Tree /*TypeTree | TypeBoundsTree*/)] = internal.matchLambdaTypeTree(tree).map(x => (x.tparams, x.body)) } implicit class LambdaTypeTreeAPI(self: LambdaTypeTree) { - def tparams given (ctx: Context): List[TypeDef] = internal.Lambdatparams(self) - def body given (ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = internal.Lambdabody(self) + def tparams(given ctx: Context): List[TypeDef] = internal.Lambdatparams(self) + def body(given ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = internal.Lambdabody(self) } object IsTypeBind { /** Matches any TypeBind and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[TypeBind] = + def unapply(tree: Tree)(given ctx: Context): Option[TypeBind] = internal.matchTypeBind(tree) } object TypeBind { - // TODO def apply(name: String, tree: Tree) given (ctx: Context): TypeBind - def copy(original: TypeBind)(name: String, tpt: Tree /*TypeTree | TypeBoundsTree*/) given (ctx: Context): TypeBind = + // TODO def apply(name: String, tree: Tree)(given ctx: Context): TypeBind + def copy(original: TypeBind)(name: String, tpt: Tree /*TypeTree | TypeBoundsTree*/)(given ctx: Context): TypeBind = internal.TypeBind_copy(original)(name, tpt) - def unapply(tree: Tree) given (ctx: Context): Option[(String, Tree /*TypeTree | TypeBoundsTree*/)] = + def unapply(tree: Tree)(given ctx: Context): Option[(String, Tree /*TypeTree | TypeBoundsTree*/)] = internal.matchTypeBind(tree).map(x => (x.name, x.body)) } implicit class TypeBindAPI(self: TypeBind) { - def name given (ctx: Context): String = internal.TypeBind_name(self) - def body given (ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = internal.TypeBind_body(self) + def name(given ctx: Context): String = internal.TypeBind_name(self) + def body(given ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = internal.TypeBind_body(self) } object IsTypeBlock { /** Matches any TypeBlock and returns it */ - def unapply(tree: Tree) given (ctx: Context): Option[TypeBlock] = + def unapply(tree: Tree)(given ctx: Context): Option[TypeBlock] = internal.matchTypeBlock(tree) } object TypeBlock { - def apply(aliases: List[TypeDef], tpt: TypeTree) given (ctx: Context): TypeBlock = + def apply(aliases: List[TypeDef], tpt: TypeTree)(given ctx: Context): TypeBlock = internal.TypeBlock_apply(aliases, tpt) - def copy(original: TypeBlock)(aliases: List[TypeDef], tpt: TypeTree) given (ctx: Context): TypeBlock = + def copy(original: TypeBlock)(aliases: List[TypeDef], tpt: TypeTree)(given ctx: Context): TypeBlock = internal.TypeBlock_copy(original)(aliases, tpt) - def unapply(tree: Tree) given (ctx: Context): Option[(List[TypeDef], TypeTree)] = + def unapply(tree: Tree)(given ctx: Context): Option[(List[TypeDef], TypeTree)] = internal.matchTypeBlock(tree).map(x => (x.aliases, x.tpt)) } implicit class TypeBlockAPI(self: TypeBlock) { - def aliases given (ctx: Context): List[TypeDef] = internal.TypeBlock_aliases(self) - def tpt given (ctx: Context): TypeTree = internal.TypeBlock_tpt(self) + def aliases(given ctx: Context): List[TypeDef] = internal.TypeBlock_aliases(self) + def tpt(given ctx: Context): TypeTree = internal.TypeBlock_tpt(self) } // ----- TypeBoundsTrees ------------------------------------------------ implicit class TypeBoundsTreeAPI(self: TypeBoundsTree) { - def tpe given (ctx: Context): TypeBounds = internal.TypeBoundsTree_tpe(self) - def low given (ctx: Context): TypeTree = internal.TypeBoundsTree_low(self) - def hi given (ctx: Context): TypeTree = internal.TypeBoundsTree_hi(self) + def tpe(given ctx: Context): TypeBounds = internal.TypeBoundsTree_tpe(self) + def low(given ctx: Context): TypeTree = internal.TypeBoundsTree_low(self) + def hi(given ctx: Context): TypeTree = internal.TypeBoundsTree_hi(self) } object IsTypeBoundsTree { - def unapply(tree: Tree) given (ctx: Context): Option[TypeBoundsTree] = + def unapply(tree: Tree)(given ctx: Context): Option[TypeBoundsTree] = internal.matchTypeBoundsTree(tree) } object TypeBoundsTree { - def unapply(tree: Tree) given (ctx: Context): Option[(TypeTree, TypeTree)] = + def unapply(tree: Tree)(given ctx: Context): Option[(TypeTree, TypeTree)] = internal.matchTypeBoundsTree(tree).map(x => (x.low, x.hi)) } implicit class WildcardTypeTreeAPI(self: WildcardTypeTree) { - def tpe given (ctx: Context): TypeOrBounds = internal.WildcardTypeTree_tpe(self) + def tpe(given ctx: Context): TypeOrBounds = internal.WildcardTypeTree_tpe(self) } object IsWildcardTypeTree { - def unapply(tree: Tree) given (ctx: Context): Option[WildcardTypeTree] = + def unapply(tree: Tree)(given ctx: Context): Option[WildcardTypeTree] = internal.matchWildcardTypeTree(tree) } /** TypeBoundsTree containing wildcard type bounds */ object WildcardTypeTree { /** Matches a TypeBoundsTree containing wildcard type bounds */ - def unapply(tree: Tree) given (ctx: Context): Boolean = + def unapply(tree: Tree)(given ctx: Context): Boolean = internal.matchWildcardTypeTree(tree).isDefined } // ----- CaseDefs ------------------------------------------------ implicit class CaseDefAPI(caseDef: CaseDef) { - def pattern given (ctx: Context): Pattern = internal.CaseDef_pattern(caseDef) - def guard given (ctx: Context): Option[Term] = internal.CaseDef_guard(caseDef) - def rhs given (ctx: Context): Term = internal.CaseDef_rhs(caseDef) + def pattern(given ctx: Context): Pattern = internal.CaseDef_pattern(caseDef) + def guard(given ctx: Context): Option[Term] = internal.CaseDef_guard(caseDef) + def rhs(given ctx: Context): Term = internal.CaseDef_rhs(caseDef) } object IsCaseDef { - def unapply(self: Tree) given (ctx: Context): Option[CaseDef] = + def unapply(self: Tree)(given ctx: Context): Option[CaseDef] = internal.matchCaseDef(self) } object CaseDef { - def apply(pattern: Pattern, guard: Option[Term], rhs: Term) given (ctx: Context): CaseDef = + def apply(pattern: Pattern, guard: Option[Term], rhs: Term)(given ctx: Context): CaseDef = internal.CaseDef_module_apply(pattern, guard, rhs) - def copy(original: CaseDef)(pattern: Pattern, guard: Option[Term], rhs: Term) given (ctx: Context): CaseDef = + def copy(original: CaseDef)(pattern: Pattern, guard: Option[Term], rhs: Term)(given ctx: Context): CaseDef = internal.CaseDef_module_copy(original)(pattern, guard, rhs) - def unapply(tree: Tree) given (ctx: Context): Option[(Pattern, Option[Term], Term)] = + def unapply(tree: Tree)(given ctx: Context): Option[(Pattern, Option[Term], Term)] = internal.matchCaseDef(tree).map( x => (x.pattern, x.guard, x.rhs)) } implicit class TypeCaseDefAPI(caseDef: TypeCaseDef) { - def pattern given (ctx: Context): TypeTree = internal.TypeCaseDef_pattern(caseDef) - def rhs given (ctx: Context): TypeTree = internal.TypeCaseDef_rhs(caseDef) + def pattern(given ctx: Context): TypeTree = internal.TypeCaseDef_pattern(caseDef) + def rhs(given ctx: Context): TypeTree = internal.TypeCaseDef_rhs(caseDef) } object IsTypeCaseDef { - def unapply(self: Tree) given (ctx: Context): Option[TypeCaseDef] = + def unapply(self: Tree)(given ctx: Context): Option[TypeCaseDef] = internal.matchTypeCaseDef(self) } object TypeCaseDef { - def apply(pattern: TypeTree, rhs: TypeTree) given (ctx: Context): TypeCaseDef = + def apply(pattern: TypeTree, rhs: TypeTree)(given ctx: Context): TypeCaseDef = internal.TypeCaseDef_module_apply(pattern, rhs) - def copy(original: TypeCaseDef)(pattern: TypeTree, rhs: TypeTree) given (ctx: Context): TypeCaseDef = + def copy(original: TypeCaseDef)(pattern: TypeTree, rhs: TypeTree)(given ctx: Context): TypeCaseDef = internal.TypeCaseDef_module_copy(original)(pattern, rhs) - def unapply(tree: Tree) given (ctx: Context): Option[(TypeTree, TypeTree)] = + def unapply(tree: Tree)(given ctx: Context): Option[(TypeTree, TypeTree)] = internal.matchTypeCaseDef(tree).map( x => (x.pattern, x.rhs)) } } diff --git a/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala b/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala index 0ace122c1475..22e7d7796cde 100644 --- a/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala +++ b/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala @@ -8,29 +8,29 @@ trait TypeOrBoundsOps extends Core { def typeOf[T: scala.quoted.Type]: Type implicit class TypeAPI(self: Type) { - def =:=(that: Type) given (ctx: Context): Boolean = internal.`Type_=:=`(self)(that) - def <:<(that: Type) given (ctx: Context): Boolean = internal.`Type_<:<`(self)(that) - def widen given (ctx: Context): Type = internal.Type_widen(self) + def =:=(that: Type)(given ctx: Context): Boolean = internal.`Type_=:=`(self)(that) + def <:<(that: Type)(given ctx: Context): Boolean = internal.`Type_<:<`(self)(that) + def widen(given ctx: Context): Type = internal.Type_widen(self) /** Follow aliases and dereferences LazyRefs, annotated types and instantiated * TypeVars until type is no longer alias type, annotated type, LazyRef, * or instantiated type variable. */ - def dealias given (ctx: Context): Type = internal.Type_dealias(self) + def dealias(given ctx: Context): Type = internal.Type_dealias(self) /** A simplified version of this type which is equivalent wrt =:= to this type. * Reduces typerefs, applied match types, and and or types. */ - def simplified given (ctx: Context): Type = internal.Type_simplified(self) + def simplified(given ctx: Context): Type = internal.Type_simplified(self) - def classSymbol given (ctx: Context): Option[ClassDefSymbol] = internal.Type_classSymbol(self) - def typeSymbol given (ctx: Context): Symbol = internal.Type_typeSymbol(self) - def termSymbol given (ctx: Context): Symbol = internal.Type_termSymbol(self) - def isSingleton given (ctx: Context): Boolean = internal.Type_isSingleton(self) - def memberType(member: Symbol) given (ctx: Context): Type = internal.Type_memberType(self)(member) + def classSymbol(given ctx: Context): Option[ClassDefSymbol] = internal.Type_classSymbol(self) + def typeSymbol(given ctx: Context): Symbol = internal.Type_typeSymbol(self) + def termSymbol(given ctx: Context): Symbol = internal.Type_termSymbol(self) + def isSingleton(given ctx: Context): Boolean = internal.Type_isSingleton(self) + def memberType(member: Symbol)(given ctx: Context): Type = internal.Type_memberType(self)(member) /** Is this type an instance of a non-bottom subclass of the given class `cls`? */ - def derivesFrom(cls: ClassDefSymbol) given (ctx: Context): Boolean = + def derivesFrom(cls: ClassDefSymbol)(given ctx: Context): Boolean = internal.Type_derivesFrom(self)(cls) /** Is this type a function type? @@ -42,353 +42,353 @@ trait TypeOrBoundsOps extends Core { * - returns true for `given Int => Int` and `erased Int => Int` * - returns false for `List[Int]`, despite that `List[Int] <:< Int => Int`. */ - def isFunctionType given (ctx: Context): Boolean = internal.Type_isFunctionType(self) + def isFunctionType(given ctx: Context): Boolean = internal.Type_isFunctionType(self) /** Is this type an implicit function type? * * @see `isFunctionType` */ - def isImplicitFunctionType given (ctx: Context): Boolean = internal.Type_isImplicitFunctionType(self) + def isImplicitFunctionType(given ctx: Context): Boolean = internal.Type_isImplicitFunctionType(self) /** Is this type an erased function type? * * @see `isFunctionType` */ - def isErasedFunctionType given (ctx: Context): Boolean = internal.Type_isErasedFunctionType(self) + def isErasedFunctionType(given ctx: Context): Boolean = internal.Type_isErasedFunctionType(self) /** Is this type a dependent function type? * * @see `isFunctionType` */ - def isDependentFunctionType given (ctx: Context): Boolean = internal.Type_isDependentFunctionType(self) + def isDependentFunctionType(given ctx: Context): Boolean = internal.Type_isDependentFunctionType(self) } object IsType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[Type] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[Type] = internal.matchType(typeOrBounds) } object Type { - def apply(clazz: Class[_]) given (ctx: Context): Type = internal.Type_apply(clazz) + def apply(clazz: Class[_])(given ctx: Context): Type = internal.Type_apply(clazz) object IsConstantType { /** Matches any ConstantType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[ConstantType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[ConstantType] = internal.matchConstantType(tpe) } object ConstantType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[Constant] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[Constant] = internal.matchConstantType(typeOrBounds).map(_.constant) } object IsTermRef { /** Matches any TermRef and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[TermRef] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[TermRef] = internal.matchTermRef(tpe) } object TermRef { - def apply(qual: TypeOrBounds, name: String) given (ctx: Context): TermRef = + def apply(qual: TypeOrBounds, name: String)(given ctx: Context): TermRef = internal.TermRef_apply(qual, name) - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(TypeOrBounds /* Type | NoPrefix */, String)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(TypeOrBounds /* Type | NoPrefix */, String)] = internal.matchTermRef(typeOrBounds).map(x => (x.qualifier, x.name)) } object IsTypeRef { /** Matches any TypeRef and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[TypeRef] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[TypeRef] = internal.matchTypeRef(tpe) } object TypeRef { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(TypeOrBounds /* Type | NoPrefix */, String)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(TypeOrBounds /* Type | NoPrefix */, String)] = internal.matchTypeRef(typeOrBounds).map(x => (x.qualifier, x.name)) } object IsSuperType { /** Matches any SuperType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[SuperType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[SuperType] = internal.matchSuperType(tpe) } object SuperType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(Type, Type)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(Type, Type)] = internal.matchSuperType(typeOrBounds).map(x => (x.thistpe, x.supertpe)) } object IsRefinement { /** Matches any Refinement and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[Refinement] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[Refinement] = internal.matchRefinement(tpe) } object Refinement { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(Type, String, TypeOrBounds /* Type | TypeBounds */)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(Type, String, TypeOrBounds /* Type | TypeBounds */)] = internal.matchRefinement(typeOrBounds).map(x => (x.parent, x.name, x.info)) } object IsAppliedType { /** Matches any AppliedType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[AppliedType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[AppliedType] = internal.matchAppliedType(tpe) } object AppliedType { - def apply(tycon: Type, args: List[TypeOrBounds]) given (ctx: Context) : AppliedType = + def apply(tycon: Type, args: List[TypeOrBounds])(given ctx: Context) : AppliedType = internal.AppliedType_apply(tycon, args) - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(Type, List[TypeOrBounds /* Type | TypeBounds */])] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(Type, List[TypeOrBounds /* Type | TypeBounds */])] = internal.matchAppliedType(typeOrBounds).map(x => (x.tycon, x.args)) } object IsAnnotatedType { /** Matches any AnnotatedType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[AnnotatedType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[AnnotatedType] = internal.matchAnnotatedType(tpe) } object AnnotatedType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(Type, Term)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(Type, Term)] = internal.matchAnnotatedType(typeOrBounds).map(x => (x.underlying, x.annot)) } object IsAndType { /** Matches any AndType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[AndType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[AndType] = internal.matchAndType(tpe) } object AndType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(Type, Type)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(Type, Type)] = internal.matchAndType(typeOrBounds).map(x => (x.left, x.right)) } object IsOrType { /** Matches any OrType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[OrType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[OrType] = internal.matchOrType(tpe) } object OrType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(Type, Type)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(Type, Type)] = internal.matchOrType(typeOrBounds).map(x => (x.left, x.right)) } object IsMatchType { /** Matches any MatchType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[MatchType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[MatchType] = internal.matchMatchType(tpe) } object MatchType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(Type, Type, List[Type])] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(Type, Type, List[Type])] = internal.matchMatchType(typeOrBounds).map(x => (x.bound, x.scrutinee, x.cases)) } object IsByNameType { /** Matches any ByNameType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[ByNameType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[ByNameType] = internal.matchByNameType(tpe) } object ByNameType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[Type] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[Type] = internal.matchByNameType(typeOrBounds).map(_.underlying) } object IsParamRef { /** Matches any ParamRef and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[ParamRef] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[ParamRef] = internal.matchParamRef(tpe) } object ParamRef { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(LambdaType[TypeOrBounds], Int)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(LambdaType[TypeOrBounds], Int)] = internal.matchParamRef(typeOrBounds).map(x => (x.binder, x.paramNum)) } object IsThisType { /** Matches any ThisType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[ThisType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[ThisType] = internal.matchThisType(tpe) } object ThisType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[Type] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[Type] = internal.matchThisType(typeOrBounds).map(_.tref) } object IsRecursiveThis { /** Matches any RecursiveThis and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[RecursiveThis] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[RecursiveThis] = internal.matchRecursiveThis(tpe) } object RecursiveThis { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[RecursiveType] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[RecursiveType] = internal.matchRecursiveThis(typeOrBounds).map(_.binder) } object IsRecursiveType { /** Matches any RecursiveType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[RecursiveType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[RecursiveType] = internal.matchRecursiveType(tpe) } object RecursiveType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[Type] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[Type] = internal.matchRecursiveType(typeOrBounds).map(_.underlying) } object IsMethodType { /** Matches any MethodType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[MethodType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[MethodType] = internal.matchMethodType(tpe) } object MethodType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(List[String], List[Type], Type)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(List[String], List[Type], Type)] = internal.matchMethodType(typeOrBounds).map(x => (x.paramNames, x.paramTypes, x.resType)) } object IsPolyType { /** Matches any PolyType and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[PolyType] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[PolyType] = internal.matchPolyType(tpe) } object PolyType { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(List[String], List[TypeBounds], Type)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(List[String], List[TypeBounds], Type)] = internal.matchPolyType(typeOrBounds).map(x => (x.paramNames, x.paramBounds, x.resType)) } object IsTypeLambda { /** Matches any TypeLambda and returns it */ - def unapply(tpe: TypeOrBounds) given (ctx: Context): Option[TypeLambda] = + def unapply(tpe: TypeOrBounds)(given ctx: Context): Option[TypeLambda] = internal.matchTypeLambda(tpe) } object TypeLambda { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(List[String], List[TypeBounds], Type)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(List[String], List[TypeBounds], Type)] = internal.matchTypeLambda(typeOrBounds).map(x => (x.paramNames, x.paramBounds, x.resType)) } } implicit class Type_ConstantTypeAPI(self: ConstantType) { - def constant given (ctx: Context): Constant = internal.ConstantType_constant(self) + def constant(given ctx: Context): Constant = internal.ConstantType_constant(self) } implicit class Type_TermRefAPI(self: TermRef) { - def qualifier given (ctx: Context): TypeOrBounds /* Type | NoPrefix */ = internal.TermRef_qualifier(self) - def name given (ctx: Context): String = internal.TermRef_name(self) + def qualifier(given ctx: Context): TypeOrBounds /* Type | NoPrefix */ = internal.TermRef_qualifier(self) + def name(given ctx: Context): String = internal.TermRef_name(self) } implicit class Type_TypeRefAPI(self: TypeRef) { - def qualifier given (ctx: Context): TypeOrBounds /* Type | NoPrefix */ = internal.TypeRef_qualifier(self) - def name given (ctx: Context): String = internal.TypeRef_name(self) + def qualifier(given ctx: Context): TypeOrBounds /* Type | NoPrefix */ = internal.TypeRef_qualifier(self) + def name(given ctx: Context): String = internal.TypeRef_name(self) } implicit class Type_SuperTypeAPI(self: SuperType) { - def thistpe given (ctx: Context): Type = internal.SuperType_thistpe(self) - def supertpe given (ctx: Context): Type = internal.SuperType_supertpe(self) + def thistpe(given ctx: Context): Type = internal.SuperType_thistpe(self) + def supertpe(given ctx: Context): Type = internal.SuperType_supertpe(self) } implicit class Type_RefinementAPI(self: Refinement) { - def parent given (ctx: Context): Type = internal.Refinement_parent(self) - def name given (ctx: Context): String = internal.Refinement_name(self) - def info given (ctx: Context): TypeOrBounds = internal.Refinement_info(self) + def parent(given ctx: Context): Type = internal.Refinement_parent(self) + def name(given ctx: Context): String = internal.Refinement_name(self) + def info(given ctx: Context): TypeOrBounds = internal.Refinement_info(self) } implicit class Type_AppliedTypeAPI(self: AppliedType) { - def tycon given (ctx: Context): Type = internal.AppliedType_tycon(self) - def args given (ctx: Context): List[TypeOrBounds /* Type | TypeBounds */] = internal.AppliedType_args(self) + def tycon(given ctx: Context): Type = internal.AppliedType_tycon(self) + def args(given ctx: Context): List[TypeOrBounds /* Type | TypeBounds */] = internal.AppliedType_args(self) } implicit class Type_AnnotatedTypeAPI(self: AnnotatedType) { - def underlying given (ctx: Context): Type = internal.AnnotatedType_underlying(self) - def annot given (ctx: Context): Term = internal.AnnotatedType_annot(self) + def underlying(given ctx: Context): Type = internal.AnnotatedType_underlying(self) + def annot(given ctx: Context): Term = internal.AnnotatedType_annot(self) } implicit class Type_AndTypeAPI(self: AndType) { - def left given (ctx: Context): Type = internal.AndType_left(self) - def right given (ctx: Context): Type = internal.AndType_right(self) + def left(given ctx: Context): Type = internal.AndType_left(self) + def right(given ctx: Context): Type = internal.AndType_right(self) } implicit class Type_OrTypeAPI(self: OrType) { - def left given (ctx: Context): Type = internal.OrType_left(self) - def right given (ctx: Context): Type = internal.OrType_right(self) + def left(given ctx: Context): Type = internal.OrType_left(self) + def right(given ctx: Context): Type = internal.OrType_right(self) } implicit class Type_MatchTypeAPI(self: MatchType) { - def bound given (ctx: Context): Type = internal.MatchType_bound(self) - def scrutinee given (ctx: Context): Type = internal.MatchType_scrutinee(self) - def cases given (ctx: Context): List[Type] = internal.MatchType_cases(self) + def bound(given ctx: Context): Type = internal.MatchType_bound(self) + def scrutinee(given ctx: Context): Type = internal.MatchType_scrutinee(self) + def cases(given ctx: Context): List[Type] = internal.MatchType_cases(self) } implicit class Type_ByNameTypeAPI(self: ByNameType) { - def underlying given (ctx: Context): Type = internal.ByNameType_underlying(self) + def underlying(given ctx: Context): Type = internal.ByNameType_underlying(self) } implicit class Type_ParamRefAPI(self: ParamRef) { - def binder given (ctx: Context): LambdaType[TypeOrBounds] = internal.ParamRef_binder(self) - def paramNum given (ctx: Context): Int = internal.ParamRef_paramNum(self) + def binder(given ctx: Context): LambdaType[TypeOrBounds] = internal.ParamRef_binder(self) + def paramNum(given ctx: Context): Int = internal.ParamRef_paramNum(self) } implicit class Type_ThisTypeAPI(self: ThisType) { - def tref given (ctx: Context): Type = internal.ThisType_tref(self) + def tref(given ctx: Context): Type = internal.ThisType_tref(self) } implicit class Type_RecursiveThisAPI(self: RecursiveThis) { - def binder given (ctx: Context): RecursiveType = internal.RecursiveThis_binder(self) + def binder(given ctx: Context): RecursiveType = internal.RecursiveThis_binder(self) } implicit class Type_RecursiveTypeAPI(self: RecursiveType) { - def underlying given (ctx: Context): Type = internal.RecursiveType_underlying(self) + def underlying(given ctx: Context): Type = internal.RecursiveType_underlying(self) } implicit class Type_MethodTypeAPI(self: MethodType) { def isImplicit: Boolean = internal.MethodType_isImplicit(self) def isErased: Boolean = internal.MethodType_isErased(self) - def paramNames given (ctx: Context): List[String] = internal.MethodType_paramNames(self) - def paramTypes given (ctx: Context): List[Type] = internal.MethodType_paramTypes(self) - def resType given (ctx: Context): Type = internal.MethodType_resType(self) + def paramNames(given ctx: Context): List[String] = internal.MethodType_paramNames(self) + def paramTypes(given ctx: Context): List[Type] = internal.MethodType_paramTypes(self) + def resType(given ctx: Context): Type = internal.MethodType_resType(self) } implicit class Type_PolyTypeAPI(self: PolyType) { - def paramNames given (ctx: Context): List[String] = internal.PolyType_paramNames(self) - def paramBounds given (ctx: Context): List[TypeBounds] = internal.PolyType_paramBounds(self) - def resType given (ctx: Context): Type = internal.PolyType_resType(self) + def paramNames(given ctx: Context): List[String] = internal.PolyType_paramNames(self) + def paramBounds(given ctx: Context): List[TypeBounds] = internal.PolyType_paramBounds(self) + def resType(given ctx: Context): Type = internal.PolyType_resType(self) } implicit class Type_TypeLambdaAPI(self: TypeLambda) { - def paramNames given (ctx: Context): List[String] = internal.TypeLambda_paramNames(self) - def paramBounds given (ctx: Context): List[TypeBounds] = internal.TypeLambda_paramBounds(self) - def resType given (ctx: Context): Type = internal.TypeLambda_resType(self) + def paramNames(given ctx: Context): List[String] = internal.TypeLambda_paramNames(self) + def paramBounds(given ctx: Context): List[TypeBounds] = internal.TypeLambda_paramBounds(self) + def resType(given ctx: Context): Type = internal.TypeLambda_resType(self) } // ----- TypeBounds ----------------------------------------------- object IsTypeBounds { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[TypeBounds] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[TypeBounds] = internal.matchTypeBounds(typeOrBounds) } object TypeBounds { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(Type, Type)] = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Option[(Type, Type)] = internal.matchTypeBounds(typeOrBounds).map(x => (x.low, x.hi)) } implicit class TypeBoundsAPI(self: TypeBounds) { - def low given (ctx: Context): Type = internal.TypeBounds_low(self) - def hi given (ctx: Context): Type = internal.TypeBounds_hi(self) + def low(given ctx: Context): Type = internal.TypeBounds_low(self) + def hi(given ctx: Context): Type = internal.TypeBounds_hi(self) } // ----- NoPrefix ------------------------------------------------- object NoPrefix { - def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Boolean = + def unapply(typeOrBounds: TypeOrBounds)(given ctx: Context): Boolean = internal.matchNoPrefix(typeOrBounds).isDefined } diff --git a/library/src/scala/util/CommandLineParser.scala b/library/src/scala/util/CommandLineParser.scala index fb4abdc4ecf7..f9dbc7daa878 100644 --- a/library/src/scala/util/CommandLineParser.scala +++ b/library/src/scala/util/CommandLineParser.scala @@ -12,7 +12,7 @@ object CommandLineParser { /** Parse command line argument `s`, which has index `n`, as a value of type `T` * @throws ParseError if argument cannot be converted to type `T`. */ - def parseString[T](str: String, n: Int) given (fs: FromString[T]): T = { + def parseString[T](str: String, n: Int)(given fs: FromString[T]): T = { try fs.fromString(str) catch { case ex: IllegalArgumentException => throw ParseError(n, ex.toString) @@ -22,14 +22,14 @@ object CommandLineParser { /** Parse `n`'th argument in `args` (counting from 0) as a value of type `T` * @throws ParseError if argument does not exist or cannot be converted to type `T`. */ - def parseArgument[T](args: Array[String], n: Int) given (fs: FromString[T]): T = + def parseArgument[T](args: Array[String], n: Int)(given fs: FromString[T]): T = if n < args.length then parseString(args(n), n) else throw ParseError(n, "more arguments expected") /** Parse all arguments from `n`'th one (counting from 0) as a list of values of type `T` * @throws ParseError if some of the arguments cannot be converted to type `T`. */ - def parseRemainingArguments[T](args: Array[String], n: Int) given (fs: FromString[T]): List[T] = + def parseRemainingArguments[T](args: Array[String], n: Int)(given fs: FromString[T]): List[T] = if n < args.length then parseString(args(n), n) :: parseRemainingArguments(args, n + 1) else Nil diff --git a/library/src/scala/util/control/NonLocalReturns.scala b/library/src/scala/util/control/NonLocalReturns.scala index 8c240f200ec1..c2de8410b856 100644 --- a/library/src/scala/util/control/NonLocalReturns.scala +++ b/library/src/scala/util/control/NonLocalReturns.scala @@ -19,13 +19,13 @@ object NonLocalReturns { } /** Performs a nonlocal return by throwing an exception. */ - def throwReturn[T](result: T) given (returner: ReturnThrowable[T]): Nothing = + def throwReturn[T](result: T)(given returner: ReturnThrowable[T]): Nothing = returner.throwReturn(result) /** Enable nonlocal returns in `op`. */ def returning[T](op: ImplicitFunction1[ReturnThrowable[T], T]): T = { val returner = new ReturnThrowable[T] - try op given returner + try op(given returner) catch { case ex: ReturnThrowable[T] => if (ex.eq(returner)) ex.result else throw ex diff --git a/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala b/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala index 0113c8ace079..49e8287e93eb 100644 --- a/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala +++ b/sbt-dotty/sbt-test/sbt-dotty/quoted-example-project/src/main/scala/hello/Hello.scala @@ -41,7 +41,7 @@ object Main { code } - def powerCode(n: Int, x: Expr[Double]) given QuoteContext: Expr[Double] = + def powerCode(n: Int, x: Expr[Double])(given QuoteContext): Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x else if (n < 0) throw new Exception("Negative powers not implemented. Left as a small exercise. Dont be shy, try it out.") diff --git a/staging/src/scala/quoted/staging/staging.scala b/staging/src/scala/quoted/staging/staging.scala index cd89f04f8c7c..a44f04cd659d 100644 --- a/staging/src/scala/quoted/staging/staging.scala +++ b/staging/src/scala/quoted/staging/staging.scala @@ -16,7 +16,7 @@ package object staging { * This method should not be called in a context where there is already has a `QuoteContext` * such as within a `run` or a `withQuoteContext`. */ - def run[T](expr: ImplicitFunction1[QuoteContext, Expr[T]]) given (toolbox: Toolbox): T = toolbox.run(expr given _) + def run[T](expr: ImplicitFunction1[QuoteContext, Expr[T]])(given toolbox: Toolbox): T = toolbox.run(expr(given _)) /** Provide a new quote context within the scope of the argument that is only valid within the scope the argument. * Return the result of the argument. @@ -32,14 +32,14 @@ package object staging { * This method should not be called in a context where there is already has a `QuoteContext` * such as within a `run` or a `withQuoteContext`. */ - def withQuoteContext[T](thunk: ImplicitFunction1[QuoteContext, T]) given (toolbox: Toolbox): T = { + def withQuoteContext[T](thunk: ImplicitFunction1[QuoteContext, T])(given toolbox: Toolbox): T = { val noResult = new Object var result: T = noResult.asInstanceOf[T] - def dummyRun given QuoteContext: Expr[Unit] = { + def dummyRun(given QuoteContext): Expr[Unit] = { result = thunk Expr.unitExpr } - toolbox.run(dummyRun given _) + toolbox.run(dummyRun(given _)) assert(result != noResult) // toolbox.run should have thrown an exception result } diff --git a/staging/test-resources/repl-staging/i6007 b/staging/test-resources/repl-staging/i6007 index cc2e2d09d97d..f6d25367eb96 100644 --- a/staging/test-resources/repl-staging/i6007 +++ b/staging/test-resources/repl-staging/i6007 @@ -2,7 +2,7 @@ scala> import scala.quoted._ scala> import scala.quoted.staging._ scala> implicit def toolbox: Toolbox = Toolbox.make(getClass.getClassLoader) def toolbox: quoted.staging.Toolbox -scala> def v given QuoteContext = '{ (if true then Some(1) else None).map(v => v+1) } +scala> def v(given QuoteContext) = '{ (if true then Some(1) else None).map(v => v+1) } def v given (x$1: quoted.QuoteContext): quoted.Expr[Option[Int]] scala> scala.quoted.staging.withQuoteContext(v.show) val res0: String = (if (true) scala.Some.apply[scala.Int](1) else scala.None).map[scala.Int](((v: scala.Int) => v.+(1))) diff --git a/tests/neg-macros/quote-this.scala b/tests/neg-macros/quote-this.scala index f7857e6f01b1..76dbf3f11469 100644 --- a/tests/neg-macros/quote-this.scala +++ b/tests/neg-macros/quote-this.scala @@ -12,12 +12,12 @@ class Foo { } inline def i(): Unit = ${ Foo.impl[Any]('{ - given QuoteContext = ??? + (given QuoteContext) = ??? 'this // error }) } inline def j(that: Foo): Unit = ${ Foo.impl[Any]('{ - given QuoteContext = ??? + (given QuoteContext) = ??? 'that // error }) } diff --git a/tests/neg/i4044a.scala b/tests/neg/i4044a.scala index 1c88be92c4e4..9d90589b09e5 100644 --- a/tests/neg/i4044a.scala +++ b/tests/neg/i4044a.scala @@ -4,11 +4,11 @@ def test(given QuoteContext) = { val a = '{1} '{ - given QuoteContext = ??? + (given QuoteContext) = ??? a // error $a '{$a} // error - '{ given QuoteContext = ???; '{$a} } // error + '{(given QuoteContext) = ???; '{$a} } // error } } diff --git a/tests/neg/i4044b.scala b/tests/neg/i4044b.scala index 791c7f72e3c0..85b2a90fc6d0 100644 --- a/tests/neg/i4044b.scala +++ b/tests/neg/i4044b.scala @@ -3,17 +3,17 @@ import scala.quoted._ def test(given QuoteContext) = { '{ - given QuoteContext = ??? + (given QuoteContext) = ??? val b = '{3} '{ - given QuoteContext = ??? + (given QuoteContext) = ??? b // error ${b} ${ '{b} } // error - '{ given QuoteContext = ???; '{$b} } // error + '{(given QuoteContext) = ???; '{$b} } // error } } diff --git a/tests/neg/i7052b.scala b/tests/neg/i7052b.scala index 941ee57fee37..911584fff64b 100644 --- a/tests/neg/i7052b.scala +++ b/tests/neg/i7052b.scala @@ -1,7 +1,7 @@ import scala.quoted._ class Test { def foo(str: String)(given QuoteContext) = '{ - given QuoteContext = ??? + (given QuoteContext) = ??? '{ @deprecated(str, "") // error def bar = ??? diff --git a/tests/neg/quote-0.scala b/tests/neg/quote-0.scala index 6a07f6abf413..d80691ee95ba 100644 --- a/tests/neg/quote-0.scala +++ b/tests/neg/quote-0.scala @@ -5,7 +5,7 @@ def test(given QuoteContext) = { val x: Int = 0 '{ - given QuoteContext = ??? + (given QuoteContext) = ??? '{x + 1} // error: wrong staging level diff --git a/tests/patmat/i6255.scala b/tests/patmat/i6255.scala index b36c0a640830..df4e31e8276b 100644 --- a/tests/patmat/i6255.scala +++ b/tests/patmat/i6255.scala @@ -1,5 +1,5 @@ class Foo { - def foo(x: quoted.Expr[Int]) given scala.quoted.QuoteContext: Unit = x match { + def foo(x: quoted.Expr[Int])(given scala.quoted.QuoteContext): Unit = x match { case '{ 1 } => case '{ 2 } => case _ => diff --git a/tests/pos/i4380b.scala b/tests/pos/i4380b.scala index 51b9c986d364..336a741f1dc4 100644 --- a/tests/pos/i4380b.scala +++ b/tests/pos/i4380b.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Test { - given QuoteContext = ??? + (given QuoteContext) = ??? def step(k: (String => Expr[Unit])): Expr[Unit] = '{} def meth(): Unit = '{ (i: Int) => ${ step(el => '{} ) } diff --git a/tests/pos/i4414.scala b/tests/pos/i4414.scala index 0517942a555b..1b7e5c590799 100644 --- a/tests/pos/i4414.scala +++ b/tests/pos/i4414.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Test { - given QuoteContext = ??? + (given QuoteContext) = ??? def a[A: Type](): Unit = { b[Expr[A]]() diff --git a/tests/pos/quote-1.scala b/tests/pos/quote-1.scala index 8265f3a2fcde..1b01a2e26427 100644 --- a/tests/pos/quote-1.scala +++ b/tests/pos/quote-1.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Test { - given QuoteContext = ??? + (given QuoteContext) = ??? def f[T](x: Expr[T])(implicit t: Type[T]) = '{ val y: $t = $x diff --git a/tests/pos/quote-lift.scala b/tests/pos/quote-lift.scala index 102a30b0e0ad..abf017f52ea0 100644 --- a/tests/pos/quote-lift.scala +++ b/tests/pos/quote-lift.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Test { - given QuoteContext = ??? + (given QuoteContext) = ??? '{ ${implicitly[Liftable[Int]].toExpr(1)} } diff --git a/tests/pos/quote-liftable.scala b/tests/pos/quote-liftable.scala index d431911bf51f..6329ba3a8e91 100644 --- a/tests/pos/quote-liftable.scala +++ b/tests/pos/quote-liftable.scala @@ -2,7 +2,7 @@ import scala.quoted._ def test(given QuoteContext) = { - given QuoteContext = ??? + (given QuoteContext) = ??? implicit def IntIsLiftable: Liftable[Int] = new { def toExpr(n: Int) = n match { diff --git a/tests/pos/quoted-inline-quote.scala b/tests/pos/quoted-inline-quote.scala index 713de60e0df5..fad0257da95e 100644 --- a/tests/pos/quoted-inline-quote.scala +++ b/tests/pos/quoted-inline-quote.scala @@ -2,6 +2,6 @@ import scala.quoted._ class Foo { inline def foo(x: Expr[String])(given QuoteContext) = '{ println(${x}) } - given QuoteContext = ??? + (given QuoteContext) = ??? foo('{"abc"}) } diff --git a/tests/run-macros/tasty-macro-positions/quoted_1.scala b/tests/run-macros/tasty-macro-positions/quoted_1.scala index aa2c93bfb59c..c24b96bc1797 100644 --- a/tests/run-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/run-macros/tasty-macro-positions/quoted_1.scala @@ -29,7 +29,7 @@ object Macros { } def posStr(qctx: QuoteContext)(pos: qctx.tasty.Position): Expr[String] = { - given QuoteContext = qctx + (given QuoteContext) = qctx import qctx.tasty._ s"${pos.sourceFile.jpath.getFileName.toString}:[${pos.start}..${pos.end}]".toExpr } From fc8e1cdc1cc52e44247312cf351810a889d6d866 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 18 Sep 2019 08:43:04 +0200 Subject: [PATCH 08/20] Fix regex replace breakage --- tests/neg-macros/quote-this.scala | 4 ++-- tests/neg/i4044a.scala | 2 +- tests/neg/i4044b.scala | 4 ++-- tests/neg/i7052b.scala | 2 +- tests/neg/quote-0.scala | 2 +- tests/pos/i4380b.scala | 2 +- tests/pos/i4414.scala | 2 +- tests/pos/quote-1.scala | 2 +- tests/pos/quote-lift.scala | 2 +- tests/pos/quote-liftable.scala | 2 +- tests/pos/quoted-inline-quote.scala | 2 +- tests/run-macros/tasty-macro-positions/quoted_1.scala | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/neg-macros/quote-this.scala b/tests/neg-macros/quote-this.scala index 76dbf3f11469..7b51712f36fb 100644 --- a/tests/neg-macros/quote-this.scala +++ b/tests/neg-macros/quote-this.scala @@ -12,12 +12,12 @@ class Foo { } inline def i(): Unit = ${ Foo.impl[Any]('{ - (given QuoteContext) = ??? + given QuoteContext = ??? 'this // error }) } inline def j(that: Foo): Unit = ${ Foo.impl[Any]('{ - (given QuoteContext) = ??? + given QuoteContext = ??? 'that // error }) } diff --git a/tests/neg/i4044a.scala b/tests/neg/i4044a.scala index 9d90589b09e5..bc7f4dc4d306 100644 --- a/tests/neg/i4044a.scala +++ b/tests/neg/i4044a.scala @@ -4,7 +4,7 @@ def test(given QuoteContext) = { val a = '{1} '{ - (given QuoteContext) = ??? + given QuoteContext = ??? a // error $a '{$a} // error diff --git a/tests/neg/i4044b.scala b/tests/neg/i4044b.scala index 85b2a90fc6d0..09402d7e7dc6 100644 --- a/tests/neg/i4044b.scala +++ b/tests/neg/i4044b.scala @@ -3,12 +3,12 @@ import scala.quoted._ def test(given QuoteContext) = { '{ - (given QuoteContext) = ??? + given QuoteContext = ??? val b = '{3} '{ - (given QuoteContext) = ??? + given QuoteContext = ??? b // error ${b} diff --git a/tests/neg/i7052b.scala b/tests/neg/i7052b.scala index 911584fff64b..941ee57fee37 100644 --- a/tests/neg/i7052b.scala +++ b/tests/neg/i7052b.scala @@ -1,7 +1,7 @@ import scala.quoted._ class Test { def foo(str: String)(given QuoteContext) = '{ - (given QuoteContext) = ??? + given QuoteContext = ??? '{ @deprecated(str, "") // error def bar = ??? diff --git a/tests/neg/quote-0.scala b/tests/neg/quote-0.scala index d80691ee95ba..f82e8cb39771 100644 --- a/tests/neg/quote-0.scala +++ b/tests/neg/quote-0.scala @@ -5,7 +5,7 @@ def test(given QuoteContext) = { val x: Int = 0 '{ - (given QuoteContext) = ??? + given QuoteContext = ??? '{x + 1} // error: wrong staging level diff --git a/tests/pos/i4380b.scala b/tests/pos/i4380b.scala index 336a741f1dc4..51b9c986d364 100644 --- a/tests/pos/i4380b.scala +++ b/tests/pos/i4380b.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Test { - (given QuoteContext) = ??? + given QuoteContext = ??? def step(k: (String => Expr[Unit])): Expr[Unit] = '{} def meth(): Unit = '{ (i: Int) => ${ step(el => '{} ) } diff --git a/tests/pos/i4414.scala b/tests/pos/i4414.scala index 1b7e5c590799..0517942a555b 100644 --- a/tests/pos/i4414.scala +++ b/tests/pos/i4414.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Test { - (given QuoteContext) = ??? + given QuoteContext = ??? def a[A: Type](): Unit = { b[Expr[A]]() diff --git a/tests/pos/quote-1.scala b/tests/pos/quote-1.scala index 1b01a2e26427..8265f3a2fcde 100644 --- a/tests/pos/quote-1.scala +++ b/tests/pos/quote-1.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Test { - (given QuoteContext) = ??? + given QuoteContext = ??? def f[T](x: Expr[T])(implicit t: Type[T]) = '{ val y: $t = $x diff --git a/tests/pos/quote-lift.scala b/tests/pos/quote-lift.scala index abf017f52ea0..248dfbbd5bbd 100644 --- a/tests/pos/quote-lift.scala +++ b/tests/pos/quote-lift.scala @@ -1,7 +1,7 @@ import scala.quoted._ object Test { - (given QuoteContext) = ??? + given QuoteContext = ??? '{ ${implicitly[Liftable[Int]].toExpr(1)} } diff --git a/tests/pos/quote-liftable.scala b/tests/pos/quote-liftable.scala index 6329ba3a8e91..d431911bf51f 100644 --- a/tests/pos/quote-liftable.scala +++ b/tests/pos/quote-liftable.scala @@ -2,7 +2,7 @@ import scala.quoted._ def test(given QuoteContext) = { - (given QuoteContext) = ??? + given QuoteContext = ??? implicit def IntIsLiftable: Liftable[Int] = new { def toExpr(n: Int) = n match { diff --git a/tests/pos/quoted-inline-quote.scala b/tests/pos/quoted-inline-quote.scala index fad0257da95e..713de60e0df5 100644 --- a/tests/pos/quoted-inline-quote.scala +++ b/tests/pos/quoted-inline-quote.scala @@ -2,6 +2,6 @@ import scala.quoted._ class Foo { inline def foo(x: Expr[String])(given QuoteContext) = '{ println(${x}) } - (given QuoteContext) = ??? + given QuoteContext = ??? foo('{"abc"}) } diff --git a/tests/run-macros/tasty-macro-positions/quoted_1.scala b/tests/run-macros/tasty-macro-positions/quoted_1.scala index c24b96bc1797..aa2c93bfb59c 100644 --- a/tests/run-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/run-macros/tasty-macro-positions/quoted_1.scala @@ -29,7 +29,7 @@ object Macros { } def posStr(qctx: QuoteContext)(pos: qctx.tasty.Position): Expr[String] = { - (given QuoteContext) = qctx + given QuoteContext = qctx import qctx.tasty._ s"${pos.sourceFile.jpath.getFileName.toString}:[${pos.start}..${pos.end}]".toExpr } From 45cba372f108a084070085c7e5d646672ba36e82 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 18 Sep 2019 08:55:29 +0200 Subject: [PATCH 09/20] Adapt CB projects to new given syntax --- community-build/community-projects/semanticdb | 2 +- community-build/community-projects/xml-interpolator | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/community-build/community-projects/semanticdb b/community-build/community-projects/semanticdb index abab7ed319b4..856d0157fa98 160000 --- a/community-build/community-projects/semanticdb +++ b/community-build/community-projects/semanticdb @@ -1 +1 @@ -Subproject commit abab7ed319b4ef5406c4640058f7e8e874098b1c +Subproject commit 856d0157fa981f2796fbc058bdbc6828a9132d03 diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index e7e12e4a5451..be8c4051304e 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit e7e12e4a54512142101bd2ebf6e4bd55e2282b93 +Subproject commit be8c4051304e8d8f5225ae51b7a233216128c7ce From f224aad4634f16e7828720d8ce240c4e557856ff Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 18 Sep 2019 09:21:15 +0200 Subject: [PATCH 10/20] More fixes --- compiler/test-resources/repl/erased-implicit | 2 +- .../test/dotty/tools/languageserver/util/CodeTester.scala | 4 ++-- tests/neg/i4044a.scala | 2 +- tests/neg/i4044b.scala | 2 +- tests/patmat/i6255b.scala | 2 +- tests/run-staging/i5152.scala | 2 +- tests/run-staging/shonan-hmm-simple.scala | 6 +++--- .../tasty-interpreter/interpreter/TastyInterpreter.scala | 2 +- .../tasty-interpreter/interpreter/TreeInterpreter.scala | 6 +++--- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/compiler/test-resources/repl/erased-implicit b/compiler/test-resources/repl/erased-implicit index ffaba6595a79..0e3020c8cd45 100644 --- a/compiler/test-resources/repl/erased-implicit +++ b/compiler/test-resources/repl/erased-implicit @@ -1,2 +1,2 @@ scala> def f(given erased a: Int): Int = ??? -def f(given erased a: Int): Int +def f given erased (a: Int): Int diff --git a/language-server/test/dotty/tools/languageserver/util/CodeTester.scala b/language-server/test/dotty/tools/languageserver/util/CodeTester.scala index d20e39a4ff49..821eb86686b7 100644 --- a/language-server/test/dotty/tools/languageserver/util/CodeTester.scala +++ b/language-server/test/dotty/tools/languageserver/util/CodeTester.scala @@ -237,7 +237,7 @@ class CodeTester(projects: List[Project]) { private def doAction(action: Action): this.type = { try { - action.execute() given (testServer, testServer.client, positions) + action.execute()(given testServer, testServer.client, positions) } catch { case ex: AssertionError => val sourcesStr = @@ -252,7 +252,7 @@ class CodeTester(projects: List[Project]) { | |$sourcesStr | - |while executing action: ${action.show given positions} + |while executing action: ${action.show(given positions)} | """.stripMargin val assertionError = new AssertionError(msg + ex.getMessage) diff --git a/tests/neg/i4044a.scala b/tests/neg/i4044a.scala index bc7f4dc4d306..78f23fe63f04 100644 --- a/tests/neg/i4044a.scala +++ b/tests/neg/i4044a.scala @@ -8,7 +8,7 @@ def test(given QuoteContext) = { a // error $a '{$a} // error - '{(given QuoteContext) = ???; '{$a} } // error + '{ given QuoteContext =???; '{$a} } // error } } diff --git a/tests/neg/i4044b.scala b/tests/neg/i4044b.scala index 09402d7e7dc6..dc2076097fb2 100644 --- a/tests/neg/i4044b.scala +++ b/tests/neg/i4044b.scala @@ -13,7 +13,7 @@ def test(given QuoteContext) = { b // error ${b} ${ '{b} } // error - '{(given QuoteContext) = ???; '{$b} } // error + '{ given QuoteContext =???; '{$b} } // error } } diff --git a/tests/patmat/i6255b.scala b/tests/patmat/i6255b.scala index fd643d69d346..b9982c8024f0 100644 --- a/tests/patmat/i6255b.scala +++ b/tests/patmat/i6255b.scala @@ -1,5 +1,5 @@ class Foo { - def foo(x: quoted.Expr[Int]) given scala.quoted.QuoteContext: Unit = x match { + def foo(x: quoted.Expr[Int])(given scala.quoted.QuoteContext): Unit = x match { case '{ 1 } => case '{ 2 } => } diff --git a/tests/run-staging/i5152.scala b/tests/run-staging/i5152.scala index 125a3518cc86..930632af23b0 100644 --- a/tests/run-staging/i5152.scala +++ b/tests/run-staging/i5152.scala @@ -5,7 +5,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def eval1(ff: Expr[Int => Int])(given QuoteContext): Expr[Int => Int] = '{identity} - def peval1()given QuoteContext: Expr[Unit] = '{ + def peval1()(given QuoteContext): Expr[Unit] = '{ lazy val f: Int => Int = ${eval1('{(y: Int) => f(y)})} } diff --git a/tests/run-staging/shonan-hmm-simple.scala b/tests/run-staging/shonan-hmm-simple.scala index 37f4fdb5d8bf..80cd92382eed 100644 --- a/tests/run-staging/shonan-hmm-simple.scala +++ b/tests/run-staging/shonan-hmm-simple.scala @@ -35,13 +35,13 @@ class RingComplex[U](u: Ring[U]) extends Ring[Complex[U]] { } sealed trait PV[T] { - def expr given Liftable[T], QuoteContext: Expr[T] + def expr(given Liftable[T], QuoteContext): Expr[T] } case class Sta[T](x: T) extends PV[T] { - def expr given Liftable[T], QuoteContext: Expr[T] = x + def expr(given Liftable[T], QuoteContext): Expr[T] = x } case class Dyn[T](x: Expr[T]) extends PV[T] { - def expr given Liftable[T], QuoteContext: Expr[T] = x + def expr(given Liftable[T], QuoteContext): Expr[T] = x } class RingPV[U: Liftable](u: Ring[U], eu: Ring[Expr[U]])(given QuoteContext) extends Ring[PV[U]] { diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala index bb389a21cd0b..6484db2e512e 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala @@ -14,7 +14,7 @@ class TastyInterpreter extends TastyConsumer { case DefDef("main", _, _, _, Some(rhs)) => val interpreter = new jvm.Interpreter(reflect) - interpreter.eval(rhs) given Map.empty + interpreter.eval(rhs)(given Map.empty) // TODO: recurse only for PackageDef, ClassDef case tree => super.traverseTree(tree) diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala index 7ca419aca141..56d9fae5d128 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala @@ -65,7 +65,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) given accEnv + def evalRhs = eval(rhs)(given 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) @@ -76,10 +76,10 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { // TODO: record the environment for closure purposes accEnv case stat => - eval(stat) given accEnv + eval(stat)(given accEnv) accEnv }) - eval(expr) given newEnv + eval(expr)(given newEnv) } def interpretUnit(): AbstractAny From 40c9bc82383a862ff9cb19a518b5065301c995ec Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 18 Sep 2019 09:24:32 +0200 Subject: [PATCH 11/20] Adapt CB projects to new given syntax --- community-build/community-projects/xml-interpolator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index be8c4051304e..f4003e569f50 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit be8c4051304e8d8f5225ae51b7a233216128c7ce +Subproject commit f4003e569f509b93ba541181b739e72e4365c8ea From 25af1de8fa1686dc5c8a44366ebdacb72341ccce Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 18 Sep 2019 11:11:34 +0200 Subject: [PATCH 12/20] Switch to new syntax for printing method types --- .../dotty/tools/dotc/printing/PlainPrinter.scala | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index bb412faff500..9ebff5785358 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -186,12 +186,13 @@ class PlainPrinter(_ctx: Context) extends Printer { "" case tp: MethodType => changePrec(GlobalPrec) { - (if (tp.isContextualMethod) " given" else "") ~ - (if (tp.isErasedMethod) " erased" else "") ~~ - ("(" + (if (tp.isImplicitMethod && !tp.isContextualMethod) "implicit " else "")) ~ - paramsText(tp) ~ - (if (tp.resultType.isInstanceOf[MethodType]) ")" else "): ") ~ - toText(tp.resultType) + "(" + ~ "given ".provided(tp.isContextualMethod) + ~ "erased ".provided(tp.isErasedMethod) + ~ "implicit ".provided(tp.isImplicitMethod && !tp.isContextualMethod) + ~ paramsText(tp) + ~ (if tp.resultType.isInstanceOf[MethodType] then ")" else "): " + ~ toText(tp.resultType) } case tp: ExprType => changePrec(GlobalPrec) { "=> " ~ toText(tp.resultType) } From ff4346694395063808ac18a0ce54dbee333f2067 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 18 Sep 2019 11:28:51 +0200 Subject: [PATCH 13/20] Update docs/docs/reference/metaprogramming/macros-spec.md --- docs/docs/reference/metaprogramming/macros-spec.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/reference/metaprogramming/macros-spec.md b/docs/docs/reference/metaprogramming/macros-spec.md index 3d2f7a41ffca..7b5a8bfc1da2 100644 --- a/docs/docs/reference/metaprogramming/macros-spec.md +++ b/docs/docs/reference/metaprogramming/macros-spec.md @@ -55,7 +55,7 @@ extends simply-typed lambda calculus with quotes and splices. ### Syntax -The syntax of terms, values, and types is given follows: +The syntax of terms, values, and types is given as follows: Terms t ::= x variable (x: T) => t lambda @@ -239,4 +239,4 @@ downright pleasant. A simple strategy first defines the underlying quoted or unq values using `Expr` and `Type` and then inserts quotes and splices to make the types line up. Phase consistency is at the same time a great guideline where to insert a splice or a quote and a vital sanity check that -the result makes sense. \ No newline at end of file +the result makes sense. From 14c4366db54adbda15fa0e20d92dff2c2a1a64fd Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 18 Sep 2019 11:36:12 +0200 Subject: [PATCH 14/20] Add missing Str --- compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 9ebff5785358..7c47a124ab24 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -187,11 +187,11 @@ class PlainPrinter(_ctx: Context) extends Printer { case tp: MethodType => changePrec(GlobalPrec) { "(" - ~ "given ".provided(tp.isContextualMethod) - ~ "erased ".provided(tp.isErasedMethod) - ~ "implicit ".provided(tp.isImplicitMethod && !tp.isContextualMethod) + ~ Str("given ").provided(tp.isContextualMethod) + ~ Str("erased ").provided(tp.isErasedMethod) + ~ Str("implicit ").provided(tp.isImplicitMethod && !tp.isContextualMethod) ~ paramsText(tp) - ~ (if tp.resultType.isInstanceOf[MethodType] then ")" else "): " + ~ (if tp.resultType.isInstanceOf[MethodType] then ")" else "): ") ~ toText(tp.resultType) } case tp: ExprType => From 30ccaf621bcece197b7fd2c5fbc0fe3103313d24 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 18 Sep 2019 12:21:55 +0200 Subject: [PATCH 15/20] Fix tests --- tests/neg/i4044a.scala | 2 +- tests/neg/i4044b.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/neg/i4044a.scala b/tests/neg/i4044a.scala index 78f23fe63f04..1c88be92c4e4 100644 --- a/tests/neg/i4044a.scala +++ b/tests/neg/i4044a.scala @@ -8,7 +8,7 @@ def test(given QuoteContext) = { a // error $a '{$a} // error - '{ given QuoteContext =???; '{$a} } // error + '{ given QuoteContext = ???; '{$a} } // error } } diff --git a/tests/neg/i4044b.scala b/tests/neg/i4044b.scala index dc2076097fb2..791c7f72e3c0 100644 --- a/tests/neg/i4044b.scala +++ b/tests/neg/i4044b.scala @@ -13,7 +13,7 @@ def test(given QuoteContext) = { b // error ${b} ${ '{b} } // error - '{ given QuoteContext =???; '{$b} } // error + '{ given QuoteContext = ???; '{$b} } // error } } From 7bc9741f76a3b6caaaf77cdb59ad64d4ddd1359a Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 18 Sep 2019 12:24:29 +0200 Subject: [PATCH 16/20] Update repl test output --- compiler/test-resources/repl/defs | 2 +- compiler/test-resources/repl/erased-implicit | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/test-resources/repl/defs b/compiler/test-resources/repl/defs index 40d0de8458ca..7e9570b3ec30 100644 --- a/compiler/test-resources/repl/defs +++ b/compiler/test-resources/repl/defs @@ -11,4 +11,4 @@ def id(x: 4): 4 scala> id(4) val res0: Int = 4 scala> def f(given Int) = 1 -def f given (x$1: Int): Int +def f(given x$1: Int): Int diff --git a/compiler/test-resources/repl/erased-implicit b/compiler/test-resources/repl/erased-implicit index 0e3020c8cd45..ffaba6595a79 100644 --- a/compiler/test-resources/repl/erased-implicit +++ b/compiler/test-resources/repl/erased-implicit @@ -1,2 +1,2 @@ scala> def f(given erased a: Int): Int = ??? -def f given erased (a: Int): Int +def f(given erased a: Int): Int From df6db9ad914944446f667e9f63ac352d46ffedfb Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 18 Sep 2019 12:27:57 +0200 Subject: [PATCH 17/20] Update test --- .../tasty-interpreter/interpreter/TreeInterpreter.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala index 56d9fae5d128..b0fb90327882 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala @@ -18,7 +18,7 @@ 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: (given Env) => T)(implicit env: Env): T = - in given env.updated(sym, value) + in(given env.updated(sym, value)) def withLocalValues[T](syms: List[Symbol], values: List[LocalValue])(in: (given Env) => T)(implicit env: Env): T = in(given env ++ syms.zip(values)) From 1f08e5bbe41d92bf2e4678aeb124ab8d074405f4 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 18 Sep 2019 12:35:18 +0200 Subject: [PATCH 18/20] Update `the` to `summon` --- community-build/community-projects/xml-interpolator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index f4003e569f50..38f2de8f44f2 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit f4003e569f509b93ba541181b739e72e4365c8ea +Subproject commit 38f2de8f44f2e7a1e52386a949ff4ea4cda0aaef From c5ca1f82fceb0d1f68ff734987a074f601ae6b04 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 18 Sep 2019 12:37:46 +0200 Subject: [PATCH 19/20] Use keywordText for argument modifiers --- compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 7c47a124ab24..7158f1640c76 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -187,9 +187,9 @@ class PlainPrinter(_ctx: Context) extends Printer { case tp: MethodType => changePrec(GlobalPrec) { "(" - ~ Str("given ").provided(tp.isContextualMethod) - ~ Str("erased ").provided(tp.isErasedMethod) - ~ Str("implicit ").provided(tp.isImplicitMethod && !tp.isContextualMethod) + ~ keywordText("given ").provided(tp.isContextualMethod) + ~ keywordText("erased ").provided(tp.isErasedMethod) + ~ keywordText("implicit ").provided(tp.isImplicitMethod && !tp.isContextualMethod) ~ paramsText(tp) ~ (if tp.resultType.isInstanceOf[MethodType] then ")" else "): ") ~ toText(tp.resultType) From 4d79c90b234de00bc6426f64c930817f758da8e7 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 18 Sep 2019 12:57:14 +0200 Subject: [PATCH 20/20] Fix repl-staging test --- staging/test-resources/repl-staging/i6007 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staging/test-resources/repl-staging/i6007 b/staging/test-resources/repl-staging/i6007 index f6d25367eb96..e5c8dc587edd 100644 --- a/staging/test-resources/repl-staging/i6007 +++ b/staging/test-resources/repl-staging/i6007 @@ -3,7 +3,7 @@ scala> import scala.quoted.staging._ scala> implicit def toolbox: Toolbox = Toolbox.make(getClass.getClassLoader) def toolbox: quoted.staging.Toolbox scala> def v(given QuoteContext) = '{ (if true then Some(1) else None).map(v => v+1) } -def v given (x$1: quoted.QuoteContext): quoted.Expr[Option[Int]] +def v(given x$1: quoted.QuoteContext): quoted.Expr[Option[Int]] scala> scala.quoted.staging.withQuoteContext(v.show) val res0: String = (if (true) scala.Some.apply[scala.Int](1) else scala.None).map[scala.Int](((v: scala.Int) => v.+(1))) scala> scala.quoted.staging.run(v)