summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-05-01 14:01:18 +0000
committerMartin Odersky <odersky@gmail.com>2007-05-01 14:01:18 +0000
commit1cc06bb6976e2d211b6219cfa7cdfbaab193791e (patch)
treee9ea3c4a2eafd5f6cd57d69c4fde3684d8f54dbc /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent28a1d779aa8e720c051890efeb711bef72528573 (diff)
downloadscala-1cc06bb6976e2d211b6219cfa7cdfbaab193791e.tar.gz
scala-1cc06bb6976e2d211b6219cfa7cdfbaab193791e.tar.bz2
scala-1cc06bb6976e2d211b6219cfa7cdfbaab193791e.zip
more additions to checknull.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 6ef190be69..8044f2ce5d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2011,15 +2011,19 @@ trait Typers requires Analyzer {
case fun1: Tree =>
val fun2 = if (stableApplication) stabilizeFun(fun1, mode, pt) else fun1
if (util.Statistics.enabled) appcnt = appcnt + 1
- if (phase.id <= currentRun.typerPhase.id &&
- fun2.isInstanceOf[Select] &&
- !fun2.tpe.isInstanceOf[ImplicitMethodType] &&
- ((fun2.symbol eq null) || !fun2.symbol.isConstructor) &&
- (mode & (EXPRmode | SNDTRYmode)) == EXPRmode) {
- tryTypedApply(fun2, args)
- } else {
- doTypedApply(tree, fun2, args, mode, pt)
- }
+ val res =
+ if (phase.id <= currentRun.typerPhase.id &&
+ fun2.isInstanceOf[Select] &&
+ !fun2.tpe.isInstanceOf[ImplicitMethodType] &&
+ ((fun2.symbol eq null) || !fun2.symbol.isConstructor) &&
+ (mode & (EXPRmode | SNDTRYmode)) == EXPRmode) {
+ tryTypedApply(fun2, args)
+ } else {
+ doTypedApply(tree, fun2, args, mode, pt)
+ }
+ if (fun2.symbol == Array_apply) typed { atPos(tree.pos) { gen.mkCheckInit(res) } }
+ else res
+
case ex: TypeError =>
fun match {
case Select(qual, name)
@@ -2180,6 +2184,9 @@ trait Typers requires Analyzer {
}
val result = stabilize(checkAccessible(tree1, sym, qual.tpe, qual), qual.tpe, mode, pt)
if (sym.isCaseFactory && !phase.erasedTypes) checkStable(qual)
+ if (!global.phase.erasedTypes && settings.checknull.value &&
+ !(qual.tpe <:< NotNullClass.tpe) && !qual.tpe.isNotNull)
+ unit.warning(tree.pos, "potential null pointer dereference")
result
}
}