[NI] remove redundant replacing receiver in lambda function descriptor
#KT-30927 Fixed #KT-31057 Fixed
This commit is contained in:
+5
@@ -19539,6 +19539,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt30826.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt30927.kt")
|
||||
public void testKt30927() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt30927.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt3224.kt")
|
||||
public void testKt3224() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3224.kt");
|
||||
|
||||
+5
-3
@@ -208,9 +208,11 @@ class ResolvedAtomCompleter(
|
||||
|
||||
val newReceiverValue = receiver.value.replaceType(newValueType)
|
||||
|
||||
functionDescriptor.setExtensionReceiverParameter(
|
||||
ReceiverParameterDescriptorImpl(receiver.containingDeclaration, newReceiverValue, receiver.annotations)
|
||||
)
|
||||
if (newReceiverValue != receiver.value) {
|
||||
functionDescriptor.setExtensionReceiverParameter(
|
||||
ReceiverParameterDescriptorImpl(receiver.containingDeclaration, newReceiverValue, receiver.annotations)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun case_0() {
|
||||
val z: Any? = 10
|
||||
val y = z.run {
|
||||
this as Int
|
||||
<!NI;DEBUG_INFO_SMARTCAST!>this<!> // error in NI: required Int, found Any?; just inferred to Any? in OI
|
||||
}
|
||||
y checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Any?>() }
|
||||
y checkType { <!OI;TYPE_MISMATCH!>_<!><Int>() }
|
||||
}
|
||||
|
||||
fun case_1(z: Any?) {
|
||||
val y = z.run {
|
||||
when (this) {
|
||||
is String -> return@run <!NI;DEBUG_INFO_SMARTCAST!>this<!> // type mismatch in the new inference (required String, found Any?)
|
||||
is Float -> ""
|
||||
else -> return@run ""
|
||||
}
|
||||
}
|
||||
y checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Any?>() }
|
||||
y checkType { <!OI;TYPE_MISMATCH!>_<!><kotlin.String>() }
|
||||
// y is inferred to Any?
|
||||
}
|
||||
|
||||
fun case_2(z: Any?) {
|
||||
val y = z.run {
|
||||
when (this) {
|
||||
is String -> <!DEBUG_INFO_SMARTCAST!>this<!>
|
||||
is Float -> ""
|
||||
else -> return@run ""
|
||||
}
|
||||
}
|
||||
y checkType { _<kotlin.String>() }
|
||||
// y is inferred to String
|
||||
}
|
||||
|
||||
fun case_3(z: Any?) {
|
||||
val y = z.let {
|
||||
when (it) {
|
||||
is String -> return@let <!NI;DEBUG_INFO_SMARTCAST!>it<!>
|
||||
is Float -> ""
|
||||
else -> return@let ""
|
||||
}
|
||||
}
|
||||
y checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Any?>() }
|
||||
y checkType { <!OI;TYPE_MISMATCH!>_<!><kotlin.String>() }
|
||||
// y is inferred to String
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public fun case_0(): kotlin.Unit
|
||||
public fun case_1(/*0*/ z: kotlin.Any?): kotlin.Unit
|
||||
public fun case_2(/*0*/ z: kotlin.Any?): kotlin.Unit
|
||||
public fun case_3(/*0*/ z: kotlin.Any?): kotlin.Unit
|
||||
@@ -19616,6 +19616,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt30826.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt30927.kt")
|
||||
public void testKt30927() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt30927.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt3224.kt")
|
||||
public void testKt3224() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3224.kt");
|
||||
|
||||
Generated
+5
@@ -19541,6 +19541,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt30826.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt30927.kt")
|
||||
public void testKt30927() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt30927.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt3224.kt")
|
||||
public void testKt3224() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/smartCasts/kt3224.kt");
|
||||
|
||||
Reference in New Issue
Block a user