NI: Prefer nullable lower bound to flexible one when substitution of type variable is performed and remember flexibility of type parameters based on flexibility of its upper bounds

^KT-32435 Fixed
This commit is contained in:
Victor Petukhov
2019-12-16 11:46:10 +03:00
parent 68576da494
commit 437a26684d
41 changed files with 985 additions and 85 deletions
@@ -0,0 +1,29 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
// FILE: Function.java
public interface Function<Param, Result> {
Result fun(Param param);
}
// FILE: AdapterProcessor.java
public class AdapterProcessor<T, S> {
public AdapterProcessor(Function<? super T, ? extends S> conversion) {}
}
// FILE: main.kt
interface PsiMethod {
val containingClass: PsiClass?
}
interface PsiClass
fun test() {
// TODO: don't forget to implement preservation flexibility of java type parameters in FIR (this is the reason of error here)
val processor = <!INAPPLICABLE_CANDIDATE!>AdapterProcessor<!><PsiMethod, PsiClass>(
Function { method: PsiMethod? -> method?.containingClass }
)
}
@@ -0,0 +1,29 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
// FILE: Function.java
public interface Function<Param, Result> {
Result fun(Param param);
}
// FILE: AdapterProcessor.java
public class AdapterProcessor<T, S> {
public AdapterProcessor(Function<? super T, ? extends S> conversion) {}
}
// FILE: main.kt
interface PsiMethod {
val containingClass: PsiClass?
}
interface PsiClass
fun test() {
// TODO: don't forget to implement preservation flexibility of java type parameters in FIR (this is the reason of error here)
val processor = AdapterProcessor<PsiMethod, PsiClass>(
Function { method: PsiMethod? -> method?.containingClass }
)
}
@@ -0,0 +1,30 @@
package
public fun test(): kotlin.Unit
public open class AdapterProcessor</*0*/ T : kotlin.Any!, /*1*/ S : kotlin.Any!> {
public constructor AdapterProcessor</*0*/ T : kotlin.Any!, /*1*/ S : kotlin.Any!>(/*0*/ conversion: Function<in T!, out S!>!)
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 Function</*0*/ Param : kotlin.Any!, /*1*/ Result : kotlin.Any!> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun `fun`(/*0*/ param: Param!): Result!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface PsiClass {
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 PsiMethod {
public abstract val containingClass: PsiClass?
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
}