[NI] Report not-a-class LHS error for callable reference arguments

^KT-37531 Fixed
This commit is contained in:
Pavel Kirpichenkov
2020-03-26 19:31:20 +03:00
parent b7ea590e23
commit 0abe3a6c39
4 changed files with 29 additions and 1 deletions
@@ -745,7 +745,13 @@ class PSICallResolver(
is DoubleColonLHS.Type -> {
val qualifiedExpression = ktExpression.receiverExpression!!
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())
}
}
}
@@ -1,9 +1,19 @@
// !WITH_NEW_INFERENCE
class A<T, U : Any> {
fun foo() = <!OTHER_ERROR!>T<!>::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 <U : Any> bar() = <!OTHER_ERROR!>U<!>::toString
fun take(arg: Any) {}
@@ -1,9 +1,19 @@
// !WITH_NEW_INFERENCE
class A<T, U : Any> {
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 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 <U : Any> bar() = <!CALLABLE_REFERENCE_LHS_NOT_A_CLASS!>U::<!UNRESOLVED_REFERENCE!>toString<!><!>
fun take(<!UNUSED_PARAMETER!>arg<!>: Any) {}
@@ -2,10 +2,12 @@ package
public fun </*0*/ U : kotlin.Any> bar(): [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 constructor A</*0*/ T, /*1*/ U : kotlin.Any>()
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 final fun foo(): [ERROR : Error function type]
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int