aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Petrashko <dark@d-d.me>2014-12-12 17:42:45 +0100
committerDmitry Petrashko <dark@d-d.me>2014-12-12 17:42:45 +0100
commit1ce4c34c65ada5eb6c42fb72a03171467c08ee9b (patch)
tree38ab3f48395e25878fa22c98b13ed0b80909b763 /src
parent95ef88f79d4560dde676db9a2439c89a7f9c582a (diff)
parent0b82c376e771e493e4d595bf22b478790f7b5166 (diff)
downloaddotty-1ce4c34c65ada5eb6c42fb72a03171467c08ee9b.tar.gz
dotty-1ce4c34c65ada5eb6c42fb72a03171467c08ee9b.tar.bz2
dotty-1ce4c34c65ada5eb6c42fb72a03171467c08ee9b.zip
Merge pull request #265 from dotty-staging/fix/type-seqliteral
Pass right prototype to SeqLiteral elements.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala7
-rw-r--r--src/dotty/tools/dotc/transform/Erasure.scala4
2 files changed, 9 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index d00b018c8..874928fcc 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -367,8 +367,11 @@ class TypeApplications(val self: Type) extends AnyVal {
}
/** The element type of a sequence or array */
- def elemType(implicit ctx: Context): Type =
- firstBaseArgInfo(defn.SeqClass) orElse firstBaseArgInfo(defn.ArrayClass)
+ def elemType(implicit ctx: Context): Type = self match {
+ case defn.ArrayType(elemtp) => elemtp
+ case JavaArrayType(elemtp) => elemtp
+ case _ => firstBaseArgInfo(defn.SeqClass)
+ }
/** Given a type alias
*
diff --git a/src/dotty/tools/dotc/transform/Erasure.scala b/src/dotty/tools/dotc/transform/Erasure.scala
index 1cf0583dc..0c81b81d0 100644
--- a/src/dotty/tools/dotc/transform/Erasure.scala
+++ b/src/dotty/tools/dotc/transform/Erasure.scala
@@ -387,6 +387,10 @@ object Erasure extends TypeTestsCasts{
}
}
+ override def typedSeqLiteral(tree: untpd.SeqLiteral, pt: Type)(implicit ctx: Context) =
+ super.typedSeqLiteral(tree, erasure(tree.typeOpt))
+ // proto type of typed seq literal is original type; this makes elements be adapted to correct type.
+
override def typedValDef(vdef: untpd.ValDef, sym: Symbol)(implicit ctx: Context): ValDef =
super.typedValDef(untpd.cpy.ValDef(vdef)(
tpt = untpd.TypedSplice(TypeTree(sym.info).withPos(vdef.tpt.pos))), sym)