Temporarily prohibit non-local returns for some stdlib functions
Make InlineUtil work with FQ names, not descriptors #KT-5496 Fixed #KT-5497 Fixed
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
import java.io.Closeable
|
||||
import java.util.concurrent.locks.Lock
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock
|
||||
import kotlin.concurrent.*
|
||||
|
||||
// Non-local returns for these functions are temporarily disabled because they contain try-finally blocks and
|
||||
// the compiler doesn't correctly include the "finally" section into the inlined result.
|
||||
// Once the compiler is fixed (KT-5506), non-local returns can be re-allowed for these functions
|
||||
|
||||
fun testSynchronized(): Int {
|
||||
synchronized("") {
|
||||
<!RETURN_NOT_ALLOWED!>return 1<!>
|
||||
}
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
|
||||
fun testUse(f: Closeable): Int {
|
||||
f.use {
|
||||
<!RETURN_NOT_ALLOWED!>return 2<!>
|
||||
}
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
|
||||
fun testWithLock(l: Lock): Int {
|
||||
l.withLock {
|
||||
<!RETURN_NOT_ALLOWED!>return 3<!>
|
||||
}
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
|
||||
fun testRead(l: ReentrantReadWriteLock): Int {
|
||||
l.read {
|
||||
<!RETURN_NOT_ALLOWED!>return 4<!>
|
||||
}
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
|
||||
fun testWrite(l: ReentrantReadWriteLock): Int {
|
||||
l.write {
|
||||
<!RETURN_NOT_ALLOWED!>return 5<!>
|
||||
}
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
+15
-1
@@ -31,7 +31,7 @@ import org.jetbrains.jet.checkers.AbstractJetDiagnosticsTestWithStdLib;
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib")
|
||||
@InnerTestClasses({JetDiagnosticsTestWithStdLibGenerated.Annotations.class, JetDiagnosticsTestWithStdLibGenerated.CallableReference.class, JetDiagnosticsTestWithStdLibGenerated.DuplicateJvmSignature.class, JetDiagnosticsTestWithStdLibGenerated.FunctionLiterals.class, JetDiagnosticsTestWithStdLibGenerated.KotlinSignature.class})
|
||||
@InnerTestClasses({JetDiagnosticsTestWithStdLibGenerated.Annotations.class, JetDiagnosticsTestWithStdLibGenerated.CallableReference.class, JetDiagnosticsTestWithStdLibGenerated.DuplicateJvmSignature.class, JetDiagnosticsTestWithStdLibGenerated.FunctionLiterals.class, JetDiagnosticsTestWithStdLibGenerated.KotlinSignature.class, JetDiagnosticsTestWithStdLibGenerated.NonLocalReturns.class})
|
||||
public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnosticsTestWithStdLib {
|
||||
public void testAllFilesPresentInTestsWithStdLib() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/testsWithStdLib"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
@@ -495,6 +495,19 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/nonLocalReturns")
|
||||
public static class NonLocalReturns extends AbstractJetDiagnosticsTestWithStdLib {
|
||||
public void testAllFilesPresentInNonLocalReturns() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/testsWithStdLib/nonLocalReturns"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("prohibitNonLocalReturnOutOfTryCatchFinally.kt")
|
||||
public void testProhibitNonLocalReturnOutOfTryCatchFinally() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/testsWithStdLib/nonLocalReturns/prohibitNonLocalReturnOutOfTryCatchFinally.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("JetDiagnosticsTestWithStdLibGenerated");
|
||||
suite.addTestSuite(JetDiagnosticsTestWithStdLibGenerated.class);
|
||||
@@ -503,6 +516,7 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic
|
||||
suite.addTestSuite(DuplicateJvmSignature.class);
|
||||
suite.addTestSuite(FunctionLiterals.class);
|
||||
suite.addTestSuite(KotlinSignature.class);
|
||||
suite.addTestSuite(NonLocalReturns.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user