diff options
author | Martin Odersky <odersky@gmail.com> | 2014-09-12 02:28:36 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-09-12 02:28:59 +0200 |
commit | bb5b049076ca733ea42e528ecef81de438a15b19 (patch) | |
tree | 3fcdf1c91c476725355e768d86c04593089d9922 /src/dotty | |
parent | f05dafedf2c63bb4aa1830b600416f80c984dce6 (diff) | |
download | dotty-bb5b049076ca733ea42e528ecef81de438a15b19.tar.gz dotty-bb5b049076ca733ea42e528ecef81de438a15b19.tar.bz2 dotty-bb5b049076ca733ea42e528ecef81de438a15b19.zip |
Fix handling of Array#clone in Erasure
Treat clone like the other primitive array operations, ensure it
returns a JavaArray.
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/core/NameOps.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/Erasure.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/TypeAssigner.scala | 6 |
3 files changed, 5 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala index 74673235a..b18f708ed 100644 --- a/src/dotty/tools/dotc/core/NameOps.scala +++ b/src/dotty/tools/dotc/core/NameOps.scala @@ -201,6 +201,7 @@ object NameOps { case nme.apply => nme.primitive.arrayApply case nme.length => nme.primitive.arrayLength case nme.update => nme.primitive.arrayUpdate + case nme.clone_ => nme.clone_ case nme.CONSTRUCTOR => nme.primitive.arrayConstructor } diff --git a/src/dotty/tools/dotc/transform/Erasure.scala b/src/dotty/tools/dotc/transform/Erasure.scala index b02b50587..d95d1379e 100644 --- a/src/dotty/tools/dotc/transform/Erasure.scala +++ b/src/dotty/tools/dotc/transform/Erasure.scala @@ -281,8 +281,6 @@ object Erasure { runtimeCallWithProtoArgs(tree.name.genericArrayOp, pt, qual) else if (!(qual.tpe <:< erasedPre)) selectArrayMember(cast(qual, erasedPre), erasedPre) - else if (sym == defn.Array_clone) - untpd.cpy.Select(tree)(qual, tree.name).withType(defn.Object_clone.termRef) else assignType(untpd.cpy.Select(tree)(qual, tree.name.primitiveArrayOp), qual) diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala index 153e0d242..c23b820e4 100644 --- a/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -184,8 +184,9 @@ trait TypeAssigner { tree.withType(tp) def assignType(tree: untpd.Select, qual: Tree)(implicit ctx: Context): Select = { + def qualType = qual.tpe.widen def arrayElemType = { - val JavaArrayType(elemtp) = qual.tpe.widen + val JavaArrayType(elemtp) = qualType elemtp } val p = nme.primitive @@ -193,7 +194,8 @@ 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, qual.tpe) + case p.arrayConstructor => MethodType(defn.IntType :: Nil, qualType) + case nme.clone_ if qualType.isInstanceOf[JavaArrayType] => MethodType(Nil, qualType) case _ => accessibleSelectionType(tree, qual) } tree.withType(tp) |