aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Definitions.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core/Definitions.scala')
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala544
1 files changed, 336 insertions, 208 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 6f322904e..fc025380d 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -82,9 +82,9 @@ class Definitions {
private def newT1EmptyParamsMethod(cls: ClassSymbol, name: TermName, resultTypeFn: PolyType => Type, flags: FlagSet) =
newPolyMethod(cls, name, 1, pt => MethodType(Nil, resultTypeFn(pt)), flags)
- private def mkArityArray(name: String, arity: Int, countFrom: Int): Array[ClassSymbol] = {
- val arr = new Array[ClassSymbol](arity + 1)
- for (i <- countFrom to arity) arr(i) = ctx.requiredClass(name + i)
+ 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
}
@@ -114,7 +114,8 @@ class Definitions {
lazy val JavaLangPackageVal = ctx.requiredPackage("java.lang")
// fundamental modules
lazy val SysPackage = ctx.requiredModule("scala.sys.package")
- def Sys_error = ctx.requiredMethod(SysPackage.moduleClass.asClass, nme.error)
+ lazy val Sys_errorR = ctx.requiredMethodRef(SysPackage.moduleClass.typeRef, nme.error)
+ def Sys_error = Sys_errorR.symbol
/** 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
@@ -160,6 +161,7 @@ class Definitions {
cls.info = ClassInfo(cls.owner.thisType, cls, AnyClass.typeRef :: Nil, newScope)
completeClass(cls)
}
+
lazy val AnyRefAlias: TypeSymbol = newAliasType(tpnme.AnyRef, ObjectType)
lazy val Object_eq = newMethod(ObjectClass, nme.eq, methOfAnyRef(BooleanType), Final)
@@ -190,29 +192,41 @@ class Definitions {
ScalaPackageClass, tpnme.Nothing, AbstractFinal, List(AnyClass.typeRef))
lazy val NullClass: ClassSymbol = newCompleteClassSymbol(
ScalaPackageClass, tpnme.Null, AbstractFinal, List(ObjectClass.typeRef))
+ lazy val NullTypeRef = NullClass.typeRef
- lazy val ScalaPredefModule = ctx.requiredModule("scala.Predef")
+ lazy val ScalaPredefModuleRef = ctx.requiredModuleRef("scala.Predef")
+ def ScalaPredefModule = ScalaPredefModuleRef.symbol
- lazy val Predef_conforms = ctx.requiredMethod(ScalaPredefModule.moduleClass.asClass, "$conforms")
+ lazy val Predef_conformsR = ctx.requiredMethodRef(ScalaPredefModuleRef, "$conforms")
+ def Predef_conforms = Predef_conformsR.symbol
- lazy val ScalaRuntimeModule = ctx.requiredModule("scala.runtime.ScalaRunTime")
- lazy val ScalaRuntimeClass = ScalaRuntimeModule.moduleClass.asClass
+ lazy val ScalaRuntimeModuleRef = ctx.requiredModuleRef("scala.runtime.ScalaRunTime")
+ def ScalaRuntimeModule = ScalaRuntimeModuleRef.symbol
+ def ScalaRuntimeClass = ScalaRuntimeModule.moduleClass.asClass
- def runtimeMethod(name: PreName) = ctx.requiredMethod(ScalaRuntimeClass, name)
+ def runtimeMethodRef(name: PreName) = ctx.requiredMethodRef(ScalaRuntimeModuleRef, name)
+ def ScalaRuntime_dropR = runtimeMethodRef(nme.drop)
+ def ScalaRuntime_drop = ScalaRuntime_dropR.symbol
- lazy val BoxesRunTimeModule = ctx.requiredModule("scala.runtime.BoxesRunTime")
- lazy val BoxesRunTimeClass = BoxesRunTimeModule.moduleClass.asClass
- lazy val ScalaStaticsModule = ctx.requiredModule("scala.runtime.Statics")
- lazy val ScalaStaticsClass = ScalaStaticsModule.moduleClass.asClass
+ lazy val BoxesRunTimeModuleRef = ctx.requiredModuleRef("scala.runtime.BoxesRunTime")
+ def BoxesRunTimeModule = BoxesRunTimeModuleRef.symbol
+ def BoxesRunTimeClass = BoxesRunTimeModule.moduleClass.asClass
+ lazy val ScalaStaticsModuleRef = ctx.requiredModuleRef("scala.runtime.Statics")
+ def ScalaStaticsModule = ScalaStaticsModuleRef.symbol
+ def ScalaStaticsClass = ScalaStaticsModule.moduleClass.asClass
- def staticsMethod(name: PreName) = ctx.requiredMethod(ScalaStaticsClass, name)
+ def staticsMethodRef(name: PreName) = ctx.requiredMethodRef(ScalaStaticsModuleRef, name)
+ def staticsMethod(name: PreName) = ctx.requiredMethod(ScalaStaticsModuleRef, name)
- lazy val DottyPredefModule = ctx.requiredModule("dotty.DottyPredef")
- lazy val DottyArraysModule = ctx.requiredModule("dotty.runtime.Arrays")
+ lazy val DottyPredefModuleRef = ctx.requiredModuleRef("dotty.DottyPredef")
+ def DottyPredefModule = DottyPredefModuleRef.symbol
+ lazy val DottyArraysModuleRef = ctx.requiredModuleRef("dotty.runtime.Arrays")
+ def DottyArraysModule = DottyArraysModuleRef.symbol
- def newRefArrayMethod = ctx.requiredMethod(DottyArraysModule.moduleClass.asClass, "newRefArray")
+ def newRefArrayMethod = ctx.requiredMethod(DottyArraysModuleRef, "newRefArray")
- lazy val NilModule = ctx.requiredModule("scala.collection.immutable.Nil")
+ lazy val NilModuleRef = ctx.requiredModuleRef("scala.collection.immutable.Nil")
+ def NilModule = NilModuleRef.symbol
// lazy val FunctionClass: ClassSymbol = ctx.requiredClass("scala.Function")
lazy val SingletonClass: ClassSymbol =
@@ -221,57 +235,96 @@ class Definitions {
newCompleteClassSymbol(
ScalaPackageClass, tpnme.Singleton, PureInterfaceCreationFlags | Final,
List(AnyClass.typeRef), EmptyScope)
- lazy val SeqClass: ClassSymbol = ctx.requiredClass("scala.collection.Seq")
- lazy val Seq_apply = ctx.requiredMethod(SeqClass, nme.apply)
- lazy val Seq_head = ctx.requiredMethod(SeqClass, nme.head)
- lazy val ArrayClass: ClassSymbol = ctx.requiredClass("scala.Array")
- lazy val Array_apply = ctx.requiredMethod(ArrayClass, nme.apply)
- lazy val Array_update = ctx.requiredMethod(ArrayClass, nme.update)
- lazy val Array_length = ctx.requiredMethod(ArrayClass, nme.length)
- lazy val Array_clone = ctx.requiredMethod(ArrayClass, nme.clone_)
- lazy val ArrayConstructor = ctx.requiredMethod(ArrayClass, nme.CONSTRUCTOR)
- lazy val traversableDropMethod = ctx.requiredMethod(ScalaRuntimeClass, nme.drop)
- lazy val uncheckedStableClass: ClassSymbol = ctx.requiredClass("scala.annotation.unchecked.uncheckedStable")
-
- lazy val UnitClass = valueClassSymbol("scala.Unit", BoxedUnitClass, java.lang.Void.TYPE, UnitEnc)
- lazy val BooleanClass = valueClassSymbol("scala.Boolean", BoxedBooleanClass, java.lang.Boolean.TYPE, BooleanEnc)
- lazy val Boolean_! = BooleanClass.requiredMethod(nme.UNARY_!)
- lazy val Boolean_&& = BooleanClass.requiredMethod(nme.ZAND)
- lazy val Boolean_|| = BooleanClass.requiredMethod(nme.ZOR)
-
- lazy val ByteClass = valueClassSymbol("scala.Byte", BoxedByteClass, java.lang.Byte.TYPE, ByteEnc)
- lazy val ShortClass = valueClassSymbol("scala.Short", BoxedShortClass, java.lang.Short.TYPE, ShortEnc)
- lazy val CharClass = valueClassSymbol("scala.Char", BoxedCharClass, java.lang.Character.TYPE, CharEnc)
- lazy val IntClass = valueClassSymbol("scala.Int", BoxedIntClass, java.lang.Integer.TYPE, IntEnc)
- lazy val Int_- = IntClass.requiredMethod(nme.MINUS, List(IntType))
- lazy val Int_+ = IntClass.requiredMethod(nme.PLUS, List(IntType))
- lazy val Int_/ = IntClass.requiredMethod(nme.DIV, List(IntType))
- lazy val Int_* = IntClass.requiredMethod(nme.MUL, List(IntType))
- lazy val Int_== = IntClass.requiredMethod(nme.EQ, List(IntType))
- lazy val Int_>= = IntClass.requiredMethod(nme.GE, List(IntType))
- lazy val Int_<= = IntClass.requiredMethod(nme.LE, List(IntType))
- lazy val LongClass = valueClassSymbol("scala.Long", BoxedLongClass, java.lang.Long.TYPE, LongEnc)
- lazy val Long_XOR_Long = LongClass.info.member(nme.XOR).requiredSymbol(
+
+ lazy val SeqTypeRef = ctx.requiredClassRef("scala.collection.Seq")
+ def SeqClass = SeqTypeRef.symbol.asClass
+ lazy val Seq_applyR = ctx.requiredMethodRef(SeqTypeRef, nme.apply)
+ def Seq_apply = Seq_applyR.symbol
+ lazy val Seq_headR = ctx.requiredMethodRef(SeqTypeRef, nme.head)
+ def Seq_head = Seq_headR.symbol
+
+ lazy val ArrayTypeRef = ctx.requiredClassRef("scala.Array")
+ def ArrayClass = ArrayTypeRef.symbol.asClass
+ lazy val Array_applyR = ctx.requiredMethodRef(ArrayTypeRef, nme.apply)
+ def Array_apply = Array_applyR.symbol
+ lazy val Array_updateR = ctx.requiredMethodRef(ArrayTypeRef, nme.update)
+ def Array_update = Array_updateR.symbol
+ lazy val Array_lengthR = ctx.requiredMethodRef(ArrayTypeRef, nme.length)
+ def Array_length = Array_lengthR.symbol
+ lazy val Array_cloneR = ctx.requiredMethodRef(ArrayTypeRef, nme.clone_)
+ def Array_clone = Array_cloneR.symbol
+ lazy val ArrayConstructorR = ctx.requiredMethodRef(ArrayTypeRef, nme.CONSTRUCTOR)
+ def ArrayConstructor = ArrayConstructorR.symbol
+
+ lazy val uncheckedStableClassRef: TypeRef = ctx.requiredClassRef("scala.annotation.unchecked.uncheckedStable") // ### roll into annotations
+
+ lazy val UnitTypeRef = valueTypeRef("scala.Unit", BoxedUnitTypeRef, java.lang.Void.TYPE, UnitEnc)
+ def UnitClass = UnitTypeRef.symbol.asClass
+ lazy val BooleanTypeRef = valueTypeRef("scala.Boolean", BoxedBooleanTypeRef, java.lang.Boolean.TYPE, BooleanEnc)
+ def BooleanClass = BooleanTypeRef.symbol.asClass
+ lazy val Boolean_notR = BooleanTypeRef.symbol.requiredMethodRef(nme.UNARY_!)
+ def Boolean_! = Boolean_notR.symbol
+ lazy val Boolean_andR = BooleanTypeRef.symbol.requiredMethodRef(nme.ZAND) // ### harmonize required... calls
+ def Boolean_&& = Boolean_andR.symbol
+ lazy val Boolean_orR = BooleanTypeRef.symbol.requiredMethodRef(nme.ZOR)
+ def Boolean_|| = Boolean_orR.symbol
+
+ lazy val ByteTypeRef = valueTypeRef("scala.Byte", BoxedByteTypeRef, java.lang.Byte.TYPE, ByteEnc)
+ def ByteClass = ByteTypeRef.symbol.asClass
+ lazy val ShortTypeRef = valueTypeRef("scala.Short", BoxedShortTypeRef, java.lang.Short.TYPE, ShortEnc)
+ def ShortClass = ShortTypeRef.symbol.asClass
+ lazy val CharTypeRef = valueTypeRef("scala.Char", BoxedCharTypeRef, java.lang.Character.TYPE, CharEnc)
+ def CharClass = CharTypeRef.symbol.asClass
+ lazy val IntTypeRef = valueTypeRef("scala.Int", BoxedIntTypeRef, java.lang.Integer.TYPE, IntEnc)
+ def IntClass = IntTypeRef.symbol.asClass
+ lazy val Int_minusR = IntTypeRef.symbol.requiredMethodRef(nme.MINUS, List(IntType))
+ def Int_- = Int_minusR.symbol
+ lazy val Int_plusR = IntTypeRef.symbol.requiredMethodRef(nme.PLUS, List(IntType))
+ def Int_+ = Int_plusR.symbol
+ lazy val Int_divR = IntTypeRef.symbol.requiredMethodRef(nme.DIV, List(IntType))
+ def Int_/ = Int_divR.symbol
+ lazy val Int_mulR = IntTypeRef.symbol.requiredMethodRef(nme.MUL, List(IntType))
+ def Int_* = Int_mulR.symbol
+ lazy val Int_eqR = IntTypeRef.symbol.requiredMethodRef(nme.EQ, List(IntType))
+ def Int_== = Int_eqR.symbol
+ lazy val Int_geR = IntTypeRef.symbol.requiredMethodRef(nme.GE, List(IntType))
+ def Int_>= = Int_geR.symbol
+ lazy val Int_leR = IntTypeRef.symbol.requiredMethodRef(nme.LE, List(IntType))
+ def Int_<= = Int_leR.symbol
+ lazy val LongTypeRef = valueTypeRef("scala.Long", BoxedLongTypeRef, java.lang.Long.TYPE, LongEnc)
+ def LongClass = LongTypeRef.symbol.asClass
+ lazy val Long_XOR_Long = LongTypeRef.member(nme.XOR).requiredSymbol(
x => (x is Method) && (x.info.firstParamTypes.head isRef defn.LongClass)
)
- lazy val Long_LSR_Int = LongClass.info.member(nme.LSR).requiredSymbol(
+ lazy val Long_LSR_Int = LongTypeRef.member(nme.LSR).requiredSymbol(
x => (x is Method) && (x.info.firstParamTypes.head isRef defn.IntClass)
)
- lazy val FloatClass = valueClassSymbol("scala.Float", BoxedFloatClass, java.lang.Float.TYPE, FloatEnc)
- lazy val DoubleClass = valueClassSymbol("scala.Double", BoxedDoubleClass, java.lang.Double.TYPE, DoubleEnc)
-
- lazy val BoxedUnitClass = ctx.requiredClass("scala.runtime.BoxedUnit")
-
- lazy val BoxedUnit_UNIT = BoxedUnitClass.linkedClass.requiredValue("UNIT")
-
- lazy val BoxedBooleanClass = ctx.requiredClass("java.lang.Boolean")
- lazy val BoxedByteClass = ctx.requiredClass("java.lang.Byte")
- lazy val BoxedShortClass = ctx.requiredClass("java.lang.Short")
- lazy val BoxedCharClass = ctx.requiredClass("java.lang.Character")
- lazy val BoxedIntClass = ctx.requiredClass("java.lang.Integer")
- lazy val BoxedLongClass = ctx.requiredClass("java.lang.Long")
- lazy val BoxedFloatClass = ctx.requiredClass("java.lang.Float")
- lazy val BoxedDoubleClass = ctx.requiredClass("java.lang.Double")
+ lazy val FloatTypeRef = valueTypeRef("scala.Float", BoxedFloatTypeRef, java.lang.Float.TYPE, FloatEnc)
+ def FloatClass = FloatTypeRef.symbol.asClass
+ lazy val DoubleTypeRef = valueTypeRef("scala.Double", BoxedDoubleTypeRef, java.lang.Double.TYPE, DoubleEnc)
+ def DoubleClass = DoubleTypeRef.symbol.asClass
+
+ lazy val BoxedUnitTypeRef = ctx.requiredClassRef("scala.runtime.BoxedUnit")
+ def BoxedUnitClass = BoxedUnitTypeRef.symbol.asClass
+
+ lazy val BoxedUnit_UNIT = BoxedUnitTypeRef.symbol.linkedClass.requiredValue("UNIT") // ### replace with BoxedUnitModule?
+
+ lazy val BoxedBooleanTypeRef = ctx.requiredClassRef("java.lang.Boolean")
+ def BoxedBooleanClass = BoxedBooleanTypeRef.symbol.asClass
+ lazy val BoxedByteTypeRef = ctx.requiredClassRef("java.lang.Byte")
+ def BoxedByteClass = BoxedByteTypeRef.symbol.asClass
+ lazy val BoxedShortTypeRef = ctx.requiredClassRef("java.lang.Short")
+ def BoxedShortClass = BoxedShortTypeRef.symbol.asClass
+ lazy val BoxedCharTypeRef = ctx.requiredClassRef("java.lang.Character")
+ def BoxedCharClass = BoxedCharTypeRef.symbol.asClass
+ lazy val BoxedIntTypeRef = ctx.requiredClassRef("java.lang.Integer")
+ def BoxedIntClass = BoxedIntTypeRef.symbol.asClass
+ lazy val BoxedLongTypeRef = ctx.requiredClassRef("java.lang.Long")
+ def BoxedLongClass = BoxedLongTypeRef.symbol.asClass
+ lazy val BoxedFloatTypeRef = ctx.requiredClassRef("java.lang.Float")
+ def BoxedFloatClass = BoxedFloatTypeRef.symbol.asClass
+ lazy val BoxedDoubleTypeRef = ctx.requiredClassRef("java.lang.Double")
+ def BoxedDoubleClass = BoxedDoubleTypeRef.symbol.asClass
lazy val BoxedBooleanModule = ctx.requiredModule("java.lang.Boolean")
lazy val BoxedByteModule = ctx.requiredModule("java.lang.Byte")
@@ -289,8 +342,8 @@ class Definitions {
lazy val RepeatedParamClass = specialPolyClass(tpnme.REPEATED_PARAM_CLASS, Covariant, ObjectType, SeqType)
// fundamental classes
- lazy val StringClass = ctx.requiredClass("java.lang.String")
- lazy val StringModule = StringClass.linkedClass
+ lazy val StringClass = ctx.requiredClass("java.lang.String")
+ lazy val StringModule = StringClass.linkedClass
lazy val String_+ = newMethod(StringClass, nme.raw.PLUS, methOfAny(StringType), Final)
lazy val String_valueOf_Object = StringModule.info.member(nme.valueOf).suchThat(_.info.firstParamTypes match {
@@ -298,71 +351,117 @@ class Definitions {
case _ => false
}).symbol
- // in scalac modified to have Any as parrent
-
- lazy val SerializableClass = ctx.requiredClass("scala.Serializable")
lazy val JavaCloneableClass = ctx.requiredClass("java.lang.Cloneable")
- lazy val StringBuilderClass = ctx.requiredClass("scala.collection.mutable.StringBuilder")
- lazy val NullPointerExceptionClass = ctx.requiredClass(jnme.NPException)
- lazy val MatchErrorClass = ctx.requiredClass("scala.MatchError")
- lazy val MatchErrorType = MatchErrorClass.typeRef
-
- lazy val StringAddClass = ctx.requiredClass("scala.runtime.StringAdd")
-
- lazy val StringAdd_+ = StringAddClass.requiredMethod(nme.raw.PLUS)
-
- lazy val PairClass = ctx.requiredClass("dotty.Pair")
- lazy val PartialFunctionClass = ctx.requiredClass("scala.PartialFunction")
- lazy val AbstractPartialFunctionClass = ctx.requiredClass("scala.runtime.AbstractPartialFunction")
- lazy val SymbolClass = ctx.requiredClass("scala.Symbol")
- lazy val ClassClass = ctx.requiredClass("java.lang.Class")
- lazy val DynamicClass = ctx.requiredClass("scala.Dynamic")
- lazy val OptionClass = ctx.requiredClass("scala.Option")
- lazy val BoxedNumberClass = ctx.requiredClass("java.lang.Number")
- lazy val ThrowableClass = ctx.requiredClass("java.lang.Throwable")
- lazy val ClassCastExceptionClass = ctx.requiredClass("java.lang.ClassCastException")
- lazy val JavaSerializableClass = ctx.requiredClass("java.lang.Serializable")
- lazy val ComparableClass = ctx.requiredClass("java.lang.Comparable")
- lazy val ProductClass = ctx.requiredClass("scala.Product")
- lazy val Product_canEqual = ProductClass.requiredMethod(nme.canEqual_)
- lazy val Product_productArity = ProductClass.requiredMethod(nme.productArity)
- lazy val Product_productPrefix = ProductClass.requiredMethod(nme.productPrefix)
- lazy val LanguageModuleClass = ctx.requiredModule("dotty.language").moduleClass.asClass
- lazy val NonLocalReturnControlClass = ctx.requiredClass("scala.runtime.NonLocalReturnControl")
+ lazy val NullPointerExceptionClass = ctx.requiredClass("java.lang.NullPointerException")
+ lazy val ClassClass = ctx.requiredClass("java.lang.Class")
+ lazy val BoxedNumberClass = ctx.requiredClass("java.lang.Number")
+ lazy val ThrowableClass = ctx.requiredClass("java.lang.Throwable")
+ lazy val ClassCastExceptionClass = ctx.requiredClass("java.lang.ClassCastException")
+ lazy val JavaSerializableClass = ctx.requiredClass("java.lang.Serializable")
+ lazy val ComparableClass = ctx.requiredClass("java.lang.Comparable")
+
+ // in scalac modified to have Any as parent
+
+ lazy val SerializableTypeRef = ctx.requiredClassRef("scala.Serializable")
+ def SerializableClass = SerializableTypeRef.symbol.asClass
+ lazy val StringBuilderTypeRef = ctx.requiredClassRef("scala.collection.mutable.StringBuilder")
+ def StringBuilderClass = StringBuilderTypeRef.symbol.asClass
+ lazy val MatchErrorTypeRef = ctx.requiredClassRef("scala.MatchError")
+ def MatchErrorClass = MatchErrorTypeRef.symbol.asClass
+
+ lazy val StringAddTypeRef = ctx.requiredClassRef("scala.runtime.StringAdd")
+ def StringAddClass = StringAddTypeRef.symbol.asClass
+
+ lazy val StringAdd_plusR = StringAddTypeRef.symbol.requiredMethodRef(nme.raw.PLUS)
+ def StringAdd_+ = StringAdd_plusR.symbol
+
+ lazy val PairTypeRef = ctx.requiredClassRef("dotty.Pair")
+ def PairClass = PairTypeRef.symbol.asClass
+ lazy val PartialFunctionTypeRef = ctx.requiredClassRef("scala.PartialFunction")
+ def PartialFunctionClass = PartialFunctionTypeRef.symbol.asClass
+ lazy val AbstractPartialFunctionTypeRef = ctx.requiredClassRef("scala.runtime.AbstractPartialFunction")
+ def AbstractPartialFunctionClass = AbstractPartialFunctionTypeRef.symbol.asClass
+ lazy val SymbolTypeRef = ctx.requiredClassRef("scala.Symbol")
+ def SymbolClass = SymbolTypeRef.symbol.asClass
+ lazy val DynamicTypeRef = ctx.requiredClassRef("scala.Dynamic")
+ def DynamicClass = DynamicTypeRef.symbol.asClass
+ lazy val OptionTypeRef = ctx.requiredClassRef("scala.Option")
+ def OptionClass = OptionTypeRef.symbol.asClass
+ lazy val ProductTypeRef = ctx.requiredClassRef("scala.Product")
+ def ProductClass = ProductTypeRef.symbol.asClass
+ lazy val Product_canEqualR = ProductTypeRef.symbol.requiredMethodRef(nme.canEqual_)
+ def Product_canEqual = Product_canEqualR.symbol
+ lazy val Product_productArityR = ProductTypeRef.symbol.requiredMethod(nme.productArity)
+ def Product_productArity = Product_productArityR.symbol
+ lazy val Product_productPrefixR = ProductTypeRef.symbol.requiredMethod(nme.productPrefix)
+ def Product_productPrefix = Product_productPrefixR.symbol
+ lazy val LanguageModuleTypeRef = ctx.requiredModule("dotty.language").moduleClass.asClass
+ def LanguageModuleClass = LanguageModuleTypeRef.symbol.asClass // ### Needed? Maube just keep LanguageModule?
+ lazy val NonLocalReturnControlTypeRef = ctx.requiredClassRef("scala.runtime.NonLocalReturnControl")
// Annotation base classes
- lazy val AnnotationClass = ctx.requiredClass("scala.annotation.Annotation")
- lazy val ClassfileAnnotationClass = ctx.requiredClass("scala.annotation.ClassfileAnnotation")
- lazy val StaticAnnotationClass = ctx.requiredClass("scala.annotation.StaticAnnotation")
- lazy val TailrecAnnotationClass = ctx.requiredClass("scala.annotation.tailrec")
- lazy val RemoteAnnot = ctx.requiredClass("scala.remote")
- lazy val SerialVersionUIDAnnot = ctx.requiredClass("scala.SerialVersionUID")
- lazy val TransientAnnot = ctx.requiredClass("scala.transient")
- lazy val NativeAnnot = ctx.requiredClass("scala.native")
- lazy val ScalaStrictFPAnnot = ctx.requiredClass("scala.annotation.strictfp")
+ lazy val AnnotationTypeRef = ctx.requiredClassRef("scala.annotation.Annotation") // ### AnnotationTypeRef --> AnnotRef?
+ def AnnotationClass = AnnotationTypeRef.symbol.asClass
+ lazy val ClassfileAnnotationTypeRef = ctx.requiredClassRef("scala.annotation.ClassfileAnnotation")
+ def ClassfileAnnotationClass = ClassfileAnnotationTypeRef.symbol.asClass
+ lazy val StaticAnnotationTypeRef = ctx.requiredClassRef("scala.annotation.StaticAnnotation")
+ def StaticAnnotationClass = StaticAnnotationTypeRef.symbol.asClass
+ lazy val TailrecAnnotationTypeRef = ctx.requiredClassRef("scala.annotation.tailrec")
+ def TailrecAnnotationClass = TailrecAnnotationTypeRef.symbol.asClass
+ lazy val RemoteAnnotRef = ctx.requiredClassRef("scala.remote")
+ def RemoteAnnot = RemoteAnnotRef.symbol.asClass
+ lazy val SerialVersionUIDAnnotRef = ctx.requiredClassRef("scala.SerialVersionUID")
+ def SerialVersionUIDAnnot = SerialVersionUIDAnnotRef.symbol.asClass
+ lazy val TransientAnnotRef = ctx.requiredClassRef("scala.transient")
+ def TransientAnnot = TransientAnnotRef.symbol.asClass
+ lazy val NativeAnnotRef = ctx.requiredClassRef("scala.native")
+ def NativeAnnot = NativeAnnotRef.symbol.asClass
+ lazy val ScalaStrictFPAnnotRef = ctx.requiredClassRef("scala.annotation.strictfp")
+ def ScalaStrictFPAnnot = ScalaStrictFPAnnotRef.symbol.asClass
// Annotation classes
- lazy val AliasAnnot = ctx.requiredClass("dotty.annotation.internal.Alias")
- lazy val ChildAnnot = ctx.requiredClass("dotty.annotation.internal.Child")
- lazy val RepeatedAnnot = ctx.requiredClass("dotty.annotation.internal.Repeated")
- lazy val InvariantBetweenClass = ctx.requiredClass("dotty.annotation.internal.InvariantBetween")
- lazy val CovariantBetweenClass = ctx.requiredClass("dotty.annotation.internal.CovariantBetween")
- lazy val ContravariantBetweenClass = ctx.requiredClass("dotty.annotation.internal.ContravariantBetween")
- lazy val ScalaSignatureAnnot = ctx.requiredClass("scala.reflect.ScalaSignature")
- lazy val ScalaLongSignatureAnnot = ctx.requiredClass("scala.reflect.ScalaLongSignature")
- lazy val TASTYSignatureAnnot = ctx.requiredClass("scala.annotation.internal.TASTYSignature")
- lazy val TASTYLongSignatureAnnot = ctx.requiredClass("scala.annotation.internal.TASTYLongSignature")
- lazy val DeprecatedAnnot = ctx.requiredClass("scala.deprecated")
- lazy val MigrationAnnot = ctx.requiredClass("scala.annotation.migration")
- lazy val AnnotationDefaultAnnot = ctx.requiredClass("dotty.annotation.internal.AnnotationDefault")
- lazy val ThrowsAnnot = ctx.requiredClass("scala.throws")
- lazy val UncheckedAnnot = ctx.requiredClass("scala.unchecked")
- lazy val UncheckedStableAnnot = ctx.requiredClass("scala.annotation.unchecked.uncheckedStable")
- lazy val UncheckedVarianceAnnot = ctx.requiredClass("scala.annotation.unchecked.uncheckedVariance")
- lazy val VolatileAnnot = ctx.requiredClass("scala.volatile")
- lazy val FieldMetaAnnot = ctx.requiredClass("scala.annotation.meta.field")
- lazy val GetterMetaAnnot = ctx.requiredClass("scala.annotation.meta.getter")
- lazy val SetterMetaAnnot = ctx.requiredClass("scala.annotation.meta.setter")
+ lazy val AliasAnnotRef = ctx.requiredClassRef("dotty.annotation.internal.Alias")
+ def AliasAnnot = AliasAnnotRef.symbol.asClass
+ lazy val ChildAnnotRef = ctx.requiredClassRef("dotty.annotation.internal.Child")
+ def ChildAnnot = ChildAnnotRef.symbol.asClass
+ lazy val RepeatedAnnotRef = ctx.requiredClassRef("dotty.annotation.internal.Repeated")
+ def RepeatedAnnot = RepeatedAnnotRef.symbol.asClass
+ lazy val InvariantBetweenAnnotRef = ctx.requiredClassRef("dotty.annotation.internal.InvariantBetween")
+ def InvariantBetweenAnnot = InvariantBetweenAnnotRef.symbol.asClass
+ lazy val CovariantBetweenAnnotRef = ctx.requiredClassRef("dotty.annotation.internal.CovariantBetween")
+ def CovariantBetweenAnnot = CovariantBetweenAnnotRef.symbol.asClass
+ lazy val ContravariantBetweenAnnotRef = ctx.requiredClassRef("dotty.annotation.internal.ContravariantBetween")
+ def ContravariantBetweenAnnot = ContravariantBetweenAnnotRef.symbol.asClass
+ lazy val ScalaSignatureAnnotRef = ctx.requiredClassRef("scala.reflect.ScalaSignature")
+ def ScalaSignatureAnnot = ScalaSignatureAnnotRef.symbol.asClass
+ lazy val ScalaLongSignatureAnnotRef = ctx.requiredClassRef("scala.reflect.ScalaLongSignature")
+ def ScalaLongSignatureAnnot = ScalaLongSignatureAnnotRef.symbol.asClass
+ lazy val TASTYSignatureAnnotRef = ctx.requiredClassRef("scala.annotation.internal.TASTYSignature")
+ def TASTYSignatureAnnot = TASTYSignatureAnnotRef.symbol.asClass
+ lazy val TASTYLongSignatureAnnotRef = ctx.requiredClassRef("scala.annotation.internal.TASTYLongSignature")
+ def TASTYLongSignatureAnnot = TASTYLongSignatureAnnotRef.symbol.asClass
+ lazy val DeprecatedAnnotRef = ctx.requiredClassRef("scala.deprecated")
+ def DeprecatedAnnot = DeprecatedAnnotRef.symbol.asClass
+ lazy val MigrationAnnotRef = ctx.requiredClassRef("scala.annotation.migration")
+ def MigrationAnnot = MigrationAnnotRef.symbol.asClass
+ lazy val AnnotationDefaultAnnotRef = ctx.requiredClassRef("dotty.annotation.internal.AnnotationDefault")
+ def AnnotationDefaultAnnot = AnnotationDefaultAnnotRef.symbol.asClass
+ lazy val ThrowsAnnotRef = ctx.requiredClassRef("scala.throws")
+ def ThrowsAnnot = ThrowsAnnotRef.symbol.asClass
+ lazy val UncheckedAnnotRef = ctx.requiredClassRef("scala.unchecked")
+ def UncheckedAnnot = UncheckedAnnotRef.symbol.asClass
+ lazy val UncheckedStableAnnotRef = ctx.requiredClassRef("scala.annotation.unchecked.uncheckedStable")
+ def UncheckedStableAnnot = UncheckedStableAnnotRef.symbol.asClass
+ lazy val UncheckedVarianceAnnotRef = ctx.requiredClassRef("scala.annotation.unchecked.uncheckedVariance")
+ def UncheckedVarianceAnnot = UncheckedVarianceAnnotRef.symbol.asClass
+ lazy val VolatileAnnotRef = ctx.requiredClassRef("scala.volatile")
+ def VolatileAnnot = VolatileAnnotRef.symbol.asClass
+ lazy val FieldMetaAnnotRef = ctx.requiredClassRef("scala.annotation.meta.field")
+ def FieldMetaAnnot = FieldMetaAnnotRef.symbol.asClass
+ lazy val GetterMetaAnnotRef = ctx.requiredClassRef("scala.annotation.meta.getter")
+ def GetterMetaAnnot = GetterMetaAnnotRef.symbol.asClass
+ lazy val SetterMetaAnnotRef = ctx.requiredClassRef("scala.annotation.meta.setter")
+ def SetterMetaAnnot = SetterMetaAnnotRef.symbol.asClass
// convenient one-parameter method types
def methOfAny(tp: Type) = MethodType(List(AnyType), tp)
@@ -376,23 +475,23 @@ class Definitions {
def AnyRefType: Type = AnyRefAlias.typeRef
def NothingType: Type = NothingClass.typeRef
def NullType: Type = NullClass.typeRef
- def SeqType: Type = SeqClass.typeRef
-
- def UnitType: Type = UnitClass.typeRef
- def BooleanType: Type = BooleanClass.typeRef
- def ByteType: Type = ByteClass.typeRef
- def ShortType: Type = ShortClass.typeRef
- def CharType: Type = CharClass.typeRef
- def IntType: Type = IntClass.typeRef
- def LongType: Type = LongClass.typeRef
- def FloatType: Type = FloatClass.typeRef
- def DoubleType: Type = DoubleClass.typeRef
- def PairType: Type = PairClass.typeRef
+ def SeqType: Type = SeqTypeRef
+
+ def UnitType: Type = UnitTypeRef
+ def BooleanType: Type = BooleanTypeRef
+ def ByteType: Type = ByteTypeRef
+ def ShortType: Type = ShortTypeRef
+ def CharType: Type = CharTypeRef
+ def IntType: Type = IntTypeRef
+ def LongType: Type = LongTypeRef
+ def FloatType: Type = FloatTypeRef
+ def DoubleType: Type = DoubleTypeRef
+ def PairType: Type = PairTypeRef
def StringType: Type = StringClass.typeRef
def RepeatedParamType = RepeatedParamClass.typeRef
def ThrowableType = ThrowableClass.typeRef
- def OptionType = OptionClass.typeRef
- def VolatileAnnotType = VolatileAnnot.typeRef
+ def OptionType = OptionTypeRef
+ def VolatileAnnotType = VolatileAnnotRef
def ClassType(arg: Type)(implicit ctx: Context) = {
val ctype = ClassClass.typeRef
@@ -409,15 +508,15 @@ class Definitions {
object FunctionType {
def apply(args: List[Type], resultType: Type)(implicit ctx: Context) =
- FunctionClass(args.length).typeRef.appliedTo(args ::: resultType :: Nil)
+ FunctionTypeRef(args.length).appliedTo(args ::: resultType :: Nil)
def unapply(ft: Type)(implicit ctx: Context)/*: Option[(List[Type], Type)]*/ = {
// -language:keepUnions difference: unapply needs result type because inferred type
// is Some[(List[Type], Type)] | None, which is not a legal unapply type.
val tsym = ft.typeSymbol
lazy val targs = ft.argInfos
- if ((FunctionClasses contains tsym) &&
- (targs.length - 1 <= MaxFunctionArity) &&
- (FunctionClass(targs.length - 1) == tsym)) Some(targs.init, targs.last)
+ val numArgs = targs.length - 1
+ if (numArgs >= 0 && numArgs <= MaxFunctionArity &&
+ (FunctionTypeRef(numArgs).symbol == tsym)) Some(targs.init, targs.last)
else None
}
}
@@ -425,9 +524,9 @@ class Definitions {
object ArrayType {
def apply(elem: Type)(implicit ctx: Context) =
if (ctx.erasedTypes) JavaArrayType(elem)
- else ArrayClass.typeRef.appliedTo(elem :: Nil)
+ else ArrayTypeRef.appliedTo(elem :: Nil)
def unapply(tp: Type)(implicit ctx: Context): Option[Type] = tp.dealias match {
- case at: RefinedType if (at isRef ArrayClass) && at.argInfos.length == 1 => Some(at.argInfos.head)
+ case at: RefinedType if (at isRef ArrayTypeRef.symbol) && at.argInfos.length == 1 => Some(at.argInfos.head)
case _ => None
}
}
@@ -448,43 +547,67 @@ class Definitions {
// ----- Symbol sets ---------------------------------------------------
- lazy val AbstractFunctionClass = mkArityArray("scala.runtime.AbstractFunction", MaxFunctionArity, 0)
- lazy val FunctionClass = mkArityArray("scala.Function", MaxFunctionArity, 0)
- lazy val Function0_apply = FunctionClass(0).requiredMethod(nme.apply)
+ lazy val AbstractFunctionTypeRef = mkArityArray("scala.runtime.AbstractFunction", MaxFunctionArity, 0)
+ def AbstractFunctionClass = AbstractFunctionTypeRef.map(_.symbol.asClass)
+ lazy val FunctionTypeRef = mkArityArray("scala.Function", MaxFunctionArity, 0)
+ def FunctionClass = FunctionTypeRef.map(_.symbol.asClass)
+ lazy val Function0_applyR = FunctionTypeRef(0).symbol.requiredMethodRef(nme.apply)
+ def Function0_apply = Function0_applyR.symbol
- lazy val TupleClass = mkArityArray("scala.Tuple", MaxTupleArity, 2)
- lazy val ProductNClass = mkArityArray("scala.Product", MaxTupleArity, 0)
+ lazy val TupleTypeRef = mkArityArray("scala.Tuple", MaxTupleArity, 2)
+ lazy val ProductNTypeRef = mkArityArray("scala.Product", MaxTupleArity, 0)
- lazy val FunctionClasses: Set[Symbol] = FunctionClass.toSet
- lazy val TupleClasses: Set[Symbol] = TupleClass.toSet
- lazy val ProductClasses: Set[Symbol] = ProductNClass.toSet
+ lazy val FunctionTypeRefs: Set[TypeRef] = FunctionTypeRef.toSet
+ lazy val TupleTypeRefs: Set[TypeRef] = TupleTypeRef.toSet
+ lazy val ProductTypeRefs: Set[TypeRef] = ProductNTypeRef.toSet
- /** `Modules whose members are in the default namespace and their module classes */
- lazy val UnqualifiedOwners = RootImports.toSet ++ RootImports.map(_.moduleClass)
+ /** If type refers to a class in the scala package, its name, otherwise EmptyTypeName */
+ def scalaClassName(ref: Type)(implicit ctx: Context): TypeName = {
+ val cls = ref.classSymbol
+ if (cls.isClass && cls.owner == ScalaPackageClass) cls.asClass.name else EmptyTypeName
+ }
- lazy val PhantomClasses = Set[Symbol](AnyClass, AnyValClass, NullClass, NothingClass)
+ def isVarArityClass(cls: Symbol, prefix: Name) = // ### use scalaClassName
+ cls.owner == ScalaPackageClass && cls.name.startsWith(prefix) &&
+ cls.name.drop(prefix.length).forall(_.isDigit)
+
+ def isFunctionClass(cls: Symbol) = isVarArityClass(cls, tpnme.Function)
+ def isAbstractFunctionClass(cls: Symbol) = isVarArityClass(cls, tpnme.AbstractFunction)
+ def isTupleClass(cls: Symbol) = isVarArityClass(cls, tpnme.Tuple)
+ def isProductClass(cls: Symbol) = isVarArityClass(cls, tpnme.Product)
+
+ val RootImportFns = List[() => TermRef](
+ () => JavaLangPackageVal.termRef,
+ () => ScalaPackageVal.termRef,
+ () => ScalaPredefModuleRef,
+ () => DottyPredefModuleRef)
- lazy val isPolymorphicAfterErasure = Set[Symbol](Any_isInstanceOf, Any_asInstanceOf, newRefArrayMethod)
+ lazy val RootImportTypes = RootImportFns.map(_())
- val RootImportFns = List[() => Symbol](() => JavaLangPackageVal, () => ScalaPackageVal, () => ScalaPredefModule, () => DottyPredefModule)
+ /** `Modules whose members are in the default namespace and their module classes */
+ lazy val UnqualifiedOwnerTypes: Set[NamedType] =
+ RootImportTypes.toSet[NamedType] ++ RootImportTypes.map(_.symbol.moduleClass.typeRef)
+
+ lazy val PhantomClasses = Set[Symbol](AnyClass, AnyValClass, NullClass, NothingClass)
- lazy val RootImports = RootImportFns.map(_())
+ lazy val isPolymorphicAfterErasure = // ### Can't be a lazy val, because of newRefArrayMethod!
+ Set[Symbol](Any_isInstanceOf, Any_asInstanceOf, newRefArrayMethod)
def isTupleType(tp: Type)(implicit ctx: Context) = {
val arity = tp.dealias.argInfos.length
- arity <= MaxTupleArity && (tp isRef TupleClass(arity))
+ arity <= MaxTupleArity && TupleTypeRef(arity) != null && (tp isRef TupleTypeRef(arity).symbol)
}
def tupleType(elems: List[Type]) = {
- TupleClass(elems.size).typeRef.appliedTo(elems)
+ TupleTypeRef(elems.size).appliedTo(elems)
}
def isProductSubType(tp: Type)(implicit ctx: Context) =
- (tp derivesFrom ProductClass) && tp.baseClasses.exists(ProductClasses contains _)
+ (tp derivesFrom ProductTypeRef.symbol) && tp.baseClasses.exists(isProductClass)
def isFunctionType(tp: Type)(implicit ctx: Context) = {
val arity = functionArity(tp)
- 0 <= arity && arity <= MaxFunctionArity && (tp isRef FunctionClass(arity))
+ 0 <= arity && arity <= MaxFunctionArity && (tp isRef FunctionTypeRef(arity).symbol)
}
def functionArity(tp: Type)(implicit ctx: Context) = tp.dealias.argInfos.length - 1
@@ -556,54 +679,57 @@ class Definitions {
// ----- primitive value class machinery ------------------------------------------
- lazy val ScalaNumericValueClassList = List(
- ByteClass,
- ShortClass,
- CharClass,
- IntClass,
- LongClass,
- FloatClass,
- DoubleClass)
-
- lazy val ScalaNumericValueClasses: collection.Set[Symbol] = ScalaNumericValueClassList.toSet
- lazy val ScalaValueClasses: collection.Set[Symbol] = ScalaNumericValueClasses + UnitClass + BooleanClass
-
- lazy val ScalaBoxedClasses = ScalaValueClasses map boxedClass
-
- private[this] val _boxedClass = mutable.Map[Symbol, Symbol]()
- private[this] val _unboxedClass = mutable.Map[Symbol, Symbol]()
-
- private[this] val _javaTypeToValueClass = mutable.Map[Class[_], Symbol]()
- private[this] val _valueClassToJavaType = mutable.Map[Symbol, Class[_]]()
- private[this] val _valueClassEnc = mutable.Map[Symbol, Int]()
-
- val boxedClass: collection.Map[Symbol, Symbol] = _boxedClass
- val unboxedClass: collection.Map[Symbol, Symbol] = _boxedClass
- val javaTypeToValueClass: collection.Map[Class[_], Symbol] = _javaTypeToValueClass
- val valueClassToJavaType: collection.Map[Symbol, Class[_]] = _valueClassToJavaType
- val valueClassEnc: collection.Map[Symbol, Int] = _valueClassEnc
-
- private def valueClassSymbol(name: String, boxed: ClassSymbol, jtype: Class[_], enc: Int): ClassSymbol = {
- val vcls = ctx.requiredClass(name)
- _unboxedClass(boxed) = vcls
- _boxedClass(vcls) = boxed
- _javaTypeToValueClass(jtype) = vcls
- _valueClassToJavaType(vcls) = jtype
- _valueClassEnc(vcls) = enc
+ lazy val ScalaNumericValueTypeList = List(
+ ByteTypeRef,
+ ShortTypeRef,
+ CharTypeRef,
+ IntTypeRef,
+ LongTypeRef,
+ FloatTypeRef,
+ DoubleTypeRef)
+
+ lazy val ScalaNumericValueTypes: collection.Set[TypeRef] = ScalaNumericValueTypeList.toSet
+ def ScalaNumericValueClasses = ScalaNumericValueTypes.map(_.symbol)
+ lazy val ScalaValueTypes: collection.Set[TypeRef] = ScalaNumericValueTypes + UnitTypeRef + BooleanTypeRef
+ def ScalaValueClasses = ScalaValueTypes.map(_.symbol)
+
+ lazy val ScalaBoxedTypeRefs = ScalaValueTypes map boxedTypeRef
+ def ScalaBoxedClasses = ScalaBoxedTypeRefs.map(_.symbol)
+
+ private[this] val _boxedTypeRef = mutable.Map[TypeRef, TypeRef]() // ### Maps over typerefs are not robust!
+ private[this] val _unboxedTypeRef = mutable.Map[TypeRef, TypeRef]()
+
+ private[this] val _javaTypeToValueTypeRef = mutable.Map[Class[_], TypeRef]()
+ private[this] val _valueTypeRefToJavaType = mutable.Map[TypeRef, Class[_]]()
+ private[this] val _valueTypeEnc = mutable.Map[TypeRef, Int]()
+
+ val boxedTypeRef: collection.Map[TypeRef, TypeRef] = _boxedTypeRef
+ val unboxedTypeRef: collection.Map[TypeRef, TypeRef] = _boxedTypeRef
+ val javaTypeToValueTypeRef: collection.Map[Class[_], TypeRef] = _javaTypeToValueTypeRef
+ val valueTypeRefToJavaType: collection.Map[TypeRef, Class[_]] = _valueTypeRefToJavaType
+ val valueTypeEnc: collection.Map[TypeRef, Int] = _valueTypeEnc
+
+ private def valueTypeRef(name: String, boxed: TypeRef, jtype: Class[_], enc: Int): TypeRef = {
+ val vcls = ctx.requiredClassRef(name)
+ _unboxedTypeRef(boxed) = vcls
+ _boxedTypeRef(vcls) = boxed
+ _javaTypeToValueTypeRef(jtype) = vcls
+ _valueTypeRefToJavaType(vcls) = jtype
+ _valueTypeEnc(vcls) = enc
vcls
}
/** The classes for which a Ref type exists. */
- lazy val refClassKeys: collection.Set[Symbol] = ScalaNumericValueClasses + BooleanClass + ObjectClass
+ lazy val refTypeKeys: collection.Set[TypeRef] = ScalaNumericValueTypes + BooleanTypeRef + ObjectClass.typeRef
- lazy val refClass: Map[Symbol, Symbol] =
- refClassKeys.map(rc => rc -> ctx.requiredClass(s"scala.runtime.${rc.name}Ref")).toMap
+ lazy val refTypeRef: Map[TypeRef, TypeRef] =
+ refTypeKeys.map(rc => rc -> ctx.requiredClassRef(s"scala.runtime.${rc.name}Ref")).toMap
- lazy val volatileRefClass: Map[Symbol, Symbol] =
- refClassKeys.map(rc => rc -> ctx.requiredClass(s"scala.runtime.Volatile${rc.name}Ref")).toMap
+ lazy val volatileRefTypeRef: Map[TypeRef, TypeRef] =
+ refTypeKeys.map(rc => rc -> ctx.requiredClassRef(s"scala.runtime.Volatile${rc.name}Ref")).toMap
- lazy val boxedRefClasses: collection.Set[Symbol] =
- refClassKeys.flatMap(k => Set(refClass(k), volatileRefClass(k)))
+ lazy val boxedRefTypeRefs: collection.Set[TypeRef] =
+ refTypeKeys.flatMap(k => Set(refTypeRef(k), volatileRefTypeRef(k)))
def wrapArrayMethodName(elemtp: Type): TermName = {
val cls = elemtp.classSymbol
@@ -622,8 +748,10 @@ class Definitions {
val BooleanEnc = 17
val UnitEnc = 19
- def isValueSubClass(cls1: Symbol, cls2: Symbol)(implicit ctx: Context) =
- valueClassEnc(cls2) % valueClassEnc(cls1) == 0
+ def isValueSubType(tref1: TypeRef, tref2: TypeRef)(implicit ctx: Context) = // ### Not stable!
+ valueTypeEnc(tref2) % valueTypeEnc(tref1) == 0
+ def isValueSubClass(sym1: Symbol, sym2: Symbol) =
+ isValueSubType(sym1.typeRef, sym2.typeRef)
// ----- Initialization ---------------------------------------------------