[FIR] Skip redundant INAPPLICABLE_CANDIDATE on call with unresolved callable reference argument

A new resolution diagnostic UnsuccessfulCallableReferenceAtom is
introduced that is used in EagerResolveOfCallableReferences.
No diagnostic is reported on unresolved calls with this diagnostic
because

#KT-59856
This commit is contained in:
Kirill Rakhman
2023-07-18 10:16:26 +02:00
committed by Space Team
parent a55f3c5583
commit 2f3293f99e
49 changed files with 91 additions and 95 deletions
@@ -34,13 +34,13 @@ fun main() {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo3<!>(KotlinClass::baz) <!OVERLOAD_RESOLUTION_AMBIGUITY!>foo3<!>(KotlinClass::baz)
// Type mismatch // Type mismatch
<!INAPPLICABLE_CANDIDATE!>foo1<!>(KotlinClass::<!UNRESOLVED_REFERENCE!>bar<!>) foo1(KotlinClass::<!UNRESOLVED_REFERENCE!>bar<!>)
foo2(KotlinClass::bar) foo2(KotlinClass::bar)
foo3(KotlinClass::bar) foo3(KotlinClass::bar)
foo1(KotlinClass2::bar) foo1(KotlinClass2::bar)
// Type mismatch // Type mismatch
<!INAPPLICABLE_CANDIDATE!>foo2<!>(KotlinClass2::<!UNRESOLVED_REFERENCE!>bar<!>) foo2(KotlinClass2::<!UNRESOLVED_REFERENCE!>bar<!>)
foo3(KotlinClass2::bar) foo3(KotlinClass2::bar)
} }
@@ -7,6 +7,6 @@ fun <T> bar(f: (T) -> Unit, e: T) {}
fun <T> baz(e: T, f: (T) -> Unit) {} fun <T> baz(e: T, f: (T) -> Unit) {}
fun test(a: A, b: B) { fun test(a: A, b: B) {
<!INAPPLICABLE_CANDIDATE!>baz<!>(a, ::<!UNRESOLVED_REFERENCE!>fooB<!>) baz(a, ::<!UNRESOLVED_REFERENCE!>fooB<!>)
<!INAPPLICABLE_CANDIDATE!>bar<!>(::<!UNRESOLVED_REFERENCE!>fooB<!>, a) bar(::<!UNRESOLVED_REFERENCE!>fooB<!>, a)
} }
@@ -3,5 +3,5 @@ fun <T, R> use(x: (T) -> R): (T) -> R = x
fun foo() = use(::bar) fun foo() = use(::bar)
fun bar(x: String) = 1 fun bar(x: String) = 1
fun loop1() = <!INAPPLICABLE_CANDIDATE!>use<!>(::<!UNRESOLVED_REFERENCE!>loop2<!>) fun loop1() = use(::<!UNRESOLVED_REFERENCE!>loop2<!>)
fun loop2() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>loop1()<!> fun loop2() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>loop1()<!>
@@ -3,5 +3,5 @@ fun <T, R> use(x: (T) -> R): (T) -> R = x
fun foo() = use(::bar) fun foo() = use(::bar)
fun bar(x: String) = 1 fun bar(x: String) = 1
fun loop1() = <!INAPPLICABLE_CANDIDATE!>use<!>(::<!UNRESOLVED_REFERENCE!>loop2<!>) fun loop1() = use(::<!UNRESOLVED_REFERENCE!>loop2<!>)
fun loop2() = loop1() fun loop2() = loop1()
@@ -255,6 +255,9 @@ private fun mapInapplicableCandidateError(
// And the errors should be reported there // And the errors should be reported there
is ErrorTypeInArguments -> null is ErrorTypeInArguments -> null
// see EagerResolveOfCallableReferences
is UnsuccessfulCallableReferenceAtom -> null
is MultipleContextReceiversApplicableForExtensionReceivers -> is MultipleContextReceiversApplicableForExtensionReceivers ->
FirErrors.AMBIGUOUS_CALL_WITH_IMPLICIT_CONTEXT_RECEIVER.createOn(qualifiedAccessSource ?: source) FirErrors.AMBIGUOUS_CALL_WITH_IMPLICIT_CONTEXT_RECEIVER.createOn(qualifiedAccessSource ?: source)
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.fir.resolve.calls package org.jetbrains.kotlin.fir.resolve.calls
import org.jetbrains.kotlin.KtFakeSourceElementKind
import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.FirElement
@@ -42,6 +41,7 @@ import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue
import org.jetbrains.kotlin.resolve.descriptorUtil.DYNAMIC_EXTENSION_FQ_NAME import org.jetbrains.kotlin.resolve.descriptorUtil.DYNAMIC_EXTENSION_FQ_NAME
import org.jetbrains.kotlin.types.AbstractNullabilityChecker import org.jetbrains.kotlin.types.AbstractNullabilityChecker
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlin.util.OperatorNameConventions
@@ -514,7 +514,13 @@ internal object EagerResolveOfCallableReferences : CheckerStage() {
val (applicability, success) = val (applicability, success) =
context.bodyResolveComponents.callResolver.resolveCallableReference(candidate.csBuilder, atom) context.bodyResolveComponents.callResolver.resolveCallableReference(candidate.csBuilder, atom)
if (!success) { if (!success) {
sink.yieldDiagnostic(InapplicableCandidate) // If the resolution was unsuccessful, we ensure that an error will be reported for the callable reference
// during completion by using the `resultingReference` of the postponed atom.
// We assert that the `resultingReference` is set to an error reference and the atom is in fact postponed.
check(atom.resultingReference is FirErrorReferenceWithCandidate)
if (AbstractTypeChecker.RUN_SLOW_ASSERTIONS) check(atom in candidate.postponedAtoms)
sink.yieldDiagnostic(UnsuccessfulCallableReferenceAtom)
} else when (applicability) { } else when (applicability) {
CandidateApplicability.RESOLVED_NEED_PRESERVE_COMPATIBILITY -> CandidateApplicability.RESOLVED_NEED_PRESERVE_COMPATIBILITY ->
sink.reportDiagnostic(LowerPriorityToPreserveCompatibilityDiagnostic) sink.reportDiagnostic(LowerPriorityToPreserveCompatibilityDiagnostic)
@@ -76,6 +76,8 @@ class NameForAmbiguousParameter(
object InapplicableCandidate : ResolutionDiagnostic(INAPPLICABLE) object InapplicableCandidate : ResolutionDiagnostic(INAPPLICABLE)
object UnsuccessfulCallableReferenceAtom : ResolutionDiagnostic(INAPPLICABLE)
object ErrorTypeInArguments : ResolutionDiagnostic(INAPPLICABLE) object ErrorTypeInArguments : ResolutionDiagnostic(INAPPLICABLE)
object HiddenCandidate : ResolutionDiagnostic(HIDDEN) object HiddenCandidate : ResolutionDiagnostic(HIDDEN)
@@ -3,7 +3,7 @@
fun f1(x: String) {} fun f1(x: String) {}
fun f2(f: () -> Unit) {} fun f2(f: () -> Unit) {}
fun test1() = <!INAPPLICABLE_CANDIDATE("fun f2(f: () -> Unit): Unit")!>f2<!>(::<!UNRESOLVED_REFERENCE("f1")!>f1<!>) fun test1() = f2(::<!UNRESOLVED_REFERENCE("f1")!>f1<!>)
@Target(AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.TYPE) @Target(AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.TYPE)
@@ -3,12 +3,12 @@ fun foo(x: String = "O"): String = x
fun bar(x: String = "K"): String = x fun bar(x: String = "K"): String = x
fun dump(dumpStrategy: String) { fun dump(dumpStrategy: String) {
val k0: kotlin.reflect.KFunction0<String> = <!INAPPLICABLE_CANDIDATE!>returnAdapter<!>(::<!UNRESOLVED_REFERENCE!>foo<!>) // Error: ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE val k0: kotlin.reflect.KFunction0<String> = returnAdapter(::<!UNRESOLVED_REFERENCE!>foo<!>) // Error: ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE
val k1: kotlin.reflect.KFunction0<String> = ::<!UNRESOLVED_REFERENCE!>foo<!> val k1: kotlin.reflect.KFunction0<String> = ::<!UNRESOLVED_REFERENCE!>foo<!>
// Should be error here, too // Should be error here, too
val k2: kotlin.reflect.KFunction0<String> = if (dumpStrategy == "KotlinLike") ::<!UNRESOLVED_REFERENCE!>foo<!> else ::<!UNRESOLVED_REFERENCE!>bar<!> val k2: kotlin.reflect.KFunction0<String> = if (dumpStrategy == "KotlinLike") ::<!UNRESOLVED_REFERENCE!>foo<!> else ::<!UNRESOLVED_REFERENCE!>bar<!>
val f0: Function0<String> = <!INAPPLICABLE_CANDIDATE!>returnAdapter<!>(::<!UNRESOLVED_REFERENCE!>foo<!>) val f0: Function0<String> = returnAdapter(::<!UNRESOLVED_REFERENCE!>foo<!>)
val f1: Function0<String> = ::foo val f1: Function0<String> = ::foo
val f2: Function0<String> = if (dumpStrategy == "KotlinLike") ::foo else ::bar val f2: Function0<String> = if (dumpStrategy == "KotlinLike") ::foo else ::bar
} }
@@ -18,6 +18,6 @@ fun <K, V> B<K>.star(p: KProperty1<*, V>): B<V> = TODO()
fun <R : A> B<R>.test(){ fun <R : A> B<R>.test(){
foo(A::bla) foo(A::bla)
bar(A::bla) bar(A::bla)
<!INAPPLICABLE_CANDIDATE!>baz<!>(A::<!UNRESOLVED_REFERENCE!>bla<!>) baz(A::<!UNRESOLVED_REFERENCE!>bla<!>)
star(A::bla) star(A::bla)
} }
@@ -14,5 +14,5 @@ fun <K, V> B<K>.foo(p: KProperty1<K, V>) {}
class C : A class C : A
fun <R : A> B<R>.test(){ fun <R : A> B<R>.test(){
<!INAPPLICABLE_CANDIDATE!>foo<!>(C::<!UNRESOLVED_REFERENCE!>bla<!>) foo(C::<!UNRESOLVED_REFERENCE!>bla<!>)
} }
@@ -7,6 +7,6 @@ fun <T> takeIt(x: T, f: SubFunction) {}
fun cr() {} fun cr() {}
fun test() { fun test() {
<!INAPPLICABLE_CANDIDATE!>takeIt<!>(42, ::<!UNRESOLVED_REFERENCE!>cr<!>) takeIt(42, ::<!UNRESOLVED_REFERENCE!>cr<!>)
takeIt(42, <!ARGUMENT_TYPE_MISMATCH!>{ }<!>) takeIt(42, <!ARGUMENT_TYPE_MISMATCH!>{ }<!>)
} }
@@ -25,7 +25,7 @@ class A {
expectFunction0Unit(::foo) expectFunction0Unit(::foo)
expectFunction0String(::foo) expectFunction0String(::foo)
<!INAPPLICABLE_CANDIDATE!>expectFunction1Unit<!>(::<!UNRESOLVED_REFERENCE!>foo<!>) expectFunction1Unit(::<!UNRESOLVED_REFERENCE!>foo<!>)
<!INAPPLICABLE_CANDIDATE!>expectFunction1String<!>(::<!UNRESOLVED_REFERENCE!>foo<!>) expectFunction1String(::<!UNRESOLVED_REFERENCE!>foo<!>)
} }
} }
@@ -17,7 +17,7 @@ fun test2() {
fun foo() {} fun foo() {}
<!UNRESOLVED_REFERENCE!>Unresolved<!>::foo <!UNRESOLVED_REFERENCE!>Unresolved<!>::foo
<!INAPPLICABLE_CANDIDATE!>foo<!>(<!UNRESOLVED_REFERENCE!>Unresolved<!>::foo) foo(<!UNRESOLVED_REFERENCE!>Unresolved<!>::foo)
<!INAPPLICABLE_CANDIDATE!>foo<!>(<!UNRESOLVED_REFERENCE!>Unresolved<!>::unresolved) foo(<!UNRESOLVED_REFERENCE!>Unresolved<!>::unresolved)
::<!UNRESOLVED_REFERENCE!>unresolved<!> ::<!UNRESOLVED_REFERENCE!>unresolved<!>
} }
@@ -16,14 +16,14 @@ fun <T> bar(s: T) {}
fun <T> complex(t: T, f: (T) -> Unit) {} fun <T> complex(t: T, f: (T) -> Unit) {}
fun test1() { fun test1() {
<!INAPPLICABLE_CANDIDATE!>foo<!>(1, A::<!UNRESOLVED_REFERENCE!>invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE foo(1, A::<!UNRESOLVED_REFERENCE!>invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
foo(1, ::bar) foo(1, ::bar)
complex(1, ::bar) complex(1, ::bar)
} }
fun <R> test2(x: R) { fun <R> test2(x: R) {
<!INAPPLICABLE_CANDIDATE!>foo<!>(x, A::<!UNRESOLVED_REFERENCE!>invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE foo(x, A::<!UNRESOLVED_REFERENCE!>invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
foo(x, ::bar) foo(x, ::bar)
complex(x, ::bar) complex(x, ::bar)
@@ -13,7 +13,7 @@ fun <T> Wrapper<T>.baz(transform: (T) -> Unit): T = TODO()
fun test() { fun test() {
takeFun<String>(::foo) takeFun<String>(::foo)
<!INAPPLICABLE_CANDIDATE!>takeFun<!><String>(::<!UNRESOLVED_REFERENCE!>fooInt<!>) takeFun<String>(::<!UNRESOLVED_REFERENCE!>fooInt<!>)
callFun<String, Wrapper<String>>(::createWrapper) callFun<String, Wrapper<String>>(::createWrapper)
callFun<Int, Wrapper<Number>>(::createWrapper) callFun<Int, Wrapper<Number>>(::createWrapper)
@@ -22,8 +22,8 @@ fun test1() {
fun <T> test2() { fun <T> test2() {
bar<Wrapper, Int, String>(Wrapper::fooReturnString).checkType { _<Tripple<Wrapper, Int, String>>() } bar<Wrapper, Int, String>(Wrapper::fooReturnString).checkType { _<Tripple<Wrapper, Int, String>>() }
bar<Wrapper, T, String>(Wrapper::fooReturnString).checkType { _<Tripple<Wrapper, T, String>>() } bar<Wrapper, T, String>(Wrapper::fooReturnString).checkType { _<Tripple<Wrapper, T, String>>() }
<!INAPPLICABLE_CANDIDATE!>bar<!><Wrapper, T, T>(Wrapper::<!UNRESOLVED_REFERENCE!>fooReturnString<!>) bar<Wrapper, T, T>(Wrapper::<!UNRESOLVED_REFERENCE!>fooReturnString<!>)
<!INAPPLICABLE_CANDIDATE!>bar<!><Wrapper, Int, Int>(Wrapper::<!UNRESOLVED_REFERENCE!>fooReturnString<!>) bar<Wrapper, Int, Int>(Wrapper::<!UNRESOLVED_REFERENCE!>fooReturnString<!>)
bar<Wrapper, Int, T>(Wrapper::fooTakeInt).checkType { _<Tripple<Wrapper, Int, T>>() } bar<Wrapper, Int, T>(Wrapper::fooTakeInt).checkType { _<Tripple<Wrapper, Int, T>>() }
bar<Wrapper, Int, String>(Wrapper::fooTakeInt).checkType { _<Tripple<Wrapper, Int, String>>() } bar<Wrapper, Int, String>(Wrapper::fooTakeInt).checkType { _<Tripple<Wrapper, Int, String>>() }
@@ -17,5 +17,5 @@ fun <T> bar(x: T, f: (T) -> Unit) {}
fun test2() { fun test2() {
bar(1, ::foo) bar(1, ::foo)
bar("", ::foo) bar("", ::foo)
<!INAPPLICABLE_CANDIDATE!>bar<!>(1.0, ::<!UNRESOLVED_REFERENCE!>foo<!>) bar(1.0, ::<!UNRESOLVED_REFERENCE!>foo<!>)
} }
@@ -4,7 +4,7 @@ fun foo(vararg ints: Int) {}
fun test(i: IntArray) { fun test(i: IntArray) {
myLet(i, ::foo) myLet(i, ::foo)
myLet(::foo) myLet(::foo)
<!INAPPLICABLE_CANDIDATE!>myLet<!><Int>(::<!UNRESOLVED_REFERENCE!>foo<!>) myLet<Int>(::<!UNRESOLVED_REFERENCE!>foo<!>)
myLet<IntArray>(::foo) myLet<IntArray>(::foo)
myLetExplicit1(::foo) myLetExplicit1(::foo)
myLetExplicit2(::foo) myLetExplicit2(::foo)
@@ -1,10 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty1
class TestClass(var prop: Int)
open class OtherClass
fun OtherClass.test(prop: KProperty1<TestClass, Int>): Unit = throw Exception()
class OtherClass2: OtherClass() {
val result = <!INAPPLICABLE_CANDIDATE!>test<!>(TestClass::<!UNRESOLVED_REFERENCE!>result<!>)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.reflect.KProperty1 import kotlin.reflect.KProperty1
@@ -22,6 +22,6 @@ object Local {
fun baz(x: Int, y: Int = 0): Int = 0 fun baz(x: Int, y: Int = 0): Int = 0
fun test() { fun test() {
<!INAPPLICABLE_CANDIDATE!>bar<!>(::<!UNRESOLVED_REFERENCE!>baz<!>) bar(::<!UNRESOLVED_REFERENCE!>baz<!>)
} }
} }
@@ -7,4 +7,4 @@ fun foo(s: String) {}
val x1 = ofType<() -> Unit>(::foo) val x1 = ofType<() -> Unit>(::foo)
val x2 = ofType<(String) -> Unit>(::foo) val x2 = ofType<(String) -> Unit>(::foo)
val x3 = <!INAPPLICABLE_CANDIDATE!>ofType<!><(Int) -> Unit>(::<!UNRESOLVED_REFERENCE!>foo<!>) val x3 = ofType<(Int) -> Unit>(::<!UNRESOLVED_REFERENCE!>foo<!>)
@@ -22,6 +22,6 @@ object Local {
fun baz(x: Int, y: Int = 0): Int = 0 fun baz(x: Int, y: Int = 0): Int = 0
fun test() { fun test() {
<!INAPPLICABLE_CANDIDATE!>bar<!>(::<!UNRESOLVED_REFERENCE!>baz<!>) bar(::<!UNRESOLVED_REFERENCE!>baz<!>)
} }
} }
@@ -5,4 +5,4 @@ import kotlin.reflect.KProperty0
object A object A
fun <TProperty> property0(property: KProperty0<TProperty>) = A fun <TProperty> property0(property: KProperty0<TProperty>) = A
val <K> K.key get() : A = <!INAPPLICABLE_CANDIDATE!>property0<!>(Map.Entry<K, *>::<!UNRESOLVED_REFERENCE!>key<!>) // should be forbidden val <K> K.key get() : A = property0(Map.Entry<K, *>::<!UNRESOLVED_REFERENCE!>key<!>) // should be forbidden
@@ -10,6 +10,6 @@ fun <T> baz(e: T, f: (T) -> Unit) {}
fun test(a: A, b: B) { fun test(a: A, b: B) {
// Note that diagnostic is always on callable references as they are resolved after simple arguments // Note that diagnostic is always on callable references as they are resolved after simple arguments
<!INAPPLICABLE_CANDIDATE!>baz<!>(a, ::<!UNRESOLVED_REFERENCE!>fooB<!>) baz(a, ::<!UNRESOLVED_REFERENCE!>fooB<!>)
<!INAPPLICABLE_CANDIDATE!>bar<!>(::<!UNRESOLVED_REFERENCE!>fooB<!>, a) bar(::<!UNRESOLVED_REFERENCE!>fooB<!>, a)
} }
@@ -8,4 +8,4 @@ fun foo(s: String) {}
val x1 = apply(1, ::foo) val x1 = apply(1, ::foo)
val x2 = apply("hello", ::foo) val x2 = apply("hello", ::foo)
val x3 = <!INAPPLICABLE_CANDIDATE!>apply<!>(true, ::<!UNRESOLVED_REFERENCE!>foo<!>) val x3 = apply(true, ::<!UNRESOLVED_REFERENCE!>foo<!>)
@@ -3,7 +3,7 @@
fun a() { fun a() {
val x = 10 val x = 10
<!INAPPLICABLE_CANDIDATE!>foo<!>(::<!UNSUPPORTED!>x<!>) foo(::<!UNSUPPORTED!>x<!>)
} }
fun foo(a: Any) {} fun foo(a: Any) {}
@@ -11,5 +11,5 @@ fun test(param: String) {
val lambda = { -> } val lambda = { -> }
val g = ::<!UNSUPPORTED!>lambda<!> val g = ::<!UNSUPPORTED!>lambda<!>
<!INAPPLICABLE_CANDIDATE!>eat<!>(::<!UNSUPPORTED!>param<!>) eat(::<!UNSUPPORTED!>param<!>)
} }
@@ -9,6 +9,6 @@ class Foo {
fun main() { fun main() {
val f = Foo() val f = Foo()
val a: Int val a: Int
<!VARIABLE_EXPECTED!><!UNRESOLVED_REFERENCE!>get<!>()<!> = f.<!INAPPLICABLE_CANDIDATE!>getValue<!>(null, ::<!UNSUPPORTED!>a<!>) // no exception after fix <!VARIABLE_EXPECTED!><!UNRESOLVED_REFERENCE!>get<!>()<!> = f.getValue(null, ::<!UNSUPPORTED!>a<!>) // no exception after fix
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>) <!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
} }
@@ -9,6 +9,6 @@ class Foo {
fun main(x: Int) { fun main(x: Int) {
val f = Foo() val f = Foo()
val a: Int val a: Int
<!VARIABLE_EXPECTED!><!UNRESOLVED_REFERENCE!>get<!>()<!> = f.<!INAPPLICABLE_CANDIDATE!>getValue<!>(null, ::<!UNSUPPORTED!>x<!>) // no exception after fix <!VARIABLE_EXPECTED!><!UNRESOLVED_REFERENCE!>get<!>()<!> = f.getValue(null, ::<!UNSUPPORTED!>x<!>) // no exception after fix
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>) <!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
} }
@@ -24,7 +24,7 @@ infix fun filter(filter: (R, Any?) -> Boolean): Delegate<R, T>
} }
class GitLabChangesProcessor: DatabaseEntity { class GitLabChangesProcessor: DatabaseEntity {
var buildProcessors by <!INAPPLICABLE_CANDIDATE!>child_many<!>( var buildProcessors by child_many(
GitLabBuildProcessor::class.java, GitLabBuildProcessor::class.java,
GitLabBuildProcessor::<!UNRESOLVED_REFERENCE!>processor<!> GitLabBuildProcessor::<!UNRESOLVED_REFERENCE!>processor<!>
) )
@@ -25,7 +25,7 @@ infix fun filter(filter: (R, Any?) -> Boolean): Delegate<R, T>
} }
class GitLabChangesProcessor: DatabaseEntity { class GitLabChangesProcessor: DatabaseEntity {
var buildProcessors by <!INAPPLICABLE_CANDIDATE!>child_many<!>( var buildProcessors by child_many(
GitLabBuildProcessor::class.java, GitLabBuildProcessor::class.java,
GitLabBuildProcessor::<!UNRESOLVED_REFERENCE!>processor<!> GitLabBuildProcessor::<!UNRESOLVED_REFERENCE!>processor<!>
) )
+16 -16
View File
@@ -27,22 +27,22 @@ interface Foo {
// CR on property with to receivers are forbidden // CR on property with to receivers are forbidden
fun <T: Foo> test() { fun <T: Foo> test() {
// with LHS and property // with LHS and property
<!INAPPLICABLE_CANDIDATE!>bar8<!><T>(Foo::<!UNRESOLVED_REFERENCE!>x1<!>) bar8<T>(Foo::<!UNRESOLVED_REFERENCE!>x1<!>)
<!INAPPLICABLE_CANDIDATE!>bar8<!><Foo>(Foo::<!UNRESOLVED_REFERENCE!>x1<!>) bar8<Foo>(Foo::<!UNRESOLVED_REFERENCE!>x1<!>)
<!INAPPLICABLE_CANDIDATE!>bar8<!>(Foo::<!UNRESOLVED_REFERENCE!>x1<!>) bar8(Foo::<!UNRESOLVED_REFERENCE!>x1<!>)
// with LHS and mutable property // with LHS and mutable property
<!INAPPLICABLE_CANDIDATE!>bar8<!><T>(Foo::<!UNRESOLVED_REFERENCE!>x2<!>) bar8<T>(Foo::<!UNRESOLVED_REFERENCE!>x2<!>)
<!INAPPLICABLE_CANDIDATE!>bar8<!><Foo>(Foo::<!UNRESOLVED_REFERENCE!>x2<!>) bar8<Foo>(Foo::<!UNRESOLVED_REFERENCE!>x2<!>)
<!INAPPLICABLE_CANDIDATE!>bar8<!>(Foo::<!UNRESOLVED_REFERENCE!>x2<!>) bar8(Foo::<!UNRESOLVED_REFERENCE!>x2<!>)
// with LHS and propery + mutable property (mixed) // with LHS and propery + mutable property (mixed)
<!INAPPLICABLE_CANDIDATE!>bar8<!><T>(Foo::<!UNRESOLVED_REFERENCE!>x3<!>) bar8<T>(Foo::<!UNRESOLVED_REFERENCE!>x3<!>)
<!INAPPLICABLE_CANDIDATE!>bar8<!><Foo>(Foo::<!UNRESOLVED_REFERENCE!>x3<!>) bar8<Foo>(Foo::<!UNRESOLVED_REFERENCE!>x3<!>)
<!INAPPLICABLE_CANDIDATE!>bar8<!>(Foo::<!UNRESOLVED_REFERENCE!>x3<!>) bar8(Foo::<!UNRESOLVED_REFERENCE!>x3<!>)
<!INAPPLICABLE_CANDIDATE!>bar9<!><T>(Foo::<!UNRESOLVED_REFERENCE!>x3<!>) bar9<T>(Foo::<!UNRESOLVED_REFERENCE!>x3<!>)
<!INAPPLICABLE_CANDIDATE!>bar9<!><Foo>(Foo::<!UNRESOLVED_REFERENCE!>x3<!>) bar9<Foo>(Foo::<!UNRESOLVED_REFERENCE!>x3<!>)
<!INAPPLICABLE_CANDIDATE!>bar9<!>(Foo::<!UNRESOLVED_REFERENCE!>x3<!>) bar9(Foo::<!UNRESOLVED_REFERENCE!>x3<!>)
} }
} }
@@ -114,14 +114,14 @@ fun <T : Foo, R: Number, D: Int> main() {
bar7(Foo::resolve) // OK bar7(Foo::resolve) // OK
// with LHS and sentension function expected type // with LHS and sentension function expected type
<!INAPPLICABLE_CANDIDATE!>bar10<!><D>(Int::<!UNRESOLVED_REFERENCE!>x1<!>) // ERROR before the fix in NI bar10<D>(Int::<!UNRESOLVED_REFERENCE!>x1<!>) // ERROR before the fix in NI
bar10<Int>(Int::x1) // OK bar10<Int>(Int::x1) // OK
bar10(Int::x1) // OK bar10(Int::x1) // OK
fun Int.ext() { fun Int.ext() {
// with LHS and sentension function expected type // with LHS and sentension function expected type
<!INAPPLICABLE_CANDIDATE!>bar10<!><D>(::<!UNRESOLVED_REFERENCE!>x1<!>) // ERROR before the fix in NI bar10<D>(::<!UNRESOLVED_REFERENCE!>x1<!>) // ERROR before the fix in NI
<!INAPPLICABLE_CANDIDATE!>bar10<!><Int>(::<!UNRESOLVED_REFERENCE!>x1<!>) // OK bar10<Int>(::<!UNRESOLVED_REFERENCE!>x1<!>) // OK
<!INAPPLICABLE_CANDIDATE!>bar10<!>(::<!UNRESOLVED_REFERENCE!>x1<!>) // OK bar10(::<!UNRESOLVED_REFERENCE!>x1<!>) // OK
} }
} }
@@ -6,5 +6,5 @@ fun foo(i: Long) {}
fun bar(f: (Boolean) -> Unit) {} fun bar(f: (Boolean) -> Unit) {}
fun test() { fun test() {
<!INAPPLICABLE_CANDIDATE!>bar<!>(::<!UNRESOLVED_REFERENCE!>foo<!>) bar(::<!UNRESOLVED_REFERENCE!>foo<!>)
} }
@@ -5,5 +5,5 @@ fun foo(x: Float) = 10f
fun foo(x: String) = "" fun foo(x: String) = ""
fun main() { fun main() {
<!INAPPLICABLE_CANDIDATE!>bar<!>(::<!UNRESOLVED_REFERENCE!>foo<!>) // no report about unresolved callable reference for `foo` bar(::<!UNRESOLVED_REFERENCE!>foo<!>) // no report about unresolved callable reference for `foo`
} }
@@ -1,7 +0,0 @@
fun <T, U> T.map(f: (T) -> U) = f(this)
fun consume(s: String) {}
fun test() {
consume(1.<!INAPPLICABLE_CANDIDATE!>map<!>(::<!UNRESOLVED_REFERENCE!>foo<!>))
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun <T, U> T.map(f: (T) -> U) = f(this) fun <T, U> T.map(f: (T) -> U) = f(this)
fun consume(s: String) {} fun consume(s: String) {}
@@ -274,7 +274,7 @@ fun poll76() {
} }
fun poll8() { fun poll8() {
val inv = ::<!UNRESOLVED_REFERENCE!>bar<!> <!INAPPLICABLE_CANDIDATE!>in<!> <!INAPPLICABLE_CANDIDATE!>setOf<!>(::<!UNRESOLVED_REFERENCE!>foo<!>) val inv = ::<!UNRESOLVED_REFERENCE!>bar<!> in setOf(::<!UNRESOLVED_REFERENCE!>foo<!>)
<!UNRESOLVED_REFERENCE!>inv<!>() <!UNRESOLVED_REFERENCE!>inv<!>()
} }
@@ -284,7 +284,7 @@ fun poll81() {
} }
fun poll82() { fun poll82() {
val inv = ::<!UNRESOLVED_REFERENCE!>bar3<!> <!INAPPLICABLE_CANDIDATE!>in<!> <!INAPPLICABLE_CANDIDATE!>setOf<!>(::<!UNRESOLVED_REFERENCE!>foo3<!>) val inv = ::<!UNRESOLVED_REFERENCE!>bar3<!> in setOf(::<!UNRESOLVED_REFERENCE!>foo3<!>)
<!UNRESOLVED_REFERENCE!>inv<!>() <!UNRESOLVED_REFERENCE!>inv<!>()
} }
@@ -294,7 +294,7 @@ fun poll83() {
} }
fun poll84() { fun poll84() {
val inv = ::<!UNRESOLVED_REFERENCE!>bar5<!> <!INAPPLICABLE_CANDIDATE!>in<!> <!INAPPLICABLE_CANDIDATE!>setOf<!>(::<!UNRESOLVED_REFERENCE!>foo5<!>) val inv = ::<!UNRESOLVED_REFERENCE!>bar5<!> in setOf(::<!UNRESOLVED_REFERENCE!>foo5<!>)
inv inv
} }
@@ -18,7 +18,7 @@ public class Inv<T> {
fun test(inv: Inv<String>) { fun test(inv: Inv<String>) {
val m: ((String) -> String) -> Inv<String> = inv::<!UNRESOLVED_REFERENCE!>map<!> val m: ((String) -> String) -> Inv<String> = inv::<!UNRESOLVED_REFERENCE!>map<!>
<!INAPPLICABLE_CANDIDATE!>take<!>(inv::<!UNRESOLVED_REFERENCE!>map<!>) take(inv::<!UNRESOLVED_REFERENCE!>map<!>)
} }
fun take(f: ((String) -> String) -> Inv<String>) {} fun take(f: ((String) -> String) -> Inv<String>) {}
@@ -4,6 +4,6 @@ fun h(x: () -> Unit) = 1
fun foo() { fun foo() {
<!UNRESOLVED_REFERENCE!>f<!>(::<!SYNTAX!><!>) <!UNRESOLVED_REFERENCE!>f<!>(::<!SYNTAX!><!>)
<!INAPPLICABLE_CANDIDATE!>g<!>(::<!SYNTAX!><!>) g(::<!SYNTAX!><!>)
<!INAPPLICABLE_CANDIDATE!>h<!>(::<!SYNTAX!><!>) h(::<!SYNTAX!><!>)
} }
@@ -14,5 +14,5 @@ fun test() {
foo2(42, ::bar2) foo2(42, ::bar2)
foo2("str", ::bar2) foo2("str", ::bar2)
<!INAPPLICABLE_CANDIDATE!>foo2<!>(42, ::<!UNRESOLVED_REFERENCE!>bar1<!>) foo2(42, ::<!UNRESOLVED_REFERENCE!>bar1<!>)
} }
@@ -20,9 +20,9 @@ fun test() {
useStringArray(::stringVararg) useStringArray(::stringVararg)
useIntArray(::numberVararg) useIntArray(::numberVararg)
usePrimitiveIntArray(::intVararg) usePrimitiveIntArray(::intVararg)
<!INAPPLICABLE_CANDIDATE!>useIntArray<!>(::<!UNRESOLVED_REFERENCE!>intVararg<!>) useIntArray(::<!UNRESOLVED_REFERENCE!>intVararg<!>)
<!INAPPLICABLE_CANDIDATE!>useMixedStringArgs1<!>(::<!UNRESOLVED_REFERENCE!>stringVararg<!>) useMixedStringArgs1(::<!UNRESOLVED_REFERENCE!>stringVararg<!>)
<!INAPPLICABLE_CANDIDATE!>useMixedStringArgs2<!>(::<!UNRESOLVED_REFERENCE!>stringVararg<!>) useMixedStringArgs2(::<!UNRESOLVED_REFERENCE!>stringVararg<!>)
<!INAPPLICABLE_CANDIDATE!>useMixedStringArgs3<!>(::<!UNRESOLVED_REFERENCE!>stringVararg<!>) useMixedStringArgs3(::<!UNRESOLVED_REFERENCE!>stringVararg<!>)
<!INAPPLICABLE_CANDIDATE!>useTwoStringArrays<!>(::<!UNRESOLVED_REFERENCE!>stringVararg<!>) useTwoStringArrays(::<!UNRESOLVED_REFERENCE!>stringVararg<!>)
} }
@@ -5,8 +5,8 @@ class Impl : Inv
class Scope<InterfaceT, ImplementationT : InterfaceT>(private val implClass: <!UNRESOLVED_REFERENCE!>j.Class<ImplementationT><!>) { class Scope<InterfaceT, ImplementationT : InterfaceT>(private val implClass: <!UNRESOLVED_REFERENCE!>j.Class<ImplementationT><!>) {
fun foo(c: Collection<InterfaceT>) { fun foo(c: Collection<InterfaceT>) {
val hm = c.asSequence() val hm = c.asSequence()
.<!INAPPLICABLE_CANDIDATE!>filter<!>(implClass::<!UNRESOLVED_REFERENCE!>isInstance<!>) .filter(implClass::<!UNRESOLVED_REFERENCE!>isInstance<!>)
.<!INAPPLICABLE_CANDIDATE!>map<!>(implClass::<!UNRESOLVED_REFERENCE!>cast<!>) .map(implClass::<!UNRESOLVED_REFERENCE!>cast<!>)
.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>toSet<!>() .<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>toSet<!>()
} }
} }
@@ -10,7 +10,7 @@ suspend fun String.id(): String = this
fun box() { fun box() {
val x = "f" val x = "f"
builder { builder {
<!INAPPLICABLE_CANDIDATE!>go1<!>(x::<!UNRESOLVED_REFERENCE!>id<!>) go1(x::<!UNRESOLVED_REFERENCE!>id<!>)
<!INAPPLICABLE_CANDIDATE!>go2<!>(x::<!UNRESOLVED_REFERENCE!>id<!>) go2(x::<!UNRESOLVED_REFERENCE!>id<!>)
} }
} }
@@ -14,8 +14,8 @@ suspend fun bar(x: Int) {}
fun test() { fun test() {
test0(::foo) test0(::foo)
<!INAPPLICABLE_CANDIDATE!>test1<!>(::<!UNRESOLVED_REFERENCE!>foo<!>) test1(::<!UNRESOLVED_REFERENCE!>foo<!>)
<!INAPPLICABLE_CANDIDATE!>test0<!>(::<!UNRESOLVED_REFERENCE!>bar<!>) test0(::<!UNRESOLVED_REFERENCE!>bar<!>)
test1(::bar) test1(::bar)
} }
@@ -3,6 +3,6 @@
internal class Z<K> { internal class Z<K> {
val map = HashMap<String, String>() val map = HashMap<String, String>()
inline fun compute(key: String, producer: () -> String): String { inline fun compute(key: String, producer: () -> String): String {
return map.<!INAPPLICABLE_CANDIDATE!>getOrPut<!>(key, ::<!UNSUPPORTED!>producer<!>) return map.getOrPut(key, ::<!UNSUPPORTED!>producer<!>)
} }
} }
@@ -9,7 +9,7 @@ class ProcessorWithParent : Entity {
} }
class ProcessorWithChildren : Entity { class ProcessorWithChildren : Entity {
var processors by <!INAPPLICABLE_CANDIDATE!>children<!>(ProcessorWithParent::class.java, ProcessorWithParent::<!UNRESOLVED_REFERENCE!>processor<!>) var processors by children(ProcessorWithParent::class.java, ProcessorWithParent::<!UNRESOLVED_REFERENCE!>processor<!>)
} }
class Processor2WithParent : Entity { class Processor2WithParent : Entity {
@@ -25,7 +25,7 @@ class Case1() {
} }
fun case() { fun case() {
<!INAPPLICABLE_CANDIDATE!>Companion<!>(::<!UNRESOLVED_REFERENCE!>x<!>) Companion(::<!UNRESOLVED_REFERENCE!>x<!>)
} }
val x = "" val x = ""
@@ -41,7 +41,7 @@ class Case2() {
} }
fun case() { fun case() {
<!INAPPLICABLE_CANDIDATE!>Companion<!>(::<!UNRESOLVED_REFERENCE!>x<!>) Companion(::<!UNRESOLVED_REFERENCE!>x<!>)
} }
val x = C() val x = C()