[NI] Fix expicit super receiver check

^KT-37497 Fixed
This commit is contained in:
Pavel Kirpichenkov
2020-04-17 12:28:42 +03:00
parent af147017b4
commit b91cf13259
9 changed files with 46 additions and 5 deletions
@@ -2418,6 +2418,11 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi
public void testKt9820_javaFunctionTypeInheritor() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/regression/kt9820_javaFunctionTypeInheritor.kt");
}
@TestMetadata("kt-37497.kt")
public void testKt_37497() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/regression/kt-37497.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/reified")
@@ -65,7 +65,7 @@ class KotlinResolutionStatelessCallbacksImpl(
descriptor,
(kotlinCall as? PSIKotlinCall)?.psiCall,
(resolutionCallbacks as? KotlinResolutionCallbacksImpl)?.trace?.bindingContext,
isSuperOrDelegatingConstructorCall(kotlinCall),
kotlinCall is PSIKotlinCallImpl && kotlinCall.psiCall.isCallWithSuperReceiver(),
)
override fun isSuperExpression(receiver: SimpleKotlinCallArgument?): Boolean =
@@ -601,7 +601,8 @@ internal fun createPreviousResolveError(status: ResolutionStatus): PreviousResol
return PreviousResolutionError(level)
}
private val BasicCallResolutionContext.isSuperCall: Boolean get() = call.explicitReceiver is SuperCallReceiverValue
internal fun Call.isCallWithSuperReceiver(): Boolean = explicitReceiver is SuperCallReceiverValue
private val BasicCallResolutionContext.isSuperCall: Boolean get() = call.isCallWithSuperReceiver()
internal fun reportResolvedUsingDeprecatedVisibility(
call: Call,
@@ -0,0 +1,18 @@
// FIR_IDENTICAL
// FULL_JDK
// Issue: KT-37497
import java.util.*
object Bug1 {
@JvmStatic
fun main(args: Array<String>) {
val list = object : ArrayList<String>(listOf("a")) {
override fun sort(c: Comparator<in String>?) {
super.sort(c)
println(c)
}
}
println(list)
}
}
@@ -0,0 +1,9 @@
package
public object Bug1 {
private constructor Bug1()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@kotlin.jvm.JvmStatic public final fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1,4 +1,3 @@
// !WITH_NEW_INFERENCE
// FULL_JDK
abstract class A : MutableList<String> {
@@ -1,9 +1,8 @@
// !WITH_NEW_INFERENCE
// FULL_JDK
abstract class A : MutableList<String> {
override fun sort(/*0*/ p0: java.util.Comparator<in String>) {
<!NI;SUPER_CANT_BE_EXTENSION_RECEIVER!>super<!>.<!NI;DEPRECATION_ERROR, OI;DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR!>sort<!>(p0)
super.<!DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR!>sort<!>(p0)
}
}
@@ -3423,6 +3423,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
public void testKt9820_javaFunctionTypeInheritor() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/regression/kt9820_javaFunctionTypeInheritor.kt");
}
@TestMetadata("kt-37497.kt")
public void testKt_37497() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/regression/kt-37497.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/reified")
@@ -3423,6 +3423,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
public void testKt9820_javaFunctionTypeInheritor() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/regression/kt9820_javaFunctionTypeInheritor.kt");
}
@TestMetadata("kt-37497.kt")
public void testKt_37497() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/regression/kt-37497.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/reified")