aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Definitions.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-03-26 18:45:03 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-03-29 09:10:10 +0100
commit6a35e3018081a1a8dd90a3e24200223fdbfdce7f (patch)
tree9426d5c581a160ba4def17600a11b71ff45db052 /src/dotty/tools/dotc/core/Definitions.scala
parent6db08e9457a8bcb093b8c8e79109f7ef419729c2 (diff)
downloaddotty-6a35e3018081a1a8dd90a3e24200223fdbfdce7f.tar.gz
dotty-6a35e3018081a1a8dd90a3e24200223fdbfdce7f.tar.bz2
dotty-6a35e3018081a1a8dd90a3e24200223fdbfdce7f.zip
Reworked erasure denotation transformer
Now works for all combinations of java/scala sue ErasedValueClass/go directly to underlying type constructors/others wildcards ok/not Signatures had to be refined as well, because the signature depends on whether a type comes form Java or Scala (handling of intersections is different). Also, replaced splitArray method in TypeApplication by extractors for single- and multi-dimensional array types in definitions.
Diffstat (limited to 'src/dotty/tools/dotc/core/Definitions.scala')
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 0ec770149..af88a04b9 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -170,6 +170,9 @@ class Definitions {
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_and = BooleanClass.requiredMethod(nme.ZAND)
+
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)
@@ -192,7 +195,7 @@ class Definitions {
lazy val EqualsPatternClass = specialPolyClass(tpnme.EQUALS_PATTERN, EmptyFlags, AnyType)
lazy val RepeatedParamClass = specialPolyClass(tpnme.REPEATED_PARAM_CLASS, Covariant, SeqType)
- lazy val JavaRepeatedParamClass = specialPolyClass(tpnme.JAVA_REPEATED_PARAM_CLASS, Covariant, ArrayType)
+ lazy val JavaRepeatedParamClass = specialPolyClass(tpnme.JAVA_REPEATED_PARAM_CLASS, Covariant, ArrayClass.typeRef)
// fundamental classes
lazy val StringClass = ctx.requiredClass("java.lang.String")
@@ -250,8 +253,7 @@ class Definitions {
def NothingType: Type = NothingClass.typeRef
def NullType: Type = NullClass.typeRef
def SeqType: Type = SeqClass.typeRef
- def ArrayType: Type = ArrayClass.typeRef
- def ObjectArrayType = ArrayType.appliedTo(ObjectType)
+ def ObjectArrayType = ArrayType(ObjectType)
def UnitType: Type = UnitClass.typeRef
def BooleanType: Type = BooleanClass.typeRef
@@ -298,6 +300,29 @@ class Definitions {
}
}
+ object ArrayType {
+ def apply(elem: Type) =
+ ArrayClass.typeRef.appliedTo(elem :: Nil)
+ def unapply(tp: Type) = tp.dealias match {
+ case at: RefinedType if (at isRef ArrayClass) && at.argInfos.length == 1 => Some(at.argInfos.head)
+ case _ => None
+ }
+ }
+
+ object MultiArrayType {
+ def apply(elem: Type, ndims: Int): Type =
+ if (ndims == 0) elem else ArrayType(apply(elem, ndims - 1))
+ def unapply(tp: Type): Option[(Type, Int)] = tp match {
+ case ArrayType(elemtp) =>
+ elemtp match {
+ case MultiArrayType(finalElemTp, n) => Some(finalElemTp, n + 1)
+ case _ => Some(elemtp, 1)
+ }
+ case _ =>
+ None
+ }
+ }
+
// ----- Symbol sets ---------------------------------------------------
lazy val FunctionClass = mkArityArray("Function", MaxFunctionArity, 0)
@@ -390,7 +415,7 @@ class Definitions {
hkTraitOfArity.getOrElseUpdate(vcs, createTrait)
}
- // ----- Value class machinery ------------------------------------------
+ // ----- primitive value class machinery ------------------------------------------
lazy val ScalaValueClasses: collection.Set[Symbol] = Set(
UnitClass,