aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala19
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala5
2 files changed, 22 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 26886ed1d..af2b694f5 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -648,6 +648,10 @@ object Types {
Set((Set(), Set()))
}
+ /** The element type of a sequence or array */
+ def elemType(implicit ctx: Context): Type =
+ firstBaseTypeArg(defn.SeqClass) orElse firstBaseTypeArg(defn.ArrayClass)
+
// ----- Substitutions -----------------------------------------------------
/** Substitute all types that refer in their symbol attribute to
@@ -742,6 +746,21 @@ object Types {
else TypeAlias(this)
}
+ /** The type arguments of the base type instance wrt `base` of this type */
+ final def baseTypeArgs(base: Symbol)(implicit ctx: Context): List[Type] =
+ if (this <:< base.symRef)
+ base.typeParams map (param => member(param.name).info.argType(param))
+ else
+ Nil
+
+ /** The first type argument of the base type instance wrt `base` of this type */
+ final def firstBaseTypeArg(base: Symbol)(implicit ctx: Context): Type = base.typeParams match {
+ case param :: _ if this <:< base.symRef =>
+ member(param.name).info.argType(param)
+ case _ =>
+ NoType
+ }
+
/** If this is an encoding of a (partially) applied type, return its arguments,
* otherwise return Nil
*/
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 3b9ca7ba5..70798ad8a 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -780,7 +780,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
val end = readNat() + readIndex
// array elements are trees representing instances of scala.annotation.Annotation
SeqLiteral(
- TypeTree(defn.AnnotationClass.typeConstructor),
+ defn.SeqType.appliedTo(defn.AnnotationClass.typeConstructor :: Nil),
until(end, () => readClassfileAnnotArg(readNat())))
}
@@ -983,7 +983,8 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot:
case ARRAYVALUEtree =>
val elemtpt = readTreeRef()
val trees = until(end, readTreeRef)
- SeqLiteral(elemtpt, trees)
+ SeqLiteral(defn.SeqType.appliedTo(elemtpt.tpe :: Nil), trees)
+ // note can't deal with trees passed to Java methods as arrays here
case FUNCTIONtree =>
setSym()