dotty.tools.dotc.core.Definitions.scala Maven / Gradle / Ivy
The newest version!
package dotty.tools
package dotc
package core
import scala.annotation.threadUnsafe
import Types._, Contexts._, Symbols._, SymDenotations._, StdNames._, Names._
import Flags._, Scopes._, Decorators._, NameOps._, Periods._
import unpickleScala2.Scala2Unpickler.ensureConstructor
import scala.collection.mutable
import collection.mutable
import Denotations.SingleDenotation
import util.SimpleIdentityMap
import scala.annotation.tailrec
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
*
* Note: There's a much nicer design possible once we have implicit functions.
* The idea is explored to some degree in branch wip-definitions (#929): Instead of a type
* and a separate symbol definition, we produce in one line an implicit function from
* Context to Symbol, and possibly also the corresponding type. This cuts down on all
* the duplication encountered here.
*
* wip-definitions tries to do the same with an implicit conversion from a SymbolPerRun
* type to a symbol type. The problem with that is universal equality. Comparisons will
* not trigger the conversion and will therefore likely return false results.
*
* So the branch is put on hold, until we have implicit functions, which will always
* automatically be dereferenced.
*/
class Definitions {
import Definitions._
private implicit var ctx: Context = _
private def newSymbol[N <: Name](owner: Symbol, name: N, flags: FlagSet, info: Type) =
ctx.newSymbol(owner, name, flags | Permanent, info)
private def newClassSymbol(owner: Symbol, name: TypeName, flags: FlagSet, infoFn: ClassSymbol => Type) =
ctx.newClassSymbol(owner, name, flags | Permanent | NoInits, infoFn)
private def enterCompleteClassSymbol(owner: Symbol, name: TypeName, flags: FlagSet, parents: List[TypeRef], decls: Scope = newScope) =
ctx.newCompleteClassSymbol(owner, name, flags | Permanent | NoInits, parents, decls).entered
private def enterTypeField(cls: ClassSymbol, name: TypeName, flags: FlagSet, scope: MutableScope) =
scope.enter(newSymbol(cls, name, flags, TypeBounds.empty))
private def enterTypeParam(cls: ClassSymbol, name: TypeName, flags: FlagSet, scope: MutableScope) =
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 .
private def enterSpecialPolyClass(name: TypeName, paramFlags: FlagSet, parentConstrs: => Seq[Type]): ClassSymbol = {
val completer = new LazyType {
def complete(denot: SymDenotation)(implicit ctx: 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)
}
}
newClassSymbol(ScalaPackageClass, name, Artifact, completer).entered
}
/** The trait FunctionN, ImplicitFunctionN, ErasedFunctionN or ErasedImplicitFunction, 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`.
*
* ImplicitFunctionN traits follow this template:
*
* trait ImplicitFunctionN[T0,...,T{N-1}, R] extends Object {
* def apply given ($x0: T0, ..., $x{N_1}: T{N-1}): R
* }
*
* 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
* }
*
* 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
* }
*
* ErasedFunctionN and ErasedImplicitFunctionN erase to Function0.
*/
def newFunctionNTrait(name: TypeName): ClassSymbol = {
val completer = new LazyType {
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = {
val cls = denot.asClass.classSymbol
val decls = newScope
val arity = name.functionArity
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(
isJava = false,
isContextual = name.isImplicitFunction,
isImplicit = false,
isErased = name.isErasedFunction)
decls.enter(newMethod(cls, nme.apply, methodType(argParamRefs, resParamRef), Deferred))
denot.info =
ClassInfo(ScalaPackageClass.thisType, cls, ObjectType :: Nil, decls)
}
}
newClassSymbol(ScalaPackageClass, name, Trait | NoInits, completer)
}
private def newMethod(cls: ClassSymbol, name: TermName, info: Type, flags: FlagSet = EmptyFlags): TermSymbol =
newSymbol(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 enterAliasType(name: TypeName, tpe: Type, flags: FlagSet = EmptyFlags): TypeSymbol = {
val sym = newSymbol(ScalaPackageClass, name, flags, TypeAlias(tpe))
ScalaPackageClass.currentPackageDecls.enter(sym)
sym
}
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,
useCompleter: Boolean = false) = {
val tparamNames = PolyType.syntheticParamNames(typeParamCount)
val tparamInfos = tparamNames map (_ => TypeBounds.empty)
def ptype = PolyType(tparamNames)(_ => tparamInfos, resultTypeFn)
val info =
if (useCompleter)
new LazyType {
def complete(denot: SymDenotation)(implicit ctx: 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] = {
val arr = new Array[TypeRef](arity + 1)
for (i <- countFrom to arity) arr(i) = ctx.requiredClassRef(name + i)
arr
}
private def completeClass(cls: ClassSymbol, ensureCtor: Boolean = true): ClassSymbol = {
if (ensureCtor) ensureConstructor(cls, EmptyScope)
if (cls.linkedClass.exists) cls.linkedClass.info = NoType
cls
}
@threadUnsafe lazy val RootClass: ClassSymbol = ctx.newPackageSymbol(
NoSymbol, nme.ROOT, (root, rootcls) => ctx.base.rootLoader(root)).moduleClass.asClass
@threadUnsafe lazy val RootPackage: TermSymbol = ctx.newSymbol(
NoSymbol, nme.ROOTPKG, PackageCreationFlags, TypeRef(NoPrefix, RootClass))
@threadUnsafe lazy val EmptyPackageVal: TermSymbol = ctx.newPackageSymbol(
RootClass, nme.EMPTY_PACKAGE, (emptypkg, emptycls) => ctx.base.rootLoader(emptypkg)).entered
@threadUnsafe lazy val EmptyPackageClass: ClassSymbol = EmptyPackageVal.moduleClass.asClass
/** A package in which we can place all methods that are interpreted specially by the compiler */
@threadUnsafe lazy val OpsPackageVal: TermSymbol = ctx.newCompletePackageSymbol(RootClass, nme.OPS_PACKAGE).entered
@threadUnsafe lazy val OpsPackageClass: ClassSymbol = OpsPackageVal.moduleClass.asClass
@threadUnsafe lazy val ScalaPackageVal: TermSymbol = ctx.requiredPackage(nme.scala_)
@threadUnsafe lazy val ScalaMathPackageVal: TermSymbol = ctx.requiredPackage("scala.math")
@threadUnsafe lazy val ScalaPackageClass: ClassSymbol = {
val cls = ScalaPackageVal.moduleClass.asClass
cls.info.decls.openForMutations.useSynthesizer(
name => ctx =>
if (name.isTypeName && name.isSyntheticFunction) newFunctionNTrait(name.asTypeName)
else NoSymbol)
cls
}
@threadUnsafe lazy val ScalaPackageObjectRef: TermRef = ctx.requiredModuleRef("scala.package")
@threadUnsafe lazy val JavaPackageVal: TermSymbol = ctx.requiredPackage(nme.java)
@threadUnsafe lazy val JavaLangPackageVal: TermSymbol = ctx.requiredPackage(jnme.JavaLang)
// fundamental modules
@threadUnsafe lazy val SysPackage: TermSymbol = ctx.requiredModule("scala.sys.package")
@threadUnsafe lazy val Sys_errorR: TermRef = SysPackage.moduleClass.requiredMethodRef(nme.error)
def Sys_error(implicit ctx: Context): Symbol = Sys_errorR.symbol
@threadUnsafe lazy val ScalaXmlPackageClass: Symbol = ctx.getPackageClassIfDefined("scala.xml")
@threadUnsafe lazy val CompiletimePackageObjectRef: TermRef = ctx.requiredModuleRef("scala.compiletime.package")
@threadUnsafe lazy val CompiletimePackageObject: Symbol = CompiletimePackageObjectRef.symbol.moduleClass
@threadUnsafe lazy val Compiletime_errorR: TermRef = CompiletimePackageObjectRef.symbol.requiredMethodRef(nme.error)
def Compiletime_error(implicit ctx: Context): Symbol = Compiletime_errorR.symbol
@threadUnsafe lazy val Compiletime_constValueR: TermRef = CompiletimePackageObjectRef.symbol.requiredMethodRef("constValue")
def Compiletime_constValue(implicit ctx: Context): Symbol = Compiletime_constValueR.symbol
@threadUnsafe lazy val Compiletime_constValueOptR: TermRef = CompiletimePackageObjectRef.symbol.requiredMethodRef("constValueOpt")
def Compiletime_constValueOpt(implicit ctx: Context): Symbol = Compiletime_constValueOptR.symbol
@threadUnsafe lazy val Compiletime_codeR: TermRef = CompiletimePackageObjectRef.symbol.requiredMethodRef("code")
def Compiletime_code(implicit ctx: Context): Symbol = Compiletime_codeR.symbol
/** The `scalaShadowing` package is used to safely modify classes and
* objects in scala so that they can be used from dotty. They will
* be visible as members of the `scala` package, replacing any objects
* or classes with the same name. But their binary artifacts are
* in `scalaShadowing` so they don't clash with the same-named `scala`
* members at runtime.
*/
@threadUnsafe lazy val ScalaShadowingPackageVal: TermSymbol = ctx.requiredPackage(nme.scalaShadowing)
def ScalaShadowingPackageClass(implicit ctx: Context): ClassSymbol = ScalaShadowingPackageVal.moduleClass.asClass
/** 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.
*
* There's a remaining question about `getClass`. In Scala2.x `getClass` was handled by compiler magic.
* This is deemed too cumersome for Dotty and therefore right now `getClass` gets no special treatment;
* it's just a method on `Any` which returns the raw type `java.lang.Class`. An alternative
* way to get better `getClass` typing would be to treat `getClass` as a method of a generic
* decorator which gets remapped in a later phase to Object#getClass. Then we could give it
* the right type without changing the typechecker:
*
* implicit class AnyGetClass[T](val x: T) extends AnyVal {
* def getClass: java.lang.Class[T] = ???
* }
*/
@threadUnsafe lazy val AnyClass: ClassSymbol = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.Any, Abstract, Nil), ensureCtor = false)
def AnyType: TypeRef = AnyClass.typeRef
@threadUnsafe lazy val AnyValClass: ClassSymbol = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.AnyVal, Abstract, List(AnyClass.typeRef)))
def AnyValType: TypeRef = AnyValClass.typeRef
@threadUnsafe lazy val Any_== : TermSymbol = enterMethod(AnyClass, nme.EQ, methOfAny(BooleanType), Final)
@threadUnsafe lazy val Any_!= : TermSymbol = enterMethod(AnyClass, nme.NE, methOfAny(BooleanType), Final)
@threadUnsafe lazy val Any_equals: TermSymbol = enterMethod(AnyClass, nme.equals_, methOfAny(BooleanType))
@threadUnsafe lazy val Any_hashCode: TermSymbol = enterMethod(AnyClass, nme.hashCode_, MethodType(Nil, IntType))
@threadUnsafe lazy val Any_toString: TermSymbol = enterMethod(AnyClass, nme.toString_, MethodType(Nil, StringType))
@threadUnsafe lazy val Any_## : TermSymbol = enterMethod(AnyClass, nme.HASHHASH, ExprType(IntType), Final)
@threadUnsafe lazy val Any_getClass: TermSymbol = enterMethod(AnyClass, nme.getClass_, MethodType(Nil, ClassClass.typeRef.appliedTo(TypeBounds.empty)), Final)
@threadUnsafe lazy val Any_isInstanceOf: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOf_, _ => BooleanType, Final)
@threadUnsafe lazy val Any_asInstanceOf: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOf_, _.paramRefs(0), Final)
@threadUnsafe lazy val Any_typeTest: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOfPM, _ => BooleanType, Final | Synthetic | Artifact)
@threadUnsafe lazy val Any_typeCast: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOfPM, _.paramRefs(0), Final | Synthetic | Artifact | StableRealizable)
// generated by pattern matcher, eliminated by erasure
def AnyMethods: List[TermSymbol] = List(Any_==, Any_!=, Any_equals, Any_hashCode,
Any_toString, Any_##, Any_getClass, Any_isInstanceOf, Any_asInstanceOf, Any_typeTest, Any_typeCast)
@threadUnsafe lazy val ObjectClass: ClassSymbol = {
val cls = ctx.requiredClass("java.lang.Object")
assert(!cls.isCompleted, "race for completing java.lang.Object")
cls.info = ClassInfo(cls.owner.thisType, cls, AnyClass.typeRef :: Nil, newScope)
cls.setFlag(NoInits)
// The companion object doesn't really exist, `NoType` is the general
// technique to do that. Here we need to set it before completing
// attempt to load Object's classfile, which causes issue #1648.
val companion = JavaLangPackageVal.info.decl(nme.Object).symbol
companion.moduleClass.info = NoType // to indicate that it does not really exist
companion.info = NoType // to indicate that it does not really exist
completeClass(cls)
}
def ObjectType: TypeRef = ObjectClass.typeRef
@threadUnsafe lazy val AnyRefAlias: TypeSymbol = enterAliasType(tpnme.AnyRef, ObjectType)
def AnyRefType: TypeRef = AnyRefAlias.typeRef
@threadUnsafe lazy val Object_eq: TermSymbol = enterMethod(ObjectClass, nme.eq, methOfAnyRef(BooleanType), Final)
@threadUnsafe lazy val Object_ne: TermSymbol = enterMethod(ObjectClass, nme.ne, methOfAnyRef(BooleanType), Final)
@threadUnsafe lazy val Object_synchronized: TermSymbol = enterPolyMethod(ObjectClass, nme.synchronized_, 1,
pt => MethodType(List(pt.paramRefs(0)), pt.paramRefs(0)), Final)
@threadUnsafe lazy val Object_clone: TermSymbol = enterMethod(ObjectClass, nme.clone_, MethodType(Nil, ObjectType), Protected)
@threadUnsafe lazy val Object_finalize: TermSymbol = enterMethod(ObjectClass, nme.finalize_, MethodType(Nil, UnitType), Protected)
@threadUnsafe lazy val Object_notify: TermSymbol = enterMethod(ObjectClass, nme.notify_, MethodType(Nil, UnitType), Final)
@threadUnsafe lazy val Object_notifyAll: TermSymbol = enterMethod(ObjectClass, nme.notifyAll_, MethodType(Nil, UnitType), Final)
@threadUnsafe lazy val Object_wait: TermSymbol = enterMethod(ObjectClass, nme.wait_, MethodType(Nil, UnitType), Final)
@threadUnsafe lazy val Object_waitL: TermSymbol = enterMethod(ObjectClass, nme.wait_, MethodType(LongType :: Nil, UnitType), Final)
@threadUnsafe 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)
@threadUnsafe lazy val AnyKindClass: ClassSymbol = {
val cls = ctx.newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal | Permanent, Nil)
if (!ctx.settings.YnoKindPolymorphism.value) {
// Enable kind-polymorphism by exposing scala.AnyKind
cls.entered
}
cls
}
def AnyKindType: TypeRef = AnyKindClass.typeRef
@threadUnsafe lazy val andType: TypeSymbol = enterBinaryAlias(tpnme.AND, AndType(_, _))
@threadUnsafe lazy val orType: TypeSymbol = enterBinaryAlias(tpnme.OR, OrType(_, _))
/** Marker method to indicate an argument to a call-by-name parameter.
* Created by byNameClosures and elimByName, eliminated by Erasure,
*/
@threadUnsafe lazy val cbnArg: TermSymbol = enterPolyMethod(OpsPackageClass, nme.cbnArg, 1,
pt => MethodType(List(FunctionOf(Nil, pt.paramRefs(0))), pt.paramRefs(0)))
/** Method representing a throw */
@threadUnsafe lazy val throwMethod: TermSymbol = enterMethod(OpsPackageClass, nme.THROWkw,
MethodType(List(ThrowableType), NothingType))
@threadUnsafe lazy val NothingClass: ClassSymbol = enterCompleteClassSymbol(
ScalaPackageClass, tpnme.Nothing, AbstractFinal, List(AnyClass.typeRef))
def NothingType: TypeRef = NothingClass.typeRef
@threadUnsafe lazy val RuntimeNothingModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Nothing")
@threadUnsafe lazy val NullClass: ClassSymbol = enterCompleteClassSymbol(
ScalaPackageClass, tpnme.Null, AbstractFinal, List(ObjectClass.typeRef))
def NullType: TypeRef = NullClass.typeRef
@threadUnsafe lazy val RuntimeNullModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Null")
@threadUnsafe lazy val ImplicitScrutineeTypeSym =
newSymbol(ScalaPackageClass, tpnme.IMPLICITkw, EmptyFlags, TypeBounds.empty).entered
def ImplicitScrutineeTypeRef: TypeRef = ImplicitScrutineeTypeSym.typeRef
@threadUnsafe lazy val ScalaPredefModuleRef: TermRef = ctx.requiredModuleRef("scala.Predef")
def ScalaPredefModule(implicit ctx: Context): Symbol = ScalaPredefModuleRef.symbol
@threadUnsafe lazy val Predef_conformsR: TermRef = ScalaPredefModule.requiredMethodRef(nme.conforms_)
def Predef_conforms(implicit ctx: Context): Symbol = Predef_conformsR.symbol
@threadUnsafe lazy val Predef_classOfR: TermRef = ScalaPredefModule.requiredMethodRef(nme.classOf)
def Predef_classOf(implicit ctx: Context): Symbol = Predef_classOfR.symbol
@threadUnsafe lazy val Predef_undefinedR: TermRef = ScalaPredefModule.requiredMethodRef(nme.???)
def Predef_undefined(implicit ctx: Context): Symbol = Predef_undefinedR.symbol
def SubTypeClass(implicit ctx: Context): ClassSymbol =
if (isNewCollections)
ctx.requiredClass("scala.<:<")
else
ScalaPredefModule.requiredClass("<:<")
def DummyImplicitClass(implicit ctx: Context): ClassSymbol =
if (isNewCollections)
ctx.requiredClass("scala.DummyImplicit")
else
ScalaPredefModule.requiredClass("DummyImplicit")
@threadUnsafe lazy val ScalaRuntimeModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.ScalaRunTime")
def ScalaRuntimeModule(implicit ctx: Context): Symbol = ScalaRuntimeModuleRef.symbol
def ScalaRuntimeClass(implicit ctx: Context): ClassSymbol = ScalaRuntimeModule.moduleClass.asClass
def runtimeMethodRef(name: PreName): TermRef = ScalaRuntimeModule.requiredMethodRef(name)
def ScalaRuntime_dropR(implicit ctx: Context): TermRef = runtimeMethodRef(nme.drop)
def ScalaRuntime_drop(implicit ctx: Context): Symbol = ScalaRuntime_dropR.symbol
@threadUnsafe lazy val BoxesRunTimeModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.BoxesRunTime")
def BoxesRunTimeModule(implicit ctx: Context): Symbol = BoxesRunTimeModuleRef.symbol
def BoxesRunTimeClass(implicit ctx: Context): ClassSymbol = BoxesRunTimeModule.moduleClass.asClass
@threadUnsafe lazy val ScalaStaticsModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Statics")
def ScalaStaticsModule(implicit ctx: Context): Symbol = ScalaStaticsModuleRef.symbol
def ScalaStaticsClass(implicit ctx: Context): ClassSymbol = ScalaStaticsModule.moduleClass.asClass
def staticsMethodRef(name: PreName): TermRef = ScalaStaticsModule.requiredMethodRef(name)
def staticsMethod(name: PreName): TermSymbol = ScalaStaticsModule.requiredMethod(name)
// Dotty deviation: we cannot use a @threadUnsafe lazy val here because @threadUnsafe lazy vals in dotty
// will return "null" when called recursively, see #1856.
def DottyPredefModuleRef: TermRef = {
if (myDottyPredefModuleRef == null) {
myDottyPredefModuleRef = ctx.requiredModuleRef("dotty.DottyPredef")
assert(myDottyPredefModuleRef != null)
}
myDottyPredefModuleRef
}
private[this] var myDottyPredefModuleRef: TermRef = _
def DottyPredefModule(implicit ctx: Context): Symbol = DottyPredefModuleRef.symbol
@threadUnsafe lazy val DottyArraysModuleRef: TermRef = ctx.requiredModuleRef("dotty.runtime.Arrays")
def DottyArraysModule(implicit ctx: Context): Symbol = DottyArraysModuleRef.symbol
def newGenericArrayMethod(implicit ctx: Context): TermSymbol = DottyArraysModule.requiredMethod("newGenericArray")
def newArrayMethod(implicit ctx: Context): TermSymbol = DottyArraysModule.requiredMethod("newArray")
// TODO: Remove once we drop support for 2.12 standard library
@threadUnsafe lazy val isNewCollections: Boolean = ctx.settings.YnewCollections.value
def getWrapVarargsArrayModule: Symbol = if (isNewCollections) ScalaRuntimeModule else ScalaPredefModule
// The set of all wrap{X, Ref}Array methods, where X is a value type
val WrapArrayMethods: PerRun[collection.Set[Symbol]] = new PerRun({ implicit ctx =>
val methodNames = ScalaValueTypes.map(ast.tpd.wrapArrayMethodName) + nme.wrapRefArray
methodNames.map(getWrapVarargsArrayModule.requiredMethodRef(_).symbol)
})
@threadUnsafe lazy val NilModuleRef: TermRef = ctx.requiredModuleRef("scala.collection.immutable.Nil")
def NilModule(implicit ctx: Context): Symbol = NilModuleRef.symbol
@threadUnsafe 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.
enterCompleteClassSymbol(
ScalaPackageClass, tpnme.Singleton, PureInterfaceCreationFlags | Final,
List(AnyClass.typeRef), EmptyScope)
@threadUnsafe lazy val SingletonType: TypeRef = SingletonClass.typeRef
@threadUnsafe lazy val SeqType: TypeRef =
if (isNewCollections) ctx.requiredClassRef("scala.collection.immutable.Seq")
else ctx.requiredClassRef("scala.collection.Seq")
def SeqClass(implicit ctx: Context): ClassSymbol = SeqType.symbol.asClass
@threadUnsafe lazy val Seq_applyR: TermRef = SeqClass.requiredMethodRef(nme.apply)
def Seq_apply(implicit ctx: Context): Symbol = Seq_applyR.symbol
@threadUnsafe lazy val Seq_headR: TermRef = SeqClass.requiredMethodRef(nme.head)
def Seq_head(implicit ctx: Context): Symbol = Seq_headR.symbol
@threadUnsafe lazy val Seq_dropR: TermRef = SeqClass.requiredMethodRef(nme.drop)
def Seq_drop(implicit ctx: Context): Symbol = Seq_dropR.symbol
@threadUnsafe lazy val Seq_lengthCompareR: TermRef = SeqClass.requiredMethodRef(nme.lengthCompare, List(IntType))
def Seq_lengthCompare(implicit ctx: Context): Symbol = Seq_lengthCompareR.symbol
@threadUnsafe lazy val Seq_lengthR: TermRef = SeqClass.requiredMethodRef(nme.length)
def Seq_length(implicit ctx: Context): Symbol = Seq_lengthR.symbol
@threadUnsafe lazy val Seq_toSeqR: TermRef = SeqClass.requiredMethodRef(nme.toSeq)
def Seq_toSeq(implicit ctx: Context): Symbol = Seq_toSeqR.symbol
@threadUnsafe lazy val ArrayType: TypeRef = ctx.requiredClassRef("scala.Array")
def ArrayClass(implicit ctx: Context): ClassSymbol = ArrayType.symbol.asClass
@threadUnsafe lazy val Array_applyR: TermRef = ArrayClass.requiredMethodRef(nme.apply)
def Array_apply(implicit ctx: Context): Symbol = Array_applyR.symbol
@threadUnsafe lazy val Array_updateR: TermRef = ArrayClass.requiredMethodRef(nme.update)
def Array_update(implicit ctx: Context): Symbol = Array_updateR.symbol
@threadUnsafe lazy val Array_lengthR: TermRef = ArrayClass.requiredMethodRef(nme.length)
def Array_length(implicit ctx: Context): Symbol = Array_lengthR.symbol
@threadUnsafe lazy val Array_cloneR: TermRef = ArrayClass.requiredMethodRef(nme.clone_)
def Array_clone(implicit ctx: Context): Symbol = Array_cloneR.symbol
@threadUnsafe lazy val ArrayConstructorR: TermRef = ArrayClass.requiredMethodRef(nme.CONSTRUCTOR)
def ArrayConstructor(implicit ctx: Context): Symbol = ArrayConstructorR.symbol
@threadUnsafe lazy val ArrayModuleType: TermRef = ctx.requiredModuleRef("scala.Array")
def ArrayModule(implicit ctx: Context): ClassSymbol = ArrayModuleType.symbol.moduleClass.asClass
@threadUnsafe lazy val UnitType: TypeRef = valueTypeRef("scala.Unit", java.lang.Void.TYPE, UnitEnc, nme.specializedTypeNames.Void)
def UnitClass(implicit ctx: Context): ClassSymbol = UnitType.symbol.asClass
def UnitModuleClass(implicit ctx: Context): Symbol = UnitType.symbol.asClass.linkedClass
@threadUnsafe lazy val BooleanType: TypeRef = valueTypeRef("scala.Boolean", java.lang.Boolean.TYPE, BooleanEnc, nme.specializedTypeNames.Boolean)
def BooleanClass(implicit ctx: Context): ClassSymbol = BooleanType.symbol.asClass
@threadUnsafe lazy val Boolean_notR: TermRef = BooleanClass.requiredMethodRef(nme.UNARY_!)
def Boolean_! : Symbol = Boolean_notR.symbol
@threadUnsafe lazy val Boolean_andR: TermRef = BooleanClass.requiredMethodRef(nme.ZAND) // ### harmonize required... calls
def Boolean_&& : Symbol = Boolean_andR.symbol
@threadUnsafe lazy val Boolean_orR: TermRef = BooleanClass.requiredMethodRef(nme.ZOR)
def Boolean_|| : Symbol = Boolean_orR.symbol
@threadUnsafe lazy val Boolean_eqeqR: SingleDenotation = BooleanClass.info.member(nme.EQ).suchThat(_.info.firstParamTypes match {
case List(pt) => (pt isRef BooleanClass)
case _ => false
})
def Boolean_== : Symbol = Boolean_eqeqR.symbol
@threadUnsafe lazy val Boolean_neqeqR: SingleDenotation = BooleanClass.info.member(nme.NE).suchThat(_.info.firstParamTypes match {
case List(pt) => (pt isRef BooleanClass)
case _ => false
})
def Boolean_!= : Symbol = Boolean_neqeqR.symbol
@threadUnsafe lazy val ByteType: TypeRef = valueTypeRef("scala.Byte", java.lang.Byte.TYPE, ByteEnc, nme.specializedTypeNames.Byte)
def ByteClass(implicit ctx: Context): ClassSymbol = ByteType.symbol.asClass
@threadUnsafe lazy val ShortType: TypeRef = valueTypeRef("scala.Short", java.lang.Short.TYPE, ShortEnc, nme.specializedTypeNames.Short)
def ShortClass(implicit ctx: Context): ClassSymbol = ShortType.symbol.asClass
@threadUnsafe lazy val CharType: TypeRef = valueTypeRef("scala.Char", java.lang.Character.TYPE, CharEnc, nme.specializedTypeNames.Char)
def CharClass(implicit ctx: Context): ClassSymbol = CharType.symbol.asClass
@threadUnsafe lazy val IntType: TypeRef = valueTypeRef("scala.Int", java.lang.Integer.TYPE, IntEnc, nme.specializedTypeNames.Int)
def IntClass(implicit ctx: Context): ClassSymbol = IntType.symbol.asClass
@threadUnsafe lazy val Int_minusR: TermRef = IntClass.requiredMethodRef(nme.MINUS, List(IntType))
def Int_- : Symbol = Int_minusR.symbol
@threadUnsafe lazy val Int_plusR: TermRef = IntClass.requiredMethodRef(nme.PLUS, List(IntType))
def Int_+ : Symbol = Int_plusR.symbol
@threadUnsafe lazy val Int_divR: TermRef = IntClass.requiredMethodRef(nme.DIV, List(IntType))
def Int_/ : Symbol = Int_divR.symbol
@threadUnsafe lazy val Int_mulR: TermRef = IntClass.requiredMethodRef(nme.MUL, List(IntType))
def Int_* : Symbol = Int_mulR.symbol
@threadUnsafe lazy val Int_eqR: TermRef = IntClass.requiredMethodRef(nme.EQ, List(IntType))
def Int_== : Symbol = Int_eqR.symbol
@threadUnsafe lazy val Int_geR: TermRef = IntClass.requiredMethodRef(nme.GE, List(IntType))
def Int_>= : Symbol = Int_geR.symbol
@threadUnsafe lazy val Int_leR: TermRef = IntClass.requiredMethodRef(nme.LE, List(IntType))
def Int_<= : Symbol = Int_leR.symbol
@threadUnsafe lazy val LongType: TypeRef = valueTypeRef("scala.Long", java.lang.Long.TYPE, LongEnc, nme.specializedTypeNames.Long)
def LongClass(implicit ctx: Context): ClassSymbol = LongType.symbol.asClass
@threadUnsafe lazy val Long_XOR_Long: Symbol = LongType.member(nme.XOR).requiredSymbol("method", nme.XOR, LongType.denot)(
x => x.is(Method) && (x.info.firstParamTypes.head isRef defn.LongClass)
)
@threadUnsafe lazy val Long_LSR_Int: Symbol = LongType.member(nme.LSR).requiredSymbol("method", nme.LSR, LongType.denot)(
x => x.is(Method) && (x.info.firstParamTypes.head isRef defn.IntClass)
)
@threadUnsafe lazy val Long_plusR: TermRef = LongClass.requiredMethodRef(nme.PLUS, List(LongType))
def Long_+ : Symbol = Long_plusR.symbol
@threadUnsafe lazy val Long_mulR: TermRef = LongClass.requiredMethodRef(nme.MUL, List(LongType))
def Long_* : Symbol = Long_mulR.symbol
@threadUnsafe lazy val Long_divR: TermRef = LongClass.requiredMethodRef(nme.DIV, List(LongType))
def Long_/ : Symbol = Long_divR.symbol
@threadUnsafe lazy val FloatType: TypeRef = valueTypeRef("scala.Float", java.lang.Float.TYPE, FloatEnc, nme.specializedTypeNames.Float)
def FloatClass(implicit ctx: Context): ClassSymbol = FloatType.symbol.asClass
@threadUnsafe lazy val DoubleType: TypeRef = valueTypeRef("scala.Double", java.lang.Double.TYPE, DoubleEnc, nme.specializedTypeNames.Double)
def DoubleClass(implicit ctx: Context): ClassSymbol = DoubleType.symbol.asClass
@threadUnsafe lazy val BoxedUnitType: TypeRef = ctx.requiredClassRef("scala.runtime.BoxedUnit")
def BoxedUnitClass(implicit ctx: Context): ClassSymbol = BoxedUnitType.symbol.asClass
def BoxedUnit_UNIT(implicit ctx: Context): TermSymbol = BoxedUnitClass.linkedClass.requiredValue("UNIT")
@threadUnsafe lazy val BoxedBooleanType: TypeRef = ctx.requiredClassRef("java.lang.Boolean")
def BoxedBooleanClass(implicit ctx: Context): ClassSymbol = BoxedBooleanType.symbol.asClass
@threadUnsafe lazy val BoxedByteType: TypeRef = ctx.requiredClassRef("java.lang.Byte")
def BoxedByteClass(implicit ctx: Context): ClassSymbol = BoxedByteType.symbol.asClass
@threadUnsafe lazy val BoxedShortType: TypeRef = ctx.requiredClassRef("java.lang.Short")
def BoxedShortClass(implicit ctx: Context): ClassSymbol = BoxedShortType.symbol.asClass
@threadUnsafe lazy val BoxedCharType: TypeRef = ctx.requiredClassRef("java.lang.Character")
def BoxedCharClass(implicit ctx: Context): ClassSymbol = BoxedCharType.symbol.asClass
@threadUnsafe lazy val BoxedIntType: TypeRef = ctx.requiredClassRef("java.lang.Integer")
def BoxedIntClass(implicit ctx: Context): ClassSymbol = BoxedIntType.symbol.asClass
@threadUnsafe lazy val BoxedLongType: TypeRef = ctx.requiredClassRef("java.lang.Long")
def BoxedLongClass(implicit ctx: Context): ClassSymbol = BoxedLongType.symbol.asClass
@threadUnsafe lazy val BoxedFloatType: TypeRef = ctx.requiredClassRef("java.lang.Float")
def BoxedFloatClass(implicit ctx: Context): ClassSymbol = BoxedFloatType.symbol.asClass
@threadUnsafe lazy val BoxedDoubleType: TypeRef = ctx.requiredClassRef("java.lang.Double")
def BoxedDoubleClass(implicit ctx: Context): ClassSymbol = BoxedDoubleType.symbol.asClass
@threadUnsafe lazy val BoxedBooleanModule: TermSymbol = ctx.requiredModule("java.lang.Boolean")
@threadUnsafe lazy val BoxedByteModule: TermSymbol = ctx.requiredModule("java.lang.Byte")
@threadUnsafe lazy val BoxedShortModule: TermSymbol = ctx.requiredModule("java.lang.Short")
@threadUnsafe lazy val BoxedCharModule: TermSymbol = ctx.requiredModule("java.lang.Character")
@threadUnsafe lazy val BoxedIntModule: TermSymbol = ctx.requiredModule("java.lang.Integer")
@threadUnsafe lazy val BoxedLongModule: TermSymbol = ctx.requiredModule("java.lang.Long")
@threadUnsafe lazy val BoxedFloatModule: TermSymbol = ctx.requiredModule("java.lang.Float")
@threadUnsafe lazy val BoxedDoubleModule: TermSymbol = ctx.requiredModule("java.lang.Double")
@threadUnsafe lazy val BoxedUnitModule: TermSymbol = ctx.requiredModule("java.lang.Void")
@threadUnsafe lazy val ByNameParamClass2x: ClassSymbol = enterSpecialPolyClass(tpnme.BYNAME_PARAM_CLASS, Covariant, Seq(AnyType))
@threadUnsafe lazy val RepeatedParamClass: ClassSymbol = enterSpecialPolyClass(tpnme.REPEATED_PARAM_CLASS, Covariant, Seq(ObjectType, SeqType))
// fundamental classes
@threadUnsafe lazy val StringClass: ClassSymbol = ctx.requiredClass("java.lang.String")
def StringType: Type = StringClass.typeRef
@threadUnsafe lazy val StringModule: Symbol = StringClass.linkedClass
@threadUnsafe lazy val String_+ : TermSymbol = enterMethod(StringClass, nme.raw.PLUS, methOfAny(StringType), Final)
@threadUnsafe lazy val String_valueOf_Object: Symbol = StringModule.info.member(nme.valueOf).suchThat(_.info.firstParamTypes match {
case List(pt) => (pt isRef AnyClass) || (pt isRef ObjectClass)
case _ => false
}).symbol
@threadUnsafe lazy val JavaCloneableClass: ClassSymbol = ctx.requiredClass("java.lang.Cloneable")
@threadUnsafe lazy val NullPointerExceptionClass: ClassSymbol = ctx.requiredClass("java.lang.NullPointerException")
@threadUnsafe lazy val IndexOutOfBoundsException: ClassSymbol = ctx.requiredClass("java.lang.IndexOutOfBoundsException")
@threadUnsafe lazy val ClassClass: ClassSymbol = ctx.requiredClass("java.lang.Class")
@threadUnsafe lazy val BoxedNumberClass: ClassSymbol = ctx.requiredClass("java.lang.Number")
@threadUnsafe lazy val ClassCastExceptionClass: ClassSymbol = ctx.requiredClass("java.lang.ClassCastException")
@threadUnsafe lazy val ClassCastExceptionClass_stringConstructor: TermSymbol = ClassCastExceptionClass.info.member(nme.CONSTRUCTOR).suchThat(_.info.firstParamTypes match {
case List(pt) => (pt isRef StringClass)
case _ => false
}).symbol.asTerm
@threadUnsafe lazy val ArithmeticExceptionClass: ClassSymbol = ctx.requiredClass("java.lang.ArithmeticException")
@threadUnsafe lazy val ArithmeticExceptionClass_stringConstructor: TermSymbol = ArithmeticExceptionClass.info.member(nme.CONSTRUCTOR).suchThat(_.info.firstParamTypes match {
case List(pt) => (pt isRef StringClass)
case _ => false
}).symbol.asTerm
@threadUnsafe lazy val JavaSerializableClass: ClassSymbol = ctx.requiredClass("java.io.Serializable")
@threadUnsafe lazy val ComparableClass: ClassSymbol = ctx.requiredClass("java.lang.Comparable")
@threadUnsafe lazy val SystemClass: ClassSymbol = ctx.requiredClass("java.lang.System")
@threadUnsafe lazy val SystemModule: Symbol = SystemClass.linkedClass
@threadUnsafe lazy val NoSuchElementExceptionClass = ctx.requiredClass("java.util.NoSuchElementException")
def NoSuchElementExceptionType = NoSuchElementExceptionClass.typeRef
@threadUnsafe lazy val IllegalArgumentExceptionClass = ctx.requiredClass("java.lang.IllegalArgumentException")
def IllegalArgumentExceptionType = IllegalArgumentExceptionClass.typeRef
// in scalac modified to have Any as parent
@threadUnsafe lazy val ThrowableType: TypeRef = ctx.requiredClassRef("java.lang.Throwable")
def ThrowableClass(implicit ctx: Context): ClassSymbol = ThrowableType.symbol.asClass
@threadUnsafe lazy val SerializableType: TypeRef =
if (isNewCollections)
JavaSerializableClass.typeRef
else
ctx.requiredClassRef("scala.Serializable")
@threadUnsafe lazy val JavaEnumClass: ClassSymbol = {
val cls = ctx.requiredClass("java.lang.Enum")
cls.infoOrCompleter match {
case completer: ClassfileLoader =>
cls.info = new ClassfileLoader(completer.classfile) {
override def complete(root: SymDenotation)(implicit ctx: Context): Unit = {
super.complete(root)
val constr = cls.primaryConstructor
val newInfo = constr.info match {
case info: PolyType =>
info.resType match {
case meth: MethodType =>
info.derivedLambdaType(
resType = meth.derivedLambdaType(
paramNames = Nil, paramInfos = Nil))
}
}
constr.info = newInfo
constr.termRef.recomputeDenot()
}
}
cls
}
}
def JavaEnumType = JavaEnumClass.typeRef
def SerializableClass(implicit ctx: Context): ClassSymbol = SerializableType.symbol.asClass
@threadUnsafe lazy val StringBuilderType: TypeRef = ctx.requiredClassRef("scala.collection.mutable.StringBuilder")
def StringBuilderClass(implicit ctx: Context): ClassSymbol = StringBuilderType.symbol.asClass
@threadUnsafe lazy val MatchErrorType: TypeRef = ctx.requiredClassRef("scala.MatchError")
def MatchErrorClass(implicit ctx: Context): ClassSymbol = MatchErrorType.symbol.asClass
@threadUnsafe lazy val ConversionType: TypeRef = ctx.requiredClass("scala.Conversion").typeRef
def ConversionClass(implicit ctx: Context): ClassSymbol = ConversionType.symbol.asClass
@threadUnsafe lazy val StringAddType: TypeRef = ctx.requiredClassRef("scala.runtime.StringAdd")
def StringAddClass(implicit ctx: Context): ClassSymbol = StringAddType.symbol.asClass
@threadUnsafe lazy val StringAdd_plusR: TermRef = StringAddClass.requiredMethodRef(nme.raw.PLUS)
def StringAdd_+(implicit ctx: Context): Symbol = StringAdd_plusR.symbol
@threadUnsafe lazy val StringContextType: TypeRef = ctx.requiredClassRef("scala.StringContext")
def StringContextClass(implicit ctx: Context): ClassSymbol = StringContextType.symbol.asClass
@threadUnsafe lazy val StringContextSR: TermRef = StringContextClass.requiredMethodRef(nme.s)
def StringContextS(implicit ctx: Context): Symbol = StringContextSR.symbol
@threadUnsafe lazy val StringContextRawR: TermRef = StringContextClass.requiredMethodRef(nme.raw_)
def StringContextRaw(implicit ctx: Context): Symbol = StringContextRawR.symbol
@threadUnsafe lazy val StringContext_fR: TermRef = StringContextClass.requiredMethodRef(nme.f)
def StringContext_f(implicit ctx: Context): Symbol = StringContext_fR.symbol
def StringContextModule(implicit ctx: Context): Symbol = StringContextClass.companionModule
@threadUnsafe lazy val StringContextModule_applyR: TermRef = StringContextModule.requiredMethodRef(nme.apply)
def StringContextModule_apply(implicit ctx: Context): Symbol = StringContextModule_applyR.symbol
@threadUnsafe lazy val InternalStringContextMacroModuleR: TermRef = ctx.requiredModuleRef("dotty.internal.StringContextMacro")
def InternalStringContextMacroModule(implicit ctx: Context): Symbol = InternalStringContextMacroModuleR.termSymbol
@threadUnsafe lazy val InternalStringContextMacroModule_fR: TermRef = InternalStringContextMacroModule.requiredMethodRef(nme.f)
def InternalStringContextMacroModule_f(implicit ctx: Context): Symbol = InternalStringContextMacroModule_fR.symbol
@threadUnsafe lazy val PartialFunctionType: TypeRef = ctx.requiredClassRef("scala.PartialFunction")
def PartialFunctionClass(implicit ctx: Context): ClassSymbol = PartialFunctionType.symbol.asClass
@threadUnsafe lazy val PartialFunction_isDefinedAtR: TermRef = PartialFunctionClass.requiredMethodRef(nme.isDefinedAt)
def PartialFunction_isDefinedAt(implicit ctx: Context): Symbol = PartialFunction_isDefinedAtR.symbol
@threadUnsafe lazy val PartialFunction_applyOrElseR: TermRef = PartialFunctionClass.requiredMethodRef(nme.applyOrElse)
def PartialFunction_applyOrElse(implicit ctx: Context): Symbol = PartialFunction_applyOrElseR.symbol
@threadUnsafe lazy val AbstractPartialFunctionType: TypeRef = ctx.requiredClassRef("scala.runtime.AbstractPartialFunction")
def AbstractPartialFunctionClass(implicit ctx: Context): ClassSymbol = AbstractPartialFunctionType.symbol.asClass
@threadUnsafe lazy val FunctionXXLType: TypeRef = ctx.requiredClassRef("scala.FunctionXXL")
def FunctionXXLClass(implicit ctx: Context): ClassSymbol = FunctionXXLType.symbol.asClass
@threadUnsafe lazy val ScalaSymbolType: TypeRef = ctx.requiredClassRef("scala.Symbol")
def ScalaSymbolClass(implicit ctx: Context): ClassSymbol = ScalaSymbolType.symbol.asClass
@threadUnsafe lazy val DynamicType: TypeRef = ctx.requiredClassRef("scala.Dynamic")
def DynamicClass(implicit ctx: Context): ClassSymbol = DynamicType.symbol.asClass
@threadUnsafe lazy val OptionType: TypeRef = ctx.requiredClassRef("scala.Option")
def OptionClass(implicit ctx: Context): ClassSymbol = OptionType.symbol.asClass
@threadUnsafe lazy val SomeType: TypeRef = ctx.requiredClassRef("scala.Some")
def SomeClass(implicit ctx: Context): ClassSymbol = SomeType.symbol.asClass
@threadUnsafe lazy val NoneModuleRef: TermRef = ctx.requiredModuleRef("scala.None")
def NoneClass(implicit ctx: Context): ClassSymbol = NoneModuleRef.symbol.moduleClass.asClass
@threadUnsafe lazy val EnumType: TypeRef = ctx.requiredClassRef("scala.Enum")
def EnumClass(implicit ctx: Context): ClassSymbol = EnumType.symbol.asClass
@threadUnsafe lazy val Enum_ordinalR: TermRef = EnumClass.requiredMethodRef(nme.ordinal)
def Enum_ordinal(implicit ctx: Context): Symbol = Enum_ordinalR.symbol
@threadUnsafe lazy val EnumValuesType: TypeRef = ctx.requiredClassRef("scala.runtime.EnumValues")
def EnumValuesClass(implicit ctx: Context): ClassSymbol = EnumValuesType.symbol.asClass
@threadUnsafe lazy val ProductType: TypeRef = ctx.requiredClassRef("scala.Product")
def ProductClass(implicit ctx: Context): ClassSymbol = ProductType.symbol.asClass
@threadUnsafe lazy val Product_canEqualR: TermRef = ProductClass.requiredMethodRef(nme.canEqual_)
def Product_canEqual(implicit ctx: Context): Symbol = Product_canEqualR.symbol
@threadUnsafe lazy val Product_productArityR: TermRef = ProductClass.requiredMethodRef(nme.productArity)
def Product_productArity(implicit ctx: Context): Symbol = Product_productArityR.symbol
@threadUnsafe lazy val Product_productElementR: TermRef = ProductClass.requiredMethodRef(nme.productElement)
def Product_productElement(implicit ctx: Context): Symbol = Product_productElementR.symbol
@threadUnsafe lazy val Product_productPrefixR: TermRef = ProductClass.requiredMethodRef(nme.productPrefix)
def Product_productPrefix(implicit ctx: Context): Symbol = Product_productPrefixR.symbol
@threadUnsafe lazy val IteratorType: TypeRef = ctx.requiredClassRef("scala.collection.Iterator")
def IteratorClass(implicit ctx: Context): ClassSymbol = IteratorType.symbol.asClass
def IteratorModule(implicit ctx: Context): Symbol = IteratorClass.companionModule
@threadUnsafe lazy val ModuleSerializationProxyType: TypeRef = ctx.requiredClassRef("scala.runtime.ModuleSerializationProxy")
def ModuleSerializationProxyClass(implicit ctx: Context): ClassSymbol = ModuleSerializationProxyType.symbol.asClass
@threadUnsafe lazy val ModuleSerializationProxyConstructor: TermSymbol =
ModuleSerializationProxyClass.requiredMethod(nme.CONSTRUCTOR, List(ClassType(TypeBounds.empty)))
@threadUnsafe lazy val MirrorType: TypeRef = ctx.requiredClassRef("scala.deriving.Mirror")
def MirrorClass(implicit ctx: Context): ClassSymbol = MirrorType.symbol.asClass
@threadUnsafe lazy val Mirror_ProductType: TypeRef = ctx.requiredClassRef("scala.deriving.Mirror.Product")
def Mirror_ProductClass(implicit ctx: Context): ClassSymbol = Mirror_ProductType.symbol.asClass
@threadUnsafe lazy val Mirror_Product_fromProductR: TermRef = Mirror_ProductClass.requiredMethodRef(nme.fromProduct)
def Mirror_Product_fromProduct(implicit ctx: Context): Symbol = Mirror_Product_fromProductR.symbol
@threadUnsafe lazy val Mirror_SumType: TypeRef = ctx.requiredClassRef("scala.deriving.Mirror.Sum")
def Mirror_SumClass(implicit ctx: Context): ClassSymbol = Mirror_SumType.symbol.asClass
@threadUnsafe lazy val Mirror_SingletonType: TypeRef = ctx.requiredClassRef("scala.deriving.Mirror.Singleton")
def Mirror_SingletonClass(implicit ctx: Context): ClassSymbol = Mirror_SingletonType.symbol.asClass
@threadUnsafe lazy val Mirror_SingletonProxyType: TypeRef = ctx.requiredClassRef("scala.deriving.Mirror.SingletonProxy")
def Mirror_SingletonProxyClass(implicit ctx: Context): ClassSymbol = Mirror_SingletonProxyType.symbol.asClass
@threadUnsafe lazy val LanguageModuleRef: TermSymbol = ctx.requiredModule("scala.language")
def LanguageModuleClass(implicit ctx: Context): ClassSymbol = LanguageModuleRef.moduleClass.asClass
@threadUnsafe lazy val NonLocalReturnControlType: TypeRef = ctx.requiredClassRef("scala.runtime.NonLocalReturnControl")
@threadUnsafe lazy val SelectableType: TypeRef = ctx.requiredClassRef("scala.Selectable")
@threadUnsafe lazy val ClassTagType: TypeRef = ctx.requiredClassRef("scala.reflect.ClassTag")
def ClassTagClass(implicit ctx: Context): ClassSymbol = ClassTagType.symbol.asClass
def ClassTagModule(implicit ctx: Context): Symbol = ClassTagClass.companionModule
@threadUnsafe lazy val ClassTagModule_applyR: TermRef = ClassTagModule.requiredMethodRef(nme.apply)
def ClassTagModule_apply(implicit ctx: Context): Symbol = ClassTagModule_applyR.symbol
@threadUnsafe lazy val QuotedExprType: TypeRef = ctx.requiredClassRef("scala.quoted.Expr")
def QuotedExprClass(implicit ctx: Context): ClassSymbol = QuotedExprType.symbol.asClass
def QuotedExprModule(implicit ctx: Context): Symbol = QuotedExprClass.companionModule
@threadUnsafe lazy val QuoteContextType: TypeRef = ctx.requiredClassRef("scala.quoted.QuoteContext")
def QuoteContextClass(implicit ctx: Context): ClassSymbol = QuoteContextType.symbol.asClass
@threadUnsafe lazy val QuoteContextModule: TermSymbol = ctx.requiredModule("scala.quoted.QuoteContext")
@threadUnsafe lazy val QuoteContext_macroContext: TermSymbol = QuoteContextModule.requiredMethod("macroContext")
@threadUnsafe lazy val LiftableModule: TermSymbol = ctx.requiredModule("scala.quoted.Liftable")
@threadUnsafe lazy val InternalQuotedModuleRef: TermRef = ctx.requiredModuleRef("scala.internal.Quoted")
def InternalQuotedModule: Symbol = InternalQuotedModuleRef.symbol
@threadUnsafe lazy val InternalQuoted_exprQuoteR: TermRef = InternalQuotedModule.requiredMethodRef("exprQuote")
def InternalQuoted_exprQuote(implicit ctx: Context): Symbol = InternalQuoted_exprQuoteR.symbol
@threadUnsafe lazy val InternalQuoted_exprSpliceR: TermRef = InternalQuotedModule.requiredMethodRef("exprSplice")
def InternalQuoted_exprSplice(implicit ctx: Context): Symbol = InternalQuoted_exprSpliceR.symbol
@threadUnsafe lazy val InternalQuoted_typeQuoteR: TermRef = InternalQuotedModule.requiredMethodRef("typeQuote")
def InternalQuoted_typeQuote(implicit ctx: Context): Symbol = InternalQuoted_typeQuoteR.symbol
@threadUnsafe lazy val InternalQuoted_patternHoleR: TermRef = InternalQuotedModule.requiredMethodRef("patternHole")
def InternalQuoted_patternHole(implicit ctx: Context): Symbol = InternalQuoted_patternHoleR.symbol
@threadUnsafe lazy val InternalQuoted_patternBindHoleAnnot: ClassSymbol = InternalQuotedModule.requiredClass("patternBindHole")
@threadUnsafe lazy val InternalQuoted_QuoteTypeTagAnnot: ClassSymbol = InternalQuotedModule.requiredClass("quoteTypeTag")
@threadUnsafe lazy val InternalQuotedMatcherModuleRef: TermRef = ctx.requiredModuleRef("scala.internal.quoted.Matcher")
def InternalQuotedMatcherModule(implicit ctx: Context): Symbol = InternalQuotedMatcherModuleRef.symbol
@threadUnsafe lazy val InternalQuotedMatcher_unapplyR: TermRef = InternalQuotedMatcherModule.requiredMethodRef(nme.unapply)
def InternalQuotedMatcher_unapply(implicit ctx: Context) = InternalQuotedMatcher_unapplyR.symbol
@threadUnsafe lazy val QuotedTypeType: TypeRef = ctx.requiredClassRef("scala.quoted.Type")
def QuotedTypeClass(implicit ctx: Context): ClassSymbol = QuotedTypeType.symbol.asClass
@threadUnsafe lazy val QuotedType_spliceR: TypeRef = QuotedTypeClass.requiredType(tpnme.splice).typeRef
def QuotedType_splice : Symbol = QuotedType_spliceR.symbol
@threadUnsafe lazy val QuotedTypeModuleRef: TermRef = ctx.requiredModuleRef("scala.quoted.Type")
def QuotedTypeModule(implicit ctx: Context): Symbol = QuotedTypeModuleRef.symbol
@threadUnsafe lazy val QuotedMatchingBindingType: TypeRef = ctx.requiredClassRef("scala.quoted.matching.Bind")
def QuotedMatchingBindingClass(implicit ctx: Context): ClassSymbol = QuotedMatchingBindingType.symbol.asClass
def Unpickler_unpickleExpr: TermSymbol = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleExpr")
def Unpickler_unpickleType: TermSymbol = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleType")
@threadUnsafe lazy val TastyReflectionType: TypeRef = ctx.requiredClassRef("scala.tasty.Reflection")
def TastyReflectionClass(implicit ctx: Context): ClassSymbol = TastyReflectionType.symbol.asClass
@threadUnsafe lazy val EqlType: TypeRef = ctx.requiredClassRef("scala.Eql")
def EqlClass(implicit ctx: Context): ClassSymbol = EqlType.symbol.asClass
def EqlModule(implicit ctx: Context): Symbol = EqlClass.companionModule
def Eql_eqlAny(implicit ctx: Context): TermSymbol = EqlModule.requiredMethod(nme.eqlAny)
@threadUnsafe lazy val TypeBoxType: TypeRef = ctx.requiredClassRef("scala.internal.TypeBox")
@threadUnsafe lazy val TypeBox_CAP: TypeSymbol = TypeBoxType.symbol.requiredType(tpnme.CAP)
@threadUnsafe lazy val MatchCaseType: TypeRef = ctx.requiredClassRef("scala.internal.MatchCase")
def MatchCaseClass(implicit ctx: Context): ClassSymbol = MatchCaseType.symbol.asClass
@threadUnsafe lazy val NotType: TypeRef = ctx.requiredClassRef("scala.implicits.Not")
def NotClass(implicit ctx: Context): ClassSymbol = NotType.symbol.asClass
def NotModule(implicit ctx: Context): Symbol = NotClass.companionModule
def Not_value(implicit ctx: Context): TermSymbol = NotModule.requiredMethod(nme.value)
@threadUnsafe lazy val ValueOfType: TypeRef = ctx.requiredClassRef("scala.ValueOf")
def ValueOfClass(implicit ctx: Context): ClassSymbol = ValueOfType.symbol.asClass
@threadUnsafe lazy val StatsModule = ctx.requiredModule("dotty.tools.dotc.util.Stats")
def Stats_doRecord(implicit ctx: Context): TermSymbol = StatsModule.requiredMethod("doRecord")
@threadUnsafe lazy val XMLTopScopeModuleRef: TermRef = ctx.requiredModuleRef("scala.xml.TopScope")
@threadUnsafe lazy val TupleTypeRef: TypeRef = ctx.requiredClassRef("scala.Tuple")
def TupleClass(implicit ctx: Context): ClassSymbol = TupleTypeRef.symbol.asClass
@threadUnsafe lazy val Tuple_consR: TermRef = TupleClass.requiredMethod("*:").termRef
def Tuple_cons: Symbol = Tuple_consR.symbol
@threadUnsafe lazy val NonEmptyTupleTypeRef: TypeRef = ctx.requiredClassRef("scala.NonEmptyTuple")
def NonEmptyTupleClass(implicit ctx: Context): ClassSymbol = NonEmptyTupleTypeRef.symbol.asClass
lazy val NonEmptyTuple_tailR: TermRef = NonEmptyTupleClass.requiredMethod("tail").termRef
def NonEmptyTuple_tail: Symbol = NonEmptyTuple_tailR.symbol
@threadUnsafe lazy val PairType: TypeRef = ctx.requiredClassRef("scala.*:")
def PairClass(implicit ctx: Context): ClassSymbol = PairType.symbol.asClass
@threadUnsafe lazy val TupleXXLType: TypeRef = ctx.requiredClassRef("scala.TupleXXL")
def TupleXXLClass(implicit ctx: Context): ClassSymbol = TupleXXLType.symbol.asClass
def TupleXXLModule(implicit ctx: Context): Symbol = TupleXXLClass.companionModule
def TupleXXL_apply(implicit ctx: Context): Symbol =
TupleXXLModule.info.member(nme.apply).requiredSymbol("method", nme.apply, TupleXXLModule)(_.info.isVarArgsMethod)
def TupleXXL_fromIterator(implicit ctx: Context): Symbol = TupleXXLModule.requiredMethod("fromIterator")
lazy val DynamicTupleModule: Symbol = ctx.requiredModule("scala.runtime.DynamicTuple")
lazy val DynamicTupleModuleClass: Symbol = DynamicTupleModule.moduleClass
lazy val DynamicTuple_consIterator: Symbol = DynamicTupleModule.requiredMethod("consIterator")
lazy val DynamicTuple_concatIterator: Symbol = DynamicTupleModule.requiredMethod("concatIterator")
lazy val DynamicTuple_dynamicApply: Symbol = DynamicTupleModule.requiredMethod("dynamicApply")
lazy val DynamicTuple_dynamicCons: Symbol = DynamicTupleModule.requiredMethod("dynamicCons")
lazy val DynamicTuple_dynamicSize: Symbol = DynamicTupleModule.requiredMethod("dynamicSize")
lazy val DynamicTuple_dynamicTail: Symbol = DynamicTupleModule.requiredMethod("dynamicTail")
lazy val DynamicTuple_dynamicConcat: Symbol = DynamicTupleModule.requiredMethod("dynamicConcat")
lazy val DynamicTuple_dynamicToArray: Symbol = DynamicTupleModule.requiredMethod("dynamicToArray")
lazy val DynamicTuple_productToArray: Symbol = DynamicTupleModule.requiredMethod("productToArray")
lazy val TupledFunctionTypeRef: TypeRef = ctx.requiredClassRef("scala.TupledFunction")
def TupledFunctionClass(implicit ctx: Context): ClassSymbol = TupledFunctionTypeRef.symbol.asClass
lazy val InternalTupledFunctionTypeRef: TypeRef = ctx.requiredClassRef("scala.internal.TupledFunction")
def InternalTupleFunctionClass(implicit ctx: Context): ClassSymbol = InternalTupledFunctionTypeRef.symbol.asClass
def InternalTupleFunctionModule(implicit ctx: Context): Symbol = ctx.requiredModule("scala.internal.TupledFunction")
// Annotation base classes
@threadUnsafe lazy val AnnotationType: TypeRef = ctx.requiredClassRef("scala.annotation.Annotation")
def AnnotationClass(implicit ctx: Context): ClassSymbol = AnnotationType.symbol.asClass
@threadUnsafe lazy val ClassfileAnnotationType: TypeRef = ctx.requiredClassRef("scala.annotation.ClassfileAnnotation")
def ClassfileAnnotationClass(implicit ctx: Context): ClassSymbol = ClassfileAnnotationType.symbol.asClass
@threadUnsafe lazy val StaticAnnotationType: TypeRef = ctx.requiredClassRef("scala.annotation.StaticAnnotation")
def StaticAnnotationClass(implicit ctx: Context): ClassSymbol = StaticAnnotationType.symbol.asClass
@threadUnsafe lazy val RefiningAnnotationType: TypeRef = ctx.requiredClassRef("scala.annotation.RefiningAnnotation")
def RefiningAnnotationClass(implicit ctx: Context): ClassSymbol = RefiningAnnotationType.symbol.asClass
// Annotation classes
@threadUnsafe lazy val AliasAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.Alias")
def AliasAnnot(implicit ctx: Context): ClassSymbol = AliasAnnotType.symbol.asClass
@threadUnsafe lazy val AnnotationDefaultAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.AnnotationDefault")
def AnnotationDefaultAnnot(implicit ctx: Context): ClassSymbol = AnnotationDefaultAnnotType.symbol.asClass
@threadUnsafe lazy val BodyAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.Body")
def BodyAnnot(implicit ctx: Context): ClassSymbol = BodyAnnotType.symbol.asClass
@threadUnsafe lazy val ChildAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.Child")
def ChildAnnot(implicit ctx: Context): ClassSymbol = ChildAnnotType.symbol.asClass
@threadUnsafe lazy val WithBoundsAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.WithBounds")
def WithBoundsAnnot(implicit ctx: Context): ClassSymbol = WithBoundsAnnotType.symbol.asClass
@threadUnsafe lazy val CovariantBetweenAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.CovariantBetween")
def CovariantBetweenAnnot(implicit ctx: Context): ClassSymbol = CovariantBetweenAnnotType.symbol.asClass
@threadUnsafe lazy val ContravariantBetweenAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.ContravariantBetween")
def ContravariantBetweenAnnot(implicit ctx: Context): ClassSymbol = ContravariantBetweenAnnotType.symbol.asClass
@threadUnsafe lazy val DeprecatedAnnotType: TypeRef = ctx.requiredClassRef("scala.deprecated")
def DeprecatedAnnot(implicit ctx: Context): ClassSymbol = DeprecatedAnnotType.symbol.asClass
@threadUnsafe lazy val ImplicitAmbiguousAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.implicitAmbiguous")
def ImplicitAmbiguousAnnot(implicit ctx: Context): ClassSymbol = ImplicitAmbiguousAnnotType.symbol.asClass
@threadUnsafe lazy val ImplicitNotFoundAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.implicitNotFound")
def ImplicitNotFoundAnnot(implicit ctx: Context): ClassSymbol = ImplicitNotFoundAnnotType.symbol.asClass
@threadUnsafe lazy val ForceInlineAnnotType: TypeRef = ctx.requiredClassRef("scala.forceInline")
def ForceInlineAnnot(implicit ctx: Context): ClassSymbol = ForceInlineAnnotType.symbol.asClass
@threadUnsafe lazy val InlineParamAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.InlineParam")
def InlineParamAnnot(implicit ctx: Context): ClassSymbol = InlineParamAnnotType.symbol.asClass
@threadUnsafe lazy val InvariantBetweenAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.InvariantBetween")
def InvariantBetweenAnnot(implicit ctx: Context): ClassSymbol = InvariantBetweenAnnotType.symbol.asClass
@threadUnsafe lazy val MigrationAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.migration")
def MigrationAnnot(implicit ctx: Context): ClassSymbol = MigrationAnnotType.symbol.asClass
@threadUnsafe lazy val NativeAnnotType: TypeRef = ctx.requiredClassRef("scala.native")
def NativeAnnot(implicit ctx: Context): ClassSymbol = NativeAnnotType.symbol.asClass
@threadUnsafe lazy val RepeatedAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.Repeated")
def RepeatedAnnot(implicit ctx: Context): ClassSymbol = RepeatedAnnotType.symbol.asClass
@threadUnsafe lazy val SourceFileAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.SourceFile")
def SourceFileAnnot(implicit ctx: Context): ClassSymbol = SourceFileAnnotType.symbol.asClass
@threadUnsafe lazy val ScalaSignatureAnnotType: TypeRef = ctx.requiredClassRef("scala.reflect.ScalaSignature")
def ScalaSignatureAnnot(implicit ctx: Context): ClassSymbol = ScalaSignatureAnnotType.symbol.asClass
@threadUnsafe lazy val ScalaLongSignatureAnnotType: TypeRef = ctx.requiredClassRef("scala.reflect.ScalaLongSignature")
def ScalaLongSignatureAnnot(implicit ctx: Context): ClassSymbol = ScalaLongSignatureAnnotType.symbol.asClass
@threadUnsafe lazy val ScalaStrictFPAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.strictfp")
def ScalaStrictFPAnnot(implicit ctx: Context): ClassSymbol = ScalaStrictFPAnnotType.symbol.asClass
@threadUnsafe lazy val ScalaStaticAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.static")
def ScalaStaticAnnot(implicit ctx: Context): ClassSymbol = ScalaStaticAnnotType.symbol.asClass
@threadUnsafe lazy val SerialVersionUIDAnnotType: TypeRef = ctx.requiredClassRef("scala.SerialVersionUID")
def SerialVersionUIDAnnot(implicit ctx: Context): ClassSymbol = SerialVersionUIDAnnotType.symbol.asClass
@threadUnsafe lazy val TASTYSignatureAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.TASTYSignature")
def TASTYSignatureAnnot(implicit ctx: Context): ClassSymbol = TASTYSignatureAnnotType.symbol.asClass
@threadUnsafe lazy val TASTYLongSignatureAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.TASTYLongSignature")
def TASTYLongSignatureAnnot(implicit ctx: Context): ClassSymbol = TASTYLongSignatureAnnotType.symbol.asClass
@threadUnsafe lazy val TailrecAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.tailrec")
def TailrecAnnot(implicit ctx: Context): ClassSymbol = TailrecAnnotType.symbol.asClass
@threadUnsafe lazy val ThreadUnsafeAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.threadUnsafe")
def ThreadUnsafeAnnot(implicit ctx: Context): ClassSymbol = ThreadUnsafeAnnotType.symbol.asClass
@threadUnsafe lazy val TransientParamAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.constructorOnly")
def TransientParamAnnot(implicit ctx: Context): ClassSymbol = TransientParamAnnotType.symbol.asClass
@threadUnsafe lazy val CompileTimeOnlyAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.compileTimeOnly")
def CompileTimeOnlyAnnot(implicit ctx: Context): ClassSymbol = CompileTimeOnlyAnnotType.symbol.asClass
@threadUnsafe lazy val SwitchAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.switch")
def SwitchAnnot(implicit ctx: Context): ClassSymbol = SwitchAnnotType.symbol.asClass
@threadUnsafe lazy val ThrowsAnnotType: TypeRef = ctx.requiredClassRef("scala.throws")
def ThrowsAnnot(implicit ctx: Context): ClassSymbol = ThrowsAnnotType.symbol.asClass
@threadUnsafe lazy val TransientAnnotType: TypeRef = ctx.requiredClassRef("scala.transient")
def TransientAnnot(implicit ctx: Context): ClassSymbol = TransientAnnotType.symbol.asClass
@threadUnsafe lazy val UncheckedAnnotType: TypeRef = ctx.requiredClassRef("scala.unchecked")
def UncheckedAnnot(implicit ctx: Context): ClassSymbol = UncheckedAnnotType.symbol.asClass
@threadUnsafe lazy val UncheckedStableAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.unchecked.uncheckedStable")
def UncheckedStableAnnot(implicit ctx: Context): ClassSymbol = UncheckedStableAnnotType.symbol.asClass
@threadUnsafe lazy val UncheckedVarianceAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.unchecked.uncheckedVariance")
def UncheckedVarianceAnnot(implicit ctx: Context): ClassSymbol = UncheckedVarianceAnnotType.symbol.asClass
@threadUnsafe lazy val VolatileAnnotType: TypeRef = ctx.requiredClassRef("scala.volatile")
def VolatileAnnot(implicit ctx: Context): ClassSymbol = VolatileAnnotType.symbol.asClass
@threadUnsafe lazy val FieldMetaAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.meta.field")
def FieldMetaAnnot(implicit ctx: Context): ClassSymbol = FieldMetaAnnotType.symbol.asClass
@threadUnsafe lazy val GetterMetaAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.meta.getter")
def GetterMetaAnnot(implicit ctx: Context): ClassSymbol = GetterMetaAnnotType.symbol.asClass
@threadUnsafe lazy val SetterMetaAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.meta.setter")
def SetterMetaAnnot(implicit ctx: Context): ClassSymbol = SetterMetaAnnotType.symbol.asClass
@threadUnsafe lazy val ShowAsInfixAnotType: TypeRef = ctx.requiredClassRef("scala.annotation.showAsInfix")
def ShowAsInfixAnnot(implicit ctx: Context): ClassSymbol = ShowAsInfixAnotType.symbol.asClass
@threadUnsafe lazy val FunctionalInterfaceAnnotType = ctx.requiredClassRef("java.lang.FunctionalInterface")
def FunctionalInterfaceAnnot(implicit ctx: Context) = FunctionalInterfaceAnnotType.symbol.asClass
@threadUnsafe lazy val InfixAnnotType = ctx.requiredClassRef("scala.annotation.infix")
def InfixAnnot(implicit ctx: Context) = InfixAnnotType.symbol.asClass
@threadUnsafe lazy val AlphaAnnotType = ctx.requiredClassRef("scala.annotation.alpha")
def AlphaAnnot(implicit ctx: Context) = AlphaAnnotType.symbol.asClass
// convenient one-parameter method types
def methOfAny(tp: Type): MethodType = MethodType(List(AnyType), tp)
def methOfAnyVal(tp: Type): MethodType = MethodType(List(AnyValType), tp)
def methOfAnyRef(tp: Type): MethodType = MethodType(List(ObjectType), tp)
// Derived types
def RepeatedParamType: TypeRef = RepeatedParamClass.typeRef
def ClassType(arg: Type)(implicit ctx: Context): Type = {
val ctype = ClassClass.typeRef
if (ctx.phase.erasedTypes) ctype else ctype.appliedTo(arg)
}
/** The enumeration type, goven a value of the enumeration */
def EnumType(sym: Symbol)(implicit ctx: Context): TypeRef =
// given (in java): "class A { enum E { VAL1 } }"
// - sym: the symbol of the actual enumeration value (VAL1)
// - .owner: the ModuleClassSymbol of the enumeration (object E)
// - .linkedClass: the ClassSymbol of the enumeration (class E)
sym.owner.linkedClass.typeRef
object FunctionOf {
def apply(args: List[Type], resultType: Type, isContextual: Boolean = false, isErased: Boolean = false)(implicit ctx: Context): Type =
FunctionType(args.length, isContextual, isErased).appliedTo(args ::: resultType :: Nil)
def unapply(ft: Type)(implicit ctx: Context): Option[(List[Type], Type, Boolean, Boolean)] = {
val tsym = ft.typeSymbol
if (isFunctionClass(tsym)) {
val targs = ft.dealias.argInfos
if (targs.isEmpty) None
else Some(targs.init, targs.last, tsym.name.isImplicitFunction, tsym.name.isErasedFunction)
}
else None
}
}
object PartialFunctionOf {
def apply(arg: Type, result: Type)(implicit ctx: Context): Type =
PartialFunctionType.appliedTo(arg :: result :: Nil)
def unapply(pft: Type)(implicit ctx: Context): Option[(Type, List[Type])] = {
if (pft.isRef(PartialFunctionClass)) {
val targs = pft.dealias.argInfos
if (targs.length == 2) Some((targs.head, targs.tail)) else None
}
else None
}
}
object ArrayOf {
def apply(elem: Type)(implicit ctx: Context): Type =
if (ctx.erasedTypes) JavaArrayType(elem)
else ArrayType.appliedTo(elem :: Nil)
def unapply(tp: Type)(implicit ctx: Context): Option[Type] = tp.dealias match {
case AppliedType(at, arg :: Nil) if at isRef ArrayType.symbol => Some(arg)
case _ => None
}
}
object MatchCase {
def apply(pat: Type, body: Type)(implicit ctx: Context): Type =
MatchCaseType.appliedTo(pat, body)
def unapply(tp: Type)(implicit ctx: Context): Option[(Type, Type)] = tp match {
case AppliedType(tycon, pat :: body :: Nil) if tycon.isRef(MatchCaseClass) =>
Some((pat, body))
case _ =>
None
}
def isInstance(tp: Type)(implicit ctx: Context): Boolean = tp match {
case AppliedType(tycon: TypeRef, _) =>
tycon.name == tpnme.MatchCase && // necessary pre-filter to avoid forcing symbols
tycon.isRef(MatchCaseClass)
case _ => false
}
}
/** An extractor for multi-dimensional arrays.
* Note that this will also extract the high bound if an
* element type is a wildcard. E.g.
*
* Array[_ <: Array[_ <: Number]]
*
* would match
*
* MultiArrayOf(, 2)
*/
object MultiArrayOf {
def apply(elem: Type, ndims: Int)(implicit ctx: Context): Type =
if (ndims == 0) elem else ArrayOf(apply(elem, ndims - 1))
def unapply(tp: Type)(implicit ctx: Context): Option[(Type, Int)] = tp match {
case ArrayOf(elemtp) =>
def recur(elemtp: Type): Option[(Type, Int)] = elemtp.dealias match {
case TypeBounds(lo, hi) => recur(hi)
case MultiArrayOf(finalElemTp, n) => Some(finalElemTp, n + 1)
case _ => Some(elemtp, 1)
}
recur(elemtp)
case _ =>
None
}
}
final def isCompiletime_S(sym: Symbol)(implicit ctx: Context): Boolean =
sym.name == tpnme.S && sym.owner == CompiletimePackageObject
// ----- Symbol sets ---------------------------------------------------
@threadUnsafe lazy val AbstractFunctionType: Array[TypeRef] = mkArityArray("scala.runtime.AbstractFunction", MaxImplementedFunctionArity, 0)
val AbstractFunctionClassPerRun: PerRun[Array[Symbol]] = new PerRun(implicit ctx => AbstractFunctionType.map(_.symbol.asClass))
def AbstractFunctionClass(n: Int)(implicit ctx: Context): Symbol = AbstractFunctionClassPerRun()(ctx)(n)
@threadUnsafe private lazy val ImplementedFunctionType = mkArityArray("scala.Function", MaxImplementedFunctionArity, 0)
def FunctionClassPerRun: PerRun[Array[Symbol]] = new PerRun(implicit ctx => ImplementedFunctionType.map(_.symbol.asClass))
val LazyHolder: PerRun[Map[Symbol, Symbol]] = new PerRun({ implicit ctx =>
def holderImpl(holderType: String) = ctx.requiredClass("scala.runtime." + holderType)
Map[Symbol, Symbol](
IntClass -> holderImpl("LazyInt"),
LongClass -> holderImpl("LazyLong"),
BooleanClass -> holderImpl("LazyBoolean"),
FloatClass -> holderImpl("LazyFloat"),
DoubleClass -> holderImpl("LazyDouble"),
ByteClass -> holderImpl("LazyByte"),
CharClass -> holderImpl("LazyChar"),
ShortClass -> holderImpl("LazyShort")
)
.withDefaultValue(holderImpl("LazyRef"))
})
@threadUnsafe lazy val TupleType: Array[TypeRef] = mkArityArray("scala.Tuple", MaxTupleArity, 1)
def FunctionClass(n: Int, isContextual: Boolean = false, isErased: Boolean = false)(implicit ctx: Context): Symbol =
if (isContextual && isErased)
ctx.requiredClass("scala.ErasedImplicitFunction" + n.toString)
else if (isContextual)
ctx.requiredClass("scala.ImplicitFunction" + n.toString)
else if (isErased)
ctx.requiredClass("scala.ErasedFunction" + n.toString)
else if (n <= MaxImplementedFunctionArity)
FunctionClassPerRun()(ctx)(n)
else
ctx.requiredClass("scala.Function" + n.toString)
@threadUnsafe lazy val Function0_applyR: TermRef = ImplementedFunctionType(0).symbol.requiredMethodRef(nme.apply)
def Function0_apply(implicit ctx: Context): Symbol = Function0_applyR.symbol
def FunctionType(n: Int, isContextual: Boolean = false, isErased: Boolean = false)(implicit ctx: Context): TypeRef =
if (n <= MaxImplementedFunctionArity && (!isContextual || ctx.erasedTypes) && !isErased) ImplementedFunctionType(n)
else FunctionClass(n, isContextual, isErased).typeRef
lazy val PolyFunctionClass = ctx.requiredClass("scala.PolyFunction")
def PolyFunctionType = PolyFunctionClass.typeRef
/** If `cls` is a class in the scala package, its name, otherwise EmptyTypeName */
def scalaClassName(cls: Symbol)(implicit ctx: Context): TypeName =
if (cls.isClass && cls.owner == ScalaPackageClass) cls.asClass.name else EmptyTypeName
/** If type `ref` refers to a class in the scala package, its name, otherwise EmptyTypeName */
def scalaClassName(ref: Type)(implicit ctx: Context): TypeName = scalaClassName(ref.classSymbol)
private def isVarArityClass(cls: Symbol, prefix: String) =
cls.isClass && cls.owner.eq(ScalaPackageClass) &&
cls.name.testSimple(name =>
name.startsWith(prefix) &&
name.length > prefix.length &&
name.drop(prefix.length).forall(_.isDigit))
def isBottomClass(cls: Symbol): Boolean =
cls == NothingClass || cls == NullClass
def isBottomType(tp: Type): Boolean =
tp.derivesFrom(NothingClass) || tp.derivesFrom(NullClass)
/** Is a function class.
* - FunctionXXL
* - FunctionN for N >= 0
* - ImplicitFunctionN for N >= 0
* - ErasedFunctionN for N > 0
* - ErasedImplicitFunctionN for N > 0
*/
def isFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isFunction
/** Is an implicit function class.
* - ImplicitFunctionN for N >= 0
* - ErasedImplicitFunctionN for N > 0
*/
def isImplicitFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isImplicitFunction
/** Is an erased function class.
* - ErasedFunctionN for N > 0
* - ErasedImplicitFunctionN for N > 0
*/
def isErasedFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isErasedFunction
/** Is either FunctionXXL or a class that will be erased to FunctionXXL
* - FunctionXXL
* - FunctionN for N >= 22
* - ImplicitFunctionN for N >= 22
*/
def isXXLFunctionClass(cls: Symbol): Boolean = {
val name = scalaClassName(cls)
(name eq tpnme.FunctionXXL) || name.functionArity > MaxImplementedFunctionArity
}
/** Is a synthetic function class
* - FunctionN for N > 22
* - ImplicitFunctionN for N >= 0
* - ErasedFunctionN for N > 0
* - ErasedImplicitFunctionN for N > 0
*/
def isSyntheticFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isSyntheticFunction
def isAbstractFunctionClass(cls: Symbol): Boolean = isVarArityClass(cls, str.AbstractFunction)
def isTupleClass(cls: Symbol): Boolean = isVarArityClass(cls, str.Tuple)
def isProductClass(cls: Symbol): Boolean = isVarArityClass(cls, str.Product)
def isScalaShadowingPackageClass(cls: Symbol): Boolean =
cls.name == tpnme.scalaShadowing && cls.owner == RootClass
/** Returns the erased class of the function class `cls`
* - FunctionN for N > 22 becomes FunctionXXL
* - FunctionN for 22 > N >= 0 remains as FunctionN
* - ImplicitFunctionN for N > 22 becomes FunctionXXL
* - ImplicitFunctionN for N <= 22 becomes FunctionN
* - ErasedFunctionN becomes Function0
* - ImplicitErasedFunctionN becomes Function0
* - anything else becomes a NoSymbol
*/
def erasedFunctionClass(cls: Symbol): Symbol = {
val arity = scalaClassName(cls).functionArity
if (cls.name.isErasedFunction) FunctionClass(0)
else if (arity > 22) FunctionXXLClass
else if (arity >= 0) FunctionClass(arity)
else NoSymbol
}
/** Returns the erased type of the function class `cls`
* - FunctionN for N > 22 becomes FunctionXXL
* - FunctionN for 22 > N >= 0 remains as FunctionN
* - ImplicitFunctionN for N > 22 becomes FunctionXXL
* - ImplicitFunctionN for N <= 22 becomes FunctionN
* - ErasedFunctionN becomes Function0
* - ImplicitErasedFunctionN becomes Function0
* - anything else becomes a NoType
*/
def erasedFunctionType(cls: Symbol): Type = {
val arity = scalaClassName(cls).functionArity
if (cls.name.isErasedFunction) FunctionType(0)
else if (arity > 22) FunctionXXLType
else if (arity >= 0) FunctionType(arity)
else NoType
}
val predefClassNames: Set[Name] =
Set("Predef$", "DeprecatedPredef", "LowPriorityImplicits").map(_.toTypeName.unmangleClassName)
/** Is `cls` the predef module class, or a class inherited by Predef? */
def isPredefClass(cls: Symbol): Boolean =
(cls.owner eq ScalaPackageClass) && predefClassNames.contains(cls.name)
val StaticRootImportFns: List[() => TermRef] = List[() => TermRef](
() => JavaLangPackageVal.termRef,
() => ScalaPackageVal.termRef
)
val PredefImportFns: List[() => TermRef] = List[() => TermRef](
() => ScalaPredefModuleRef,
() => DottyPredefModuleRef
)
@threadUnsafe lazy val RootImportFns: List[() => TermRef] =
if (ctx.settings.YnoImports.value) List.empty[() => TermRef]
else if (ctx.settings.YnoPredef.value) StaticRootImportFns
else StaticRootImportFns ++ PredefImportFns
@threadUnsafe lazy val ShadowableImportNames: Set[TermName] = Set("Predef", "DottyPredef").map(_.toTermName)
@threadUnsafe lazy val RootImportTypes: List[TermRef] = RootImportFns.map(_())
/** Modules whose members are in the default namespace and their module classes */
@threadUnsafe lazy val UnqualifiedOwnerTypes: Set[NamedType] =
RootImportTypes.toSet[NamedType] ++ RootImportTypes.map(_.symbol.moduleClass.typeRef)
@threadUnsafe lazy val NotRuntimeClasses: Set[Symbol] = Set(AnyClass, AnyValClass, NullClass, NothingClass)
/** Classes that are known not to have an initializer irrespective of
* whether NoInits is set. Note: FunctionXXLClass is in this set
* because if it is compiled by Scala2, it does not get a NoInit flag.
* But since it is introduced only at erasure, there's no chance
* for augmentScala2Traits to do anything on a class that inherits it. So
* it also misses an implementation class, which means that the usual scheme
* of calling a superclass init in the implementation class of a Scala2
* trait gets screwed up. Therefore, it is mandatory that FunctionXXL
* is treated as a NoInit trait.
*/
@threadUnsafe lazy val NoInitClasses: Set[Symbol] = NotRuntimeClasses + FunctionXXLClass
def isPolymorphicAfterErasure(sym: Symbol): Boolean =
(sym eq Any_isInstanceOf) || (sym eq Any_asInstanceOf) || (sym eq Object_synchronized)
def isTupleType(tp: Type)(implicit ctx: Context): Boolean = {
val arity = tp.dealias.argInfos.length
arity <= MaxTupleArity && TupleType(arity) != null && (tp isRef TupleType(arity).symbol)
}
def tupleType(elems: List[Type]): Type = {
val arity = elems.length
if (0 < arity && arity <= MaxTupleArity && TupleType(arity) != null) TupleType(arity).appliedTo(elems)
else TypeOps.nestedPairs(elems)
}
def tupleTypes(tp: Type, bound: Int = Int.MaxValue)(implicit ctx: Context): Option[List[Type]] = {
@tailrec def rec(tp: Type, acc: List[Type], bound: Int): Option[List[Type]] = tp.normalized match {
case _ if bound < 0 => Some(acc.reverse)
case tp: AppliedType if defn.PairClass == tp.classSymbol => rec(tp.args(1), tp.args.head :: acc, bound - 1)
case tp: AppliedType if defn.isTupleClass(tp.tycon.classSymbol) => Some(acc.reverse ::: tp.args)
case tp if tp.classSymbol == defn.UnitClass => Some(acc.reverse)
case _ => None
}
rec(tp.stripTypeVar, Nil, bound)
}
def isProductSubType(tp: Type)(implicit ctx: Context): Boolean =
tp.derivesFrom(ProductType.symbol)
/** Is `tp` (an alias) of either a scala.FunctionN or a scala.ImplicitFunctionN
* instance?
*/
def isNonRefinedFunction(tp: Type)(implicit ctx: Context): Boolean = {
val arity = functionArity(tp)
val sym = tp.dealias.typeSymbol
arity >= 0 &&
isFunctionClass(sym) &&
tp.isRef(FunctionType(arity, sym.name.isImplicitFunction, sym.name.isErasedFunction).typeSymbol) &&
!tp.isInstanceOf[RefinedType]
}
/** Is `tp` a representation of a (possibly depenent) function type or an alias of such? */
def isFunctionType(tp: Type)(implicit ctx: Context): Boolean =
isNonRefinedFunction(tp.dropDependentRefinement)
// Specialized type parameters defined for scala.Function{0,1,2}.
@threadUnsafe lazy val Function1SpecializedParamTypes: collection.Set[TypeRef] =
Set(IntType, LongType, FloatType, DoubleType)
@threadUnsafe lazy val Function2SpecializedParamTypes: collection.Set[TypeRef] =
Set(IntType, LongType, DoubleType)
@threadUnsafe lazy val Function0SpecializedReturnTypes: collection.Set[TypeRef] =
ScalaNumericValueTypeList.toSet + UnitType + BooleanType
@threadUnsafe lazy val Function1SpecializedReturnTypes: collection.Set[TypeRef] =
Set(UnitType, BooleanType, IntType, FloatType, LongType, DoubleType)
@threadUnsafe lazy val Function2SpecializedReturnTypes: collection.Set[TypeRef] =
Function1SpecializedReturnTypes
@threadUnsafe lazy val Function1SpecializedParamClasses: PerRun[collection.Set[Symbol]] =
new PerRun(implicit ctx => Function1SpecializedParamTypes.map(_.symbol))
@threadUnsafe lazy val Function2SpecializedParamClasses: PerRun[collection.Set[Symbol]] =
new PerRun(implicit ctx => Function2SpecializedParamTypes.map(_.symbol))
@threadUnsafe lazy val Function0SpecializedReturnClasses: PerRun[collection.Set[Symbol]] =
new PerRun(implicit ctx => Function0SpecializedReturnTypes.map(_.symbol))
@threadUnsafe lazy val Function1SpecializedReturnClasses: PerRun[collection.Set[Symbol]] =
new PerRun(implicit ctx => Function1SpecializedReturnTypes.map(_.symbol))
@threadUnsafe lazy val Function2SpecializedReturnClasses: PerRun[collection.Set[Symbol]] =
new PerRun(implicit ctx => Function2SpecializedReturnTypes.map(_.symbol))
def isSpecializableFunction(cls: ClassSymbol, paramTypes: List[Type], retType: Type)(implicit ctx: Context): Boolean =
paramTypes.length <= 2 && cls.derivesFrom(FunctionClass(paramTypes.length)) && (paramTypes match {
case Nil =>
Function0SpecializedReturnClasses().contains(retType.typeSymbol)
case List(paramType0) =>
Function1SpecializedParamClasses().contains(paramType0.typeSymbol) &&
Function1SpecializedReturnClasses().contains(retType.typeSymbol)
case List(paramType0, paramType1) =>
Function2SpecializedParamClasses().contains(paramType0.typeSymbol) &&
Function2SpecializedParamClasses().contains(paramType1.typeSymbol) &&
Function2SpecializedReturnClasses().contains(retType.typeSymbol)
case _ =>
false
})
def functionArity(tp: Type)(implicit ctx: Context): Int = tp.dropDependentRefinement.dealias.argInfos.length - 1
/** Return underlying immplicit function type (i.e. instance of an ImplicitFunctionN class)
* or NoType if none exists. The following types are considered as underlying types:
* - the alias of an alias type
* - the instance or origin of a TypeVar (i.e. the result of a stripTypeVar)
* - the upper bound of a TypeParamRef in the current constraint
*/
def asImplicitFunctionType(tp: Type)(implicit ctx: Context): Type =
tp.stripTypeVar.dealias match {
case tp1: TypeParamRef if ctx.typerState.constraint.contains(tp1) =>
asImplicitFunctionType(ctx.typeComparer.bounds(tp1).hiBound)
case tp1 =>
if (isFunctionType(tp1) && tp1.typeSymbol.name.isImplicitFunction) tp1
else NoType
}
/** Is `tp` an implicit function type? */
def isImplicitFunctionType(tp: Type)(implicit ctx: Context): Boolean =
asImplicitFunctionType(tp).exists
def isErasedFunctionType(tp: Type)(implicit ctx: Context): Boolean =
isFunctionType(tp) && tp.dealias.typeSymbol.name.isErasedFunction
/** A whitelist of Scala-2 classes that are known to be pure */
def isAssuredNoInits(sym: Symbol): Boolean =
(sym `eq` SomeClass) || isTupleClass(sym)
/** If `cls` is Tuple1..Tuple22, add the corresponding *: type as last parent to `parents` */
def adjustForTuple(cls: ClassSymbol, tparams: List[TypeSymbol], parents: List[Type]): List[Type] = {
def syntheticParent(tparams: List[TypeSymbol]): Type =
if (tparams.isEmpty) TupleTypeRef
else TypeOps.nestedPairs(tparams.map(_.typeRef))
if (isTupleClass(cls) || cls == UnitClass) parents :+ syntheticParent(tparams)
else parents
}
/** Is synthesized symbol with alphanumeric name allowed to be used as an infix operator? */
def isInfix(sym: Symbol)(implicit ctx: Context): Boolean =
(sym eq Object_eq) || (sym eq Object_ne)
// ----- primitive value class machinery ------------------------------------------
/** This class would also be obviated by the implicit function type design */
class PerRun[T](generate: Context => T) {
private[this] var current: RunId = NoRunId
private[this] var cached: T = _
def apply()(implicit ctx: Context): T = {
if (current != ctx.runId) {
cached = generate(ctx)
current = ctx.runId
}
cached
}
}
@threadUnsafe lazy val ScalaNumericValueTypeList: List[TypeRef] = List(
ByteType, ShortType, CharType, IntType, LongType, FloatType, DoubleType)
@threadUnsafe private lazy val ScalaNumericValueTypes: collection.Set[TypeRef] = ScalaNumericValueTypeList.toSet
@threadUnsafe private lazy val ScalaValueTypes: collection.Set[TypeRef] = ScalaNumericValueTypes + UnitType + BooleanType
val ScalaNumericValueClasses: PerRun[collection.Set[Symbol]] = new PerRun(implicit ctx => ScalaNumericValueTypes.map(_.symbol))
val ScalaValueClasses: PerRun[collection.Set[Symbol]] = new PerRun(implicit ctx => ScalaValueTypes.map(_.symbol))
val ScalaBoxedClasses: PerRun[collection.Set[Symbol]] = new PerRun(implicit ctx =>
Set(BoxedByteClass, BoxedShortClass, BoxedCharClass, BoxedIntClass, BoxedLongClass, BoxedFloatClass, BoxedDoubleClass, BoxedUnitClass, BoxedBooleanClass)
)
private val valueTypeEnc = mutable.Map[TypeName, PrimitiveClassEnc]()
private val typeTags = mutable.Map[TypeName, Name]().withDefaultValue(nme.specializedTypeNames.Object)
// private val unboxedTypeRef = mutable.Map[TypeName, TypeRef]()
// private val javaTypeToValueTypeRef = mutable.Map[Class[_], TypeRef]()
// private val valueTypeNamesToJavaType = mutable.Map[TypeName, Class[_]]()
private def valueTypeRef(name: String, jtype: Class[_], enc: Int, tag: Name): TypeRef = {
val vcls = ctx.requiredClassRef(name)
valueTypeEnc(vcls.name) = enc
typeTags(vcls.name) = tag
// unboxedTypeRef(boxed.name) = vcls
// javaTypeToValueTypeRef(jtype) = vcls
// valueTypeNamesToJavaType(vcls.name) = jtype
vcls
}
/** The type of the boxed class corresponding to primitive value type `tp`. */
def boxedType(tp: Type)(implicit ctx: Context): TypeRef = {
val cls = tp.classSymbol
if (cls eq ByteClass) BoxedByteType
else if (cls eq ShortClass) BoxedShortType
else if (cls eq CharClass) BoxedCharType
else if (cls eq IntClass) BoxedIntType
else if (cls eq LongClass) BoxedLongType
else if (cls eq FloatClass) BoxedFloatType
else if (cls eq DoubleClass) BoxedDoubleType
else if (cls eq UnitClass) BoxedUnitType
else if (cls eq BooleanClass) BoxedBooleanType
else sys.error(s"Not a primitive value type: $tp")
}
/** The JVM tag for `tp` if it's a primitive, `java.lang.Object` otherwise. */
def typeTag(tp: Type)(implicit ctx: Context): Name = typeTags(scalaClassName(tp))
// /** The `Class[_]` of a primitive value type name */
// def valueTypeNameToJavaType(name: TypeName)(implicit ctx: Context): Option[Class[_]] =
// valueTypeNamesToJavaType.get(if (name.firstPart eq nme.scala_) name.lastPart.toTypeName else name)
type PrimitiveClassEnc = Int
val ByteEnc: Int = 2
val ShortEnc: Int = ByteEnc * 3
val CharEnc: Int = 5
val IntEnc: Int = ShortEnc * CharEnc
val LongEnc: Int = IntEnc * 7
val FloatEnc: Int = LongEnc * 11
val DoubleEnc: Int = FloatEnc * 13
val BooleanEnc: Int = 17
val UnitEnc: Int = 19
def isValueSubType(tref1: TypeRef, tref2: TypeRef)(implicit ctx: Context): Boolean =
valueTypeEnc(tref2.name) % valueTypeEnc(tref1.name) == 0
def isValueSubClass(sym1: Symbol, sym2: Symbol): Boolean =
valueTypeEnc(sym2.asClass.name) % valueTypeEnc(sym1.asClass.name) == 0
@threadUnsafe lazy val specialErasure: SimpleIdentityMap[Symbol, ClassSymbol] =
SimpleIdentityMap.Empty[Symbol]
.updated(AnyClass, ObjectClass)
.updated(AnyValClass, ObjectClass)
.updated(SingletonClass, ObjectClass)
.updated(TupleClass, ObjectClass)
.updated(NonEmptyTupleClass, ProductClass)
// ----- Initialization ---------------------------------------------------
/** Lists core classes that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe */
@threadUnsafe lazy val syntheticScalaClasses: List[TypeSymbol] = List(
AnyClass,
AnyRefAlias,
AnyKindClass,
andType,
orType,
RepeatedParamClass,
ByNameParamClass2x,
AnyValClass,
NullClass,
NothingClass,
SingletonClass)
@threadUnsafe lazy val syntheticCoreClasses: List[Symbol] = syntheticScalaClasses ++ List(
EmptyPackageVal,
OpsPackageClass)
/** Lists core methods that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe */
@threadUnsafe lazy val syntheticCoreMethods: List[TermSymbol] =
AnyMethods ++ ObjectMethods ++ List(String_+, throwMethod)
@threadUnsafe lazy val reservedScalaClassNames: Set[Name] = syntheticScalaClasses.map(_.name).toSet
private[this] var isInitialized = false
def init()(implicit ctx: Context): Unit = {
this.ctx = ctx
if (!isInitialized) {
// Enter all symbols from the scalaShadowing package in the scala package
for (m <- ScalaShadowingPackageClass.info.decls)
ScalaPackageClass.enter(m)
// force initialization of every symbol that is synthesized or hijacked by the compiler
val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses() :+ JavaEnumClass
isInitialized = true
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy