KT-1189 StackOverflow in ide

This commit is contained in:
svtk
2012-02-03 13:14:28 +04:00
parent 6251b413a2
commit 34ee879094
2 changed files with 40 additions and 1 deletions
@@ -315,7 +315,7 @@ public class Pseudocode {
}
private void collectAllowedDeadInstructions(Instruction allowedDeadInstruction, Set<Instruction> instructionSet, Set<Instruction> 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()) {
@@ -0,0 +1,39 @@
//KT-1189 StackOverflow in ide
package kt1189
//+JDK
import java.util.concurrent.locks.ReentrantReadWriteLock
inline fun <erased T> 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) {}
}
}