Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addAssert/beforeTryWithResources.java
Tagir Valeev 1bb6f68f9b EnsureCodeBlockImpl: support try splitting; used in AddAssertStatementFix
Fixes IDEA-230023 Applying `Assert != null` in try-with-resources leads to uncompilable code

GitOrigin-RevId: 3dc141010420570c061849287adaeb0fccbcf1f4
2020-01-10 11:37:34 +00:00

29 lines
588 B
Java

// "Assert 'foo != null'" "true"
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
class X {
class Foo implements AutoCloseable {
public void close() {}
}
class Bar implements AutoCloseable {
Bar(@NotNull Foo foo) {}
public void close() {}
}
native @Nullable Foo getFoo();
void test() {
try (Foo foo = getFoo();
Bar bar = new Bar(f<caret>oo))
{
System.out.println(bar);
}
catch (Exception ex) {
ex.printStackTrace();
}
finally {
System.out.println("exiting");
}
}
}