@@ -274,9 +274,9 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
274
274
type TypeBoundsTree = internal.TypeBoundsTree
275
275
276
276
/** Type tree representing wildcard type bounds written in the source.
277
- * The wildcard type `_` (for example in in `List[_]`) will be a type tree that
278
- * represents a type but has `TypeBound`a inside.
279
- */
277
+ * The wildcard type `_` (for example in in `List[_]`) will be a type tree that
278
+ * represents a type but has `TypeBound`a inside.
279
+ */
280
280
type WildcardTypeTree = internal.WildcardTypeTree
281
281
282
282
/** Branch of a pattern match or catch clause */
@@ -367,10 +367,10 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
367
367
368
368
369
369
/** Import selectors:
370
- * * SimpleSelector: `.bar` in `import foo.bar`
371
- * * RenameSelector: `.{bar => baz}` in `import foo.{bar => baz}`
372
- * * OmitSelector: `.{bar => _}` in `import foo.{bar => _}`
373
- */
370
+ * * SimpleSelector: `.bar` in `import foo.bar`
371
+ * * RenameSelector: `.{bar => baz}` in `import foo.{bar => baz}`
372
+ * * OmitSelector: `.{bar => _}` in `import foo.{bar => _}`
373
+ */
374
374
type ImportSelector = internal.ImportSelector
375
375
type SimpleSelector = internal.SimpleSelector
376
376
type RenameSelector = internal.RenameSelector
@@ -395,8 +395,8 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
395
395
type Constant = internal.Constant
396
396
397
397
/** Symbol of a definition.
398
- * Then can be compared with == to know if the definition is the same.
399
- */
398
+ * Then can be compared with == to know if the definition is the same.
399
+ */
400
400
type Symbol = internal.Symbol
401
401
402
402
/** FlagSet of a Symbol */
@@ -454,25 +454,27 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
454
454
/** Context of the macro expansion */
455
455
given rootContext : Context = internal.rootContext // TODO: Use given // TODO: Should this be moved to QuoteContext?
456
456
457
- extension ContextOps on (self : Context ) {
458
- /** Returns the owner of the context */
459
- def owner : Symbol = internal.Context_owner (self)
457
+ object Context {
458
+ extension ContextOps on (self : Context ) {
459
+ /** Returns the owner of the context */
460
+ def owner : Symbol = internal.Context_owner (self)
460
461
461
- /** Returns the source file being compiled. The path is relative to the current working directory. */
462
- def source : java.nio.file.Path = internal.Context_source (self)
462
+ /** Returns the source file being compiled. The path is relative to the current working directory. */
463
+ def source : java.nio.file.Path = internal.Context_source (self)
463
464
464
- /** Get package symbol if package is either defined in current compilation run or present on classpath. */
465
- def requiredPackage (path : String ): Symbol = internal.Context_requiredPackage (self)(path)
465
+ /** Get package symbol if package is either defined in current compilation run or present on classpath. */
466
+ def requiredPackage (path : String ): Symbol = internal.Context_requiredPackage (self)(path)
466
467
467
- /** Get class symbol if class is either defined in current compilation run or present on classpath. */
468
- def requiredClass (path : String ): Symbol = internal.Context_requiredClass (self)(path)
468
+ /** Get class symbol if class is either defined in current compilation run or present on classpath. */
469
+ def requiredClass (path : String ): Symbol = internal.Context_requiredClass (self)(path)
469
470
470
- /** Get module symbol if module is either defined in current compilation run or present on classpath. */
471
- def requiredModule (path : String ): Symbol = internal.Context_requiredModule (self)(path)
471
+ /** Get module symbol if module is either defined in current compilation run or present on classpath. */
472
+ def requiredModule (path : String ): Symbol = internal.Context_requiredModule (self)(path)
472
473
473
- /** Get method symbol if method is either defined in current compilation run or present on classpath. Throws if the method has an overload. */
474
- def requiredMethod (path : String ): Symbol = internal.Context_requiredMethod (self)(path)
474
+ /** Get method symbol if method is either defined in current compilation run or present on classpath. Throws if the method has an overload. */
475
+ def requiredMethod (path : String ): Symbol = internal.Context_requiredMethod (self)(path)
475
476
477
+ }
476
478
}
477
479
478
480
@@ -675,19 +677,19 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
675
677
object Ref {
676
678
677
679
/** Create a reference tree from a symbol
678
- *
679
- * If `sym` refers to a class member `foo` in class `C`,
680
- * returns a tree representing `C.this.foo`.
681
- *
682
- * If `sym` refers to a local definition `foo`, returns
683
- * a tree representing `foo`.
684
- *
685
- * @note In both cases, the constructed tree should only
686
- * be spliced into the places where such accesses make sense.
687
- * For example, it is incorrect to have `C.this.foo` outside
688
- * the class body of `C`, or have `foo` outside the lexical
689
- * scope for the definition of `foo`.
690
- */
680
+ *
681
+ * If `sym` refers to a class member `foo` in class `C`,
682
+ * returns a tree representing `C.this.foo`.
683
+ *
684
+ * If `sym` refers to a local definition `foo`, returns
685
+ * a tree representing `foo`.
686
+ *
687
+ * @note In both cases, the constructed tree should only
688
+ * be spliced into the places where such accesses make sense.
689
+ * For example, it is incorrect to have `C.this.foo` outside
690
+ * the class body of `C`, or have `foo` outside the lexical
691
+ * scope for the definition of `foo`.
692
+ */
691
693
def apply (sym : Symbol )(given ctx : Context ): Ref =
692
694
internal.Ref_apply (sym)
693
695
}
@@ -1804,7 +1806,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
1804
1806
1805
1807
/**
1806
1808
* An accessor for `scala.internal.MatchCase[_,_]`, the representation of a `MatchType` case.
1807
- */
1809
+ */
1808
1810
def MatchCaseType (given Context ): Type = {
1809
1811
import scala .internal .MatchCase
1810
1812
Type (classOf [MatchCase [_,_]])
@@ -2028,15 +2030,16 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2028
2030
* this symbol to the DefDef constructor.
2029
2031
*
2030
2032
* @note As a macro can only splice code into the point at which it is expanded, all generated symbols must be
2031
- * direct or indirect children of the reflection context's owner. */
2033
+ * direct or indirect children of the reflection context's owner.
2034
+ */
2032
2035
def newMethod (parent : Symbol , name : String , tpe : Type )(given ctx : Context ): Symbol =
2033
2036
newMethod(parent, name, tpe, Flags .EmptyFlags , noSymbol)
2034
2037
2035
2038
/** Works as the other newMethod, but with additional parameters.
2036
2039
*
2037
2040
* @param flags extra flags to with which the symbol should be constructed
2038
2041
* @param privateWithin the symbol within which this new method symbol should be private. May be noSymbol.
2039
- * * /
2042
+ */
2040
2043
def newMethod (parent : Symbol , name : String , tpe : Type , flags : Flags , privateWithin : Symbol )(given ctx : Context ): Symbol =
2041
2044
internal.Symbol_newMethod (parent, name, flags, tpe, privateWithin)
2042
2045
@@ -2194,12 +2197,12 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2194
2197
extension signatureOps on (sig : Signature ) {
2195
2198
2196
2199
/** The signatures of the method parameters.
2197
- *
2198
- * Each *type parameter section* is represented by a single Int corresponding
2199
- * to the number of type parameters in the section.
2200
- * Each *term parameter* is represented by a String corresponding to the fully qualified
2201
- * name of the parameter type.
2202
- */
2200
+ *
2201
+ * Each *type parameter section* is represented by a single Int corresponding
2202
+ * to the number of type parameters in the section.
2203
+ * Each *term parameter* is represented by a String corresponding to the fully qualified
2204
+ * name of the parameter type.
2205
+ */
2203
2206
def paramSigs : List [String | Int ] = internal.Signature_paramSigs (sig)
2204
2207
2205
2208
/** The signature of the result type */
@@ -2217,8 +2220,8 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2217
2220
object defn extends StandardSymbols with StandardTypes
2218
2221
2219
2222
/** Defines standard symbols (and types via its base trait).
2220
- * @group API
2221
- */
2223
+ * @group API
2224
+ */
2222
2225
trait StandardSymbols {
2223
2226
2224
2227
/** The module symbol of root package `_root_`. */
@@ -2315,8 +2318,8 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2315
2318
def Array_update : Symbol = internal.Definitions_Array_update
2316
2319
2317
2320
/** A dummy class symbol that is used to indicate repeated parameters
2318
- * compiled by the Scala compiler.
2319
- */
2321
+ * compiled by the Scala compiler.
2322
+ */
2320
2323
def RepeatedParamClass : Symbol = internal.Definitions_RepeatedParamClass
2321
2324
2322
2325
/** The class symbol of class `scala.Option`. */
@@ -2332,23 +2335,23 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2332
2335
def ProductClass : Symbol = internal.Definitions_ProductClass
2333
2336
2334
2337
/** Function-like object that maps arity to symbols for classes `scala.FunctionX`.
2335
- * - 0th element is `Function0`
2336
- * - 1st element is `Function1`
2337
- * - ...
2338
- * - Nth element is `FunctionN`
2339
- */
2338
+ * - 0th element is `Function0`
2339
+ * - 1st element is `Function1`
2340
+ * - ...
2341
+ * - Nth element is `FunctionN`
2342
+ */
2340
2343
def FunctionClass (arity : Int , isImplicit : Boolean = false , isErased : Boolean = false ): Symbol =
2341
2344
internal.Definitions_FunctionClass (arity, isImplicit, isErased)
2342
2345
2343
2346
/** Function-like object that maps arity to symbols for classes `scala.TupleX`.
2344
- * - 0th element is `NoSymbol`
2345
- * - 1st element is `NoSymbol`
2346
- * - 2st element is `Tuple2`
2347
- * - ...
2348
- * - 22nd element is `Tuple22`
2349
- * - 23nd element is `NoSymbol` // TODO update when we will have more tuples
2350
- * - ...
2351
- */
2347
+ * - 0th element is `NoSymbol`
2348
+ * - 1st element is `NoSymbol`
2349
+ * - 2st element is `Tuple2`
2350
+ * - ...
2351
+ * - 22nd element is `Tuple22`
2352
+ * - 23nd element is `NoSymbol` // TODO update when we will have more tuples
2353
+ * - ...
2354
+ */
2352
2355
def TupleClass (arity : Int ): Symbol =
2353
2356
internal.Definitions_TupleClass (arity)
2354
2357
@@ -2357,28 +2360,28 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2357
2360
internal.Definitions_isTupleClass (sym)
2358
2361
2359
2362
/** Contains Scala primitive value classes:
2360
- * - Byte
2361
- * - Short
2362
- * - Int
2363
- * - Long
2364
- * - Float
2365
- * - Double
2366
- * - Char
2367
- * - Boolean
2368
- * - Unit
2369
- */
2363
+ * - Byte
2364
+ * - Short
2365
+ * - Int
2366
+ * - Long
2367
+ * - Float
2368
+ * - Double
2369
+ * - Char
2370
+ * - Boolean
2371
+ * - Unit
2372
+ */
2370
2373
def ScalaPrimitiveValueClasses : List [Symbol ] =
2371
2374
UnitClass :: BooleanClass :: ScalaNumericValueClasses
2372
2375
2373
2376
/** Contains Scala numeric value classes:
2374
- * - Byte
2375
- * - Short
2376
- * - Int
2377
- * - Long
2378
- * - Float
2379
- * - Double
2380
- * - Char
2381
- */
2377
+ * - Byte
2378
+ * - Short
2379
+ * - Int
2380
+ * - Long
2381
+ * - Float
2382
+ * - Double
2383
+ * - Char
2384
+ */
2382
2385
def ScalaNumericValueClasses : List [Symbol ] =
2383
2386
ByteClass :: ShortClass :: IntClass :: LongClass :: FloatClass :: DoubleClass :: CharClass :: Nil
2384
2387
0 commit comments