diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-28 22:35:09 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-28 22:36:49 +0200 |
commit | aae91eddee1a90dc5312ce156b772f090001721f (patch) | |
tree | 6ce2de879d48939ba1914e8e450ff77f45c5c89c /src/dotty/tools/dotc/typer/TypeAssigner.scala | |
parent | f7d3f3b12e0f3f69954bfb9980134968abf541f5 (diff) | |
download | dotty-aae91eddee1a90dc5312ce156b772f090001721f.tar.gz dotty-aae91eddee1a90dc5312ce156b772f090001721f.tar.bz2 dotty-aae91eddee1a90dc5312ce156b772f090001721f.zip |
Fixes to erasure to make -Ycheck:all work.
Main change: Introduce JavaArrayType as a new type constructor
for Java erased array. Translate all methods of Array class during
erasure to primitive operations on arrays.
Some other small fixes for more localized problems.
Diffstat (limited to 'src/dotty/tools/dotc/typer/TypeAssigner.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/TypeAssigner.scala | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala index 4d996fd61..153e0d242 100644 --- a/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -5,7 +5,7 @@ package typer import core._ import ast._ import Scopes._, Contexts._, Constants._, Types._, Symbols._, Names._, Flags._, Decorators._ -import ErrorReporting._, Annotations._, Denotations._, SymDenotations._, StdNames._ +import ErrorReporting._, Annotations._, Denotations._, SymDenotations._, StdNames._, TypeErasure._ import util.Positions._ import config.Printers._ @@ -183,8 +183,21 @@ trait TypeAssigner { def assignType(tree: untpd.Ident, tp: Type)(implicit ctx: Context) = tree.withType(tp) - def assignType(tree: untpd.Select, qual: Tree)(implicit ctx: Context) = - tree.withType(accessibleSelectionType(tree, qual)) + def assignType(tree: untpd.Select, qual: Tree)(implicit ctx: Context): Select = { + def arrayElemType = { + val JavaArrayType(elemtp) = qual.tpe.widen + elemtp + } + val p = nme.primitive + val tp = tree.name match { + 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 _ => accessibleSelectionType(tree, qual) + } + tree.withType(tp) + } def assignType(tree: untpd.SelectFromTypeTree, qual: Tree)(implicit ctx: Context) = tree.withType(accessibleSelectionType(tree, qual)) |