diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/ParallelMatching.scala | 3 | ||||
-rw-r--r-- | test/files/run/bug2241.scala | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 6dd1996074..315ce16562 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -788,7 +788,8 @@ trait ParallelMatching extends ast.TreeDSL { protected def lengthCheck(tree: Tree, len: Int, op: TreeFunction2) = { def compareOp = head.tpe member nme.lengthCompare // symbol for "lengthCompare" method - typer typed op((tree.duplicate DOT compareOp)(LIT(len)), ZERO) + // first ascertain lhs is not null: bug #2241 + typer typed((tree OBJ_!= NULL) AND op((tree.duplicate DOT compareOp)(LIT(len)), ZERO)) } // precondition for matching: sequence is exactly length of arg diff --git a/test/files/run/bug2241.scala b/test/files/run/bug2241.scala new file mode 100644 index 0000000000..58cc46fe69 --- /dev/null +++ b/test/files/run/bug2241.scala @@ -0,0 +1,7 @@ +object Test extends Application { + def f(a:Array[Int]) = a match { + case Array(1, _*) => "yes" + case _ => "no" + } + assert(f(null) == "no") +}
\ No newline at end of file |