|
| 1 | +package dotty.tools |
| 2 | +package dotc |
| 3 | +package core |
| 4 | + |
| 5 | +import Types._, Contexts._, Symbols._, Denotations._, SymDenotations._, StdNames._, Names._ |
| 6 | +import Flags._, Scopes._, Decorators._, NameOps._, util.Positions._ |
| 7 | +import pickling.UnPickler.ensureConstructor |
| 8 | +import scala.annotation.{ switch, meta } |
| 9 | +import scala.collection.{ mutable, immutable } |
| 10 | +import PartialFunction._ |
| 11 | +import collection.mutable |
| 12 | +import scala.reflect.api.{ Universe => ApiUniverse } |
| 13 | + |
| 14 | +object Definitions { |
| 15 | + val MaxFunctionArity, MaxTupleArity = 22 |
| 16 | +} |
| 17 | + |
| 18 | +/** A class defining symbols and types of standard definitions */ |
| 19 | +class Definitions { |
| 20 | + |
| 21 | + /** The HigherKinded trait corresponding to symbols `boundSyms` (which are assumed |
| 22 | + * to be the type parameters of a higher-kided type). This is a class symbol that |
| 23 | + * would be generated by the following schema. |
| 24 | + * |
| 25 | + * class LambdaXYZ extends Object with P1 with ... with Pn { |
| 26 | + * type v_1 $hk$Arg0; ...; type v_N $hk$ArgN; |
| 27 | + * type Apply |
| 28 | + * } |
| 29 | + * |
| 30 | + * Here: |
| 31 | + * |
| 32 | + * - v_i are the variances of the bound symbols (i.e. +, -, or empty). |
| 33 | + * - XYZ is a string of length N with one letter for each variant of a bound symbol, |
| 34 | + * using `P` (positive variance), `N` (negative variance), `I` (invariant). |
| 35 | + * - for each positive or negative variance v_i there is a parent trait Pj which |
| 36 | + * is the same as LambdaXYZ except that it has `I` in i-th position. |
| 37 | + */ |
| 38 | + def lambdaTrait(vcs: List[Int]): ClassSymbol = { |
| 39 | + |
| 40 | + val completer = new LazyType { |
| 41 | + def complete(denot: SymDenotation)(implicit ctx: Context): Unit = { |
| 42 | +// val cls = denot.asClass.classSymbol |
| 43 | +// val paramDecls = newScope |
| 44 | +// for (i <- 0 until vcs.length) |
| 45 | +// newTypeParam(cls, tpnme.lambdaArgName(i), varianceFlags(vcs(i)), paramDecls) |
| 46 | +// newTypeField(cls, tpnme.Apply, Covariant, paramDecls) |
| 47 | + val parentTraitRefs = |
| 48 | + for (i <- 0 until vcs.length if vcs(i) != 0) |
| 49 | + yield lambdaTrait(vcs.updated(i, 0)).typeRef |
| 50 | +// denot.info = ClassInfo( |
| 51 | +// ScalaPackageClass.thisType, cls, ObjectClass.typeRef :: parentTraitRefs.toList, paramDecls) |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | +// val traitName = tpnme.lambdaTraitName(vcs) |
| 56 | + |
| 57 | +// def createTrait = ??? |
| 58 | + |
| 59 | + ??? |
| 60 | + |
| 61 | + } |
| 62 | +} |
0 commit comments