Skip to content

Commit c3d6157

Browse files
committed
Revert "SI-8601 Don't treat newarray as dead code"
This reverts commit 70b912a.
1 parent 0e87b12 commit c3d6157

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ abstract class DeadCodeElimination extends SubComponent {
169169

170170
case RETURN(_) | JUMP(_) | CJUMP(_, _, _, _) | CZJUMP(_, _, _, _) | STORE_FIELD(_, _) | LOAD_FIELD(_, _) | // Why LOAD_FIELD? It can NPE!
171171
THROW(_) | LOAD_ARRAY_ITEM(_) | STORE_ARRAY_ITEM(_) | SCOPE_ENTER(_) | SCOPE_EXIT(_) | STORE_THIS(_) |
172-
LOAD_EXCEPTION(_) | SWITCH(_, _) | MONITOR_ENTER() | MONITOR_EXIT() | CHECK_CAST(_) | CREATE_ARRAY(_, _) =>
172+
LOAD_EXCEPTION(_) | SWITCH(_, _) | MONITOR_ENTER() | MONITOR_EXIT() | CHECK_CAST(_) =>
173173
moveToWorkList()
174174

175175
case CALL_METHOD(m1, _) if isSideEffecting(m1) =>

test/files/run/t8601b.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
object Test {
22
def len(x: Array[String]): Unit = x.length
33
def load(x: Array[String]): Unit = x(0)
4-
def newarray(i: Int): Unit = new Array[Int](i)
54

65
def check(x: => Any) = try { x; sys.error("failed to throw NPE!") } catch { case _: NullPointerException => }
7-
def checkNegSize(x: => Any) = try { x; sys.error("failed to throw NegativeArraySizeException!") } catch { case _: NegativeArraySizeException => }
86

97
def main(args: Array[String]) {
108
check(len(null)) // bug: did not NPE
119
check(load(null))
12-
checkNegSize(newarray(-1))
1310
}
1411
}

0 commit comments

Comments
 (0)