[FIR] Fix resolve inside lambda
The lambda is passed to extension function with type parameters that defined inside this lambda ^KT-52197 ^KT-52190 Fixed
This commit is contained in:
+6
@@ -25784,6 +25784,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt")
|
||||
public void testVarInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("wrongNumberOfTypeArguments.kt")
|
||||
public void testWrongNumberOfTypeArguments() throws Exception {
|
||||
|
||||
+6
@@ -25784,6 +25784,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt")
|
||||
public void testVarInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("wrongNumberOfTypeArguments.kt")
|
||||
public void testWrongNumberOfTypeArguments() throws Exception {
|
||||
|
||||
+6
@@ -25784,6 +25784,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt")
|
||||
public void testVarInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("wrongNumberOfTypeArguments.kt")
|
||||
public void testWrongNumberOfTypeArguments() throws Exception {
|
||||
|
||||
+4
-1
@@ -650,7 +650,10 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
||||
map.put(SUPER_IS_NOT_AN_EXPRESSION, "Super cannot be a callee")
|
||||
map.put(SUPER_NOT_AVAILABLE, "No supertypes are accessible in this context")
|
||||
map.put(ABSTRACT_SUPER_CALL, "Abstract member cannot be accessed directly")
|
||||
map.put(ABSTRACT_SUPER_CALL_WARNING, "Abstract fake override member access is deprecated. See https://youtrack.jetbrains.com/issue/KT-49017")
|
||||
map.put(
|
||||
ABSTRACT_SUPER_CALL_WARNING,
|
||||
"Abstract fake override member access is deprecated. See https://youtrack.jetbrains.com/issue/KT-49017"
|
||||
)
|
||||
map.put(
|
||||
INSTANCE_ACCESS_BEFORE_SUPER_CALL,
|
||||
"Cannot access ''{0}'' before superclass constructor has been called",
|
||||
|
||||
+6
@@ -131,6 +131,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/annotations/constValInAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("correctTypeForClassReferenceExpressionInAnnotation.kt")
|
||||
public void testCorrectTypeForClassReferenceExpressionInAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/correctTypeForClassReferenceExpressionInAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParameterValues.kt")
|
||||
public void testDefaultParameterValues() throws Exception {
|
||||
|
||||
@@ -354,7 +354,9 @@ private inline fun <T : FirExpression> BodyResolveComponents.transformExpression
|
||||
|
||||
val originalType = expression.resultType.coneType
|
||||
val allTypes = typesFromSmartCast.also {
|
||||
it += originalType
|
||||
if (originalType !is ConeStubType) {
|
||||
it += originalType
|
||||
}
|
||||
}
|
||||
val intersectedType = ConeTypeIntersector.intersectTypes(session.typeContext, allTypes)
|
||||
if (intersectedType == originalType) return null
|
||||
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-52190
|
||||
|
||||
fun box(): String {
|
||||
buildMap {
|
||||
val replaced = put("key", "value")
|
||||
if (replaced != null) {
|
||||
return "Error: $replaced"
|
||||
}
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+9
-9
@@ -57,13 +57,13 @@ fun test() {
|
||||
if (get() === null) {}
|
||||
|
||||
if (x != null) {
|
||||
x?.hashCode()
|
||||
x?.<!NONE_APPLICABLE!>equals<!>(1)
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>hashCode()
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>equals(1)
|
||||
x.equals("")
|
||||
x.hashCode()
|
||||
x.toString()
|
||||
x.test()
|
||||
x?.test2()
|
||||
x<!UNNECESSARY_SAFE_CALL!>?.<!>test2()
|
||||
x.test2()
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ fun test() {
|
||||
emit(null)
|
||||
val x = get()
|
||||
if (x == null) {
|
||||
x.<!NONE_APPLICABLE!>toString<!>("")
|
||||
x<!UNSAFE_CALL!>.<!>toString("")
|
||||
}
|
||||
|
||||
""
|
||||
@@ -104,7 +104,7 @@ fun test() {
|
||||
emit(null)
|
||||
val x = get()
|
||||
if (x == null) {
|
||||
x.test()
|
||||
x<!UNSAFE_CALL!>.<!>test()
|
||||
}
|
||||
|
||||
""
|
||||
@@ -134,7 +134,7 @@ fun test() {
|
||||
emit(null)
|
||||
val x = get()
|
||||
if (x === null) {
|
||||
x.<!NONE_APPLICABLE!>toString<!>("")
|
||||
x<!UNSAFE_CALL!>.<!>toString("")
|
||||
}
|
||||
|
||||
""
|
||||
@@ -144,7 +144,7 @@ fun test() {
|
||||
emit(null)
|
||||
val x = get()
|
||||
if (x === null) {
|
||||
x.test()
|
||||
x<!UNSAFE_CALL!>.<!>test()
|
||||
}
|
||||
|
||||
""
|
||||
@@ -239,7 +239,7 @@ fun test() {
|
||||
emit(null)
|
||||
val x = get()
|
||||
if (x == null) {
|
||||
x.test()
|
||||
x<!UNSAFE_CALL!>.<!>test()
|
||||
}
|
||||
""
|
||||
}
|
||||
@@ -276,7 +276,7 @@ fun test() {
|
||||
emit(null)
|
||||
val x = get()
|
||||
if (x === null) {
|
||||
x.test()
|
||||
x<!UNSAFE_CALL!>.<!>test()
|
||||
}
|
||||
""
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-52197
|
||||
|
||||
fun <K, V> helper(builderAction: MutableMap<K, V>.() -> Unit) {
|
||||
builderAction(mutableMapOf())
|
||||
}
|
||||
|
||||
fun test(){
|
||||
helper {
|
||||
val x = put("key", "value")
|
||||
if (x != null) {
|
||||
"Error: $x"
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
x.<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-52197
|
||||
|
||||
fun <K, V> helper(builderAction: MutableMap<K, V>.() -> Unit) {
|
||||
builderAction(mutableMapOf())
|
||||
}
|
||||
|
||||
fun test(){
|
||||
helper {
|
||||
val x = put("key", "value")
|
||||
if (x != null) {
|
||||
"Error: $x"
|
||||
x.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
x.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE, DEBUG_INFO_UNRESOLVED_WITH_TARGET, UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K, /*1*/ V> helper(/*0*/ builderAction: kotlin.collections.MutableMap<K, V>.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
Generated
+6
@@ -25796,6 +25796,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt")
|
||||
public void testVarInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/varInsideLambdaThatPassedToExtensionFunctionWithTypeParametersThatDefinedInsideThisLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("wrongNumberOfTypeArguments.kt")
|
||||
public void testWrongNumberOfTypeArguments() throws Exception {
|
||||
|
||||
+6
@@ -119,6 +119,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/annotations/constValInAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("correctTypeForClassReferenceExpressionInAnnotation.kt")
|
||||
public void testCorrectTypeForClassReferenceExpressionInAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/correctTypeForClassReferenceExpressionInAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParameterValues.kt")
|
||||
public void testDefaultParameterValues() throws Exception {
|
||||
|
||||
+6
@@ -131,6 +131,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/annotations/constValInAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("correctTypeForClassReferenceExpressionInAnnotation.kt")
|
||||
public void testCorrectTypeForClassReferenceExpressionInAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/correctTypeForClassReferenceExpressionInAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParameterValues.kt")
|
||||
public void testDefaultParameterValues() throws Exception {
|
||||
|
||||
+5
@@ -113,6 +113,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/annotations/constValInAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("correctTypeForClassReferenceExpressionInAnnotation.kt")
|
||||
public void testCorrectTypeForClassReferenceExpressionInAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/correctTypeForClassReferenceExpressionInAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValues.kt")
|
||||
public void testDefaultParameterValues() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/defaultParameterValues.kt");
|
||||
|
||||
Reference in New Issue
Block a user