[NI] Report not-a-class LHS error for callable reference arguments
^KT-37531 Fixed
This commit is contained in:
@@ -745,7 +745,13 @@ class PSICallResolver(
|
|||||||
is DoubleColonLHS.Type -> {
|
is DoubleColonLHS.Type -> {
|
||||||
val qualifiedExpression = ktExpression.receiverExpression!!
|
val qualifiedExpression = ktExpression.receiverExpression!!
|
||||||
val qualifier = expressionTypingContext.trace.get(BindingContext.QUALIFIER, qualifiedExpression)
|
val qualifier = expressionTypingContext.trace.get(BindingContext.QUALIFIER, qualifiedExpression)
|
||||||
LHSResult.Type(qualifier, lhsResult.type.unwrap())
|
val classifier = lhsResult.type.constructor.declarationDescriptor
|
||||||
|
if (classifier !is ClassDescriptor) {
|
||||||
|
expressionTypingContext.trace.report(Errors.CALLABLE_REFERENCE_LHS_NOT_A_CLASS.on(ktExpression))
|
||||||
|
LHSResult.Error
|
||||||
|
} else {
|
||||||
|
LHSResult.Type(qualifier, lhsResult.type.unwrap())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
@@ -1,9 +1,19 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
class A<T, U : Any> {
|
class A<T, U : Any> {
|
||||||
fun foo() = <!OTHER_ERROR!>T<!>::toString
|
fun foo() = <!OTHER_ERROR!>T<!>::toString
|
||||||
|
|
||||||
fun bar() = <!OTHER_ERROR!>U<!>::toString
|
fun bar() = <!OTHER_ERROR!>U<!>::toString
|
||||||
|
|
||||||
|
fun baz() {
|
||||||
|
take(<!OTHER_ERROR!>T<!>::toString)
|
||||||
|
|
||||||
|
take(<!OTHER_ERROR!>U<!>::toString)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> foo() = <!OTHER_ERROR!>T<!>::toString
|
fun <T> foo() = <!OTHER_ERROR!>T<!>::toString
|
||||||
|
|
||||||
fun <U : Any> bar() = <!OTHER_ERROR!>U<!>::toString
|
fun <U : Any> bar() = <!OTHER_ERROR!>U<!>::toString
|
||||||
|
|
||||||
|
fun take(arg: Any) {}
|
||||||
|
|||||||
+10
@@ -1,9 +1,19 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
class A<T, U : Any> {
|
class A<T, U : Any> {
|
||||||
fun foo() = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>T::<!UNRESOLVED_REFERENCE!>toString<!><!>
|
fun foo() = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>T::<!UNRESOLVED_REFERENCE!>toString<!><!>
|
||||||
|
|
||||||
fun bar() = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>U::<!UNRESOLVED_REFERENCE!>toString<!><!>
|
fun bar() = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>U::<!UNRESOLVED_REFERENCE!>toString<!><!>
|
||||||
|
|
||||||
|
fun baz() {
|
||||||
|
take(<!CALLABLE_REFERENCE_LHS_NOT_A_CLASS, OI;CALLABLE_REFERENCE_LHS_NOT_A_CLASS, OI;CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>T::<!OI;UNRESOLVED_REFERENCE!>toString<!><!>)
|
||||||
|
|
||||||
|
take(<!CALLABLE_REFERENCE_LHS_NOT_A_CLASS, OI;CALLABLE_REFERENCE_LHS_NOT_A_CLASS, OI;CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>U::<!OI;UNRESOLVED_REFERENCE!>toString<!><!>)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> foo() = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>T::<!UNRESOLVED_REFERENCE!>toString<!><!>
|
fun <T> foo() = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>T::<!UNRESOLVED_REFERENCE!>toString<!><!>
|
||||||
|
|
||||||
fun <U : Any> bar() = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>U::<!UNRESOLVED_REFERENCE!>toString<!><!>
|
fun <U : Any> bar() = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>U::<!UNRESOLVED_REFERENCE!>toString<!><!>
|
||||||
|
|
||||||
|
fun take(<!UNUSED_PARAMETER!>arg<!>: Any) {}
|
||||||
|
|||||||
+2
@@ -2,10 +2,12 @@ package
|
|||||||
|
|
||||||
public fun </*0*/ U : kotlin.Any> bar(): [ERROR : Error function type]
|
public fun </*0*/ U : kotlin.Any> bar(): [ERROR : Error function type]
|
||||||
public fun </*0*/ T> foo(): [ERROR : Error function type]
|
public fun </*0*/ T> foo(): [ERROR : Error function type]
|
||||||
|
public fun take(/*0*/ arg: kotlin.Any): kotlin.Unit
|
||||||
|
|
||||||
public final class A</*0*/ T, /*1*/ U : kotlin.Any> {
|
public final class A</*0*/ T, /*1*/ U : kotlin.Any> {
|
||||||
public constructor A</*0*/ T, /*1*/ U : kotlin.Any>()
|
public constructor A</*0*/ T, /*1*/ U : kotlin.Any>()
|
||||||
public final fun bar(): [ERROR : Error function type]
|
public final fun bar(): [ERROR : Error function type]
|
||||||
|
public final fun baz(): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public final fun foo(): [ERROR : Error function type]
|
public final fun foo(): [ERROR : Error function type]
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
|||||||
Reference in New Issue
Block a user