Skip to content

Commit 5cd8627

Browse files
committed
[WIP] Tenantive new HK scheme.
For the moment under newHK flag.
1 parent 6925cb0 commit 5cd8627

13 files changed

+402
-167
lines changed

src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ class Definitions {
668668
private var myLambdaTraits: Set[Symbol] = Set()
669669

670670
/** The set of HigherKindedXYZ traits encountered so far */
671-
def lambdaTraits: Set[Symbol] = myLambdaTraits
671+
def lambdaTraitsOBS: Set[Symbol] = myLambdaTraits
672672

673673
private var LambdaTraitForVariances = mutable.Map[List[Int], ClassSymbol]()
674674

@@ -689,7 +689,7 @@ class Definitions {
689689
* - for each positive or negative variance v_i there is a parent trait Pj which
690690
* is the same as LambdaXYZ except that it has `I` in i-th position.
691691
*/
692-
def LambdaTrait(vcs: List[Int]): ClassSymbol = {
692+
def LambdaTraitOBS(vcs: List[Int]): ClassSymbol = {
693693
assert(vcs.nonEmpty)
694694

695695
def varianceFlags(v: Int) = v match {
@@ -704,16 +704,16 @@ class Definitions {
704704
val paramDecls = newScope
705705
for (i <- 0 until vcs.length)
706706
newTypeParam(cls, tpnme.hkArg(i), varianceFlags(vcs(i)), paramDecls)
707-
newTypeField(cls, tpnme.hkApply, Covariant, paramDecls)
707+
newTypeField(cls, tpnme.hkApplyOBS, Covariant, paramDecls)
708708
val parentTraitRefs =
709709
for (i <- 0 until vcs.length if vcs(i) != 0)
710-
yield LambdaTrait(vcs.updated(i, 0)).typeRef
710+
yield LambdaTraitOBS(vcs.updated(i, 0)).typeRef
711711
denot.info = ClassInfo(
712712
ScalaPackageClass.thisType, cls, ObjectClass.typeRef :: parentTraitRefs.toList, paramDecls)
713713
}
714714
}
715715

716-
val traitName = tpnme.hkLambda(vcs)
716+
val traitName = tpnme.hkLambdaOBS(vcs)
717717

718718
def createTrait = {
719719
val cls = newClassSymbol(

src/dotty/tools/dotc/core/NameOps.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ object NameOps {
115115
def hkArgIndex: Int =
116116
name.drop(tpnme.hkArgPrefixLength).toString.toInt
117117

118-
def isLambdaTraitName(implicit ctx: Context): Boolean =
119-
name.isTypeName && name.startsWith(tpnme.hkLambdaPrefix)
118+
def isLambdaTraitNameOBS(implicit ctx: Context): Boolean =
119+
name.isTypeName && name.startsWith(tpnme.hkLambdaPrefixOBS)
120120

121-
def lambdaTraitVariances(implicit ctx: Context): List[Int] = {
122-
val vs = name.drop(tpnme.hkLambdaPrefix.length)
123-
vs.toList.map(c => tpnme.varianceSuffixes.indexOf(c) - 1)
121+
def lambdaTraitVariancesOBS(implicit ctx: Context): List[Int] = {
122+
val vs = name.drop(tpnme.hkLambdaPrefixOBS.length)
123+
vs.toList.map(c => tpnme.varianceSuffixesOBS.indexOf(c) - 1)
124124
}
125125

126126
/** If the name ends with $nn where nn are

src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,9 @@ object StdNames {
529529

530530
val synthSwitch: N = "$synthSwitch"
531531

532-
val hkApply: N = "$Apply"
532+
val hkApplyOBS: N = "$Apply"
533533
val hkArgPrefix: N = "$hk"
534-
val hkLambdaPrefix: N = "Lambda$"
534+
val hkLambdaPrefixOBS: N = "Lambda$"
535535
val hkArgPrefixHead: Char = hkArgPrefix.head
536536
val hkArgPrefixLength: Int = hkArgPrefix.length
537537

@@ -744,11 +744,11 @@ object StdNames {
744744
def syntheticTypeParamNames(num: Int): List[TypeName] =
745745
(0 until num).map(syntheticTypeParamName)(breakOut)
746746

747-
def hkLambda(vcs: List[Int]): TypeName = hkLambdaPrefix ++ vcs.map(varianceSuffix).mkString
747+
def hkLambdaOBS(vcs: List[Int]): TypeName = hkLambdaPrefixOBS ++ vcs.map(varianceSuffixOBS).mkString
748748
def hkArg(n: Int): TypeName = hkArgPrefix ++ n.toString
749749

750-
def varianceSuffix(v: Int): Char = varianceSuffixes.charAt(v + 1)
751-
val varianceSuffixes = "NIP"
750+
def varianceSuffixOBS(v: Int): Char = varianceSuffixesOBS.charAt(v + 1)
751+
val varianceSuffixesOBS = "NIP"
752752

753753
final val Conforms = encode("<:<")
754754
}

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@ object SymDenotations {
479479
name.decode == tpnme.REFINE_CLASS
480480

481481
/** is this symbol a trait representing a type lambda? */
482-
final def isLambdaTrait(implicit ctx: Context): Boolean =
483-
isClass && name.startsWith(tpnme.hkLambdaPrefix) && owner == defn.ScalaPackageClass
482+
final def isLambdaTraitOBS(implicit ctx: Context): Boolean =
483+
isClass && name.startsWith(tpnme.hkLambdaPrefixOBS) && owner == defn.ScalaPackageClass
484484

485485
/** Is this symbol a package object or its module class? */
486486
def isPackageObject(implicit ctx: Context): Boolean = {

0 commit comments

Comments
 (0)