Fix missing error on fun interface constructor reference

#KT-51843 Fixed
This commit is contained in:
Alexander Udalov
2022-04-05 23:53:08 +02:00
parent 6402c3908c
commit 349c17786e
5 changed files with 14 additions and 2 deletions
@@ -16,7 +16,7 @@ object FunInterfaceConstructorReferenceChecker : CallChecker {
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
if (context.languageVersionSettings.supportsFeature(LanguageFeature.KotlinFunInterfaceConstructorReference)) return
val resultingDescriptor = resolvedCall.resultingDescriptor
val resultingDescriptor = resolvedCall.resultingDescriptor.original
if (resultingDescriptor !is SamConstructorDescriptor || !resolvedCall.call.isCallableReference()) return
if (resultingDescriptor.baseDescriptorForSynthetic.isFun) {
@@ -25,4 +25,4 @@ object FunInterfaceConstructorReferenceChecker : CallChecker {
)
}
}
}
}
@@ -8,3 +8,6 @@ fun interface Foo {
val x = ::Foo
val y = Foo { }
val z = ::<!JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE!>Runnable<!>
val w = id(::Foo)
fun <T> id(t: T): T = t
@@ -1,8 +1,10 @@
package
public val w: kotlin.reflect.KFunction1<() -> kotlin.Unit, Foo>
public val x: kotlin.reflect.KFunction1<() -> kotlin.Unit, Foo>
public val y: Foo
public val z: kotlin.reflect.KFunction1<() -> kotlin.Unit, java.lang.Runnable>
public fun </*0*/ T> id(/*0*/ t: T): T
public fun interface Foo {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@@ -10,3 +12,4 @@ public fun interface Foo {
public abstract fun run(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -8,3 +8,6 @@ fun interface Foo {
val x = ::<!FUN_INTERFACE_CONSTRUCTOR_REFERENCE!>Foo<!>
val y = Foo { }
val z = ::<!JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE!>Runnable<!>
val w = id(::<!FUN_INTERFACE_CONSTRUCTOR_REFERENCE!>Foo<!>)
fun <T> id(t: T): T = t
@@ -1,8 +1,10 @@
package
public val w: kotlin.reflect.KFunction1<() -> kotlin.Unit, Foo>
public val x: kotlin.reflect.KFunction1<() -> kotlin.Unit, Foo>
public val y: Foo
public val z: kotlin.reflect.KFunction1<() -> kotlin.Unit, java.lang.Runnable>
public fun </*0*/ T> id(/*0*/ t: T): T
public fun interface Foo {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@@ -10,3 +12,4 @@ public fun interface Foo {
public abstract fun run(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}