diff options
author | Dmitry Petrashko <dark@d-d.me> | 2015-04-28 09:19:07 +0200 |
---|---|---|
committer | Dmitry Petrashko <dark@d-d.me> | 2015-04-28 09:19:07 +0200 |
commit | d55b7190fbba2794a020347241e838eeeca978da (patch) | |
tree | a99861ebbf7ae48a42fd2c847969558b2bf0e3bf /src | |
parent | 9ba09d426dcc3fa0e0fb8422df9722bc95b1d611 (diff) | |
parent | 96d75318959156c71628d8878fc5bcf0185821b4 (diff) | |
download | dotty-d55b7190fbba2794a020347241e838eeeca978da.tar.gz dotty-d55b7190fbba2794a020347241e838eeeca978da.tar.bz2 dotty-d55b7190fbba2794a020347241e838eeeca978da.zip |
Merge pull request #501 from smarter/fix/arrayClone
TypeAssigner: fix return type of clone() for arrays
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/typer/TypeAssigner.scala | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala index 2ec510a3d..d3baad848 100644 --- a/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -210,7 +210,13 @@ 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 nme.clone_ if qualType.isInstanceOf[JavaArrayType] => MethodType(Nil, qualType) + + // Note that we do not need to handle calls to Array[T]#clone() specially: + // The JLS section 10.7 says "The return type of the clone method of an array type + // T[] is T[]", but the actual return type at the bytecode level is Object which + // is casted to T[] by javac. Since the return type of Array[T]#clone() is Array[T], + // this is exactly what Erasure will do. + case _ => accessibleSelectionType(tree, qual) } tree.withType(tp) |