diff options
Diffstat (limited to 'src/dotty/tools/dotc/core/Definitions.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 73 |
1 files changed, 4 insertions, 69 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index 5cb373cfd..8d020a428 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -86,17 +86,17 @@ class Definitions { } private def newPolyMethod(cls: ClassSymbol, name: TermName, typeParamCount: Int, - resultTypeFn: PolyType => Type, flags: FlagSet = EmptyFlags) = { + resultTypeFn: GenericType => Type, flags: FlagSet = EmptyFlags) = { val tparamNames = tpnme.syntheticTypeParamNames(typeParamCount) val tparamBounds = tparamNames map (_ => TypeBounds.empty) val ptype = PolyType(tparamNames)(_ => tparamBounds, resultTypeFn) newMethod(cls, name, ptype, flags) } - private def newT1ParameterlessMethod(cls: ClassSymbol, name: TermName, resultTypeFn: PolyType => Type, flags: FlagSet) = + private def newT1ParameterlessMethod(cls: ClassSymbol, name: TermName, resultTypeFn: GenericType => Type, flags: FlagSet) = newPolyMethod(cls, name, 1, resultTypeFn, flags) - private def newT1EmptyParamsMethod(cls: ClassSymbol, name: TermName, resultTypeFn: PolyType => Type, flags: FlagSet) = + private def newT1EmptyParamsMethod(cls: ClassSymbol, name: TermName, resultTypeFn: GenericType => Type, flags: FlagSet) = newPolyMethod(cls, name, 1, pt => MethodType(Nil, resultTypeFn(pt)), flags) private def mkArityArray(name: String, arity: Int, countFrom: Int): Array[TypeRef] = { @@ -167,7 +167,7 @@ class Definitions { lazy val Any_hashCode = newMethod(AnyClass, nme.hashCode_, MethodType(Nil, IntType)) lazy val Any_toString = newMethod(AnyClass, nme.toString_, MethodType(Nil, StringType)) lazy val Any_## = newMethod(AnyClass, nme.HASHHASH, ExprType(IntType), Final) - lazy val Any_getClass = newMethod(AnyClass, nme.getClass_, MethodType(Nil, ClassClass.typeRef), Final) + lazy val Any_getClass = newMethod(AnyClass, nme.getClass_, MethodType(Nil, ClassClass.typeRef.appliedTo(TypeBounds.empty)), Final) lazy val Any_isInstanceOf = newT1ParameterlessMethod(AnyClass, nme.isInstanceOf_, _ => BooleanType, Final) lazy val Any_asInstanceOf = newT1ParameterlessMethod(AnyClass, nme.asInstanceOf_, PolyParam(_, 0), Final) @@ -663,71 +663,6 @@ class Definitions { def functionArity(tp: Type)(implicit ctx: Context) = tp.dealias.argInfos.length - 1 - // ----- LambdaXYZ traits ------------------------------------------ - - private var myLambdaTraits: Set[Symbol] = Set() - - /** The set of HigherKindedXYZ traits encountered so far */ - def lambdaTraits: Set[Symbol] = myLambdaTraits - - private var LambdaTraitForVariances = mutable.Map[List[Int], ClassSymbol]() - - /** The HigherKinded trait corresponding to symbols `boundSyms` (which are assumed - * to be the type parameters of a higher-kided type). This is a class symbol that - * would be generated by the following schema. - * - * trait LambdaXYZ extends Object with P1 with ... with Pn { - * type v_1 hk$0; ...; type v_N hk$N; - * type +$Apply - * } - * - * Here: - * - * - v_i are the variances of the bound symbols (i.e. +, -, or empty). - * - XYZ is a string of length N with one letter for each variant of a bound symbol, - * using `P` (positive variance), `N` (negative variance), `I` (invariant). - * - for each positive or negative variance v_i there is a parent trait Pj which - * is the same as LambdaXYZ except that it has `I` in i-th position. - */ - def LambdaTrait(vcs: List[Int]): ClassSymbol = { - assert(vcs.nonEmpty) - - def varianceFlags(v: Int) = v match { - case -1 => Contravariant - case 0 => EmptyFlags - case 1 => Covariant - } - - val completer = new LazyType { - def complete(denot: SymDenotation)(implicit ctx: Context): Unit = { - val cls = denot.asClass.classSymbol - val paramDecls = newScope - for (i <- 0 until vcs.length) - newTypeParam(cls, tpnme.hkArg(i), varianceFlags(vcs(i)), paramDecls) - newTypeField(cls, tpnme.hkApply, Covariant, paramDecls) - val parentTraitRefs = - for (i <- 0 until vcs.length if vcs(i) != 0) - yield LambdaTrait(vcs.updated(i, 0)).typeRef - denot.info = ClassInfo( - ScalaPackageClass.thisType, cls, ObjectClass.typeRef :: parentTraitRefs.toList, paramDecls) - } - } - - val traitName = tpnme.hkLambda(vcs) - - def createTrait = { - val cls = newClassSymbol( - ScalaPackageClass, - traitName, - PureInterfaceCreationFlags | Synthetic, - completer) - myLambdaTraits += cls - cls - } - - LambdaTraitForVariances.getOrElseUpdate(vcs, createTrait) - } - // ----- primitive value class machinery ------------------------------------------ /** This class would also be obviated by the implicit function type design */ |