-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Definitions.scala
2590 lines (2269 loc) · 134 KB
/
Definitions.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package dotty.tools
package dotc
package core
import scala.annotation.{threadUnsafe => tu}
import Types.*, Contexts.*, Symbols.*, SymDenotations.*, StdNames.*, Names.*, Phases.*
import Flags.*, Scopes.*, Decorators.*, NameOps.*, Periods.*, NullOpsDecorator.*
import unpickleScala2.Scala2Unpickler.ensureConstructor
import scala.collection.mutable
import collection.mutable
import Denotations.{SingleDenotation, staticRef}
import util.{SimpleIdentityMap, SourceFile, NoSource}
import typer.ImportInfo.RootRef
import Comments.{Comment, docCtx}
import util.Spans.NoSpan
import config.Feature
import Symbols.requiredModuleRef
import cc.{CaptureSet, RetainingType}
import ast.tpd.ref
import scala.annotation.tailrec
import scala.compiletime.uninitialized
object Definitions {
/** The maximum number of elements in a tuple or product.
* This should be removed once we go to hlists.
*/
val MaxTupleArity: Int = 22
/** The maximum arity N of a function type that's implemented
* as a trait `scala.FunctionN`. Functions of higher arity are possible,
* but are mapped in erasure to functions taking a single parameter of type
* Object[].
* The limit 22 is chosen for Scala2x interop. It could be something
* else without affecting the set of programs that can be compiled.
*/
val MaxImplementedFunctionArity: Int = MaxTupleArity
}
/** A class defining symbols and types of standard definitions
*
*/
class Definitions {
import Definitions.*
private var initCtx: Context = uninitialized
private given currentContext[Dummy_so_its_a_def]: Context = initCtx
private def newPermanentSymbol[N <: Name](owner: Symbol, name: N, flags: FlagSet, info: Type) =
newSymbol(owner, name, flags | Permanent, info)
private def newPermanentClassSymbol(owner: Symbol, name: TypeName, flags: FlagSet, infoFn: ClassSymbol => Type) =
newClassSymbol(owner, name, flags | Permanent | NoInits | Open, infoFn)
private def enterCompleteClassSymbol(owner: Symbol, name: TypeName, flags: FlagSet, parents: List[TypeRef]): ClassSymbol =
enterCompleteClassSymbol(owner, name, flags, parents, newScope(owner.nestingLevel + 1))
private def enterCompleteClassSymbol(owner: Symbol, name: TypeName, flags: FlagSet, parents: List[TypeRef], decls: Scope) =
newCompleteClassSymbol(owner, name, flags | Permanent | NoInits | Open, parents, decls).entered
private def enterTypeField(cls: ClassSymbol, name: TypeName, flags: FlagSet, scope: MutableScope): TypeSymbol =
scope.enter(newPermanentSymbol(cls, name, flags, TypeBounds.empty))
private def enterTypeParam(cls: ClassSymbol, name: TypeName, flags: FlagSet, scope: MutableScope): TypeSymbol =
enterTypeField(cls, name, flags | ClassTypeParamCreationFlags, scope)
private def enterSyntheticTypeParam(cls: ClassSymbol, paramFlags: FlagSet, scope: MutableScope, suffix: String = "T0") =
enterTypeParam(cls, suffix.toTypeName, paramFlags, scope)
// NOTE: Ideally we would write `parentConstrs: => Type*` but SIP-24 is only
// implemented in Dotty and not in Scala 2.
// See <http://docs.scala-lang.org/sips/pending/repeated-byname.html>.
private def enterSpecialPolyClass(name: TypeName, paramFlags: FlagSet, parentConstrs: => Seq[Type]): ClassSymbol = {
val completer = new LazyType {
def complete(denot: SymDenotation)(using Context): Unit = {
val cls = denot.asClass.classSymbol
val paramDecls = newScope
val typeParam = enterSyntheticTypeParam(cls, paramFlags, paramDecls)
def instantiate(tpe: Type) =
if (tpe.typeParams.nonEmpty) tpe.appliedTo(typeParam.typeRef)
else tpe
val parents = parentConstrs.toList map instantiate
denot.info = ClassInfo(ScalaPackageClass.thisType, cls, parents, paramDecls)
}
}
newPermanentClassSymbol(ScalaPackageClass, name, Artifact, completer).entered
}
/** The trait FunctionN and ContextFunctionN for some N
* @param name The name of the trait to be created
*
* FunctionN traits follow this template:
*
* trait FunctionN[-T0,...-T{N-1}, +R] extends Object {
* def apply($x0: T0, ..., $x{N_1}: T{N-1}): R
* }
*
* That is, they follow the template given for Function2..Function22 in the
* standard library, but without `tupled` and `curried` methods and without
* a `toString`.
*
* ContextFunctionN traits follow this template:
*
* trait ContextFunctionN[-T0,...,-T{N-1}, +R] extends Object {
* def apply(using $x0: T0, ..., $x{N_1}: T{N-1}): R
* }
* ImpureXYZFunctionN follow this template:
*
* type ImpureXYZFunctionN[-T0,...,-T{N-1}, +R] = {cap} XYZFunctionN[T0,...,T{N-1}, R]
*/
private def newFunctionNType(name: TypeName): Symbol = {
val impure = name.startsWith("Impure")
val completer = new LazyType {
def complete(denot: SymDenotation)(using Context): Unit = {
val arity = name.functionArity
if impure then
val argParamNames = List.tabulate(arity)(tpnme.syntheticTypeParamName)
val argVariances = List.fill(arity)(Contravariant)
val underlyingName = name.asSimpleName.drop(6)
val underlyingClass = ScalaPackageVal.requiredClass(underlyingName)
denot.info = TypeAlias(
HKTypeLambda(argParamNames :+ "R".toTypeName, argVariances :+ Covariant)(
tl => List.fill(arity + 1)(TypeBounds.empty),
tl => RetainingType(underlyingClass.typeRef.appliedTo(tl.paramRefs),
ref(captureRoot.termRef) :: Nil)
))
else
val cls = denot.asClass.classSymbol
val decls = newScope
val paramNamePrefix = tpnme.scala ++ str.NAME_JOIN ++ name ++ str.EXPAND_SEPARATOR
val argParamRefs = List.tabulate(arity) { i =>
enterTypeParam(cls, paramNamePrefix ++ "T" ++ (i + 1).toString, Contravariant, decls).typeRef
}
val resParamRef = enterTypeParam(cls, paramNamePrefix ++ "R", Covariant, decls).typeRef
val methodType = MethodType.companion(
isContextual = name.isContextFunction,
isImplicit = false)
decls.enter(newMethod(cls, nme.apply, methodType(argParamRefs, resParamRef), Deferred))
denot.info =
ClassInfo(ScalaPackageClass.thisType, cls, ObjectType :: Nil, decls)
}
}
if impure then
newPermanentSymbol(ScalaPackageClass, name, EmptyFlags, completer)
else
newPermanentClassSymbol(ScalaPackageClass, name, Trait | NoInits, completer)
}
private def newMethod(cls: ClassSymbol, name: TermName, info: Type, flags: FlagSet = EmptyFlags): TermSymbol =
newPermanentSymbol(cls, name, flags | Method, info).asTerm
private def enterMethod(cls: ClassSymbol, name: TermName, info: Type, flags: FlagSet = EmptyFlags): TermSymbol =
newMethod(cls, name, info, flags).entered
private def enterPermanentSymbol(name: Name, info: Type, flags: FlagSet = EmptyFlags): Symbol =
val sym = newPermanentSymbol(ScalaPackageClass, name, flags, info)
ScalaPackageClass.currentPackageDecls.enter(sym)
sym
private def enterAliasType(name: TypeName, tpe: Type, flags: FlagSet = EmptyFlags): TypeSymbol =
enterPermanentSymbol(name, TypeAlias(tpe), flags).asType
private def enterBinaryAlias(name: TypeName, op: (Type, Type) => Type): TypeSymbol =
enterAliasType(name,
HKTypeLambda(TypeBounds.empty :: TypeBounds.empty :: Nil)(
tl => op(tl.paramRefs(0), tl.paramRefs(1))))
private def enterPolyMethod(cls: ClassSymbol, name: TermName, typeParamCount: Int,
resultTypeFn: PolyType => Type,
flags: FlagSet = EmptyFlags,
bounds: TypeBounds = TypeBounds.empty,
useCompleter: Boolean = false) = {
val tparamNames = PolyType.syntheticParamNames(typeParamCount)
val tparamInfos = tparamNames map (_ => bounds)
def ptype = PolyType(tparamNames)(_ => tparamInfos, resultTypeFn)
val info =
if (useCompleter)
new LazyType {
def complete(denot: SymDenotation)(using Context): Unit =
denot.info = ptype
}
else ptype
enterMethod(cls, name, info, flags)
}
private def enterT1ParameterlessMethod(cls: ClassSymbol, name: TermName, resultTypeFn: PolyType => Type, flags: FlagSet) =
enterPolyMethod(cls, name, 1, resultTypeFn, flags)
private def mkArityArray(name: String, arity: Int, countFrom: Int): Array[TypeRef | Null] = {
val arr = new Array[TypeRef | Null](arity + 1)
for (i <- countFrom to arity) arr(i) = requiredClassRef(name + i)
arr
}
private def completeClass(cls: ClassSymbol, ensureCtor: Boolean = true): ClassSymbol = {
if (ensureCtor) ensureConstructor(cls, cls.denot.asClass, EmptyScope)
if (cls.linkedClass.exists) cls.linkedClass.markAbsent()
cls
}
@tu lazy val RootClass: ClassSymbol = newPackageSymbol(
NoSymbol, nme.ROOT, (root, rootcls) => ctx.base.rootLoader(root)).moduleClass.asClass
@tu lazy val RootPackage: TermSymbol = newSymbol(
NoSymbol, nme.ROOTPKG, PackageCreationFlags, TypeRef(NoPrefix, RootClass))
@tu lazy val EmptyPackageVal: TermSymbol = newPackageSymbol(
RootClass, nme.EMPTY_PACKAGE, (emptypkg, emptycls) => ctx.base.rootLoader(emptypkg)).entered
@tu lazy val EmptyPackageClass: ClassSymbol = EmptyPackageVal.moduleClass.asClass
/** A package in which we can place all methods and types that are interpreted specially by the compiler */
@tu lazy val OpsPackageVal: TermSymbol = newCompletePackageSymbol(RootClass, nme.OPS_PACKAGE).entered
@tu lazy val OpsPackageClass: ClassSymbol = OpsPackageVal.moduleClass.asClass
@tu lazy val ScalaPackageVal: TermSymbol = requiredPackage(nme.scala)
@tu lazy val ScalaMathPackageVal: TermSymbol = requiredPackage("scala.math")
@tu lazy val ScalaPackageClass: ClassSymbol = {
val cls = ScalaPackageVal.moduleClass.asClass
cls.info.decls.openForMutations.useSynthesizer(
name =>
if (name.isTypeName && name.isSyntheticFunction) newFunctionNType(name.asTypeName)
else NoSymbol)
cls
}
@tu lazy val ScalaPackageObject: Symbol = requiredModule("scala.package")
@tu lazy val ScalaRuntimePackageVal: TermSymbol = requiredPackage("scala.runtime")
@tu lazy val ScalaRuntimePackageClass: ClassSymbol = ScalaRuntimePackageVal.moduleClass.asClass
@tu lazy val JavaPackageVal: TermSymbol = requiredPackage(nme.java)
@tu lazy val JavaPackageClass: ClassSymbol = JavaPackageVal.moduleClass.asClass
@tu lazy val JavaLangPackageVal: TermSymbol = requiredPackage(jnme.JavaLang)
@tu lazy val JavaLangPackageClass: ClassSymbol = JavaLangPackageVal.moduleClass.asClass
// fundamental modules
@tu lazy val SysPackage : Symbol = requiredModule("scala.sys.package")
@tu lazy val Sys_error: Symbol = SysPackage.moduleClass.requiredMethod(nme.error)
@tu lazy val ScalaXmlPackageClass: Symbol = getPackageClassIfDefined("scala.xml")
@tu lazy val CompiletimePackageClass: Symbol = requiredPackage("scala.compiletime").moduleClass
@tu lazy val Compiletime_codeOf: Symbol = CompiletimePackageClass.requiredMethod("codeOf")
@tu lazy val Compiletime_erasedValue : Symbol = CompiletimePackageClass.requiredMethod("erasedValue")
@tu lazy val Compiletime_uninitialized: Symbol = CompiletimePackageClass.requiredMethod("uninitialized")
@tu lazy val Compiletime_deferred : Symbol = CompiletimePackageClass.requiredMethod("deferred")
@tu lazy val Compiletime_error : Symbol = CompiletimePackageClass.requiredMethod(nme.error)
@tu lazy val Compiletime_requireConst : Symbol = CompiletimePackageClass.requiredMethod("requireConst")
@tu lazy val Compiletime_constValue : Symbol = CompiletimePackageClass.requiredMethod("constValue")
@tu lazy val Compiletime_constValueOpt: Symbol = CompiletimePackageClass.requiredMethod("constValueOpt")
@tu lazy val Compiletime_constValueTuple: Symbol = CompiletimePackageClass.requiredMethod("constValueTuple")
@tu lazy val Compiletime_summonFrom : Symbol = CompiletimePackageClass.requiredMethod("summonFrom")
@tu lazy val Compiletime_summonInline : Symbol = CompiletimePackageClass.requiredMethod("summonInline")
@tu lazy val Compiletime_summonAll : Symbol = CompiletimePackageClass.requiredMethod("summonAll")
@tu lazy val CompiletimeTestingPackage: Symbol = requiredPackage("scala.compiletime.testing")
@tu lazy val CompiletimeTesting_typeChecks: Symbol = CompiletimeTestingPackage.requiredMethod("typeChecks")
@tu lazy val CompiletimeTesting_typeCheckErrors: Symbol = CompiletimeTestingPackage.requiredMethod("typeCheckErrors")
@tu lazy val CompiletimeTesting_ErrorClass: ClassSymbol = requiredClass("scala.compiletime.testing.Error")
@tu lazy val CompiletimeTesting_Error: Symbol = requiredModule("scala.compiletime.testing.Error")
@tu lazy val CompiletimeTesting_Error_apply = CompiletimeTesting_Error.requiredMethod(nme.apply)
@tu lazy val CompiletimeTesting_ErrorKind: Symbol = requiredModule("scala.compiletime.testing.ErrorKind")
@tu lazy val CompiletimeTesting_ErrorKind_Parser: Symbol = CompiletimeTesting_ErrorKind.requiredMethod("Parser")
@tu lazy val CompiletimeTesting_ErrorKind_Typer: Symbol = CompiletimeTesting_ErrorKind.requiredMethod("Typer")
@tu lazy val CompiletimeOpsPackage: Symbol = requiredPackage("scala.compiletime.ops")
@tu lazy val CompiletimeOpsAnyModuleClass: Symbol = requiredModule("scala.compiletime.ops.any").moduleClass
@tu lazy val CompiletimeOpsIntModuleClass: Symbol = requiredModule("scala.compiletime.ops.int").moduleClass
@tu lazy val CompiletimeOpsLongModuleClass: Symbol = requiredModule("scala.compiletime.ops.long").moduleClass
@tu lazy val CompiletimeOpsFloatModuleClass: Symbol = requiredModule("scala.compiletime.ops.float").moduleClass
@tu lazy val CompiletimeOpsDoubleModuleClass: Symbol = requiredModule("scala.compiletime.ops.double").moduleClass
@tu lazy val CompiletimeOpsStringModuleClass: Symbol = requiredModule("scala.compiletime.ops.string").moduleClass
@tu lazy val CompiletimeOpsBooleanModuleClass: Symbol = requiredModule("scala.compiletime.ops.boolean").moduleClass
/** Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter)
* because after erasure the Any and AnyVal references get remapped to the Object methods
* which would result in a double binding assertion failure.
* Instead we do the following:
*
* - Have some methods exist only in Any, and remap them with the Erasure denotation
* transformer to be owned by Object.
* - Have other methods exist only in Object.
* To achieve this, we synthesize all Any and Object methods; Object methods no longer get
* loaded from a classfile.
*/
@tu lazy val AnyClass: ClassSymbol = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.Any, Abstract, Nil), ensureCtor = false)
def AnyType: TypeRef = AnyClass.typeRef
@tu lazy val MatchableClass: ClassSymbol = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.Matchable, Trait, AnyType :: Nil), ensureCtor = false)
def MatchableType: TypeRef = MatchableClass.typeRef
@tu lazy val AnyValClass: ClassSymbol =
val res = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.AnyVal, Abstract, List(AnyType, MatchableType)))
// Mark companion as absent, so that class does not get re-completed
val companion = ScalaPackageVal.info.decl(nme.AnyVal).symbol
companion.moduleClass.markAbsent()
companion.markAbsent()
res
def AnyValType: TypeRef = AnyValClass.typeRef
@tu lazy val Any_== : TermSymbol = enterMethod(AnyClass, nme.EQ, methOfAny(BooleanType), Final)
@tu lazy val Any_!= : TermSymbol = enterMethod(AnyClass, nme.NE, methOfAny(BooleanType), Final)
@tu lazy val Any_equals: TermSymbol = enterMethod(AnyClass, nme.equals_, methOfAny(BooleanType))
@tu lazy val Any_hashCode: TermSymbol = enterMethod(AnyClass, nme.hashCode_, MethodType(Nil, IntType))
@tu lazy val Any_toString: TermSymbol = enterMethod(AnyClass, nme.toString_, MethodType(Nil, StringType))
@tu lazy val Any_## : TermSymbol = enterMethod(AnyClass, nme.HASHHASH, ExprType(IntType), Final)
@tu lazy val Any_isInstanceOf: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOf_, _ => BooleanType, Final)
@tu lazy val Any_asInstanceOf: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOf_, _.paramRefs(0), Final)
@tu lazy val Any_typeTest: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOfPM, _ => BooleanType, Final | SyntheticArtifact)
@tu lazy val Any_typeCast: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOfPM, _.paramRefs(0), Final | SyntheticArtifact | StableRealizable)
// generated by pattern matcher and explicit nulls, eliminated by erasure
/** def getClass[A >: this.type](): Class[? <: A] */
@tu lazy val Any_getClass: TermSymbol =
enterPolyMethod(
AnyClass, nme.getClass_, 1,
pt => MethodType(Nil, ClassClass.typeRef.appliedTo(TypeBounds.upper(pt.paramRefs(0)))),
Final,
bounds = TypeBounds.lower(AnyClass.thisType))
def AnyMethods: List[TermSymbol] = List(Any_==, Any_!=, Any_equals, Any_hashCode,
Any_toString, Any_##, Any_getClass, Any_isInstanceOf, Any_asInstanceOf, Any_typeTest, Any_typeCast)
@tu lazy val ObjectClass: ClassSymbol = {
val cls = requiredClass("java.lang.Object")
assert(!cls.isCompleted, "race for completing java.lang.Object")
cls.info = ClassInfo(cls.owner.thisType, cls, List(AnyType, MatchableType), newScope)
cls.setFlag(NoInits | JavaDefined)
ensureConstructor(cls, cls.denot.asClass, EmptyScope)
val companion = JavaLangPackageVal.info.decl(nme.Object).symbol.asTerm
NamerOps.makeConstructorCompanion(companion, cls)
cls
}
def ObjectType: TypeRef = ObjectClass.typeRef
/** A type alias of Object used to represent any reference to Object in a Java
* signature, the secret sauce is that subtype checking treats it specially:
*
* tp <:< FromJavaObject
*
* is equivalent to:
*
* tp <:< Any
*
* This is useful to avoid usability problems when interacting with Java
* code where Object is the top type. This is safe because this type will
* only appear in signatures of Java definitions in positions where `Object`
* might appear, let's enumerate all possible cases this gives us:
*
* 1. At the top level:
*
* // A.java
* void meth1(Object arg) {}
* <T> void meth2(T arg) {} // T implicitly extends Object
*
* // B.scala
* meth1(1) // OK
* meth2(1) // OK
*
* This is safe even though Int is not a subtype of Object, because Erasure
* will detect the mismatch and box the value type.
*
* 2. In a class type parameter:
*
* // A.java
* void meth3(scala.List<Object> arg) {}
* <T> void meth4(scala.List<T> arg) {}
*
* // B.scala
* meth3(List[Int](1)) // OK
* meth4(List[Int](1)) // OK
*
* At erasure, type parameters are removed and value types are boxed.
*
* 3. As the type parameter of an array:
*
* // A.java
* void meth5(Object[] arg) {}
* <T> void meth6(T[] arg) {}
*
* // B.scala
* meth5(Array[Int](1)) // error: Array[Int] is not a subtype of Array[Object]
* meth6(Array[Int](1)) // error: Array[Int] is not a subtype of Array[T & Object]
*
*
* This is a bit more subtle: at erasure, Arrays keep their type parameter,
* and primitive Arrays are not subtypes of reference Arrays on the JVM,
* so we can't pass an Array of Int where a reference Array is expected.
* Array is invariant in Scala, so `meth5` is safe even if we use `FromJavaObject`,
* but generic Arrays are treated specially: we always add `& Object` (and here
* we mean the normal java.lang.Object type) to these types when they come from
* Java signatures (see `translateJavaArrayElementType`), this ensure that `meth6`
* is safe to use.
*
* 4. As the repeated argument of a varargs method:
*
* // A.java
* void meth7(Object... args) {}
* <T> void meth8(T... args) {}
*
* // B.scala
* meth7(1) // OK (creates a reference array)
* meth8(1) // OK (creates a primitive array and copies it into a reference array at Erasure)
* val ai = Array[Int](1)
* meth7(ai: _*) // OK (will copy the array at Erasure)
* meth8(ai: _*) // OK (will copy the array at Erasure)
*
* Java repeated arguments are erased to arrays, so it would be safe to treat
* them in the same way: add an `& Object` to the parameter type to disallow
* passing primitives, but that would be very inconvenient as it is common to
* want to pass a primitive to an Object repeated argument (e.g.
* `String.format("foo: %d", 1)`). So instead we type them _without_ adding the
* `& Object` and let `ElimRepeated` and `Erasure` take care of doing any necessary adaptation
* (note that adapting a primitive array to a reference array requires
* copying the whole array, so this transformation only preserves semantics
* if the callee does not try to mutate the varargs array which is a reasonable
* assumption to make).
*
*
* This mechanism is similar to `ObjectTpeJavaRef` in Scala 2, except that we
* create a new symbol with its own name, this is needed because this type
* can show up in inferred types and therefore needs to be preserved when
* pickling so that unpickled trees pass `-Ycheck`.
*
* Note that by default we pretty-print `FromJavaObject` as `Object` or simply omit it
* if it's the sole upper-bound of a type parameter, use `-Yprint-debug` to explicitly
* display it.
*/
@tu lazy val FromJavaObjectSymbol: TypeSymbol =
newPermanentSymbol(OpsPackageClass, tpnme.FromJavaObject, JavaDefined, TypeAlias(ObjectType)).entered
def FromJavaObjectType: TypeRef = FromJavaObjectSymbol.typeRef
@tu lazy val AnyRefAlias: TypeSymbol = enterAliasType(tpnme.AnyRef, ObjectType)
def AnyRefType: TypeRef = AnyRefAlias.typeRef
@tu lazy val Object_eq: TermSymbol = enterMethod(ObjectClass, nme.eq, methOfAnyRef(BooleanType), Final)
@tu lazy val Object_ne: TermSymbol = enterMethod(ObjectClass, nme.ne, methOfAnyRef(BooleanType), Final)
@tu lazy val Object_synchronized: TermSymbol = enterPolyMethod(ObjectClass, nme.synchronized_, 1,
pt => MethodType(List(pt.paramRefs(0)), pt.paramRefs(0)), Final)
@tu lazy val Object_clone: TermSymbol = enterMethod(ObjectClass, nme.clone_, MethodType(Nil, ObjectType), Protected)
@tu lazy val Object_finalize: TermSymbol = enterMethod(ObjectClass, nme.finalize_, MethodType(Nil, UnitType), Protected)
@tu lazy val Object_notify: TermSymbol = enterMethod(ObjectClass, nme.notify_, MethodType(Nil, UnitType), Final)
@tu lazy val Object_notifyAll: TermSymbol = enterMethod(ObjectClass, nme.notifyAll_, MethodType(Nil, UnitType), Final)
@tu lazy val Object_wait: TermSymbol = enterMethod(ObjectClass, nme.wait_, MethodType(Nil, UnitType), Final)
@tu lazy val Object_waitL: TermSymbol = enterMethod(ObjectClass, nme.wait_, MethodType(LongType :: Nil, UnitType), Final)
@tu lazy val Object_waitLI: TermSymbol = enterMethod(ObjectClass, nme.wait_, MethodType(LongType :: IntType :: Nil, UnitType), Final)
def ObjectMethods: List[TermSymbol] = List(Object_eq, Object_ne, Object_synchronized, Object_clone,
Object_finalize, Object_notify, Object_notifyAll, Object_wait, Object_waitL, Object_waitLI)
/** Methods in Object and Any that do not have a side effect */
@tu lazy val pureMethods: List[TermSymbol] = List(Any_==, Any_!=, Any_equals, Any_hashCode,
Any_toString, Any_##, Any_getClass, Any_isInstanceOf, Any_typeTest, Object_eq, Object_ne)
@tu lazy val AnyKindClass: ClassSymbol = {
val cls = newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal | Permanent, Nil, newScope(0))
if (!ctx.settings.YnoKindPolymorphism.value)
// Enable kind-polymorphism by exposing scala.AnyKind
cls.entered
cls
}
def AnyKindType: TypeRef = AnyKindClass.typeRef
@tu lazy val andType: TypeSymbol = enterBinaryAlias(tpnme.AND, AndType(_, _))
@tu lazy val orType: TypeSymbol = enterBinaryAlias(tpnme.OR, OrType(_, _, soft = false))
@tu lazy val CBCompanion: TypeSymbol = // type `<context-bound-companion>`[-Refs]
enterPermanentSymbol(tpnme.CBCompanion,
TypeBounds(NothingType,
HKTypeLambda(tpnme.syntheticTypeParamName(0) :: Nil, Contravariant :: Nil)(
tl => TypeBounds.empty :: Nil,
tl => AnyType))).asType
/** Method representing a throw */
@tu lazy val throwMethod: TermSymbol = enterMethod(OpsPackageClass, nme.THROWkw,
MethodType(List(ThrowableType), NothingType))
@tu lazy val NothingClass: ClassSymbol = enterCompleteClassSymbol(
ScalaPackageClass, tpnme.Nothing, AbstractFinal, List(AnyType))
def NothingType: TypeRef = NothingClass.typeRef
@tu lazy val NullClass: ClassSymbol = {
// When explicit-nulls is enabled, Null becomes a direct subtype of Any and Matchable
val parents = if ctx.explicitNulls then AnyType :: MatchableType :: Nil else ObjectType :: Nil
enterCompleteClassSymbol(ScalaPackageClass, tpnme.Null, AbstractFinal, parents)
}
def NullType: TypeRef = NullClass.typeRef
@tu lazy val InvokerModule = requiredModule("scala.runtime.coverage.Invoker")
@tu lazy val InvokedMethodRef = InvokerModule.requiredMethodRef("invoked")
@tu lazy val ImplicitScrutineeTypeSym =
newPermanentSymbol(ScalaPackageClass, tpnme.IMPLICITkw, EmptyFlags, TypeBounds.empty).entered
def ImplicitScrutineeTypeRef: TypeRef = ImplicitScrutineeTypeSym.typeRef
@tu lazy val ScalaPredefModule: Symbol = requiredModule("scala.Predef")
@tu lazy val Predef_conforms : Symbol = ScalaPredefModule.requiredMethod(nme.conforms_)
@tu lazy val Predef_classOf : Symbol = ScalaPredefModule.requiredMethod(nme.classOf)
@tu lazy val Predef_identity : Symbol = ScalaPredefModule.requiredMethod(nme.identity)
@tu lazy val Predef_undefined: Symbol = ScalaPredefModule.requiredMethod(nme.???)
@tu lazy val ScalaPredefModuleClass: ClassSymbol = ScalaPredefModule.moduleClass.asClass
@tu lazy val SubTypeClass: ClassSymbol = requiredClass("scala.<:<")
@tu lazy val SubType_refl: Symbol = SubTypeClass.companionModule.requiredMethod(nme.refl)
@tu lazy val DummyImplicitClass: ClassSymbol = requiredClass("scala.DummyImplicit")
@tu lazy val ScalaRuntimeModule: Symbol = requiredModule("scala.runtime.ScalaRunTime")
def runtimeMethodRef(name: PreName): TermRef = ScalaRuntimeModule.requiredMethodRef(name)
def ScalaRuntime_drop: Symbol = runtimeMethodRef(nme.drop).symbol
@tu lazy val ScalaRuntime__hashCode: Symbol = ScalaRuntimeModule.requiredMethod(nme._hashCode_)
@tu lazy val ScalaRuntime_toArray: Symbol = ScalaRuntimeModule.requiredMethod(nme.toArray)
@tu lazy val ScalaRuntime_toObjectArray: Symbol = ScalaRuntimeModule.requiredMethod(nme.toObjectArray)
@tu lazy val BoxesRunTimeModule: Symbol = requiredModule("scala.runtime.BoxesRunTime")
@tu lazy val BoxesRunTimeModule_externalEquals: Symbol = BoxesRunTimeModule.info.decl(nme.equals_).suchThat(toDenot(_).info.firstParamTypes.size == 2).symbol
@tu lazy val ScalaStaticsModule: Symbol = requiredModule("scala.runtime.Statics")
def staticsMethodRef(name: PreName): TermRef = ScalaStaticsModule.requiredMethodRef(name)
def staticsMethod(name: PreName): TermSymbol = ScalaStaticsModule.requiredMethod(name)
@tu lazy val DottyArraysModule: Symbol = requiredModule("scala.runtime.Arrays")
@tu lazy val newGenericArrayMethod: TermSymbol = DottyArraysModule.requiredMethod("newGenericArray")
@tu lazy val newArrayMethod: TermSymbol = DottyArraysModule.requiredMethod("newArray")
def getWrapVarargsArrayModule: Symbol = ScalaRuntimeModule
// The set of all wrap{X, Ref}Array methods, where X is a value type
val WrapArrayMethods: PerRun[collection.Set[Symbol]] = new PerRun({
val methodNames = ScalaValueTypes.map(ast.tpd.wrapArrayMethodName) `union` Set(nme.wrapRefArray)
methodNames.map(getWrapVarargsArrayModule.requiredMethod(_))
})
@tu lazy val ListClass: Symbol = requiredClass("scala.collection.immutable.List")
def ListType: TypeRef = ListClass.typeRef
@tu lazy val ListModule: Symbol = requiredModule("scala.collection.immutable.List")
@tu lazy val ListModule_apply: Symbol = ListModule.requiredMethod(nme.apply)
def ListModuleAlias: Symbol = ScalaPackageClass.requiredMethod(nme.List)
@tu lazy val NilModule: Symbol = requiredModule("scala.collection.immutable.Nil")
def NilType: TermRef = NilModule.termRef
@tu lazy val ConsClass: Symbol = requiredClass("scala.collection.immutable.::")
def ConsType: TypeRef = ConsClass.typeRef
@tu lazy val SeqFactoryClass: Symbol = requiredClass("scala.collection.SeqFactory")
@tu lazy val PreciseClass: ClassSymbol = requiredClass("scala.Precise")
@tu lazy val SingletonClass: ClassSymbol =
// needed as a synthetic class because Scala 2.x refers to it in classfiles
// but does not define it as an explicit class.
val cls = enterCompleteClassSymbol(
ScalaPackageClass, tpnme.Singleton, PureInterfaceCreationFlags | Final | Erased,
List(AnyType))
enterTypeField(cls, tpnme.Self, Deferred, cls.info.decls.openForMutations)
cls
@tu lazy val SingletonType: TypeRef = SingletonClass.typeRef
@tu lazy val MaybeCapabilityAnnot: ClassSymbol =
completeClass(enterCompleteClassSymbol(
ScalaPackageClass, tpnme.maybeCapability, Final, List(StaticAnnotationClass.typeRef)))
@tu lazy val CollectionSeqType: TypeRef = requiredClassRef("scala.collection.Seq")
@tu lazy val SeqType: TypeRef = requiredClassRef("scala.collection.immutable.Seq")
@tu lazy val SeqModule: Symbol = requiredModule("scala.collection.immutable.Seq")
@tu lazy val SeqModule_apply: Symbol = SeqModule.requiredMethod(nme.apply)
def SeqModuleAlias: Symbol = ScalaPackageClass.requiredMethod(nme.Seq)
def SeqClass(using 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)
@tu lazy val Seq_lengthCompare: Symbol = SeqClass.requiredMethod(nme.lengthCompare, List(IntType))
@tu lazy val Seq_length : Symbol = SeqClass.requiredMethod(nme.length)
@tu lazy val Seq_toSeq : Symbol = SeqClass.requiredMethod(nme.toSeq)
@tu lazy val StringOps: Symbol = requiredClass("scala.collection.StringOps")
@tu lazy val StringOps_format: Symbol = StringOps.requiredMethod(nme.format)
@tu lazy val ArrayType: TypeRef = requiredClassRef("scala.Array")
def ArrayClass(using 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)
@tu lazy val Array_clone : Symbol = ArrayClass.requiredMethod(nme.clone_)
@tu lazy val ArrayConstructor: Symbol = ArrayClass.requiredMethod(nme.CONSTRUCTOR)
@tu lazy val ArrayModule: Symbol = requiredModule("scala.Array")
def ArrayModuleClass: Symbol = ArrayModule.moduleClass
@tu lazy val IArrayModule: Symbol = requiredModule("scala.IArray")
def IArrayModuleClass: Symbol = IArrayModule.moduleClass
@tu lazy val UnitType: TypeRef = valueTypeRef("scala.Unit", java.lang.Void.TYPE, UnitEnc, nme.specializedTypeNames.Void)
def UnitClass(using Context): ClassSymbol = UnitType.symbol.asClass
def UnitModuleClass(using Context): Symbol = UnitType.symbol.asClass.linkedClass
@tu lazy val BooleanType: TypeRef = valueTypeRef("scala.Boolean", java.lang.Boolean.TYPE, BooleanEnc, nme.specializedTypeNames.Boolean)
def BooleanClass(using 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)
@tu lazy val Boolean_== : Symbol =
BooleanClass.info.member(nme.EQ).suchThat(_.info.firstParamTypes match {
case List(pt) => pt.isRef(BooleanClass)
case _ => false
}).symbol
@tu lazy val Boolean_!= : Symbol =
BooleanClass.info.member(nme.NE).suchThat(_.info.firstParamTypes match {
case List(pt) => pt.isRef(BooleanClass)
case _ => false
}).symbol
@tu lazy val ByteType: TypeRef = valueTypeRef("scala.Byte", java.lang.Byte.TYPE, ByteEnc, nme.specializedTypeNames.Byte)
def ByteClass(using Context): ClassSymbol = ByteType.symbol.asClass
@tu lazy val ShortType: TypeRef = valueTypeRef("scala.Short", java.lang.Short.TYPE, ShortEnc, nme.specializedTypeNames.Short)
def ShortClass(using Context): ClassSymbol = ShortType.symbol.asClass
@tu lazy val CharType: TypeRef = valueTypeRef("scala.Char", java.lang.Character.TYPE, CharEnc, nme.specializedTypeNames.Char)
def CharClass(using Context): ClassSymbol = CharType.symbol.asClass
@tu lazy val IntType: TypeRef = valueTypeRef("scala.Int", java.lang.Integer.TYPE, IntEnc, nme.specializedTypeNames.Int)
def IntClass(using 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))
@tu lazy val Int_* : Symbol = IntClass.requiredMethod(nme.MUL, List(IntType))
@tu lazy val Int_== : Symbol = IntClass.requiredMethod(nme.EQ, List(IntType))
@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(using 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(using Context): ClassSymbol = FloatType.symbol.asClass
@tu lazy val DoubleType: TypeRef = valueTypeRef("scala.Double", java.lang.Double.TYPE, DoubleEnc, nme.specializedTypeNames.Double)
def DoubleClass(using Context): ClassSymbol = DoubleType.symbol.asClass
@tu lazy val BoxedUnitClass: ClassSymbol = requiredClass("scala.runtime.BoxedUnit")
def BoxedUnit_UNIT(using Context): TermSymbol = BoxedUnitClass.linkedClass.requiredValue("UNIT")
def BoxedUnit_TYPE(using Context): TermSymbol = BoxedUnitClass.linkedClass.requiredValue("TYPE")
@tu lazy val BoxedBooleanClass: ClassSymbol = requiredClass("java.lang.Boolean")
@tu lazy val BoxedByteClass : ClassSymbol = requiredClass("java.lang.Byte")
@tu lazy val BoxedShortClass : ClassSymbol = requiredClass("java.lang.Short")
@tu lazy val BoxedCharClass : ClassSymbol = requiredClass("java.lang.Character")
@tu lazy val BoxedIntClass : ClassSymbol = requiredClass("java.lang.Integer")
@tu lazy val BoxedLongClass : ClassSymbol = requiredClass("java.lang.Long")
@tu lazy val BoxedFloatClass : ClassSymbol = requiredClass("java.lang.Float")
@tu lazy val BoxedDoubleClass : ClassSymbol = requiredClass("java.lang.Double")
@tu lazy val BoxedBooleanModule: TermSymbol = requiredModule("java.lang.Boolean")
@tu lazy val BoxedByteModule : TermSymbol = requiredModule("java.lang.Byte")
@tu lazy val BoxedShortModule : TermSymbol = requiredModule("java.lang.Short")
@tu lazy val BoxedCharModule : TermSymbol = requiredModule("java.lang.Character")
@tu lazy val BoxedIntModule : TermSymbol = requiredModule("java.lang.Integer")
@tu lazy val BoxedLongModule : TermSymbol = requiredModule("java.lang.Long")
@tu lazy val BoxedFloatModule : TermSymbol = requiredModule("java.lang.Float")
@tu lazy val BoxedDoubleModule : TermSymbol = requiredModule("java.lang.Double")
@tu lazy val BoxedUnitModule : TermSymbol = requiredModule("java.lang.Void")
@tu lazy val ByNameParamClass2x: ClassSymbol = enterSpecialPolyClass(tpnme.BYNAME_PARAM_CLASS, Covariant, Seq(AnyType))
@tu lazy val RepeatedParamClass: ClassSymbol = enterSpecialPolyClass(tpnme.REPEATED_PARAM_CLASS, Covariant, Seq(ObjectType, SeqType))
// fundamental classes
@tu lazy val StringClass: ClassSymbol = requiredClass("java.lang.String")
def StringType: Type = StringClass.typeRef
@tu lazy val StringModule: Symbol = StringClass.linkedClass
@tu lazy val String_+ : TermSymbol = enterMethod(StringClass, nme.raw.PLUS, methOfAny(StringType), Final)
@tu lazy val String_valueOf_Object: Symbol = StringModule.info.member(nme.valueOf).suchThat(_.info.firstParamTypes match {
case List(pt) => pt.isAny || pt.stripNull().isAnyRef
case _ => false
}).symbol
@tu lazy val JavaCloneableClass: ClassSymbol = requiredClass("java.lang.Cloneable")
@tu lazy val NullPointerExceptionClass: ClassSymbol = requiredClass("java.lang.NullPointerException")
@tu lazy val IndexOutOfBoundsException: ClassSymbol = requiredClass("java.lang.IndexOutOfBoundsException")
@tu lazy val ClassClass: ClassSymbol = requiredClass("java.lang.Class")
@tu lazy val BoxedNumberClass: ClassSymbol = requiredClass("java.lang.Number")
@tu lazy val ClassCastExceptionClass: ClassSymbol = requiredClass("java.lang.ClassCastException")
@tu lazy val ClassCastExceptionClass_stringConstructor: TermSymbol = ClassCastExceptionClass.info.member(nme.CONSTRUCTOR).suchThat(_.info.firstParamTypes match {
case List(pt) =>
pt.stripNull().isRef(StringClass)
case _ => false
}).symbol.asTerm
@tu lazy val ArithmeticExceptionClass: ClassSymbol = requiredClass("java.lang.ArithmeticException")
@tu lazy val ArithmeticExceptionClass_stringConstructor: TermSymbol = ArithmeticExceptionClass.info.member(nme.CONSTRUCTOR).suchThat(_.info.firstParamTypes match {
case List(pt) =>
pt.stripNull().isRef(StringClass)
case _ => false
}).symbol.asTerm
@tu lazy val JavaSerializableClass: ClassSymbol = requiredClass("java.io.Serializable")
@tu lazy val ComparableClass: ClassSymbol = requiredClass("java.lang.Comparable")
@tu lazy val SystemClass: ClassSymbol = requiredClass("java.lang.System")
@tu lazy val SystemModule: Symbol = SystemClass.linkedClass
@tu lazy val NoSuchElementExceptionClass = requiredClass("java.util.NoSuchElementException")
def NoSuchElementExceptionType = NoSuchElementExceptionClass.typeRef
@tu lazy val IllegalArgumentExceptionClass = requiredClass("java.lang.IllegalArgumentException")
def IllegalArgumentExceptionType = IllegalArgumentExceptionClass.typeRef
// in scalac modified to have Any as parent
@tu lazy val ThrowableType: TypeRef = requiredClassRef("java.lang.Throwable")
def ThrowableClass(using Context): ClassSymbol = ThrowableType.symbol.asClass
@tu lazy val ExceptionClass: ClassSymbol = requiredClass("java.lang.Exception")
@tu lazy val RuntimeExceptionClass: ClassSymbol = requiredClass("java.lang.RuntimeException")
@tu lazy val SerializableType: TypeRef = JavaSerializableClass.typeRef
def SerializableClass(using Context): ClassSymbol = SerializableType.symbol.asClass
@tu lazy val JavaBigIntegerClass: ClassSymbol = requiredClass("java.math.BigInteger")
@tu lazy val JavaBigDecimalClass: ClassSymbol = requiredClass("java.math.BigDecimal")
@tu lazy val JavaCalendarClass: ClassSymbol = requiredClass("java.util.Calendar")
@tu lazy val JavaDateClass: ClassSymbol = requiredClass("java.util.Date")
@tu lazy val JavaFormattableClass: ClassSymbol = requiredClass("java.util.Formattable")
@tu lazy val JavaRecordClass: Symbol = getClassIfDefined("java.lang.Record")
@tu lazy val JavaEnumClass: ClassSymbol = {
val cls = requiredClass("java.lang.Enum")
// jl.Enum has a single constructor protected(name: String, ordinal: Int).
// We remove the arguments from the primary constructor, and enter
// a new constructor symbol with 2 arguments, so that both
// `X extends jl.Enum[X]` and `X extends jl.Enum[X](name, ordinal)`
// pass typer and go through jl.Enum-specific checks in RefChecks.
cls.infoOrCompleter match {
case completer: ClassfileLoader =>
cls.info = new ClassfileLoader(completer.classfile) {
override def complete(root: SymDenotation)(using Context): Unit = {
super.complete(root)
val constr = cls.primaryConstructor
val noArgInfo = constr.info match {
case info: PolyType =>
info.resType match {
case meth: MethodType =>
info.derivedLambdaType(
resType = meth.derivedLambdaType(
paramNames = Nil, paramInfos = Nil))
}
}
val argConstr = constr.copy().entered
constr.info = noArgInfo
constr.termRef.recomputeDenot()
}
}
cls
}
}
def JavaEnumType = JavaEnumClass.typeRef
@tu lazy val MethodHandleClass: ClassSymbol = requiredClass("java.lang.invoke.MethodHandle")
@tu lazy val MethodHandlesLookupClass: ClassSymbol = requiredClass("java.lang.invoke.MethodHandles.Lookup")
@tu lazy val VarHandleClass: ClassSymbol = requiredClass("java.lang.invoke.VarHandle")
@tu lazy val StringBuilderClass: ClassSymbol = requiredClass("scala.collection.mutable.StringBuilder")
@tu lazy val MatchErrorClass : ClassSymbol = requiredClass("scala.MatchError")
@tu lazy val ConversionClass : ClassSymbol = requiredClass("scala.Conversion").typeRef.symbol.asClass
@tu lazy val StringAddClass : ClassSymbol = requiredClass("scala.runtime.StringAdd")
@tu lazy val StringAdd_+ : Symbol = StringAddClass.requiredMethod(nme.raw.PLUS)
@tu lazy val StringContextClass: ClassSymbol = requiredClass("scala.StringContext")
@tu lazy val StringContext_s : Symbol = StringContextClass.requiredMethod(nme.s)
@tu lazy val StringContext_raw: Symbol = StringContextClass.requiredMethod(nme.raw_)
@tu lazy val StringContext_f : Symbol = StringContextClass.requiredMethod(nme.f)
@tu lazy val StringContext_parts: Symbol = StringContextClass.requiredMethod(nme.parts)
@tu lazy val StringContextModule: Symbol = StringContextClass.companionModule
@tu lazy val StringContextModule_apply: Symbol = StringContextModule.requiredMethod(nme.apply)
@tu lazy val StringContextModule_standardInterpolator: Symbol = StringContextModule.requiredMethod(nme.standardInterpolator)
@tu lazy val StringContextModule_processEscapes: Symbol = StringContextModule.requiredMethod(nme.processEscapes)
@tu lazy val PartialFunctionClass: ClassSymbol = requiredClass("scala.PartialFunction")
@tu lazy val PartialFunction_apply: Symbol = PartialFunctionClass.requiredMethod(nme.apply)
@tu lazy val PartialFunction_isDefinedAt: Symbol = PartialFunctionClass.requiredMethod(nme.isDefinedAt)
@tu lazy val PartialFunction_applyOrElse: Symbol = PartialFunctionClass.requiredMethod(nme.applyOrElse)
@tu lazy val AbstractPartialFunctionClass: ClassSymbol = requiredClass("scala.runtime.AbstractPartialFunction")
@tu lazy val FunctionXXLClass: ClassSymbol = requiredClass("scala.runtime.FunctionXXL")
@tu lazy val ScalaSymbolClass: ClassSymbol = requiredClass("scala.Symbol")
@tu lazy val DynamicClass: ClassSymbol = requiredClass("scala.Dynamic")
@tu lazy val OptionClass: ClassSymbol = requiredClass("scala.Option")
@tu lazy val SomeClass: ClassSymbol = requiredClass("scala.Some")
@tu lazy val NoneModule: Symbol = requiredModule("scala.None")
@tu lazy val EnumClass: ClassSymbol = requiredClass("scala.reflect.Enum")
@tu lazy val Enum_ordinal: Symbol = EnumClass.requiredMethod(nme.ordinal)
@tu lazy val EnumValueSerializationProxyClass: ClassSymbol = requiredClass("scala.runtime.EnumValueSerializationProxy")
@tu lazy val EnumValueSerializationProxyConstructor: TermSymbol =
EnumValueSerializationProxyClass.requiredMethod(nme.CONSTRUCTOR, List(ClassType(TypeBounds.empty), IntType))
@tu lazy val ProductClass: ClassSymbol = requiredClass("scala.Product")
@tu lazy val Product_canEqual : Symbol = ProductClass.requiredMethod(nme.canEqual_)
@tu lazy val Product_productArity : Symbol = ProductClass.requiredMethod(nme.productArity)
@tu lazy val Product_productElement : Symbol = ProductClass.requiredMethod(nme.productElement)
@tu lazy val Product_productElementName: Symbol = ProductClass.requiredMethod(nme.productElementName)
@tu lazy val Product_productPrefix : Symbol = ProductClass.requiredMethod(nme.productPrefix)
@tu lazy val IteratorClass: ClassSymbol = requiredClass("scala.collection.Iterator")
def IteratorModule(using Context): Symbol = IteratorClass.companionModule
@tu lazy val ModuleSerializationProxyClass: ClassSymbol = requiredClass("scala.runtime.ModuleSerializationProxy")
@tu lazy val ModuleSerializationProxyConstructor: TermSymbol =
ModuleSerializationProxyClass.requiredMethod(nme.CONSTRUCTOR, List(ClassType(TypeBounds.empty)))
@tu lazy val MirrorClass: ClassSymbol = requiredClass("scala.deriving.Mirror")
@tu lazy val Mirror_ProductClass: ClassSymbol = requiredClass("scala.deriving.Mirror.Product")
@tu lazy val Mirror_Product_fromProduct: Symbol = Mirror_ProductClass.requiredMethod(nme.fromProduct)
@tu lazy val Mirror_SumClass: ClassSymbol = requiredClass("scala.deriving.Mirror.Sum")
@tu lazy val Mirror_SingletonClass: ClassSymbol = requiredClass("scala.deriving.Mirror.Singleton")
@tu lazy val Mirror_SingletonProxyClass: ClassSymbol = requiredClass("scala.deriving.Mirror.SingletonProxy")
@tu lazy val LanguageModule: Symbol = requiredModule("scala.language")
@tu lazy val LanguageModuleClass: Symbol = LanguageModule.moduleClass.asClass
@tu lazy val LanguageExperimentalModule: Symbol = requiredModule("scala.language.experimental")
@tu lazy val LanguageDeprecatedModule: Symbol = requiredModule("scala.language.deprecated")
@tu lazy val NonLocalReturnControlClass: ClassSymbol = requiredClass("scala.runtime.NonLocalReturnControl")
@tu lazy val SelectableClass: ClassSymbol = requiredClass("scala.Selectable")
@tu lazy val WithoutPreciseParameterTypesClass: Symbol = requiredClass("scala.Selectable.WithoutPreciseParameterTypes")
@tu lazy val ManifestClass: ClassSymbol = requiredClass("scala.reflect.Manifest")
@tu lazy val ManifestFactoryModule: Symbol = requiredModule("scala.reflect.ManifestFactory")
@tu lazy val ClassManifestFactoryModule: Symbol = requiredModule("scala.reflect.ClassManifestFactory")
@tu lazy val OptManifestClass: ClassSymbol = requiredClass("scala.reflect.OptManifest")
@tu lazy val NoManifestModule: Symbol = requiredModule("scala.reflect.NoManifest")
@tu lazy val ReflectPackageClass: Symbol = requiredPackage("scala.reflect.package").moduleClass
@tu lazy val ClassTagClass: ClassSymbol = requiredClass("scala.reflect.ClassTag")
@tu lazy val ClassTagClass_unapply: Symbol = ClassTagClass.requiredMethod("unapply")
@tu lazy val ClassTagModule: Symbol = ClassTagClass.companionModule
@tu lazy val ClassTagModule_apply: Symbol = ClassTagModule.requiredMethod(nme.apply)
@tu lazy val ReflectSelectableTypeRef: TypeRef = requiredClassRef("scala.reflect.Selectable")
@tu lazy val TypeTestClass: ClassSymbol = requiredClass("scala.reflect.TypeTest")
@tu lazy val TypeTest_unapply: Symbol = TypeTestClass.requiredMethod(nme.unapply)
@tu lazy val TypeTestModule_identity: Symbol = TypeTestClass.companionModule.requiredMethod(nme.identity)
@tu lazy val QuotedExprClass: ClassSymbol = requiredClass("scala.quoted.Expr")
@tu lazy val QuotesClass: ClassSymbol = requiredClass("scala.quoted.Quotes")
@tu lazy val Quotes_reflect: Symbol = QuotesClass.requiredValue("reflect")
@tu lazy val Quotes_reflect_asTerm: Symbol = Quotes_reflect.requiredMethod("asTerm")
@tu lazy val Quotes_reflect_Apply: Symbol = Quotes_reflect.requiredValue("Apply")
@tu lazy val Quotes_reflect_Apply_apply: Symbol = Quotes_reflect_Apply.requiredMethod(nme.apply)
@tu lazy val Quotes_reflect_TypeApply: Symbol = Quotes_reflect.requiredValue("TypeApply")
@tu lazy val Quotes_reflect_TypeApply_apply: Symbol = Quotes_reflect_TypeApply.requiredMethod(nme.apply)
@tu lazy val Quotes_reflect_Assign: Symbol = Quotes_reflect.requiredValue("Assign")
@tu lazy val Quotes_reflect_Assign_apply: Symbol = Quotes_reflect_Assign.requiredMethod(nme.apply)
@tu lazy val Quotes_reflect_Inferred: Symbol = Quotes_reflect.requiredValue("Inferred")
@tu lazy val Quotes_reflect_Inferred_apply: Symbol = Quotes_reflect_Inferred.requiredMethod(nme.apply)
@tu lazy val Quotes_reflect_Literal: Symbol = Quotes_reflect.requiredValue("Literal")
@tu lazy val Quotes_reflect_Literal_apply: Symbol = Quotes_reflect_Literal.requiredMethod(nme.apply)
@tu lazy val Quotes_reflect_TreeMethods: Symbol = Quotes_reflect.requiredMethod("TreeMethods")
@tu lazy val Quotes_reflect_TreeMethods_asExpr: Symbol = Quotes_reflect_TreeMethods.requiredMethod("asExpr")
@tu lazy val Quotes_reflect_TypeRepr: Symbol = Quotes_reflect.requiredValue("TypeRepr")
@tu lazy val Quotes_reflect_TypeRepr_of: Symbol = Quotes_reflect_TypeRepr.requiredMethod("of")
@tu lazy val Quotes_reflect_TypeRepr_typeConstructorOf: Symbol = Quotes_reflect_TypeRepr.requiredMethod("typeConstructorOf")
@tu lazy val Quotes_reflect_TypeReprMethods: Symbol = Quotes_reflect.requiredValue("TypeReprMethods")
@tu lazy val Quotes_reflect_TypeReprMethods_asType: Symbol = Quotes_reflect_TypeReprMethods.requiredMethod("asType")
@tu lazy val Quotes_reflect_TypeTreeType: Symbol = Quotes_reflect.requiredType("TypeTree")
@tu lazy val Quotes_reflect_TermType: Symbol = Quotes_reflect.requiredType("Term")
@tu lazy val Quotes_reflect_BooleanConstant: Symbol = Quotes_reflect.requiredValue("BooleanConstant")
@tu lazy val Quotes_reflect_ByteConstant: Symbol = Quotes_reflect.requiredValue("ByteConstant")
@tu lazy val Quotes_reflect_ShortConstant: Symbol = Quotes_reflect.requiredValue("ShortConstant")
@tu lazy val Quotes_reflect_IntConstant: Symbol = Quotes_reflect.requiredValue("IntConstant")
@tu lazy val Quotes_reflect_LongConstant: Symbol = Quotes_reflect.requiredValue("LongConstant")
@tu lazy val Quotes_reflect_FloatConstant: Symbol = Quotes_reflect.requiredValue("FloatConstant")
@tu lazy val Quotes_reflect_DoubleConstant: Symbol = Quotes_reflect.requiredValue("DoubleConstant")
@tu lazy val Quotes_reflect_CharConstant: Symbol = Quotes_reflect.requiredValue("CharConstant")
@tu lazy val Quotes_reflect_StringConstant: Symbol = Quotes_reflect.requiredValue("StringConstant")
@tu lazy val Quotes_reflect_UnitConstant: Symbol = Quotes_reflect.requiredValue("UnitConstant")
@tu lazy val Quotes_reflect_NullConstant: Symbol = Quotes_reflect.requiredValue("NullConstant")
@tu lazy val Quotes_reflect_ClassOfConstant: Symbol = Quotes_reflect.requiredValue("ClassOfConstant")
@tu lazy val QuoteUnpicklerClass: ClassSymbol = requiredClass("scala.quoted.runtime.QuoteUnpickler")
@tu lazy val QuoteUnpickler_unpickleExprV2: Symbol = QuoteUnpicklerClass.requiredMethod("unpickleExprV2")
@tu lazy val QuoteUnpickler_unpickleTypeV2: Symbol = QuoteUnpicklerClass.requiredMethod("unpickleTypeV2")
@tu lazy val QuoteMatchingClass: ClassSymbol = requiredClass("scala.quoted.runtime.QuoteMatching")
@tu lazy val QuoteMatching_ExprMatch: Symbol = QuoteMatchingClass.requiredMethod("ExprMatch")
@tu lazy val QuoteMatching_ExprMatch_unapply: Symbol = QuoteMatchingClass.requiredClass("ExprMatchModule").requiredMethod(nme.unapply)
@tu lazy val QuoteMatching_TypeMatch: Symbol = QuoteMatchingClass.requiredMethod("TypeMatch")
@tu lazy val QuoteMatching_TypeMatch_unapply: Symbol = QuoteMatchingClass.requiredClass("TypeMatchModule").requiredMethod(nme.unapply)
@tu lazy val QuoteMatchingModule: Symbol = requiredModule("scala.quoted.runtime.QuoteMatching")
@tu lazy val QuoteMatching_KNil: Symbol = QuoteMatchingModule.requiredType("KNil")
@tu lazy val QuoteMatching_KCons: Symbol = QuoteMatchingModule.requiredType("KCons")
@tu lazy val ToExprModule: Symbol = requiredModule("scala.quoted.ToExpr")
@tu lazy val ToExprModule_BooleanToExpr: Symbol = ToExprModule.requiredMethod("BooleanToExpr")
@tu lazy val ToExprModule_ByteToExpr: Symbol = ToExprModule.requiredMethod("ByteToExpr")
@tu lazy val ToExprModule_ShortToExpr: Symbol = ToExprModule.requiredMethod("ShortToExpr")
@tu lazy val ToExprModule_IntToExpr: Symbol = ToExprModule.requiredMethod("IntToExpr")
@tu lazy val ToExprModule_LongToExpr: Symbol = ToExprModule.requiredMethod("LongToExpr")
@tu lazy val ToExprModule_FloatToExpr: Symbol = ToExprModule.requiredMethod("FloatToExpr")
@tu lazy val ToExprModule_DoubleToExpr: Symbol = ToExprModule.requiredMethod("DoubleToExpr")
@tu lazy val ToExprModule_CharToExpr: Symbol = ToExprModule.requiredMethod("CharToExpr")
@tu lazy val ToExprModule_StringToExpr: Symbol = ToExprModule.requiredMethod("StringToExpr")
@tu lazy val QuotedRuntimeModule: Symbol = requiredModule("scala.quoted.runtime.Expr")
@tu lazy val QuotedRuntime_exprQuote : Symbol = QuotedRuntimeModule.requiredMethod("quote")
@tu lazy val QuotedRuntime_exprSplice : Symbol = QuotedRuntimeModule.requiredMethod("splice")
@tu lazy val QuotedRuntime_exprNestedSplice : Symbol = QuotedRuntimeModule.requiredMethod("nestedSplice")
@tu lazy val QuotedRuntime_SplicedTypeAnnot: ClassSymbol = requiredClass("scala.quoted.runtime.SplicedType")
@tu lazy val QuotedRuntimePatterns: Symbol = requiredModule("scala.quoted.runtime.Patterns")
@tu lazy val QuotedRuntimePatterns_patternHole: Symbol = QuotedRuntimePatterns.requiredMethod("patternHole")
@tu lazy val QuotedRuntimePatterns_higherOrderHole: Symbol = QuotedRuntimePatterns.requiredMethod("higherOrderHole")
@tu lazy val QuotedRuntimePatterns_patternTypeAnnot: ClassSymbol = QuotedRuntimePatterns.requiredClass("patternType")
@tu lazy val QuotedRuntimePatterns_fromAboveAnnot: ClassSymbol = QuotedRuntimePatterns.requiredClass("fromAbove")
@tu lazy val QuotedTypeClass: ClassSymbol = requiredClass("scala.quoted.Type")
@tu lazy val QuotedType_splice: Symbol = QuotedTypeClass.requiredType(tpnme.Underlying)
@tu lazy val QuotedTypeModule: Symbol = QuotedTypeClass.companionModule
@tu lazy val QuotedTypeModule_of: Symbol = QuotedTypeModule.requiredMethod("of")
@tu lazy val MacroAnnotationClass: ClassSymbol = requiredClass("scala.annotation.MacroAnnotation")
@tu lazy val CanEqualClass: ClassSymbol = getClassIfDefined("scala.Eql").orElse(requiredClass("scala.CanEqual")).asClass
def CanEqual_canEqualAny(using Context): TermSymbol =
val methodName = if CanEqualClass.name == tpnme.Eql then nme.eqlAny else nme.canEqualAny
CanEqualClass.companionModule.requiredMethod(methodName)
@tu lazy val CanThrowClass: ClassSymbol = requiredClass("scala.CanThrow")
@tu lazy val throwsAlias: Symbol = ScalaRuntimePackageVal.requiredType(tpnme.THROWS)
@tu lazy val TypeBoxClass: ClassSymbol = requiredClass("scala.runtime.TypeBox")
@tu lazy val TypeBox_CAP: TypeSymbol = TypeBoxClass.requiredType(tpnme.CAP)
@tu lazy val MatchCaseClass: ClassSymbol = requiredClass("scala.runtime.MatchCase")
@tu lazy val NotGivenClass: ClassSymbol = requiredClass("scala.util.NotGiven")
@tu lazy val NotGiven_value: Symbol = NotGivenClass.companionModule.requiredMethod(nme.value)
@tu lazy val ValueOfClass: ClassSymbol = requiredClass("scala.ValueOf")
@tu lazy val FromDigitsClass: ClassSymbol = requiredClass("scala.util.FromDigits")
@tu lazy val FromDigits_WithRadixClass: ClassSymbol = requiredClass("scala.util.FromDigits.WithRadix")
@tu lazy val FromDigits_DecimalClass: ClassSymbol = requiredClass("scala.util.FromDigits.Decimal")
@tu lazy val FromDigits_FloatingClass: ClassSymbol = requiredClass("scala.util.FromDigits.Floating")
@tu lazy val XMLTopScopeModule: Symbol = requiredModule("scala.xml.TopScope")
@tu lazy val CommandLineParserModule: Symbol = requiredModule("scala.util.CommandLineParser")
@tu lazy val CLP_ParseError: ClassSymbol = CommandLineParserModule.requiredClass("ParseError").typeRef.symbol.asClass
@tu lazy val CLP_parseArgument: Symbol = CommandLineParserModule.requiredMethod("parseArgument")
@tu lazy val CLP_parseRemainingArguments: Symbol = CommandLineParserModule.requiredMethod("parseRemainingArguments")
@tu lazy val CLP_showError: Symbol = CommandLineParserModule.requiredMethod("showError")
@tu lazy val TupleTypeRef: TypeRef = requiredClassRef("scala.Tuple")
def TupleClass(using Context): ClassSymbol = TupleTypeRef.symbol.asClass
@tu lazy val Tuple_cons: Symbol = TupleClass.requiredMethod("*:")
@tu lazy val TupleModule: Symbol = requiredModule("scala.Tuple")
@tu lazy val EmptyTupleClass: Symbol = requiredClass("scala.EmptyTuple")
@tu lazy val EmptyTupleModule: Symbol = requiredModule("scala.EmptyTuple")
@tu lazy val NonEmptyTupleTypeRef: TypeRef = requiredClassRef("scala.NonEmptyTuple")
def NonEmptyTupleClass(using Context): ClassSymbol = NonEmptyTupleTypeRef.symbol.asClass
lazy val NonEmptyTuple_tail: Symbol = NonEmptyTupleClass.requiredMethod("tail")
@tu lazy val PairClass: ClassSymbol = requiredClass("scala.*:")
@tu lazy val TupleXXLClass: ClassSymbol = requiredClass("scala.runtime.TupleXXL")
def TupleXXLModule(using Context): Symbol = TupleXXLClass.companionModule
def TupleXXL_fromIterator(using Context): Symbol = TupleXXLModule.requiredMethod("fromIterator")
def TupleXXL_unapplySeq(using Context): Symbol = TupleXXLModule.requiredMethod(nme.unapplySeq)
@tu lazy val NamedTupleModule = requiredModule("scala.NamedTuple")
@tu lazy val NamedTupleTypeRef: TypeRef = NamedTupleModule.termRef.select(tpnme.NamedTuple).asInstanceOf
@tu lazy val RuntimeTupleMirrorTypeRef: TypeRef = requiredClassRef("scala.runtime.TupleMirror")
@tu lazy val RuntimeTuplesModule: Symbol = requiredModule("scala.runtime.Tuples")
@tu lazy val RuntimeTuplesModuleClass: Symbol = RuntimeTuplesModule.moduleClass
@tu lazy val RuntimeTuples_consIterator: Symbol = RuntimeTuplesModule.requiredMethod("consIterator")
@tu lazy val RuntimeTuples_concatIterator: Symbol = RuntimeTuplesModule.requiredMethod("concatIterator")
@tu lazy val RuntimeTuples_apply: Symbol = RuntimeTuplesModule.requiredMethod("apply")
@tu lazy val RuntimeTuples_cons: Symbol = RuntimeTuplesModule.requiredMethod("cons")
@tu lazy val RuntimeTuples_size: Symbol = RuntimeTuplesModule.requiredMethod("size")
@tu lazy val RuntimeTuples_tail: Symbol = RuntimeTuplesModule.requiredMethod("tail")
@tu lazy val RuntimeTuples_concat: Symbol = RuntimeTuplesModule.requiredMethod("concat")
@tu lazy val RuntimeTuples_toArray: Symbol = RuntimeTuplesModule.requiredMethod("toArray")
@tu lazy val RuntimeTuples_productToArray: Symbol = RuntimeTuplesModule.requiredMethod("productToArray")
@tu lazy val RuntimeTuples_isInstanceOfTuple: Symbol = RuntimeTuplesModule.requiredMethod("isInstanceOfTuple")
@tu lazy val RuntimeTuples_isInstanceOfEmptyTuple: Symbol = RuntimeTuplesModule.requiredMethod("isInstanceOfEmptyTuple")
@tu lazy val RuntimeTuples_isInstanceOfNonEmptyTuple: Symbol = RuntimeTuplesModule.requiredMethod("isInstanceOfNonEmptyTuple")
@tu lazy val TupledFunctionTypeRef: TypeRef = requiredClassRef("scala.util.TupledFunction")
def TupledFunctionClass(using Context): ClassSymbol = TupledFunctionTypeRef.symbol.asClass
def RuntimeTupleFunctionsModule(using Context): Symbol = requiredModule("scala.runtime.TupledFunctions")
@tu lazy val boundaryModule: Symbol = requiredModule("scala.util.boundary")
@tu lazy val LabelClass: Symbol = requiredClass("scala.util.boundary.Label")
@tu lazy val BreakClass: Symbol = requiredClass("scala.util.boundary.Break")
@tu lazy val CapsModule: Symbol = requiredModule("scala.caps")
@tu lazy val captureRoot: TermSymbol = CapsModule.requiredValue("cap")
@tu lazy val Caps_Capability: ClassSymbol = requiredClass("scala.caps.Capability")
@tu lazy val Caps_reachCapability: TermSymbol = CapsModule.requiredMethod("reachCapability")
@tu lazy val CapsUnsafeModule: Symbol = requiredModule("scala.caps.unsafe")
@tu lazy val Caps_unsafeAssumePure: Symbol = CapsUnsafeModule.requiredMethod("unsafeAssumePure")
@tu lazy val Caps_unsafeBox: Symbol = CapsUnsafeModule.requiredMethod("unsafeBox")
@tu lazy val Caps_unsafeUnbox: Symbol = CapsUnsafeModule.requiredMethod("unsafeUnbox")
@tu lazy val Caps_unsafeBoxFunArg: Symbol = CapsUnsafeModule.requiredMethod("unsafeBoxFunArg")