Fix type of callable reference to fake override
This commit is contained in:
+7
-2
@@ -205,8 +205,13 @@ private fun createReflectionTypeForCallableDescriptor(
|
||||
trace: BindingTrace?,
|
||||
reportOn: JetExpression?
|
||||
): JetType? {
|
||||
val extensionReceiver = descriptor.getExtensionReceiverParameter()
|
||||
val dispatchReceiver = descriptor.getDispatchReceiverParameter()
|
||||
val extensionReceiver = descriptor.extensionReceiverParameter
|
||||
val dispatchReceiver = descriptor.dispatchReceiverParameter?.let { dispatchReceiver ->
|
||||
// See CallableDescriptor#getOwnerForEffectiveDispatchReceiverParameter
|
||||
if ((descriptor as? CallableMemberDescriptor)?.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE)
|
||||
DescriptorUtils.getDispatchReceiverParameterIfNeeded(descriptor.containingDeclaration)
|
||||
else dispatchReceiver
|
||||
}
|
||||
|
||||
if (extensionReceiver != null && dispatchReceiver != null && descriptor is CallableMemberDescriptor) {
|
||||
if (reportOn != null) {
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
open class A {
|
||||
fun foo(s: String): String = s
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
}
|
||||
|
||||
|
||||
fun test() {
|
||||
B::foo checkType { _<KFunction2<B, String, String>>() }
|
||||
|
||||
(B::hashCode)(<!TYPE_MISMATCH!>"No."<!>)
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(/*0*/ s: kotlin.String): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B : A {
|
||||
public constructor B()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun foo(/*0*/ s: kotlin.String): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -1721,6 +1721,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fakeOverrideType.kt")
|
||||
public void testFakeOverrideType() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/function/fakeOverrideType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("genericClassFromTopLevel.kt")
|
||||
public void testGenericClassFromTopLevel() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/function/genericClassFromTopLevel.kt");
|
||||
|
||||
Reference in New Issue
Block a user