K2: Fix false-positive UNSAFE_CALL on safe call with flexible type alias
The idea of the fix is just unwrapping flexible version of type alias, before creating a not-nullable version for safe-call subject. Otherwise, it was remained to be JsExpressionResult after applying makeConeTypeDefinitelyNotNullOrNotNull (and the type is still nullable) ^KT-57190 Fixed
This commit is contained in:
committed by
Space Team
parent
bf977d4262
commit
823c60a7dc
+16
@@ -27811,6 +27811,22 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/safeCalls")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SafeCalls {
|
||||
@Test
|
||||
public void testAllFilesPresentInSafeCalls() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/safeCalls"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("safeCallOnFlexibleTypeAlias.kt")
|
||||
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/samConversions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+16
@@ -27823,6 +27823,22 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/safeCalls")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SafeCalls {
|
||||
@Test
|
||||
public void testAllFilesPresentInSafeCalls() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/safeCalls"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("safeCallOnFlexibleTypeAlias.kt")
|
||||
public void testSafeCallOnFlexibleTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/safeCalls/safeCallOnFlexibleTypeAlias.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/samConversions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
@@ -482,7 +482,7 @@ fun FirCheckedSafeCallSubject.propagateTypeFromOriginalReceiver(
|
||||
?: nullableReceiverExpression.typeRef)
|
||||
.coneTypeSafe<ConeKotlinType>() ?: return
|
||||
|
||||
val expandedReceiverType = if (receiverType is ConeClassLikeType) receiverType.fullyExpandedType(session) else receiverType
|
||||
val expandedReceiverType = receiverType.fullyExpandedType(session)
|
||||
|
||||
val resolvedTypeRef =
|
||||
typeRef.resolvedTypeFromPrototype(expandedReceiverType.makeConeTypeDefinitelyNotNullOrNotNull(session.typeContext))
|
||||
|
||||
Reference in New Issue
Block a user