[Test] Add diagnostic tests for smartcast in K2
List of issues: KT-28806, KT-7186, KT-22997, KT-1982, KT-22996, KT-54443, KT-37308, KT-37115, KT-4113, KT-25747, KT-24779
This commit is contained in:
committed by
Space Team
parent
48072c822b
commit
c6b32200df
+82
@@ -34156,6 +34156,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/alwaysNullWithJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("binaryOperatorsWithJumps.kt")
|
||||
public void testBinaryOperatorsWithJumps() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/binaryOperatorsWithJumps.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classObjectMember.kt")
|
||||
public void testClassObjectMember() throws Exception {
|
||||
@@ -34168,6 +34174,18 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonOfBuiltInTypesUnderOr.kt")
|
||||
public void testComparisonOfBuiltInTypesUnderOr() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/comparisonOfBuiltInTypesUnderOr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonOfClassTypesUnderOr.kt")
|
||||
public void testComparisonOfClassTypesUnderOr() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/comparisonOfClassTypesUnderOr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonUnderAnd.kt")
|
||||
public void testComparisonUnderAnd() throws Exception {
|
||||
@@ -34720,6 +34738,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/NullableFunctionTypeAsMemberMutablePropertyFromConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableLambda.kt")
|
||||
public void testNullableLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/nullableLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("openInSealed.kt")
|
||||
public void testOpenInSealed() throws Exception {
|
||||
@@ -34750,6 +34774,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safeAs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("savedSmartcastResult.kt")
|
||||
public void testSavedSmartcastResult() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/savedSmartcastResult.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("severalSmartCastsOnReified.kt")
|
||||
public void testSeveralSmartCastsOnReified() throws Exception {
|
||||
@@ -34888,6 +34918,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/typeInComparison.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterWithBounds.kt")
|
||||
public void testTypeParameterWithBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/typeParameterWithBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unstableToStable.kt")
|
||||
public void testUnstableToStable() throws Exception {
|
||||
@@ -35276,6 +35312,46 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class LambdasWithContracts {
|
||||
@Test
|
||||
public void testAllFilesPresentInLambdasWithContracts() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlace.kt")
|
||||
public void testLambdaWithCallInPlace() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlace.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndBounds.kt")
|
||||
public void testLambdaWithCallInPlaceAndBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndDelegate.kt")
|
||||
public void testLambdaWithCallInPlaceAndDelegate() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndOperators.kt")
|
||||
public void testLambdaWithCallInPlaceAndOperators() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndOperators.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithImpliesContract.kt")
|
||||
public void testLambdaWithImpliesContract() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithImpliesContract.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/loops")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -35795,6 +35871,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safecalls/chainMixedUnsafe.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("childProperty.kt")
|
||||
public void testChildProperty() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safecalls/childProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doubleCall.kt")
|
||||
public void testDoubleCall() throws Exception {
|
||||
|
||||
+82
@@ -34156,6 +34156,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/alwaysNullWithJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("binaryOperatorsWithJumps.kt")
|
||||
public void testBinaryOperatorsWithJumps() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/binaryOperatorsWithJumps.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classObjectMember.kt")
|
||||
public void testClassObjectMember() throws Exception {
|
||||
@@ -34168,6 +34174,18 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonOfBuiltInTypesUnderOr.kt")
|
||||
public void testComparisonOfBuiltInTypesUnderOr() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/comparisonOfBuiltInTypesUnderOr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonOfClassTypesUnderOr.kt")
|
||||
public void testComparisonOfClassTypesUnderOr() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/comparisonOfClassTypesUnderOr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonUnderAnd.kt")
|
||||
public void testComparisonUnderAnd() throws Exception {
|
||||
@@ -34720,6 +34738,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/NullableFunctionTypeAsMemberMutablePropertyFromConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableLambda.kt")
|
||||
public void testNullableLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/nullableLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("openInSealed.kt")
|
||||
public void testOpenInSealed() throws Exception {
|
||||
@@ -34750,6 +34774,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safeAs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("savedSmartcastResult.kt")
|
||||
public void testSavedSmartcastResult() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/savedSmartcastResult.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("severalSmartCastsOnReified.kt")
|
||||
public void testSeveralSmartCastsOnReified() throws Exception {
|
||||
@@ -34888,6 +34918,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/typeInComparison.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterWithBounds.kt")
|
||||
public void testTypeParameterWithBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/typeParameterWithBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unstableToStable.kt")
|
||||
public void testUnstableToStable() throws Exception {
|
||||
@@ -35276,6 +35312,46 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class LambdasWithContracts {
|
||||
@Test
|
||||
public void testAllFilesPresentInLambdasWithContracts() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlace.kt")
|
||||
public void testLambdaWithCallInPlace() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlace.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndBounds.kt")
|
||||
public void testLambdaWithCallInPlaceAndBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndDelegate.kt")
|
||||
public void testLambdaWithCallInPlaceAndDelegate() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndOperators.kt")
|
||||
public void testLambdaWithCallInPlaceAndOperators() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndOperators.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithImpliesContract.kt")
|
||||
public void testLambdaWithImpliesContract() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithImpliesContract.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/loops")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -35795,6 +35871,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safecalls/chainMixedUnsafe.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("childProperty.kt")
|
||||
public void testChildProperty() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safecalls/childProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doubleCall.kt")
|
||||
public void testDoubleCall() throws Exception {
|
||||
|
||||
+82
@@ -31924,6 +31924,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/alwaysNullWithJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("binaryOperatorsWithJumps.kt")
|
||||
public void testBinaryOperatorsWithJumps() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/binaryOperatorsWithJumps.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classObjectMember.kt")
|
||||
public void testClassObjectMember() throws Exception {
|
||||
@@ -31936,6 +31942,18 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonOfBuiltInTypesUnderOr.kt")
|
||||
public void testComparisonOfBuiltInTypesUnderOr() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/comparisonOfBuiltInTypesUnderOr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonOfClassTypesUnderOr.kt")
|
||||
public void testComparisonOfClassTypesUnderOr() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/comparisonOfClassTypesUnderOr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonUnderAnd.kt")
|
||||
public void testComparisonUnderAnd() throws Exception {
|
||||
@@ -32488,6 +32506,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/NullableFunctionTypeAsMemberMutablePropertyFromConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableLambda.kt")
|
||||
public void testNullableLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/nullableLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("openInSealed.kt")
|
||||
public void testOpenInSealed() throws Exception {
|
||||
@@ -32518,6 +32542,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safeAs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("savedSmartcastResult.kt")
|
||||
public void testSavedSmartcastResult() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/savedSmartcastResult.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("severalSmartCastsOnReified.kt")
|
||||
public void testSeveralSmartCastsOnReified() throws Exception {
|
||||
@@ -32656,6 +32686,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/typeInComparison.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterWithBounds.kt")
|
||||
public void testTypeParameterWithBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/typeParameterWithBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unstableToStable.kt")
|
||||
public void testUnstableToStable() throws Exception {
|
||||
@@ -33044,6 +33080,46 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class LambdasWithContracts {
|
||||
@Test
|
||||
public void testAllFilesPresentInLambdasWithContracts() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlace.kt")
|
||||
public void testLambdaWithCallInPlace() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlace.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndBounds.kt")
|
||||
public void testLambdaWithCallInPlaceAndBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndDelegate.kt")
|
||||
public void testLambdaWithCallInPlaceAndDelegate() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndOperators.kt")
|
||||
public void testLambdaWithCallInPlaceAndOperators() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndOperators.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithImpliesContract.kt")
|
||||
public void testLambdaWithImpliesContract() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithImpliesContract.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/loops")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -33563,6 +33639,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safecalls/chainMixedUnsafe.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("childProperty.kt")
|
||||
public void testChildProperty() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safecalls/childProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doubleCall.kt")
|
||||
public void testDoubleCall() throws Exception {
|
||||
|
||||
+82
@@ -32044,6 +32044,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/alwaysNullWithJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("binaryOperatorsWithJumps.kt")
|
||||
public void testBinaryOperatorsWithJumps() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/binaryOperatorsWithJumps.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classObjectMember.kt")
|
||||
public void testClassObjectMember() throws Exception {
|
||||
@@ -32056,6 +32062,18 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonOfBuiltInTypesUnderOr.kt")
|
||||
public void testComparisonOfBuiltInTypesUnderOr() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/comparisonOfBuiltInTypesUnderOr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonOfClassTypesUnderOr.kt")
|
||||
public void testComparisonOfClassTypesUnderOr() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/comparisonOfClassTypesUnderOr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonUnderAnd.kt")
|
||||
public void testComparisonUnderAnd() throws Exception {
|
||||
@@ -32608,6 +32626,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/NullableFunctionTypeAsMemberMutablePropertyFromConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableLambda.kt")
|
||||
public void testNullableLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/nullableLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("openInSealed.kt")
|
||||
public void testOpenInSealed() throws Exception {
|
||||
@@ -32638,6 +32662,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safeAs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("savedSmartcastResult.kt")
|
||||
public void testSavedSmartcastResult() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/savedSmartcastResult.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("severalSmartCastsOnReified.kt")
|
||||
public void testSeveralSmartCastsOnReified() throws Exception {
|
||||
@@ -32776,6 +32806,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/typeInComparison.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterWithBounds.kt")
|
||||
public void testTypeParameterWithBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/typeParameterWithBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unstableToStable.kt")
|
||||
public void testUnstableToStable() throws Exception {
|
||||
@@ -33164,6 +33200,46 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class LambdasWithContracts {
|
||||
@Test
|
||||
public void testAllFilesPresentInLambdasWithContracts() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlace.kt")
|
||||
public void testLambdaWithCallInPlace() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlace.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndBounds.kt")
|
||||
public void testLambdaWithCallInPlaceAndBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndDelegate.kt")
|
||||
public void testLambdaWithCallInPlaceAndDelegate() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndOperators.kt")
|
||||
public void testLambdaWithCallInPlaceAndOperators() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndOperators.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithImpliesContract.kt")
|
||||
public void testLambdaWithImpliesContract() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithImpliesContract.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/loops")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -33683,6 +33759,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safecalls/chainMixedUnsafe.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("childProperty.kt")
|
||||
public void testChildProperty() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safecalls/childProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doubleCall.kt")
|
||||
public void testDoubleCall() throws Exception {
|
||||
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
// ISSUE: KT-37115
|
||||
|
||||
fun test1(foo: String?) {
|
||||
foo != null || throw IllegalArgumentException()
|
||||
foo.length
|
||||
}
|
||||
|
||||
fun test2(foo: String?) {
|
||||
foo != null || return
|
||||
foo.length
|
||||
}
|
||||
|
||||
fun test3(foo: String?) {
|
||||
while (true) {
|
||||
foo != null || continue
|
||||
foo.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(foo: String?) {
|
||||
while (true) {
|
||||
foo == null || break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
foo.length
|
||||
}
|
||||
|
||||
fun test5(foo: String?) {
|
||||
while (true) {
|
||||
foo != null || break
|
||||
foo.length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test6(foo: String?) {
|
||||
var i = 0
|
||||
while (i == 0) {
|
||||
foo == null || break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test7(foo: String?) {
|
||||
for (i in 1..3) {
|
||||
foo != null || break
|
||||
foo.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test8(foo: String?) {
|
||||
foo == null && throw IllegalArgumentException()
|
||||
foo.length
|
||||
}
|
||||
|
||||
fun test9(foo: String?) {
|
||||
foo == null && return
|
||||
foo.length
|
||||
}
|
||||
|
||||
fun test10(foo: String?) {
|
||||
while (true) {
|
||||
foo == null && continue
|
||||
foo.length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test11(foo: String?) {
|
||||
for (i in 1..3) {
|
||||
foo == null && continue
|
||||
foo.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test12(foo: String?) {
|
||||
while (true) {
|
||||
foo != null && break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
foo.length
|
||||
}
|
||||
|
||||
fun test13(foo: String?) {
|
||||
var i = 0
|
||||
while (i == 0) {
|
||||
foo != null && break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test14(foo: String?) {
|
||||
while (true) {
|
||||
foo == null && break
|
||||
foo.length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test15(foo: String?) {
|
||||
for (i in 1..3) {
|
||||
foo != null && break
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test16(foo: String?) {
|
||||
for (i in 1..3) {
|
||||
foo == null && break
|
||||
foo.length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test17(foo: Any?) {
|
||||
foo !=null && foo is String? || throw IllegalArgumentException()
|
||||
foo.length
|
||||
}
|
||||
|
||||
fun test18(foo: Any?) {
|
||||
foo != null && foo !is String && throw IllegalArgumentException()
|
||||
var k: String? = foo
|
||||
}
|
||||
|
||||
fun test19(foo: Any?) {
|
||||
foo is String || foo == null || throw IllegalArgumentException()
|
||||
var k: String? = foo
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
// ISSUE: KT-37115
|
||||
|
||||
fun test1(foo: String?) {
|
||||
foo != null || throw IllegalArgumentException()
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test2(foo: String?) {
|
||||
foo != null || return
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test3(foo: String?) {
|
||||
while (true) {
|
||||
foo != null || continue
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(foo: String?) {
|
||||
while (true) {
|
||||
foo == null || break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test5(foo: String?) {
|
||||
while (true) {
|
||||
foo != null || break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test6(foo: String?) {
|
||||
var i = 0
|
||||
while (i == 0) {
|
||||
foo == null || break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test7(foo: String?) {
|
||||
for (i in 1..3) {
|
||||
foo != null || break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
}
|
||||
|
||||
fun test8(foo: String?) {
|
||||
foo == null && throw IllegalArgumentException()
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test9(foo: String?) {
|
||||
foo == null && return
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test10(foo: String?) {
|
||||
while (true) {
|
||||
foo == null && continue
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
<!UNREACHABLE_CODE!>foo<!UNSAFE_CALL!>.<!>length<!>
|
||||
}
|
||||
|
||||
fun test11(foo: String?) {
|
||||
for (i in 1..3) {
|
||||
foo == null && continue
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
}
|
||||
|
||||
fun test12(foo: String?) {
|
||||
while (true) {
|
||||
foo != null && break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test13(foo: String?) {
|
||||
var i = 0
|
||||
while (i == 0) {
|
||||
foo != null && break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test14(foo: String?) {
|
||||
while (true) {
|
||||
foo == null && break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test15(foo: String?) {
|
||||
for (i in 1..3) {
|
||||
foo != null && break
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test16(foo: String?) {
|
||||
for (i in 1..3) {
|
||||
foo == null && break
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
foo<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test17(foo: Any?) {
|
||||
foo !=null && foo is String? || throw IllegalArgumentException()
|
||||
foo.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test18(foo: Any?) {
|
||||
foo != null && foo !is String && throw IllegalArgumentException()
|
||||
var k: String? = <!TYPE_MISMATCH!>foo<!>
|
||||
}
|
||||
|
||||
fun test19(foo: Any?) {
|
||||
foo is String || foo == null || throw IllegalArgumentException()
|
||||
var k: String? = <!TYPE_MISMATCH!>foo<!>
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
// ISSUE: KT-1982
|
||||
// DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
|
||||
fun test1(x: Any?) {
|
||||
if (x is Any || <!SENSELESS_COMPARISON!>x == null<!>) {
|
||||
var k: Any? = x
|
||||
} else {
|
||||
var k: Any = x
|
||||
var k2: Nothing = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(x: Any?) {
|
||||
if (x is Any || <!SENSELESS_COMPARISON!>x != null<!>) {
|
||||
var k: Any = x
|
||||
} else {
|
||||
var k: Any? = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(x: Any?) {
|
||||
if (<!USELESS_IS_CHECK!>x is Any?<!> || <!SENSELESS_COMPARISON!>x != null<!>) {
|
||||
var k: Any? = x
|
||||
} else {
|
||||
var k: Nothing = x
|
||||
var k2: Int = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(x: Any?) {
|
||||
if (x !is Any || <!SENSELESS_COMPARISON!>x != null<!>) {
|
||||
var k: Any? = x
|
||||
} else {
|
||||
var k: Nothing = x
|
||||
var k2: Any? = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(x: Any?) {
|
||||
if (x is String || x == null){
|
||||
var k: String? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test6(x: Any?) {
|
||||
if (x !is String || <!SENSELESS_COMPARISON!>x == null<!>){
|
||||
var k: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: String = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test7(x: Any?) {
|
||||
if (x is String || x != null){
|
||||
var k: Any = x
|
||||
}
|
||||
else {
|
||||
var k: Any? = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test8(x: Any?) {
|
||||
if (x !is String || <!SENSELESS_COMPARISON!>x != null<!>){
|
||||
var k: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: String? = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test9(x: Any?) {
|
||||
if (x is String?){
|
||||
var k: String? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test10(x: Any?) {
|
||||
if (x !is String?){
|
||||
var k: Any = x
|
||||
}
|
||||
else {
|
||||
var k: String? = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test11(x: Any?) {
|
||||
if (x is List<*> || x == null){
|
||||
var k : List<*>? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test12(x: Any?) {
|
||||
if (x is List<*> || x != null){
|
||||
var k2: Any = x
|
||||
}
|
||||
else {
|
||||
var k: Any? = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test13(list: List<String>?) {
|
||||
if (list is ArrayList || list == null) {
|
||||
var k: ArrayList<String>? = list
|
||||
}
|
||||
}
|
||||
|
||||
fun test14(list: List<String>?) {
|
||||
if (list is ArrayList || list != null) {
|
||||
var k: ArrayList<String>? = <!INITIALIZER_TYPE_MISMATCH!>list<!>
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
// ISSUE: KT-1982
|
||||
// DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
|
||||
fun test1(x: Any?) {
|
||||
if (x is Any || x == null) {
|
||||
var k: Any? = x
|
||||
} else {
|
||||
var k: Any = x
|
||||
var k2: Nothing = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(x: Any?) {
|
||||
if (x is Any || x != null) {
|
||||
var k: Any = x
|
||||
} else {
|
||||
var k: Any? = <!DEBUG_INFO_CONSTANT!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(x: Any?) {
|
||||
if (<!USELESS_IS_CHECK!>x is Any?<!> || x != null) {
|
||||
var k: Any? = x
|
||||
} else {
|
||||
var k: Nothing = <!DEBUG_INFO_CONSTANT, TYPE_MISMATCH!>x<!>
|
||||
var k2: Int = <!DEBUG_INFO_CONSTANT, TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(x: Any?) {
|
||||
if (x !is Any || <!SENSELESS_COMPARISON!>x != null<!>) {
|
||||
var k: Any? = x
|
||||
} else {
|
||||
<!UNREACHABLE_CODE!>var k: Nothing =<!> x
|
||||
<!UNREACHABLE_CODE!>var k2: Any? = x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(x: Any?) {
|
||||
if (x is String || x == null){
|
||||
var k: String? = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test6(x: Any?) {
|
||||
if (x !is String || <!SENSELESS_COMPARISON!>x == null<!>){
|
||||
var k: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: String = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test7(x: Any?) {
|
||||
if (x is String || x != null){
|
||||
var k: Any = x
|
||||
}
|
||||
else {
|
||||
var k: Any? = <!DEBUG_INFO_CONSTANT!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test8(x: Any?) {
|
||||
if (x !is String || <!SENSELESS_COMPARISON!>x != null<!>){
|
||||
var k: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: String? = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test9(x: Any?) {
|
||||
if (x is String?){
|
||||
var k: String? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test10(x: Any?) {
|
||||
if (x !is String?){
|
||||
var k: Any = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
else {
|
||||
var k: String? = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test11(x: Any?) {
|
||||
if (x is List<*> || x == null){
|
||||
var k : List<*>? = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test12(x: Any?) {
|
||||
if (x is List<*> || x != null){
|
||||
var k2: Any = x
|
||||
}
|
||||
else {
|
||||
var k: Any? = <!DEBUG_INFO_CONSTANT!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test13(list: List<String>?) {
|
||||
if (list is ArrayList || list == null) {
|
||||
var k: ArrayList<String>? = <!TYPE_MISMATCH!>list<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test14(list: List<String>?) {
|
||||
if (list is ArrayList || list != null) {
|
||||
var k: ArrayList<String>? = <!TYPE_MISMATCH!>list<!>
|
||||
}
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
// ISSUE: KT-1982
|
||||
// DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
|
||||
interface A
|
||||
class B : A
|
||||
|
||||
fun test1(x:Any?) {
|
||||
if (x is A || x !is B) {
|
||||
var k: B? = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k2: A? = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k3: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A = x
|
||||
var k3: B = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(x:Any?) {
|
||||
if (x is A || x is B) {
|
||||
var k: B = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k2: A = x
|
||||
var k3: Any = x
|
||||
}
|
||||
else {
|
||||
var k: Any? = x
|
||||
var k2: A = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k3: B = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(x:Any?) {
|
||||
if (x !is A || x is B) {
|
||||
var k: B = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k2: A = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k3: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A = x
|
||||
var k3: B = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(x:Any?) {
|
||||
if (x is A || x is B || x == null) {
|
||||
var k: B? = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k2: A? = x
|
||||
var k3: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k3: B = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
sealed interface A2
|
||||
class B2 : A2
|
||||
class C2 : A2
|
||||
|
||||
fun test5(x:Any?) {
|
||||
if (x is C2 || x is B2) {
|
||||
var k: B2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = x
|
||||
var k3: C2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k4: Any = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test6(x:Any?) {
|
||||
if (x is C2 || x !is B2) {
|
||||
var k: B2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k3: C2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k4: Any? = x
|
||||
} else {
|
||||
var k: Any = x
|
||||
var k2: A2 = x
|
||||
var k3: B2 = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test7(x:Any?) {
|
||||
if (x is A2 || x !is B2) {
|
||||
var k: B2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k3: C2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k4: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A2 = x
|
||||
var k3: B2 = x
|
||||
var k4 : C2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test8(x:Any?) {
|
||||
if (x is A2 || x is B2) {
|
||||
var k: B2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = x
|
||||
var k3: C2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k4: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any? = x
|
||||
var k2: A2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k3: B2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k4 : C2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test9(x:Any?) {
|
||||
if (x !is A2 || x is B2) {
|
||||
var k: B2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k3: C2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k4: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A2 = x
|
||||
var k3: B2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k4 : C2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test10(x:Any?) {
|
||||
if (x !is A2 || x is B2) {
|
||||
var k: B2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k3: C2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k4: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A2 = x
|
||||
var k3: B2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
var k4 : C2 = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test11(x:A2?) {
|
||||
if (x !is B2 || <!USELESS_IS_CHECK!>x is B2<!>) {
|
||||
var k: A2? = x
|
||||
}
|
||||
else {
|
||||
var k : B2 = x
|
||||
var k2 : A2? = x
|
||||
}
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
// ISSUE: KT-1982
|
||||
// DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
|
||||
interface A
|
||||
class B : A
|
||||
|
||||
fun test1(x:Any?) {
|
||||
if (x is A || x !is B) {
|
||||
var k: B? = <!TYPE_MISMATCH!>x<!>
|
||||
var k2: A? = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A = x
|
||||
var k3: B = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(x:Any?) {
|
||||
if (x is A || x is B) {
|
||||
var k: B = <!TYPE_MISMATCH!>x<!>
|
||||
var k2: A = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: Any = x
|
||||
}
|
||||
else {
|
||||
var k: Any? = x
|
||||
var k2: A = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: B = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(x:Any?) {
|
||||
if (x !is A || x is B) {
|
||||
var k: B = <!TYPE_MISMATCH!>x<!>
|
||||
var k2: A = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A = x
|
||||
var k3: B = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(x:Any?) {
|
||||
if (x is A || x is B || x == null) {
|
||||
var k: B? = <!TYPE_MISMATCH!>x<!>
|
||||
var k2: A? = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: B = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
sealed interface A2
|
||||
class B2 : A2
|
||||
class C2 : A2
|
||||
|
||||
fun test5(x:Any?) {
|
||||
if (x is C2 || x is B2) {
|
||||
var k: B2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: C2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k4: Any = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test6(x:Any?) {
|
||||
if (x is C2 || x !is B2) {
|
||||
var k: B2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: C2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k4: Any? = x
|
||||
} else {
|
||||
var k: Any = x
|
||||
var k2: A2 = x
|
||||
var k3: B2 = x
|
||||
}
|
||||
}
|
||||
|
||||
fun test7(x:Any?) {
|
||||
if (x is A2 || x !is B2) {
|
||||
var k: B2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: C2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k4: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A2 = x
|
||||
var k3: B2 = x
|
||||
var k4 : C2 = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test8(x:Any?) {
|
||||
if (x is A2 || x is B2) {
|
||||
var k: B2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: C2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k4: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any? = x
|
||||
var k2: A2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: B2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k4 : C2 = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test9(x:Any?) {
|
||||
if (x !is A2 || x is B2) {
|
||||
var k: B2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: C2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k4: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A2 = x
|
||||
var k3: B2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k4 : C2 = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test10(x:Any?) {
|
||||
if (x !is A2 || x is B2) {
|
||||
var k: B2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k2: A2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k3: C2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k4: Any? = x
|
||||
}
|
||||
else {
|
||||
var k: Any = x
|
||||
var k2: A2 = x
|
||||
var k3: B2 = <!TYPE_MISMATCH!>x<!>
|
||||
var k4 : C2 = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test11(x:A2?) {
|
||||
if (x !is B2 || <!USELESS_IS_CHECK!>x is B2<!>) {
|
||||
var k: A2? = x
|
||||
}
|
||||
else {
|
||||
var k : B2 = x
|
||||
var k2 : A2? = x
|
||||
}
|
||||
}
|
||||
Vendored
+622
@@ -0,0 +1,622 @@
|
||||
// ISSUE: KT-28806
|
||||
// WITH_STDLIB
|
||||
// DIAGNOSTICS: -ERROR_SUPPRESSION, -DEBUG_INFO_SMARTCAST
|
||||
import kotlin.contracts.*
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun atLeastOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
|
||||
}
|
||||
block()
|
||||
}
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun exactlyOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
block()
|
||||
}
|
||||
|
||||
fun runWithoutContract(block: () -> Unit): Unit = block()
|
||||
|
||||
fun <R> materialize(): R = null!!
|
||||
|
||||
fun test1() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
x = ""
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test5() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
x = ""
|
||||
x.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test6() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
x = ""
|
||||
x.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test7() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test8() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
x.length
|
||||
exactlyOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test9() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
atLeastOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test10() {
|
||||
var x: Any? = materialize()
|
||||
runWithoutContract {
|
||||
val b = x is String
|
||||
if (b) {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test11(x: Any) {
|
||||
exactlyOnce {
|
||||
val b = x is String
|
||||
if (b) {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test12(x: Any) {
|
||||
atLeastOnce {
|
||||
val b = x is String
|
||||
if (b) {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test13(x: Any) {
|
||||
if (x is String) {
|
||||
runWithoutContract {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test14(x: Any) {
|
||||
if (x is String) {
|
||||
exactlyOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test15(x: Any) {
|
||||
if (x is String) {
|
||||
atLeastOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test16(x: Any) {
|
||||
atLeastOnce {
|
||||
when (x) {
|
||||
is String -> x.length
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test17(x: Any) {
|
||||
runWithoutContract {
|
||||
when (x) {
|
||||
is String -> x.length
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test18(x: Any) {
|
||||
exactlyOnce {
|
||||
when (x) {
|
||||
is String -> x.length
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test19(x: Any) {
|
||||
when (x) {
|
||||
is String -> atLeastOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test20(x: Any) {
|
||||
when (x) {
|
||||
is String -> runWithoutContract {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test21(x: Any) {
|
||||
when (x) {
|
||||
is String -> exactlyOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test22(x: Any) {
|
||||
val state: Boolean = x is String
|
||||
runWithoutContract {
|
||||
if (state) {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test23(x: Any) {
|
||||
val state: Boolean = x is String
|
||||
exactlyOnce {
|
||||
if (state) {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test24(x: Any) {
|
||||
val state: Boolean = x is String
|
||||
atLeastOnce {
|
||||
if (state) {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test25() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
|
||||
fun test26() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
x.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
|
||||
fun test27() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
x.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
|
||||
fun test28(x: Any) {
|
||||
runWithoutContract {
|
||||
require(x is String)
|
||||
x.length
|
||||
}
|
||||
runWithoutContract {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test29(x: Any) {
|
||||
exactlyOnce {
|
||||
require(x is String)
|
||||
x.length
|
||||
}
|
||||
exactlyOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test30(x: Any) {
|
||||
atLeastOnce {
|
||||
require(x is String)
|
||||
x.length
|
||||
}
|
||||
atLeastOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test31(x: Any) {
|
||||
runWithoutContract {
|
||||
require(x is String)
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test32(x: Any) {
|
||||
exactlyOnce {
|
||||
require(x is String)
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test33(x: Any) {
|
||||
atLeastOnce {
|
||||
require(x is String)
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test34() {
|
||||
var x: Any? = materialize()
|
||||
runWithoutContract {
|
||||
require(x is String)
|
||||
x = 10
|
||||
}
|
||||
runWithoutContract {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test35() {
|
||||
var x: Any? = materialize()
|
||||
exactlyOnce {
|
||||
require(x is String)
|
||||
x = 10
|
||||
}
|
||||
exactlyOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test36() {
|
||||
var x: Any? = materialize()
|
||||
atLeastOnce {
|
||||
require(x is String)
|
||||
x = 10
|
||||
}
|
||||
atLeastOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test37() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
atLeastOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test38() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
exactlyOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test39() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test40() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
atLeastOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test41() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
exactlyOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test42() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
runWithoutContract {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test43() {
|
||||
runWithoutContract {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test44() {
|
||||
atLeastOnce {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test45() {
|
||||
exactlyOnce {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test46() {
|
||||
var x: Any = materialize()
|
||||
exactlyOnce {
|
||||
while (x is String) {
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test47() {
|
||||
var x: Any = materialize()
|
||||
atLeastOnce {
|
||||
while (x is String) {
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test48() {
|
||||
var x: Any = materialize()
|
||||
runWithoutContract {
|
||||
while (x is String) {
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test49() {
|
||||
var x: Any = materialize()
|
||||
while (x is String) {
|
||||
exactlyOnce {
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test50() {
|
||||
var x: Any = materialize()
|
||||
while (x is String) {
|
||||
atLeastOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test51() {
|
||||
var x: Any = materialize()
|
||||
while (x is String) {
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test52() {
|
||||
var x: Any = materialize()
|
||||
exactlyOnce {
|
||||
do {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
} while (x is String)
|
||||
}
|
||||
}
|
||||
|
||||
fun test53() {
|
||||
var x: Any = materialize()
|
||||
atLeastOnce {
|
||||
do {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
} while (x is String)
|
||||
}
|
||||
}
|
||||
|
||||
fun test54() {
|
||||
var x: Any = materialize()
|
||||
runWithoutContract {
|
||||
do {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
} while (x is String)
|
||||
}
|
||||
}
|
||||
|
||||
fun test55() {
|
||||
var x: Any = materialize()
|
||||
runWithoutContract {
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test56() {
|
||||
var x: Any = materialize()
|
||||
atLeastOnce {
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test57() {
|
||||
var x: Any = materialize()
|
||||
exactlyOnce {
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test58() {
|
||||
var x: Any = materialize()
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test59() {
|
||||
var x: Any = materialize()
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test60() {
|
||||
var x: Any = materialize()
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test61() {
|
||||
var x: String? = materialize()
|
||||
runWithoutContract {
|
||||
x?.length ?: -1
|
||||
x = null
|
||||
}
|
||||
}
|
||||
|
||||
fun test62() {
|
||||
var x: String? = materialize()
|
||||
atLeastOnce {
|
||||
x?.length ?: -1
|
||||
x = null
|
||||
}
|
||||
}
|
||||
|
||||
fun test63() {
|
||||
var x: String? = materialize()
|
||||
exactlyOnce {
|
||||
x?.length ?: -1
|
||||
x = null
|
||||
}
|
||||
}
|
||||
Vendored
+622
@@ -0,0 +1,622 @@
|
||||
// ISSUE: KT-28806
|
||||
// WITH_STDLIB
|
||||
// DIAGNOSTICS: -ERROR_SUPPRESSION, -DEBUG_INFO_SMARTCAST
|
||||
import kotlin.contracts.*
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun atLeastOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
|
||||
}
|
||||
block()
|
||||
}
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun exactlyOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
block()
|
||||
}
|
||||
|
||||
fun runWithoutContract(block: () -> Unit): Unit = block()
|
||||
|
||||
fun <R> materialize(): R = null!!
|
||||
|
||||
fun test1() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
x = ""
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test5() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
x = ""
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test6() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
x = ""
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test7() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test8() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
exactlyOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test9() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
atLeastOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test10() {
|
||||
var x: Any? = materialize()
|
||||
runWithoutContract {
|
||||
val b = x is String
|
||||
if (b) {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test11(x: Any) {
|
||||
exactlyOnce {
|
||||
val b = x is String
|
||||
if (b) {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test12(x: Any) {
|
||||
atLeastOnce {
|
||||
val b = x is String
|
||||
if (b) {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test13(x: Any) {
|
||||
if (x is String) {
|
||||
runWithoutContract {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test14(x: Any) {
|
||||
if (x is String) {
|
||||
exactlyOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test15(x: Any) {
|
||||
if (x is String) {
|
||||
atLeastOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test16(x: Any) {
|
||||
atLeastOnce {
|
||||
when (x) {
|
||||
is String -> x.length
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test17(x: Any) {
|
||||
runWithoutContract {
|
||||
when (x) {
|
||||
is String -> x.length
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test18(x: Any) {
|
||||
exactlyOnce {
|
||||
when (x) {
|
||||
is String -> x.length
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test19(x: Any) {
|
||||
when (x) {
|
||||
is String -> atLeastOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test20(x: Any) {
|
||||
when (x) {
|
||||
is String -> runWithoutContract {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test21(x: Any) {
|
||||
when (x) {
|
||||
is String -> exactlyOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test22(x: Any) {
|
||||
val state: Boolean = x is String
|
||||
runWithoutContract {
|
||||
if (state) {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test23(x: Any) {
|
||||
val state: Boolean = x is String
|
||||
exactlyOnce {
|
||||
if (state) {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test24(x: Any) {
|
||||
val state: Boolean = x is String
|
||||
atLeastOnce {
|
||||
if (state) {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test25() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
|
||||
fun test26() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
|
||||
fun test27() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
|
||||
fun test28(x: Any) {
|
||||
runWithoutContract {
|
||||
require(x is String)
|
||||
x.length
|
||||
}
|
||||
runWithoutContract {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test29(x: Any) {
|
||||
exactlyOnce {
|
||||
require(x is String)
|
||||
x.length
|
||||
}
|
||||
exactlyOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test30(x: Any) {
|
||||
atLeastOnce {
|
||||
require(x is String)
|
||||
x.length
|
||||
}
|
||||
atLeastOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test31(x: Any) {
|
||||
runWithoutContract {
|
||||
require(x is String)
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test32(x: Any) {
|
||||
exactlyOnce {
|
||||
require(x is String)
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test33(x: Any) {
|
||||
atLeastOnce {
|
||||
require(x is String)
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test34() {
|
||||
var x: Any? = materialize()
|
||||
runWithoutContract {
|
||||
require(x is String)
|
||||
x = 10
|
||||
}
|
||||
runWithoutContract {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test35() {
|
||||
var x: Any? = materialize()
|
||||
exactlyOnce {
|
||||
require(x is String)
|
||||
x = 10
|
||||
}
|
||||
exactlyOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test36() {
|
||||
var x: Any? = materialize()
|
||||
atLeastOnce {
|
||||
require(x is String)
|
||||
x = 10
|
||||
}
|
||||
atLeastOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test37() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
atLeastOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test38() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
exactlyOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test39() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test40() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
atLeastOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test41() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
exactlyOnce {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test42() {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
fun local() {
|
||||
runWithoutContract {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test43() {
|
||||
runWithoutContract {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test44() {
|
||||
atLeastOnce {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test45() {
|
||||
exactlyOnce {
|
||||
var x: Any? = materialize()
|
||||
require(x is String)
|
||||
x.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test46() {
|
||||
var x: Any = materialize()
|
||||
exactlyOnce {
|
||||
while (x is String) {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test47() {
|
||||
var x: Any = materialize()
|
||||
atLeastOnce {
|
||||
while (x is String) {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test48() {
|
||||
var x: Any = materialize()
|
||||
runWithoutContract {
|
||||
while (x is String) {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test49() {
|
||||
var x: Any = materialize()
|
||||
while (x is String) {
|
||||
exactlyOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test50() {
|
||||
var x: Any = materialize()
|
||||
while (x is String) {
|
||||
atLeastOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test51() {
|
||||
var x: Any = materialize()
|
||||
while (x is String) {
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test52() {
|
||||
var x: Any = materialize()
|
||||
exactlyOnce {
|
||||
do {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
} while (x is String)
|
||||
}
|
||||
}
|
||||
|
||||
fun test53() {
|
||||
var x: Any = materialize()
|
||||
atLeastOnce {
|
||||
do {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
} while (x is String)
|
||||
}
|
||||
}
|
||||
|
||||
fun test54() {
|
||||
var x: Any = materialize()
|
||||
runWithoutContract {
|
||||
do {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
} while (x is String)
|
||||
}
|
||||
}
|
||||
|
||||
fun test55() {
|
||||
var x: Any = materialize()
|
||||
runWithoutContract {
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test56() {
|
||||
var x: Any = materialize()
|
||||
atLeastOnce {
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test57() {
|
||||
var x: Any = materialize()
|
||||
exactlyOnce {
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test58() {
|
||||
var x: Any = materialize()
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test59() {
|
||||
var x: Any = materialize()
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test60() {
|
||||
var x: Any = materialize()
|
||||
for (i in 1..3) {
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test61() {
|
||||
var x: String? = materialize()
|
||||
runWithoutContract {
|
||||
x?.length ?: -1
|
||||
x = null
|
||||
}
|
||||
}
|
||||
|
||||
fun test62() {
|
||||
var x: String? = materialize()
|
||||
atLeastOnce {
|
||||
x?.length ?: -1
|
||||
x = null
|
||||
}
|
||||
}
|
||||
|
||||
fun test63() {
|
||||
var x: String? = materialize()
|
||||
exactlyOnce {
|
||||
x?.length ?: -1
|
||||
x = null
|
||||
}
|
||||
}
|
||||
+378
@@ -0,0 +1,378 @@
|
||||
// ISSUE: KT-28806
|
||||
// WITH_STDLIB
|
||||
// DIAGNOSTICS: -ERROR_SUPPRESSION, -DEBUG_INFO_SMARTCAST
|
||||
import kotlin.contracts.*
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun atLeastOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
|
||||
}
|
||||
block()
|
||||
}
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun exactlyOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
block()
|
||||
}
|
||||
|
||||
fun runWithoutContract(block: () -> Unit): Unit = block()
|
||||
|
||||
fun <R> materialize(): R = null!!
|
||||
|
||||
fun test1(x: Any) {
|
||||
var y = x
|
||||
require(y is String)
|
||||
runWithoutContract {
|
||||
y = 10
|
||||
y = x
|
||||
x.length
|
||||
<!SMARTCAST_IMPOSSIBLE!>y<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(x: Any) {
|
||||
var y = x
|
||||
require(y is String)
|
||||
exactlyOnce {
|
||||
y = 10
|
||||
y = x
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(x: Any) {
|
||||
var y = x
|
||||
require(y is String)
|
||||
atLeastOnce {
|
||||
y = 10
|
||||
y = x
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(x: Any) {
|
||||
var y: Any
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
y = 10
|
||||
y = x
|
||||
x.length
|
||||
<!SMARTCAST_IMPOSSIBLE!>y<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(x: Any) {
|
||||
var y: Any
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
y = 10
|
||||
y = x
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test6(x: Any) {
|
||||
var y: Any
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
y = 10
|
||||
y = x
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test7(x: Any) {
|
||||
var y: Any?
|
||||
val b = x is String
|
||||
if (b) {
|
||||
y = x
|
||||
exactlyOnce {
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test8(x: Any) {
|
||||
var y: Any?
|
||||
val b = x is String
|
||||
if (b) {
|
||||
y = x
|
||||
atLeastOnce {
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test9(x: Any) {
|
||||
var y: Any?
|
||||
val b = x is String
|
||||
if (b) {
|
||||
y = x
|
||||
runWithoutContract {
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test10(x: Any) {
|
||||
var y = x
|
||||
runWithoutContract {
|
||||
require(y is String)
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test11(x: Any) {
|
||||
var y = x
|
||||
atLeastOnce {
|
||||
require(y is String)
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test12(x: Any) {
|
||||
var y = x
|
||||
exactlyOnce {
|
||||
require(y is String)
|
||||
x.length
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test13() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
atLeastOnce {
|
||||
require(y is String)
|
||||
x = 10
|
||||
y = x
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.inc()
|
||||
}
|
||||
}
|
||||
|
||||
fun test14() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
exactlyOnce {
|
||||
require(y is String)
|
||||
x = 10
|
||||
y = x
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.inc()
|
||||
}
|
||||
}
|
||||
|
||||
fun test15() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
runWithoutContract {
|
||||
require(y is String)
|
||||
x = 10
|
||||
y = x
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.<!UNRESOLVED_REFERENCE!>inc<!>()
|
||||
}
|
||||
}
|
||||
|
||||
fun test16(x: Any) {
|
||||
var y: Any
|
||||
runWithoutContract {
|
||||
require(x is String)
|
||||
y = x
|
||||
<!SMARTCAST_IMPOSSIBLE!>y<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test17(x: Any) {
|
||||
var y: Any
|
||||
exactlyOnce {
|
||||
require(x is String)
|
||||
y = x
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test18(x: Any) {
|
||||
var y: Any
|
||||
atLeastOnce {
|
||||
require(x is String)
|
||||
y = x
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test19(x: Any?) {
|
||||
var y: Any
|
||||
atLeastOnce {
|
||||
if (x != null) {
|
||||
y = x
|
||||
} else {
|
||||
y = <!ASSIGNMENT_TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
require(x is String)
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test20(x: Any?) {
|
||||
var y: Any
|
||||
exactlyOnce {
|
||||
if (x != null) {
|
||||
y = x
|
||||
} else {
|
||||
y = <!ASSIGNMENT_TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
require(x is String)
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test21(x: Any?) {
|
||||
var y: Any
|
||||
runWithoutContract {
|
||||
if (x != null) {
|
||||
y = x
|
||||
} else {
|
||||
y = <!ASSIGNMENT_TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
require(x is String)
|
||||
<!SMARTCAST_IMPOSSIBLE!>y<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test22(x: Any) {
|
||||
var y: Any = materialize()
|
||||
runWithoutContract {
|
||||
require(x is String)
|
||||
y = x
|
||||
}
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test23(x: Any) {
|
||||
var y: Any
|
||||
exactlyOnce {
|
||||
require(x is String)
|
||||
y = x
|
||||
}
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test24(x: Any) {
|
||||
var y: Any
|
||||
atLeastOnce {
|
||||
require(x is String)
|
||||
y = x
|
||||
}
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test25(x: Any) {
|
||||
var y = x
|
||||
exactlyOnce {
|
||||
while (x is String) {
|
||||
y.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test26(x: Any) {
|
||||
var y = x
|
||||
atLeastOnce {
|
||||
while (x is String) {
|
||||
y.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test27(x: Any) {
|
||||
var y = x
|
||||
runWithoutContract {
|
||||
while (x is String) {
|
||||
y.length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test28() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
exactlyOnce {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test29() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
atLeastOnce {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test30() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
runWithoutContract {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test31() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
exactlyOnce {
|
||||
while (x is String) {
|
||||
y.length
|
||||
x.length
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test32() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
atLeastOnce {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
x.length
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test33() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
runWithoutContract {
|
||||
while (x is String) {
|
||||
y.length
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
+378
@@ -0,0 +1,378 @@
|
||||
// ISSUE: KT-28806
|
||||
// WITH_STDLIB
|
||||
// DIAGNOSTICS: -ERROR_SUPPRESSION, -DEBUG_INFO_SMARTCAST
|
||||
import kotlin.contracts.*
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun atLeastOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
|
||||
}
|
||||
block()
|
||||
}
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun exactlyOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
block()
|
||||
}
|
||||
|
||||
fun runWithoutContract(block: () -> Unit): Unit = block()
|
||||
|
||||
fun <R> materialize(): R = null!!
|
||||
|
||||
fun test1(x: Any) {
|
||||
var y = x
|
||||
require(y is String)
|
||||
runWithoutContract {
|
||||
y = 10
|
||||
y = x
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(x: Any) {
|
||||
var y = x
|
||||
require(y is String)
|
||||
exactlyOnce {
|
||||
y = 10
|
||||
y = x
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(x: Any) {
|
||||
var y = x
|
||||
require(y is String)
|
||||
atLeastOnce {
|
||||
y = 10
|
||||
y = x
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(x: Any) {
|
||||
var y: Any
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
y = 10
|
||||
y = x
|
||||
x.length
|
||||
<!SMARTCAST_IMPOSSIBLE!>y<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(x: Any) {
|
||||
var y: Any
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
y = 10
|
||||
y = x
|
||||
x.length
|
||||
<!SMARTCAST_IMPOSSIBLE!>y<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test6(x: Any) {
|
||||
var y: Any
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
y = 10
|
||||
y = x
|
||||
x.length
|
||||
<!SMARTCAST_IMPOSSIBLE!>y<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test7(x: Any) {
|
||||
var y: Any?
|
||||
val b = x is String
|
||||
if (b) {
|
||||
y = x
|
||||
exactlyOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test8(x: Any) {
|
||||
var y: Any?
|
||||
val b = x is String
|
||||
if (b) {
|
||||
y = x
|
||||
atLeastOnce {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test9(x: Any) {
|
||||
var y: Any?
|
||||
val b = x is String
|
||||
if (b) {
|
||||
y = x
|
||||
runWithoutContract {
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test10(x: Any) {
|
||||
var y = x
|
||||
runWithoutContract {
|
||||
require(y is String)
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test11(x: Any) {
|
||||
var y = x
|
||||
atLeastOnce {
|
||||
require(y is String)
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test12(x: Any) {
|
||||
var y = x
|
||||
exactlyOnce {
|
||||
require(y is String)
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test13() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
atLeastOnce {
|
||||
require(y is String)
|
||||
x = 10
|
||||
y = x
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inc<!>()
|
||||
}
|
||||
}
|
||||
|
||||
fun test14() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
exactlyOnce {
|
||||
require(y is String)
|
||||
x = 10
|
||||
y = x
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inc<!>()
|
||||
}
|
||||
}
|
||||
|
||||
fun test15() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
runWithoutContract {
|
||||
require(y is String)
|
||||
x = 10
|
||||
y = x
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inc<!>()
|
||||
}
|
||||
}
|
||||
|
||||
fun test16(x: Any) {
|
||||
var y: Any
|
||||
runWithoutContract {
|
||||
require(x is String)
|
||||
y = x
|
||||
<!SMARTCAST_IMPOSSIBLE!>y<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test17(x: Any) {
|
||||
var y: Any
|
||||
exactlyOnce {
|
||||
require(x is String)
|
||||
y = x
|
||||
<!SMARTCAST_IMPOSSIBLE!>y<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test18(x: Any) {
|
||||
var y: Any
|
||||
atLeastOnce {
|
||||
require(x is String)
|
||||
y = x
|
||||
<!SMARTCAST_IMPOSSIBLE!>y<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test19(x: Any?) {
|
||||
var y: Any
|
||||
atLeastOnce {
|
||||
if (x != null) {
|
||||
y = x
|
||||
} else {
|
||||
y = <!DEBUG_INFO_CONSTANT, TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
require(x is String)
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test20(x: Any?) {
|
||||
var y: Any
|
||||
exactlyOnce {
|
||||
if (x != null) {
|
||||
y = x
|
||||
} else {
|
||||
y = <!DEBUG_INFO_CONSTANT, TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
require(x is String)
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test21(x: Any?) {
|
||||
var y: Any
|
||||
runWithoutContract {
|
||||
if (x != null) {
|
||||
y = x
|
||||
} else {
|
||||
y = <!DEBUG_INFO_CONSTANT, TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
require(x is String)
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test22(x: Any) {
|
||||
var y: Any = materialize()
|
||||
runWithoutContract {
|
||||
require(x is String)
|
||||
y = x
|
||||
}
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test23(x: Any) {
|
||||
var y: Any
|
||||
exactlyOnce {
|
||||
require(x is String)
|
||||
y = x
|
||||
}
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test24(x: Any) {
|
||||
var y: Any
|
||||
atLeastOnce {
|
||||
require(x is String)
|
||||
y = x
|
||||
}
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
|
||||
fun test25(x: Any) {
|
||||
var y = x
|
||||
exactlyOnce {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test26(x: Any) {
|
||||
var y = x
|
||||
atLeastOnce {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test27(x: Any) {
|
||||
var y = x
|
||||
runWithoutContract {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test28() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
exactlyOnce {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test29() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
atLeastOnce {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test30() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
runWithoutContract {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test31() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
exactlyOnce {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test32() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
atLeastOnce {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun test33() {
|
||||
var x: Any? = materialize()
|
||||
var y = x
|
||||
runWithoutContract {
|
||||
while (x is String) {
|
||||
y.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
// ISSUE: KT-28806
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
// DIAGNOSTICS: -ERROR_SUPPRESSION
|
||||
import kotlin.contracts.*
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun atLeastOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
|
||||
}
|
||||
block()
|
||||
}
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun exactlyOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
block()
|
||||
}
|
||||
|
||||
fun runWithoutContract(block: () -> Unit): Unit = block()
|
||||
|
||||
class Delegate {
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): Any {
|
||||
TODO()
|
||||
}
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Any) {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
var x: Any by Delegate()
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
var x: Any by Delegate()
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
var x: Any by Delegate()
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
val x: Any by Delegate()
|
||||
require(x is String)
|
||||
runWithoutContract {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test5() {
|
||||
val x: Any by Delegate()
|
||||
require(x is String)
|
||||
atLeastOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test6() {
|
||||
val x: Any by Delegate()
|
||||
require(x is String)
|
||||
exactlyOnce {
|
||||
<!SMARTCAST_IMPOSSIBLE!>x<!>.length
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
// ISSUE: KT-28806
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
// DIAGNOSTICS: -ERROR_SUPPRESSION, -DEBUG_INFO_SMARTCAST
|
||||
import kotlin.contracts.*
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun atLeastOnce(block: () -> Unit): Boolean {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
|
||||
}
|
||||
block()
|
||||
return true
|
||||
}
|
||||
|
||||
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
|
||||
fun exactlyOnce(block: () -> Unit): Boolean {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
block()
|
||||
return true
|
||||
}
|
||||
|
||||
fun runWithoutContract(block: () -> Unit): Boolean {
|
||||
block()
|
||||
return true
|
||||
}
|
||||
|
||||
fun test1(x: Any) {
|
||||
if (x !is String || atLeastOnce { x.length }) return
|
||||
}
|
||||
|
||||
fun test2(x: Any) {
|
||||
if (x !is String || exactlyOnce { x.length }) return
|
||||
}
|
||||
|
||||
fun test3(x: Any) {
|
||||
if (x !is String || runWithoutContract { x.length }) return
|
||||
}
|
||||
|
||||
fun test4(x: Any) {
|
||||
if (x is String && atLeastOnce { x.length }) {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(x: Any) {
|
||||
if (x is String && exactlyOnce { x.length }) {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test6(x: Any) {
|
||||
if (x is String && runWithoutContract { x.length }) {
|
||||
x.length
|
||||
}
|
||||
}
|
||||
compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithImpliesContract.fir.kt
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
// ISSUE: KT-37308
|
||||
// WITH_STDLIB
|
||||
// DIAGNOSTICS: -ERROR_SUPPRESSION
|
||||
import kotlin.contracts.*
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun CharSequence?.valueIsNotNull(): Boolean {
|
||||
contract {
|
||||
returns(true) implies (this@valueIsNotNull != null)
|
||||
}
|
||||
return this != null
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun CharSequence?.valueIsNull(): Boolean {
|
||||
contract {
|
||||
returns(false) implies (this@valueIsNull != null)
|
||||
}
|
||||
return this == null
|
||||
}
|
||||
|
||||
class A {
|
||||
val b: String? = ""
|
||||
val e: C? = C()
|
||||
}
|
||||
|
||||
class C {
|
||||
val d: String? = ""
|
||||
}
|
||||
|
||||
fun test1(a: A?) {
|
||||
if (!a?.b.valueIsNull()) {
|
||||
a.b.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(a: A?) {
|
||||
require(!a?.b.valueIsNull())
|
||||
a.b.length
|
||||
}
|
||||
|
||||
fun test3(a: A?) {
|
||||
if(a?.b.valueIsNotNull()){
|
||||
a.b.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(a :A?) {
|
||||
require(a?.b.valueIsNotNull())
|
||||
a.b.length
|
||||
}
|
||||
|
||||
fun test5(a :A?) {
|
||||
require(a?.e?.d.valueIsNotNull())
|
||||
a.e.d.length
|
||||
}
|
||||
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
// ISSUE: KT-37308
|
||||
// WITH_STDLIB
|
||||
// DIAGNOSTICS: -ERROR_SUPPRESSION
|
||||
import kotlin.contracts.*
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun CharSequence?.valueIsNotNull(): Boolean {
|
||||
contract {
|
||||
returns(true) implies (this@valueIsNotNull != null)
|
||||
}
|
||||
return this != null
|
||||
}
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
fun CharSequence?.valueIsNull(): Boolean {
|
||||
contract {
|
||||
returns(false) implies (this@valueIsNull != null)
|
||||
}
|
||||
return this == null
|
||||
}
|
||||
|
||||
class A {
|
||||
val b: String? = ""
|
||||
val e: C? = C()
|
||||
}
|
||||
|
||||
class C {
|
||||
val d: String? = ""
|
||||
}
|
||||
|
||||
fun test1(a: A?) {
|
||||
if (!a?.b.valueIsNull()) {
|
||||
a<!UNSAFE_CALL!>.<!>b<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(a: A?) {
|
||||
require(!a?.b.valueIsNull())
|
||||
a<!UNSAFE_CALL!>.<!>b<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test3(a: A?) {
|
||||
if(a?.b.valueIsNotNull()){
|
||||
a<!UNSAFE_CALL!>.<!>b<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(a :A?) {
|
||||
require(a?.b.valueIsNotNull())
|
||||
a<!UNSAFE_CALL!>.<!>b<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
fun test5(a :A?) {
|
||||
require(a?.e?.d.valueIsNotNull())
|
||||
a<!UNSAFE_CALL!>.<!>e<!UNSAFE_CALL!>.<!>d<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// ISSUE: KT-4113
|
||||
// DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
class Test1(val lambda: (() -> String)?) {
|
||||
fun foo() {
|
||||
if (lambda != null) {
|
||||
lambda.invoke()
|
||||
lambda()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(lambda: (() -> String)?) {
|
||||
if (lambda != null) {
|
||||
lambda.invoke()
|
||||
lambda()
|
||||
}
|
||||
}
|
||||
|
||||
class A
|
||||
operator fun A.invoke(): Unit = TODO()
|
||||
|
||||
class Test3 {
|
||||
val nullableCallableClass: A? = null
|
||||
fun foo() {
|
||||
if (nullableCallableClass != null) {
|
||||
nullableCallableClass()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(nullableCallableClass: A?){
|
||||
if (nullableCallableClass != null) {
|
||||
nullableCallableClass()
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
operator fun invoke(s: String): (() -> String)? = TODO()
|
||||
operator fun invoke(): (() -> String) = TODO()
|
||||
}
|
||||
|
||||
class Test4 {
|
||||
fun foo(a: B) {
|
||||
if (a("") != null) {
|
||||
a()()
|
||||
<!UNSAFE_IMPLICIT_INVOKE_CALL!>a("")<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(a: B) {
|
||||
if (a("") != null) {
|
||||
a()()
|
||||
<!UNSAFE_IMPLICIT_INVOKE_CALL!>a("")<!>()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// ISSUE: KT-4113
|
||||
// DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
class Test1(val lambda: (() -> String)?) {
|
||||
fun foo() {
|
||||
if (lambda != null) {
|
||||
lambda.invoke()
|
||||
<!UNSAFE_IMPLICIT_INVOKE_CALL!>lambda<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(lambda: (() -> String)?) {
|
||||
if (lambda != null) {
|
||||
lambda.invoke()
|
||||
lambda()
|
||||
}
|
||||
}
|
||||
|
||||
class A
|
||||
operator fun A.invoke(): Unit = TODO()
|
||||
|
||||
class Test3 {
|
||||
val nullableCallableClass: A? = null
|
||||
fun foo() {
|
||||
if (nullableCallableClass != null) {
|
||||
<!UNSAFE_CALL!>nullableCallableClass<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(nullableCallableClass: A?){
|
||||
if (nullableCallableClass != null) {
|
||||
nullableCallableClass()
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
operator fun invoke(s: String): (() -> String)? = TODO()
|
||||
operator fun invoke(): (() -> String) = TODO()
|
||||
}
|
||||
|
||||
class Test4 {
|
||||
fun foo(a: B) {
|
||||
if (a("") != null) {
|
||||
a()()
|
||||
<!UNSAFE_IMPLICIT_INVOKE_CALL!>a("")<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(a: B) {
|
||||
if (a("") != null) {
|
||||
a()()
|
||||
<!UNSAFE_IMPLICIT_INVOKE_CALL!>a("")<!>()
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// ISSUE: KT-54443
|
||||
// WITH_STDLIB
|
||||
|
||||
class A {
|
||||
val b: Int? = 1
|
||||
val e: C? = C()
|
||||
}
|
||||
|
||||
class C {
|
||||
val d: Int? = 2
|
||||
}
|
||||
|
||||
fun test(a: A?) {
|
||||
require(a?.b != null)
|
||||
a.b.inc()
|
||||
}
|
||||
|
||||
fun test2(a: A?){
|
||||
require(a?.e?.d != null)
|
||||
var k: C = a.e
|
||||
var k2: Int = a.e.d
|
||||
var k3: Int? = a.b
|
||||
}
|
||||
|
||||
fun test3(a:A?){
|
||||
val t = (a?.b != null)
|
||||
require(t)
|
||||
a.b.inc()
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// ISSUE: KT-54443
|
||||
// WITH_STDLIB
|
||||
|
||||
class A {
|
||||
val b: Int? = 1
|
||||
val e: C? = C()
|
||||
}
|
||||
|
||||
class C {
|
||||
val d: Int? = 2
|
||||
}
|
||||
|
||||
fun test(a: A?) {
|
||||
require(a?.b != null)
|
||||
a<!UNSAFE_CALL!>.<!>b<!UNSAFE_CALL!>.<!>inc()
|
||||
}
|
||||
|
||||
fun test2(a: A?){
|
||||
require(a?.e?.d != null)
|
||||
var k: C = <!TYPE_MISMATCH!>a<!UNSAFE_CALL!>.<!>e<!>
|
||||
var k2: Int = <!TYPE_MISMATCH!>a<!UNSAFE_CALL!>.<!>e<!UNSAFE_CALL!>.<!>d<!>
|
||||
var k3: Int? = a<!UNSAFE_CALL!>.<!>b
|
||||
}
|
||||
|
||||
fun test3(a:A?){
|
||||
val t = (a?.b != null)
|
||||
require(t)
|
||||
a<!UNSAFE_CALL!>.<!>b<!UNSAFE_CALL!>.<!>inc()
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// ISSUE: KT-25747
|
||||
fun test1() {
|
||||
val nullableString: String? = ""
|
||||
val savedSmartCastResult = nullableString != null
|
||||
if (savedSmartCastResult) {
|
||||
nullableString.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
var nullableAny: Any? = ""
|
||||
val savedSmartCastResult = nullableAny is String
|
||||
nullableAny = 10
|
||||
if (savedSmartCastResult) {
|
||||
nullableAny.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
val a: String? = ""
|
||||
}
|
||||
fun test3(a: A){
|
||||
val savedSmartCastResult = a.a != null
|
||||
if(savedSmartCastResult) {
|
||||
a.a.length
|
||||
}
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
val nullableAny: Any? = ""
|
||||
val savedSmartCastResult = (nullableAny!= null && nullableAny is String?)
|
||||
if(savedSmartCastResult) {
|
||||
nullableAny.length
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// ISSUE: KT-25747
|
||||
fun test1() {
|
||||
val nullableString: String? = ""
|
||||
val savedSmartCastResult = nullableString != null
|
||||
if (savedSmartCastResult) {
|
||||
nullableString<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
var nullableAny: Any? = ""
|
||||
val savedSmartCastResult = nullableAny is String
|
||||
nullableAny = 10
|
||||
if (savedSmartCastResult) {
|
||||
nullableAny.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
val a: String? = ""
|
||||
}
|
||||
fun test3(a: A){
|
||||
val savedSmartCastResult = a.a != null
|
||||
if(savedSmartCastResult) {
|
||||
a.a<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
val nullableAny: Any? = ""
|
||||
val savedSmartCastResult = (nullableAny!= null && nullableAny is String?)
|
||||
if(savedSmartCastResult) {
|
||||
nullableAny.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// ISSUE: KT-24779
|
||||
// WITH_STDLIB
|
||||
// DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
|
||||
class C<T>(val data: T)
|
||||
|
||||
fun test1(x: C<out Any?>) {
|
||||
val y = x.data
|
||||
require(y is String)
|
||||
x.data.length
|
||||
y.length
|
||||
}
|
||||
|
||||
fun test2(x: C<out String?>) {
|
||||
val y = x.data
|
||||
require(y is String)
|
||||
x.data.length
|
||||
y.length
|
||||
}
|
||||
|
||||
fun test3(x: C<out Int?>) {
|
||||
val y = x.data
|
||||
require(y is Number)
|
||||
x.data.inc()
|
||||
y.inc()
|
||||
}
|
||||
|
||||
fun test4(x: C<in Any?>) {
|
||||
val y = x.data
|
||||
require(y is String)
|
||||
x.data.length
|
||||
y.length
|
||||
}
|
||||
|
||||
fun test5(x: C<in String?>) {
|
||||
val y = x.data
|
||||
require(y is String)
|
||||
x.data.length
|
||||
y.length
|
||||
}
|
||||
|
||||
fun test6(x: C<in Number?>) {
|
||||
val y = x.data
|
||||
require(y is Int)
|
||||
x.data.inc()
|
||||
y.inc()
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// ISSUE: KT-24779
|
||||
// WITH_STDLIB
|
||||
// DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
|
||||
|
||||
class C<T>(val data: T)
|
||||
|
||||
fun test1(x: C<out Any?>) {
|
||||
val y = x.data
|
||||
require(y is String)
|
||||
x.data.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.length
|
||||
}
|
||||
|
||||
fun test2(x: C<out String?>) {
|
||||
val y = x.data
|
||||
require(y is String)
|
||||
x.data.length
|
||||
y.length
|
||||
}
|
||||
|
||||
fun test3(x: C<out Int?>) {
|
||||
val y = x.data
|
||||
require(y is Number)
|
||||
x.data.inc()
|
||||
y.inc()
|
||||
}
|
||||
|
||||
fun test4(x: C<in Any?>) {
|
||||
val y = x.data
|
||||
require(y is String)
|
||||
x.data.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.length
|
||||
}
|
||||
|
||||
fun test5(x: C<in String?>) {
|
||||
val y = x.data
|
||||
require(y is String)
|
||||
x.data.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
y.length
|
||||
}
|
||||
|
||||
fun test6(x: C<in Number?>) {
|
||||
val y = x.data
|
||||
require(y is Int)
|
||||
x.data.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inc<!>()
|
||||
y.inc()
|
||||
}
|
||||
Generated
+82
@@ -34156,6 +34156,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/alwaysNullWithJava.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("binaryOperatorsWithJumps.kt")
|
||||
public void testBinaryOperatorsWithJumps() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/binaryOperatorsWithJumps.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("classObjectMember.kt")
|
||||
public void testClassObjectMember() throws Exception {
|
||||
@@ -34168,6 +34174,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonOfBuiltInTypesUnderOr.kt")
|
||||
public void testComparisonOfBuiltInTypesUnderOr() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/comparisonOfBuiltInTypesUnderOr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonOfClassTypesUnderOr.kt")
|
||||
public void testComparisonOfClassTypesUnderOr() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/comparisonOfClassTypesUnderOr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comparisonUnderAnd.kt")
|
||||
public void testComparisonUnderAnd() throws Exception {
|
||||
@@ -34720,6 +34738,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/NullableFunctionTypeAsMemberMutablePropertyFromConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableLambda.kt")
|
||||
public void testNullableLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/nullableLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("openInSealed.kt")
|
||||
public void testOpenInSealed() throws Exception {
|
||||
@@ -34750,6 +34774,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safeAs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("savedSmartcastResult.kt")
|
||||
public void testSavedSmartcastResult() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/savedSmartcastResult.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("severalSmartCastsOnReified.kt")
|
||||
public void testSeveralSmartCastsOnReified() throws Exception {
|
||||
@@ -34888,6 +34918,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/typeInComparison.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterWithBounds.kt")
|
||||
public void testTypeParameterWithBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/typeParameterWithBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unstableToStable.kt")
|
||||
public void testUnstableToStable() throws Exception {
|
||||
@@ -35276,6 +35312,46 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class LambdasWithContracts {
|
||||
@Test
|
||||
public void testAllFilesPresentInLambdasWithContracts() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlace.kt")
|
||||
public void testLambdaWithCallInPlace() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlace.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndBounds.kt")
|
||||
public void testLambdaWithCallInPlaceAndBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndDelegate.kt")
|
||||
public void testLambdaWithCallInPlaceAndDelegate() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithCallInPlaceAndOperators.kt")
|
||||
public void testLambdaWithCallInPlaceAndOperators() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithCallInPlaceAndOperators.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaWithImpliesContract.kt")
|
||||
public void testLambdaWithImpliesContract() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/lambdasWithContracts/lambdaWithImpliesContract.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/loops")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -35795,6 +35871,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safecalls/chainMixedUnsafe.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("childProperty.kt")
|
||||
public void testChildProperty() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/safecalls/childProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("doubleCall.kt")
|
||||
public void testDoubleCall() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user