diff options
author | Paul Phillips <paulp@improving.org> | 2009-02-10 23:49:22 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-02-10 23:49:22 +0000 |
commit | 347e682ba28c6cbec3169b450074b4f1d2fd4bd9 (patch) | |
tree | f7d2ef6368d04b55dc889eee0cd5dfc2b361e5ce /src | |
parent | 64af689e6659ab170826508f37720ee6e54386fa (diff) | |
download | scala-347e682ba28c6cbec3169b450074b4f1d2fd4bd9.tar.gz scala-347e682ba28c6cbec3169b450074b4f1d2fd4bd9.tar.bz2 scala-347e682ba28c6cbec3169b450074b4f1d2fd4bd9.zip |
Add recognition that null.isInstanceOf[T] is no...
Add recognition that null.isInstanceOf[T] is not a null dereference,
closing out bug #1356.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 20e5a9101e..c23853caed 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2873,11 +2873,15 @@ trait Typers { self: Analyzer => case SelectFromTypeTree(_, _) => copy.SelectFromTypeTree(tree, qual, name) } val result = stabilize(makeAccessible(tree1, sym, qual.tpe, qual), qual.tpe, mode, pt) - if (phase.id <= currentRun.typerPhase.id && - settings.Xchecknull.value && - !sym.isConstructor && - !(qual.tpe <:< NotNullClass.tpe) && !qual.tpe.isNotNull) + def isPotentialNullDeference() = { + phase.id <= currentRun.typerPhase.id && + !sym.isConstructor && + !(qual.tpe <:< NotNullClass.tpe) && !qual.tpe.isNotNull && + (result.symbol != Any_isInstanceOf) // null.isInstanceOf[T] is not a dereference; bug #1356 + } + if (settings.Xchecknull.value && isPotentialNullDeference) unit.warning(tree.pos, "potential null pointer dereference: "+tree) + result } } |