Fix multiple exceptions related to subtypes of function types

The main change is in FunctionsTypingVisitor#visitLambdaExpression, where we
incorrectly allowed subtypes of function types to be expected type during
resolution of lambdas

Also see EA-70485

 #KT-9820 Fixed
This commit is contained in:
Alexander Udalov
2016-03-14 12:43:00 +03:00
parent 33ff1e1e29
commit 117d0bcf03
9 changed files with 103 additions and 32 deletions
@@ -0,0 +1,17 @@
class O : Function2<Int, String, Unit> {
override fun invoke(p1: Int, p2: String) {
}
}
fun test() {
val a = fun(<!UNUSED_PARAMETER!>o<!>: O) {
}
a <!TYPE_MISMATCH!>{}<!>
}
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>class Ext<!> : <!SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE!>String.() -> Unit<!> {
}
fun test2() {
val <!UNUSED_VARIABLE!>f<!>: Ext = <!TYPE_MISMATCH!>{}<!>
}
@@ -0,0 +1,20 @@
package
public fun test(): kotlin.Unit
public fun test2(): kotlin.Unit
public final class Ext : kotlin.String.() -> kotlin.Unit {
public constructor Ext()
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 override /*1*/ /*fake_override*/ fun invoke(/*0*/ p1: kotlin.String): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class O : (kotlin.Int, kotlin.String) -> kotlin.Unit {
public constructor O()
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*/ fun invoke(/*0*/ p1: kotlin.Int, /*1*/ p2: kotlin.String): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,16 @@
// FILE: J.java
import kotlin.jvm.functions.Function1;
public interface J extends Function1<Integer, Void> {
}
// FILE: 1.kt
fun useJ(j: J) {
j(42)
}
fun jj() {
useJ(<!TYPE_MISMATCH!>{}<!>)
}
@@ -0,0 +1,12 @@
package
public /*synthesized*/ fun J(/*0*/ function: (kotlin.Int!) -> java.lang.Void!): J
public fun jj(): kotlin.Unit
public fun useJ(/*0*/ j: J): kotlin.Unit
public interface J : (kotlin.Int!) -> java.lang.Void! {
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 override /*1*/ /*fake_override*/ fun invoke(/*0*/ p1: kotlin.Int!): java.lang.Void!
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}