diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-09-29 12:38:35 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-10-11 06:39:09 +0200 |
commit | df28f8a6d254384ca13473f0261d8f561499b5f7 (patch) | |
tree | c8bd9a26c59c35f80f0d21a51741f8281d7c5b57 /src/dotty/tools/dotc/typer/RefChecks.scala | |
parent | 7b407e59bebbb04e8328b33b01fa15b77c28ccb5 (diff) | |
download | dotty-df28f8a6d254384ca13473f0261d8f561499b5f7.tar.gz dotty-df28f8a6d254384ca13473f0261d8f561499b5f7.tar.bz2 dotty-df28f8a6d254384ca13473f0261d8f561499b5f7.zip |
Move check for casting a primitive to a non-primitive type from erasure to refchecks
Diffstat (limited to 'src/dotty/tools/dotc/typer/RefChecks.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/RefChecks.scala | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/RefChecks.scala b/src/dotty/tools/dotc/typer/RefChecks.scala index 2b81af5cb..f45966741 100644 --- a/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/src/dotty/tools/dotc/typer/RefChecks.scala @@ -814,6 +814,22 @@ class RefChecks extends MiniPhase with SymTransformer { thisTransformer => currentLevel.enterReference(tree.tpe.typeSymbol, tree.pos) tree } + + override def transformTypeApply(tree: tpd.TypeApply)(implicit ctx: Context, info: TransformerInfo): tpd.Tree = { + tree.fun match { + case fun@Select(qual, selector) => + val sym = tree.symbol + + if (sym == defn.Any_isInstanceOf) { + val argType = tree.args.head.tpe + val qualCls = qual.tpe.widen.classSymbol + val argCls = argType.classSymbol + if (qualCls.isPrimitiveValueClass && !argCls.isPrimitiveValueClass) ctx.error("isInstanceOf cannot test if value types are references", tree.pos) + } + case _ => + } + tree + } } } |