diff options
author | Paul Phillips <paulp@improving.org> | 2011-01-15 23:21:50 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-01-15 23:21:50 +0000 |
commit | e89b53d7e1f0ec376bd237fbaa8d7a19928e020e (patch) | |
tree | 7f9695a5533cc0c3cd1f828e15b87cb4b1b59707 /src/compiler | |
parent | 866801385f81417a2ac33916280df918e4bd5b3b (diff) | |
download | scala-e89b53d7e1f0ec376bd237fbaa8d7a19928e020e.tar.gz scala-e89b53d7e1f0ec376bd237fbaa8d7a19928e020e.tar.bz2 scala-e89b53d7e1f0ec376bd237fbaa8d7a19928e020e.zip |
This outlaws explicit isInstanceOf tests on val...
This outlaws explicit isInstanceOf tests on value types, which are
nonsense in any case, as long threatened in ticket #1872. Closes #1872,
review by rytz.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index fa5f899da0..5de5bd9a99 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -983,9 +983,12 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast. tree } // todo: also handle the case where the singleton type is buried in a compound - else if (fn.symbol == Any_isInstanceOf) + else if (fn.symbol == Any_isInstanceOf) { fn match { case TypeApply(sel @ Select(qual, name), List(targ)) => + if (qual.tpe != null && isValueClass(qual.tpe.typeSymbol) && targ.tpe != null && targ.tpe <:< AnyRefClass.tpe) + unit.error(sel.pos, "isInstanceOf cannot test if value types are references.") + def mkIsInstanceOf(q: () => Tree)(tp: Type): Tree = Apply( TypeApply( @@ -1009,6 +1012,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast. } case _ => tree } + } else { def doDynamic(fn: Tree, qual: Tree): Tree = { if (fn.symbol.owner.isRefinementClass && fn.symbol.allOverriddenSymbols.isEmpty) |