Fix compatibility resolve for references with multiple outer candidates

#KT-39533 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2020-06-18 16:24:09 +03:00
parent 58183b774d
commit 9c8e979308
15 changed files with 280 additions and 4 deletions
@@ -0,0 +1,18 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun interface IFoo {
fun foo(i: Int)
}
fun interface IFoo2 : IFoo
object A
operator fun A.get(i: IFoo) = 1
operator fun A.set(i: IFoo, newValue: Int) {}
fun withVararg(vararg xs: Int) = 42
fun test1() {
<!UNRESOLVED_REFERENCE!><!INAPPLICABLE_CANDIDATE!>A[::withVararg]<!> += 1<!>
}
@@ -0,0 +1,18 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun interface IFoo {
fun foo(i: Int)
}
fun interface IFoo2 : IFoo
object A
operator fun A.get(i: IFoo) = 1
operator fun A.set(i: IFoo, newValue: Int) {}
fun withVararg(vararg xs: Int) = 42
fun test1() {
A[::withVararg] += 1
}
@@ -0,0 +1,27 @@
package
public fun test1(): kotlin.Unit
public fun withVararg(/*0*/ vararg xs: kotlin.Int /*kotlin.IntArray*/): kotlin.Int
public operator fun A.get(/*0*/ i: IFoo): kotlin.Int
public operator fun A.set(/*0*/ i: IFoo, /*1*/ newValue: kotlin.Int): kotlin.Unit
public object A {
private 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 fun interface IFoo {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(/*0*/ i: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public fun interface IFoo2 : IFoo {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ i: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,21 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
fun <T> foo(f: () -> T): T = f()
fun bar(): Unit {}
object Scope {
fun bar(s: String = ""): Double = 0.0
fun <T> foo(f: () -> T): T = f()
object NestedScope {
fun bar(a: Int = 0): String = ""
fun test() {
// Despite the fact ::bar is resolved with compatibility warning, it's important not to propagate it to the outer call
val result = <!DEBUG_INFO_CALL("fqName: Scope.foo; typeCall: function")!>foo(::bar)<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
}
}
}
@@ -0,0 +1,21 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
fun <T> foo(f: () -> T): T = f()
fun bar(): Unit {}
object Scope {
fun bar(s: String = ""): Double = 0.0
fun <T> foo(f: () -> T): T = f()
object NestedScope {
fun bar(a: Int = 0): String = ""
fun test() {
// Despite the fact ::bar is resolved with compatibility warning, it's important not to propagate it to the outer call
val result = <!DEBUG_INFO_CALL("fqName: Scope.foo; typeCall: function")!>foo(<!COMPATIBILITY_WARNING!>::bar<!>)<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit")!>result<!>
}
}
}
@@ -0,0 +1,22 @@
package
public fun bar(): kotlin.Unit
public fun </*0*/ T> foo(/*0*/ f: () -> T): T
public object Scope {
private constructor Scope()
public final fun bar(/*0*/ s: kotlin.String = ...): kotlin.Double
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun </*0*/ T> foo(/*0*/ f: () -> T): T
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public object NestedScope {
private constructor NestedScope()
public final fun bar(/*0*/ a: kotlin.Int = ...): kotlin.String
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 final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -0,0 +1,25 @@
// FILE: Callable.java
public interface Callable<V> {
V call() throws Exception;
}
// FILE: Future.java
public class Future<T> {}
// FILE: Executor.java
public interface Executor {
<T> Future<T> submit(Callable<T> task);
Future<?> submit(Runnable task);
}
// FILE: test.kt
fun f(): String = "test"
class A {
fun schedule1(e: Executor): Future<String> = e.submit(::f)
fun schedule2(e: Executor): Future<String> = e.submit { f() }
}
@@ -0,0 +1,25 @@
// FILE: Callable.java
public interface Callable<V> {
V call() throws Exception;
}
// FILE: Future.java
public class Future<T> {}
// FILE: Executor.java
public interface Executor {
<T> Future<T> submit(Callable<T> task);
Future<?> submit(Runnable task);
}
// FILE: test.kt
fun f(): String = "test"
class A {
fun schedule1(e: Executor): Future<String> = e.submit(::f)
fun schedule2(e: Executor): Future<String> = <!TYPE_MISMATCH!>e.submit { f() }<!>
}
@@ -0,0 +1,34 @@
package
public fun f(): kotlin.String
public final 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 final fun schedule1(/*0*/ e: Executor): Future<kotlin.String>
public final fun schedule2(/*0*/ e: Executor): Future<kotlin.String>
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface Callable</*0*/ V : kotlin.Any!> {
public abstract fun call(): V!
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 Executor {
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 abstract fun </*0*/ T : kotlin.Any!> submit(/*0*/ task: Callable<T!>!): Future<T!>!
public abstract fun submit(/*0*/ task: java.lang.Runnable!): Future<*>!
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class Future</*0*/ T : kotlin.Any!> {
public constructor Future</*0*/ T : kotlin.Any!>()
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
}