diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode.java index b4565b36517..659504f0578 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode.java @@ -315,7 +315,7 @@ public class Pseudocode { } private void collectAllowedDeadInstructions(Instruction allowedDeadInstruction, Set instructionSet, Set stopAllowDeadInstructions) { - if (stopAllowDeadInstructions.contains(allowedDeadInstruction)) return; + if (instructionSet.contains(allowedDeadInstruction) || stopAllowDeadInstructions.contains(allowedDeadInstruction)) return; if (((InstructionImpl)allowedDeadInstruction).isDead()) { instructionSet.add(allowedDeadInstruction); for (Instruction instruction : allowedDeadInstruction.getNextInstructions()) { diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt1189.jet b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt1189.jet new file mode 100644 index 00000000000..c3fef37b9cc --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt1189.jet @@ -0,0 +1,39 @@ +//KT-1189 StackOverflow in ide +package kt1189 +//+JDK +import java.util.concurrent.locks.ReentrantReadWriteLock + +inline fun ReentrantReadWriteLock.write(action: ()->T) : T { + val rl = readLock().sure() + var readCount = 0 + val writeCount = getWriteHoldCount() + if(writeCount == 0) { + readCount = getReadHoldCount() + if(readCount > 0) + for(i in 1..readCount) + rl.unlock() + } + + val wl = writeLock().sure() + wl.lock() + try { + return action() + } + finally { + if(readCount > 0) { + for(j in 1..readCount) { + rl.lock() + } + } + wl.unlock() + } +} + +fun foo() { + try { + return + } + finally { + for (i in 1..10) {} + } +} \ No newline at end of file