[NI] Resolve callable reference eagerly if there is only one candidate
#KT-30737 Fixed
This commit is contained in:
+30
@@ -2298,11 +2298,21 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference/resolve"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("ambiguityWhenNoApplicableCallableReferenceCandidate.kt")
|
||||
public void testAmbiguityWhenNoApplicableCallableReferenceCandidate() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWhenNoApplicableCallableReferenceCandidate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ambiguousWithVararg.kt")
|
||||
public void testAmbiguousWithVararg() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/ambiguousWithVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("applicableCallableReferenceFromDistantScope.kt")
|
||||
public void testApplicableCallableReferenceFromDistantScope() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/applicableCallableReferenceFromDistantScope.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("byArgType.kt")
|
||||
public void testByArgType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/byArgType.kt");
|
||||
@@ -2318,11 +2328,26 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/byValType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("commonSupertypeFromReturnTypesOfCallableReference.kt")
|
||||
public void testCommonSupertypeFromReturnTypesOfCallableReference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/commonSupertypeFromReturnTypesOfCallableReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/constructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eagerAndPostponedCallableReferences.kt")
|
||||
public void testEagerAndPostponedCallableReferences() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eagerResolveOfSingleCallableReference.kt")
|
||||
public void testEagerResolveOfSingleCallableReference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/eagerResolveOfSingleCallableReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassConstructorOnOuterClassInstance.kt")
|
||||
public void testInnerClassConstructorOnOuterClassInstance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/innerClassConstructorOnOuterClassInstance.kt");
|
||||
@@ -2393,6 +2418,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/overloadsMember.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("postponedResolveOfManyCallableReference.kt")
|
||||
public void testPostponedResolveOfManyCallableReference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/postponedResolveOfManyCallableReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("resolveEqualsOperatorWithAnyExpectedType.kt")
|
||||
public void testResolveEqualsOperatorWithAnyExpectedType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/resolveEqualsOperatorWithAnyExpectedType.kt");
|
||||
|
||||
+9
@@ -74,6 +74,15 @@ class CallableReferenceResolver(
|
||||
val candidates = runRHSResolution(scopeTower, argument, expectedType) { checkCallableReference ->
|
||||
csBuilder.runTransaction { checkCallableReference(this); false }
|
||||
}
|
||||
|
||||
if (candidates.size > 1 && resolvedAtom is EagerCallableReferenceAtom) {
|
||||
resolvedAtom.setAnalyzedResults(
|
||||
candidate = null,
|
||||
subResolvedAtoms = listOf(resolvedAtom.transformToPostponed())
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
val chosenCandidate = candidates.singleOrNull()
|
||||
if (chosenCandidate != null) {
|
||||
val (toFreshSubstitutor, diagnostic) = with(chosenCandidate) {
|
||||
|
||||
+1
-4
@@ -19,13 +19,10 @@ package org.jetbrains.kotlin.resolve.calls.components
|
||||
import org.jetbrains.kotlin.builtins.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ArgumentConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.LHSArgumentConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableForLambdaReturnType
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.types.TypeConstructor
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
@@ -140,7 +137,7 @@ private fun preprocessCallableReference(
|
||||
expectedType: UnwrappedType?,
|
||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||
): ResolvedAtom {
|
||||
val result = ResolvedCallableReferenceAtom(argument, expectedType)
|
||||
val result = EagerCallableReferenceAtom(argument, expectedType)
|
||||
if (expectedType == null) return result
|
||||
|
||||
val notCallableTypeConstructor =
|
||||
|
||||
+1
-3
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.inference.components
|
||||
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.NewTypeVariable
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.NotEnoughInformationForTypeParameter
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
@@ -15,7 +14,6 @@ import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
@@ -79,7 +77,7 @@ class KotlinConstraintSystemCompleter(
|
||||
) ?: break
|
||||
|
||||
if (shouldForceCallableReferenceOrLambdaResolution(completionMode, variableForFixation)) {
|
||||
if (forcePostponedAtomResolution<ResolvedCallableReferenceAtom>(topLevelAtoms, analyze)) continue
|
||||
if (forcePostponedAtomResolution<PostponedCallableReferenceAtom>(topLevelAtoms, analyze)) continue
|
||||
if (forcePostponedAtomResolution<LambdaWithTypeVariableAsExpectedTypeAtom>(topLevelAtoms, analyze)) continue
|
||||
}
|
||||
|
||||
|
||||
+18
-1
@@ -111,7 +111,7 @@ class ResolvedLambdaAtom(
|
||||
override val outputType: UnwrappedType get() = returnType
|
||||
}
|
||||
|
||||
class ResolvedCallableReferenceAtom(
|
||||
abstract class ResolvedCallableReferenceAtom(
|
||||
override val atom: CallableReferenceKotlinCallArgument,
|
||||
val expectedType: UnwrappedType?
|
||||
) : PostponedResolvedAtom() {
|
||||
@@ -126,6 +126,23 @@ class ResolvedCallableReferenceAtom(
|
||||
setAnalyzedResults(subResolvedAtoms)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class EagerCallableReferenceAtom(
|
||||
atom: CallableReferenceKotlinCallArgument,
|
||||
expectedType: UnwrappedType?
|
||||
) : ResolvedCallableReferenceAtom(atom, expectedType) {
|
||||
|
||||
override val inputTypes: Collection<UnwrappedType> get() = emptyList()
|
||||
override val outputType: UnwrappedType? get() = null
|
||||
|
||||
fun transformToPostponed(): PostponedCallableReferenceAtom = PostponedCallableReferenceAtom(this)
|
||||
}
|
||||
|
||||
class PostponedCallableReferenceAtom(
|
||||
eagerCallableReferenceAtom: EagerCallableReferenceAtom
|
||||
) : ResolvedCallableReferenceAtom(eagerCallableReferenceAtom.atom, eagerCallableReferenceAtom.expectedType) {
|
||||
|
||||
override val inputTypes: Collection<UnwrappedType>
|
||||
get() = extractInputOutputTypesFromCallableReferenceExpectedType(expectedType)?.inputTypes ?: listOfNotNull(expectedType)
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ fun <T> Wrapper<T>.baz(transform: (T) -> Unit): T = TODO()
|
||||
|
||||
fun test() {
|
||||
takeFun<String>(::foo)
|
||||
takeFun<String>(<!NI;TYPE_MISMATCH!>::<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>fooInt<!><!>)
|
||||
takeFun<String>(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>::<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>fooInt<!><!>)
|
||||
|
||||
callFun<String, Wrapper<String>>(::createWrapper)
|
||||
callFun<Int, Wrapper<Number>>(::createWrapper)
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo(x: Int) {}
|
||||
fun foo(y: String) {}
|
||||
|
||||
fun <T> bar(f: (T) -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
bar(::<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>)
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> bar(/*0*/ f: (T) -> kotlin.Unit): kotlin.Unit
|
||||
public fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun foo(/*0*/ y: kotlin.String): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
fun foo(s: String) {}
|
||||
|
||||
object Scope {
|
||||
fun foo(a: Int) {}
|
||||
fun foo(b: Boolean) {}
|
||||
|
||||
fun <T> bar(f: (T) -> Unit): T = TODO()
|
||||
|
||||
fun test() {
|
||||
val s: String = bar(::foo)
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
|
||||
public object Scope {
|
||||
private constructor Scope()
|
||||
public final fun </*0*/ T> bar(/*0*/ f: (T) -> kotlin.Unit): T
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(/*0*/ b: kotlin.Boolean): kotlin.Unit
|
||||
public final fun foo(/*0*/ a: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
class A {
|
||||
fun foo(i: A) {}
|
||||
|
||||
fun baz(i: A) {}
|
||||
}
|
||||
|
||||
class B {
|
||||
fun foo(s: B) {}
|
||||
fun foo(c: Char) {}
|
||||
|
||||
fun baz(s: B) {}
|
||||
}
|
||||
|
||||
fun <T> bar(f: (T) -> Unit): T = TODO()
|
||||
|
||||
fun test() {
|
||||
myWith(A()) {
|
||||
val t1 = bar(::foo)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("A")!>t1<!>
|
||||
|
||||
val t2 = bar(::baz)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("A")!>t2<!>
|
||||
|
||||
myWith(B()) {
|
||||
val a: A = bar(::foo)
|
||||
val b: B = bar(::foo)
|
||||
|
||||
val t3 = bar(::baz)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("B")!>t3<!>
|
||||
|
||||
<!IMPLICIT_NOTHING_AS_TYPE_PARAMETER, IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>bar<!>(::<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T, R> myWith(receiver: T, block: T.() -> R): R = TODO()
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> bar(/*0*/ f: (T) -> kotlin.Unit): T
|
||||
public inline fun </*0*/ T, /*1*/ R> myWith(/*0*/ receiver: T, /*1*/ block: T.() -> R): R
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun baz(/*0*/ i: A): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(/*0*/ i: A): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor B()
|
||||
public final fun baz(/*0*/ s: B): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(/*0*/ s: B): kotlin.Unit
|
||||
public final fun foo(/*0*/ c: kotlin.Char): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
interface Parent
|
||||
interface Child1 : Parent
|
||||
interface Child2 : Parent
|
||||
|
||||
fun foo(): Child1 = TODO()
|
||||
fun bar(): Child2 = TODO()
|
||||
|
||||
fun <K> select(x: K, y: K): K = TODO()
|
||||
|
||||
fun test() {
|
||||
val a = select(::foo, ::bar)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction0<Parent>")!>a<!>
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package
|
||||
|
||||
public fun bar(): Child2
|
||||
public fun foo(): Child1
|
||||
public fun </*0*/ K> select(/*0*/ x: K, /*1*/ y: K): K
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public interface Child1 : Parent {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Child2 : Parent {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Parent {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.kt
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
interface A
|
||||
interface B
|
||||
|
||||
fun multiple(a: A) {}
|
||||
fun multiple(b: B) {}
|
||||
|
||||
fun singleA(a: A) {}
|
||||
fun singleB(a: B) {}
|
||||
|
||||
fun <T> foo(f: (T) -> Unit, g: (T) -> Unit): T = TODO()
|
||||
|
||||
fun test() {
|
||||
val a1 = foo(::singleA, ::multiple)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("A")!>a1<!>
|
||||
|
||||
val a2 = foo(::singleB, ::multiple)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("B")!>a2<!>
|
||||
|
||||
val a3 = foo(::multiple, ::singleA)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("A")!>a3<!>
|
||||
|
||||
val a4 = foo(::multiple, ::singleB)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("B")!>a4<!>
|
||||
|
||||
val a5 = foo(::singleA, ::singleA)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("A")!>a5<!>
|
||||
|
||||
val a6 = foo(::singleA, ::singleB)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("{A & B}")!>a6<!>
|
||||
|
||||
<!IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>foo<!>(::<!DEBUG_INFO_MISSING_UNRESOLVED!>multiple<!>, ::<!DEBUG_INFO_MISSING_UNRESOLVED!>multiple<!>)
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> foo(/*0*/ f: (T) -> kotlin.Unit, /*1*/ g: (T) -> kotlin.Unit): T
|
||||
public fun multiple(/*0*/ a: A): kotlin.Unit
|
||||
public fun multiple(/*0*/ b: B): kotlin.Unit
|
||||
public fun singleA(/*0*/ a: A): kotlin.Unit
|
||||
public fun singleB(/*0*/ a: B): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public interface A {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: -NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
open class A
|
||||
class B : A()
|
||||
|
||||
class Or(left: A, right: A) : A()
|
||||
|
||||
class Out<out T>
|
||||
|
||||
fun test(ls: Out<B>) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("A")!>ls.reduce(::Or)<!>
|
||||
}
|
||||
|
||||
fun <S, T : S> Out<T>.reduce(operation: (S, T) -> S): S = TODO()
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ ls: Out<B>): kotlin.Unit
|
||||
public fun </*0*/ S, /*1*/ T : S> Out<T>.reduce(/*0*/ operation: (S, T) -> S): S
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
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 open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Or : A {
|
||||
public constructor Or(/*0*/ left: A, /*1*/ right: A)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Out</*0*/ out T> {
|
||||
public constructor Out</*0*/ out T>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
interface A
|
||||
interface B
|
||||
|
||||
fun foo(i: A) {}
|
||||
fun foo(b: B) {}
|
||||
|
||||
fun <T> bar1(f: (T) -> Unit): T = TODO()
|
||||
fun <T> bar2(f: (T) -> Unit, e: T) {}
|
||||
|
||||
fun test(a: A, b: B) {
|
||||
val expectedType1: A = bar1(::foo)
|
||||
val expectedType2: B = bar1(::foo)
|
||||
|
||||
bar2(::foo, a)
|
||||
bar2(::foo, b)
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> bar1(/*0*/ f: (T) -> kotlin.Unit): T
|
||||
public fun </*0*/ T> bar2(/*0*/ f: (T) -> kotlin.Unit, /*1*/ e: T): kotlin.Unit
|
||||
public fun foo(/*0*/ i: A): kotlin.Unit
|
||||
public fun foo(/*0*/ b: B): kotlin.Unit
|
||||
public fun test(/*0*/ a: A, /*1*/ b: B): kotlin.Unit
|
||||
|
||||
public interface A {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+6
-7
@@ -16,17 +16,16 @@ fun test(f1: (Int) -> Unit, f2: kotlin.Function1<Int, Unit>) {
|
||||
select3(null, f1, ::bar)
|
||||
select3(null, f2, ::bar)
|
||||
|
||||
select3(null, f1, <!TYPE_MISMATCH!>::foo<!>)
|
||||
select3(null, f2, <!TYPE_MISMATCH!>::foo<!>)
|
||||
select3(null, f1, ::foo)
|
||||
select3(null, f2, ::foo)
|
||||
|
||||
dependantSelect2(null, ::foo)
|
||||
dependantSelect3(null, ::foo, ::cloneFoo)
|
||||
dependantSelect3(null, f1, ::bar)
|
||||
dependantSelect3(null, ::bar, f1)
|
||||
|
||||
// These errors are actually can be fixed (and, probably, should) if we force resolution of callable reference
|
||||
dependantSelect3(null, ::foo, <!TYPE_MISMATCH!>::bar<!>)
|
||||
dependantSelect3(null, ::bar, <!TYPE_MISMATCH!>::foo<!>)
|
||||
dependantSelect3(null, f1, <!TYPE_MISMATCH!>::foo<!>)
|
||||
dependantSelect3(null, <!TYPE_MISMATCH!>::foo<!>, f1)
|
||||
dependantSelect3(null, ::foo, ::bar)
|
||||
dependantSelect3(null, ::bar, ::foo)
|
||||
dependantSelect3(null, f1, ::foo)
|
||||
dependantSelect3(null, ::foo, f1)
|
||||
}
|
||||
|
||||
@@ -2305,11 +2305,21 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference/resolve"), Pattern.compile("^(.*)\\.kts?$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("ambiguityWhenNoApplicableCallableReferenceCandidate.kt")
|
||||
public void testAmbiguityWhenNoApplicableCallableReferenceCandidate() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWhenNoApplicableCallableReferenceCandidate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ambiguousWithVararg.kt")
|
||||
public void testAmbiguousWithVararg() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/ambiguousWithVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("applicableCallableReferenceFromDistantScope.kt")
|
||||
public void testApplicableCallableReferenceFromDistantScope() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/applicableCallableReferenceFromDistantScope.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("byArgType.kt")
|
||||
public void testByArgType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/byArgType.kt");
|
||||
@@ -2325,11 +2335,31 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/byValType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("chooseOuterCallBySingleCallableReference.kt")
|
||||
public void testChooseOuterCallBySingleCallableReference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/chooseOuterCallBySingleCallableReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("commonSupertypeFromReturnTypesOfCallableReference.kt")
|
||||
public void testCommonSupertypeFromReturnTypesOfCallableReference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/commonSupertypeFromReturnTypesOfCallableReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/constructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eagerAndPostponedCallableReferences.kt")
|
||||
public void testEagerAndPostponedCallableReferences() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eagerResolveOfSingleCallableReference.kt")
|
||||
public void testEagerResolveOfSingleCallableReference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/eagerResolveOfSingleCallableReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassConstructorOnOuterClassInstance.kt")
|
||||
public void testInnerClassConstructorOnOuterClassInstance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/innerClassConstructorOnOuterClassInstance.kt");
|
||||
@@ -2400,6 +2430,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/overloadsMember.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("postponedResolveOfManyCallableReference.kt")
|
||||
public void testPostponedResolveOfManyCallableReference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/postponedResolveOfManyCallableReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("resolveEqualsOperatorWithAnyExpectedType.kt")
|
||||
public void testResolveEqualsOperatorWithAnyExpectedType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/resolveEqualsOperatorWithAnyExpectedType.kt");
|
||||
|
||||
Generated
+30
@@ -2300,11 +2300,21 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference/resolve"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("ambiguityWhenNoApplicableCallableReferenceCandidate.kt")
|
||||
public void testAmbiguityWhenNoApplicableCallableReferenceCandidate() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWhenNoApplicableCallableReferenceCandidate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ambiguousWithVararg.kt")
|
||||
public void testAmbiguousWithVararg() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/ambiguousWithVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("applicableCallableReferenceFromDistantScope.kt")
|
||||
public void testApplicableCallableReferenceFromDistantScope() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/applicableCallableReferenceFromDistantScope.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("byArgType.kt")
|
||||
public void testByArgType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/byArgType.kt");
|
||||
@@ -2320,11 +2330,26 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/byValType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("commonSupertypeFromReturnTypesOfCallableReference.kt")
|
||||
public void testCommonSupertypeFromReturnTypesOfCallableReference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/commonSupertypeFromReturnTypesOfCallableReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/constructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eagerAndPostponedCallableReferences.kt")
|
||||
public void testEagerAndPostponedCallableReferences() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/eagerAndPostponedCallableReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eagerResolveOfSingleCallableReference.kt")
|
||||
public void testEagerResolveOfSingleCallableReference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/eagerResolveOfSingleCallableReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassConstructorOnOuterClassInstance.kt")
|
||||
public void testInnerClassConstructorOnOuterClassInstance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/innerClassConstructorOnOuterClassInstance.kt");
|
||||
@@ -2395,6 +2420,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/overloadsMember.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("postponedResolveOfManyCallableReference.kt")
|
||||
public void testPostponedResolveOfManyCallableReference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/postponedResolveOfManyCallableReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("resolveEqualsOperatorWithAnyExpectedType.kt")
|
||||
public void testResolveEqualsOperatorWithAnyExpectedType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/resolve/resolveEqualsOperatorWithAnyExpectedType.kt");
|
||||
|
||||
Reference in New Issue
Block a user