aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-11-28 22:10:37 +0100
committerMartin Odersky <odersky@gmail.com>2014-11-28 22:12:51 +0100
commit91c61e4694097971b9a0c139048b7239d0f05588 (patch)
tree6836b169dce43f32e588f60bb16d14dba850b254 /src/dotty/tools/dotc/typer
parentb18ce863f5f2444a5a00ccc9d55c4ee12115c467 (diff)
downloaddotty-91c61e4694097971b9a0c139048b7239d0f05588.tar.gz
dotty-91c61e4694097971b9a0c139048b7239d0f05588.tar.bz2
dotty-91c61e4694097971b9a0c139048b7239d0f05588.zip
Previous scheme was buggy; leaked Array types to backend.
Now: All new Array[T] methods are translated to calls of the form dotty.Arrays.newXYZArray ...
Diffstat (limited to 'src/dotty/tools/dotc/typer')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala11
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala1
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala3
3 files changed, 12 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index ba770cf2c..fe45beb04 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -596,7 +596,16 @@ trait Applications extends Compatibility { self: Typer =>
checkBounds(typedArgs, pt)
case _ =>
}
- assignType(cpy.TypeApply(tree)(typedFn, typedArgs), typedFn, typedArgs)
+ convertNewArray(
+ assignType(cpy.TypeApply(tree)(typedFn, typedArgs), typedFn, typedArgs))
+ }
+
+ /** Rewrite `new Array[T]` trees to calls of newXYZArray methods. */
+ def convertNewArray(tree: Tree)(implicit ctx: Context): Tree = tree match {
+ case TypeApply(tycon, targs) if tycon.symbol == defn.ArrayConstructor =>
+ newArray(targs.head, tree.pos)
+ case _ =>
+ tree
}
def typedUnApply(tree: untpd.Apply, selType: Type)(implicit ctx: Context): Tree = track("typedUnApply") {
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index 6c5e48edb..41dc3c3f7 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -208,7 +208,6 @@ trait TypeAssigner {
case p.arrayApply => MethodType(defn.IntType :: Nil, arrayElemType)
case p.arrayUpdate => MethodType(defn.IntType :: arrayElemType :: Nil, defn.UnitType)
case p.arrayLength => MethodType(Nil, defn.IntType)
- case p.arrayConstructor => MethodType(defn.IntType :: Nil, qualType)
case nme.clone_ if qualType.isInstanceOf[JavaArrayType] => MethodType(Nil, qualType)
case _ => accessibleSelectionType(tree, qual)
}
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 7d4e8d132..f6027165b 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1326,7 +1326,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
if (pt.isInstanceOf[PolyProto]) tree
else {
val (_, tvars) = constrained(poly, tree)
- adaptInterpolated(tree appliedToTypes tvars, pt, original)
+ convertNewArray(
+ adaptInterpolated(tree.appliedToTypes(tvars), pt, original))
}
case wtp =>
pt match {