aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-12-02 10:56:49 +0100
committerMartin Odersky <odersky@gmail.com>2015-12-06 16:09:20 +0100
commit0fde4b4902f81f9a020dbf460925596a276ab328 (patch)
treea66dc2b849a871580f0861f610f48341a7ff9be8 /src
parentdf00eb195d86a3d1425029f2f2436029a757ee5d (diff)
downloaddotty-0fde4b4902f81f9a020dbf460925596a276ab328.tar.gz
dotty-0fde4b4902f81f9a020dbf460925596a276ab328.tar.bz2
dotty-0fde4b4902f81f9a020dbf460925596a276ab328.zip
Change hk naming scheme
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala10
-rw-r--r--src/dotty/tools/dotc/core/NameOps.scala15
-rw-r--r--src/dotty/tools/dotc/core/StdNames.scala20
3 files changed, 24 insertions, 21 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 4556dd9d5..650cfe79c 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -642,9 +642,9 @@ class Definitions {
* to be the type parameters of a higher-kided type). This is a class symbol that
* would be generated by the following schema.
*
- * class LambdaXYZ extends Object with P1 with ... with Pn {
- * type v_1 $hk$Arg0; ...; type v_N $hk$ArgN;
- * type Apply
+ * trait LambdaXYZ extends Object with P1 with ... with Pn {
+ * type v_1 hk$0; ...; type v_N hk$N;
+ * type +$Apply
* }
*
* Here:
@@ -669,7 +669,7 @@ class Definitions {
val cls = denot.asClass.classSymbol
val paramDecls = newScope
for (i <- 0 until vcs.length)
- newTypeParam(cls, tpnme.LambdaArgName(i), varianceFlags(vcs(i)), paramDecls)
+ 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)
@@ -679,7 +679,7 @@ class Definitions {
}
}
- val traitName = tpnme.LambdaTraitName(vcs)
+ val traitName = tpnme.hkLambda(vcs)
def createTrait = {
val cls = newClassSymbol(
diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala
index 1a2646347..7dbd492b4 100644
--- a/src/dotty/tools/dotc/core/NameOps.scala
+++ b/src/dotty/tools/dotc/core/NameOps.scala
@@ -99,19 +99,22 @@ object NameOps {
}
/** Is this the name of a higher-kinded type parameter of a Lambda? */
- def isLambdaArgName =
+ def isHkArgName =
name.length > 0 &&
- name.head == tpnme.LAMBDA_ARG_PREFIXhead &&
- name.startsWith(tpnme.LAMBDA_ARG_PREFIX) && {
- val digits = name.drop(tpnme.LAMBDA_ARG_PREFIX.length)
+ name.head == tpnme.hkArgPrefixHead &&
+ name.startsWith(tpnme.hkArgPrefix) && {
+ val digits = name.drop(tpnme.hkArgPrefixLength)
digits.length <= 4 && digits.forall(_.isDigit)
}
/** The index of the higher-kinded type parameter with this name.
* Pre: isLambdaArgName.
*/
- def LambdaArgIndex: Int =
- name.drop(tpnme.LAMBDA_ARG_PREFIX.length).toString.toInt
+ def hkArgIndex: Int =
+ name.drop(tpnme.hkArgPrefixLength).toString.toInt
+
+ def isLambdaTraitName(implicit ctx: Context): Boolean =
+ name.startsWith(tpnme.hkLambdaPrefix)
/** If the name ends with $nn where nn are
* all digits, strip the $ and the digits.
diff --git a/src/dotty/tools/dotc/core/StdNames.scala b/src/dotty/tools/dotc/core/StdNames.scala
index e8cddd3d4..e2add1a52 100644
--- a/src/dotty/tools/dotc/core/StdNames.scala
+++ b/src/dotty/tools/dotc/core/StdNames.scala
@@ -173,8 +173,6 @@ object StdNames {
final val WILDCARD_STAR: N = "_*"
final val REIFY_TREECREATOR_PREFIX: N = "$treecreator"
final val REIFY_TYPECREATOR_PREFIX: N = "$typecreator"
- final val LAMBDA_ARG_PREFIX: N = "hk$"
- final val LAMBDA_ARG_PREFIXhead: Char = LAMBDA_ARG_PREFIX.head
final val AbstractFunction: N = "AbstractFunction"
final val Any: N = "Any"
@@ -314,7 +312,6 @@ object StdNames {
val AnnotatedType: N = "AnnotatedType"
val AppliedTypeTree: N = "AppliedTypeTree"
- val hkApply: N = "$apply"
val ArrayAnnotArg: N = "ArrayAnnotArg"
val Constant: N = "Constant"
val ConstantType: N = "ConstantType"
@@ -322,7 +319,6 @@ object StdNames {
val Flag : N = "Flag"
val Ident: N = "Ident"
val Import: N = "Import"
- val LambdaPrefix: N = "Lambda$"
val Literal: N = "Literal"
val LiteralAnnotArg: N = "LiteralAnnotArg"
val Modifiers: N = "Modifiers"
@@ -530,9 +526,14 @@ object StdNames {
val nothingRuntimeClass: N = "scala.runtime.Nothing$"
val nullRuntimeClass: N = "scala.runtime.Null$"
-
val synthSwitch: N = "$synthSwitch"
+ val hkApply: N = "$Apply"
+ val hkArgPrefix: N = "$hk"
+ val hkLambdaPrefix: N = "Lambda$"
+ val hkArgPrefixHead: Char = hkArgPrefix.head
+ val hkArgPrefixLength: Int = hkArgPrefix.length
+
// unencoded operators
object raw {
final val AMP : N = "&"
@@ -742,14 +743,13 @@ object StdNames {
def syntheticTypeParamNames(num: Int): List[TypeName] =
(0 until num).map(syntheticTypeParamName)(breakOut)
- def LambdaTraitName(vcs: List[Int]): TypeName = LambdaPrefix ++ vcs.map(varianceSuffix).mkString
- def LambdaArgName(n: Int) = LAMBDA_ARG_PREFIX ++ n.toString
-
- final val Conforms = encode("<:<")
+ def hkLambda(vcs: List[Int]): TypeName = hkLambdaPrefix ++ vcs.map(varianceSuffix).mkString
+ def hkArg(n: Int): TypeName = hkArgPrefix ++ n.toString
def varianceSuffix(v: Int): Char = varianceSuffixes.charAt(v + 1)
-
val varianceSuffixes = "NIP"
+
+ final val Conforms = encode("<:<")
}
abstract class JavaNames[N <: Name] extends DefinedNames[N] {