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
@@ -1,10 +1,10 @@
FILE fqName:<root> fileName:/samConversionInGenericConstructorCall.kt
FUN name:test1 visibility:public modality:FINAL <> (f:kotlin.Function1<kotlin.String, kotlin.String>) returnType:<root>.C<kotlin.String>
FUN name:test1 visibility:public modality:FINAL <> (f:kotlin.Function1<kotlin.String, kotlin.String>) returnType:<root>.C<kotlin.String?>
VALUE_PARAMETER name:f index:0 type:kotlin.Function1<kotlin.String, kotlin.String>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test1 (f: kotlin.Function1<kotlin.String, kotlin.String>): <root>.C<kotlin.String> declared in <root>'
CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String> origin=null
<class: X>: kotlin.String
RETURN type=kotlin.Nothing from='public final fun test1 (f: kotlin.Function1<kotlin.String, kotlin.String>): <root>.C<kotlin.String?> declared in <root>'
CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String?> origin=null
<class: X>: kotlin.String?
jxx: TYPE_OP type=<root>.J<kotlin.String?, kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.String?>?
GET_VAR 'f: kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test1' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null
FUN name:test2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
@@ -14,8 +14,8 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall.kt
TYPE_OP type=kotlin.Function1<kotlin.String, kotlin.String> origin=CAST typeOperand=kotlin.Function1<kotlin.String, kotlin.String>
GET_VAR 'x: kotlin.Any declared in <root>.test2' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String> origin=null
<class: X>: kotlin.String
CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String?> origin=null
<class: X>: kotlin.String?
jxx: TYPE_OP type=<root>.J<kotlin.String?, kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.String?>?
TYPE_OP type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String?, kotlin.String?> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String?, kotlin.String?>
GET_VAR 'x: kotlin.Any declared in <root>.test2' type=kotlin.Any origin=null
@@ -1,13 +1,13 @@
FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt
FUN name:test3 visibility:public modality:FINAL <> (f1:kotlin.Function1<kotlin.String, kotlin.String>, f2:kotlin.Function1<kotlin.Int, kotlin.String>) returnType:<root>.C.D<kotlin.Int, kotlin.String>
FUN name:test3 visibility:public modality:FINAL <> (f1:kotlin.Function1<kotlin.String, kotlin.String>, f2:kotlin.Function1<kotlin.Int, kotlin.String>) returnType:<root>.C.D<kotlin.Int?, kotlin.String?>
VALUE_PARAMETER name:f1 index:0 type:kotlin.Function1<kotlin.String, kotlin.String>
VALUE_PARAMETER name:f2 index:1 type:kotlin.Function1<kotlin.Int, kotlin.String>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test3 (f1: kotlin.Function1<kotlin.String, kotlin.String>, f2: kotlin.Function1<kotlin.Int, kotlin.String>): <root>.C.D<kotlin.Int, kotlin.String> declared in <root>'
CONSTRUCTOR_CALL 'public constructor <init> (jxy: <root>.J<X of <root>.C?, Y of <root>.C.D?>?) declared in <root>.C.D' type=<root>.C.D<kotlin.Int, kotlin.String> origin=null
<class: Y>: kotlin.Int
$outer: CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String> origin=null
<class: X>: kotlin.String
RETURN type=kotlin.Nothing from='public final fun test3 (f1: kotlin.Function1<kotlin.String, kotlin.String>, f2: kotlin.Function1<kotlin.Int, kotlin.String>): <root>.C.D<kotlin.Int?, kotlin.String?> declared in <root>'
CONSTRUCTOR_CALL 'public constructor <init> (jxy: <root>.J<X of <root>.C?, Y of <root>.C.D?>?) declared in <root>.C.D' type=<root>.C.D<kotlin.Int?, kotlin.String?> origin=null
<class: Y>: kotlin.Int?
$outer: CONSTRUCTOR_CALL 'public constructor <init> (jxx: <root>.J<X of <root>.C?, X of <root>.C?>?) declared in <root>.C' type=<root>.C<kotlin.String?> origin=null
<class: X>: kotlin.String?
jxx: TYPE_OP type=<root>.J<kotlin.String?, kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.String?>?
GET_VAR 'f1: kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test3' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null
jxy: TYPE_OP type=<root>.J<kotlin.String?, kotlin.Int?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.Int?>?
@@ -77,26 +77,26 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:test4 visibility:public modality:FINAL <> (f:kotlin.Function1<kotlin.String, kotlin.String>, g:kotlin.Function1<kotlin.Any, kotlin.String>) returnType:<root>.Outer.Inner<kotlin.Any, kotlin.String>
FUN name:test4 visibility:public modality:FINAL <> (f:kotlin.Function1<kotlin.String, kotlin.String>, g:kotlin.Function1<kotlin.Any, kotlin.String>) returnType:<root>.Outer.Inner<kotlin.Any?, kotlin.String?>
VALUE_PARAMETER name:f index:0 type:kotlin.Function1<kotlin.String, kotlin.String>
VALUE_PARAMETER name:g index:1 type:kotlin.Function1<kotlin.Any, kotlin.String>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test4 (f: kotlin.Function1<kotlin.String, kotlin.String>, g: kotlin.Function1<kotlin.Any, kotlin.String>): <root>.Outer.Inner<kotlin.Any, kotlin.String> declared in <root>'
CONSTRUCTOR_CALL 'public constructor <init> (j12: <root>.J<T1 of <root>.Outer, T2 of <root>.Outer.Inner>) [primary] declared in <root>.Outer.Inner' type=<root>.Outer.Inner<kotlin.Any, kotlin.String> origin=null
<class: T2>: kotlin.Any
$outer: CONSTRUCTOR_CALL 'public constructor <init> (j11: <root>.J<T1 of <root>.Outer, T1 of <root>.Outer>) [primary] declared in <root>.Outer' type=<root>.Outer<kotlin.String> origin=null
<class: T1>: kotlin.String
j11: TYPE_OP type=<root>.J<kotlin.String, kotlin.String> origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String, kotlin.String>
RETURN type=kotlin.Nothing from='public final fun test4 (f: kotlin.Function1<kotlin.String, kotlin.String>, g: kotlin.Function1<kotlin.Any, kotlin.String>): <root>.Outer.Inner<kotlin.Any?, kotlin.String?> declared in <root>'
CONSTRUCTOR_CALL 'public constructor <init> (j12: <root>.J<T1 of <root>.Outer, T2 of <root>.Outer.Inner>) [primary] declared in <root>.Outer.Inner' type=<root>.Outer.Inner<kotlin.Any?, kotlin.String?> origin=null
<class: T2>: kotlin.Any?
$outer: CONSTRUCTOR_CALL 'public constructor <init> (j11: <root>.J<T1 of <root>.Outer, T1 of <root>.Outer>) [primary] declared in <root>.Outer' type=<root>.Outer<kotlin.String?> origin=null
<class: T1>: kotlin.String?
j11: TYPE_OP type=<root>.J<kotlin.String?, kotlin.String?> origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.String?>
GET_VAR 'f: kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test4' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null
j12: TYPE_OP type=<root>.J<kotlin.String, kotlin.Any> origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String, kotlin.Any>
j12: TYPE_OP type=<root>.J<kotlin.String?, kotlin.Any?> origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.String?, kotlin.Any?>
GET_VAR 'g: kotlin.Function1<kotlin.Any, kotlin.String> declared in <root>.test4' type=kotlin.Function1<kotlin.Any, kotlin.String> origin=null
FUN name:testGenericJavaCtor1 visibility:public modality:FINAL <> (f:kotlin.Function1<kotlin.String, kotlin.Int>) returnType:<root>.G<kotlin.String>
FUN name:testGenericJavaCtor1 visibility:public modality:FINAL <> (f:kotlin.Function1<kotlin.String, kotlin.Int>) returnType:<root>.G<kotlin.String?>
VALUE_PARAMETER name:f index:0 type:kotlin.Function1<kotlin.String, kotlin.Int>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testGenericJavaCtor1 (f: kotlin.Function1<kotlin.String, kotlin.Int>): <root>.G<kotlin.String> declared in <root>'
CONSTRUCTOR_CALL 'public constructor <init> <TCtor> (x: <root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>?) declared in <root>.G' type=<root>.G<kotlin.String> origin=null
<class: TClass>: kotlin.String
<TCtor>: kotlin.Int
RETURN type=kotlin.Nothing from='public final fun testGenericJavaCtor1 (f: kotlin.Function1<kotlin.String, kotlin.Int>): <root>.G<kotlin.String?> declared in <root>'
CONSTRUCTOR_CALL 'public constructor <init> <TCtor> (x: <root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>?) declared in <root>.G' type=<root>.G<kotlin.String?> origin=null
<class: TClass>: kotlin.String?
<TCtor>: kotlin.Int?
x: TYPE_OP type=<root>.J<kotlin.Int?, kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.Int?, kotlin.String?>?
GET_VAR 'f: kotlin.Function1<kotlin.String, kotlin.Int> declared in <root>.testGenericJavaCtor1' type=kotlin.Function1<kotlin.String, kotlin.Int> origin=null
FUN name:testGenericJavaCtor2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit
@@ -106,9 +106,9 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt
TYPE_OP type=kotlin.Function1<kotlin.String, kotlin.Int> origin=CAST typeOperand=kotlin.Function1<kotlin.String, kotlin.Int>
GET_VAR 'x: kotlin.Any declared in <root>.testGenericJavaCtor2' type=kotlin.Any origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CONSTRUCTOR_CALL 'public constructor <init> <TCtor> (x: <root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>?) declared in <root>.G' type=<root>.G<kotlin.String> origin=null
<class: TClass>: kotlin.String
<TCtor>: kotlin.Int
CONSTRUCTOR_CALL 'public constructor <init> <TCtor> (x: <root>.J<TCtor of <root>.G.<init>?, TClass of <root>.G?>?) declared in <root>.G' type=<root>.G<kotlin.String?> origin=null
<class: TClass>: kotlin.String?
<TCtor>: kotlin.Int?
x: TYPE_OP type=<root>.J<kotlin.Int?, kotlin.String?>? origin=SAM_CONVERSION typeOperand=<root>.J<kotlin.Int?, kotlin.String?>?
TYPE_OP type=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String?, kotlin.Int?> origin=IMPLICIT_CAST typeOperand=kotlin.Function1<@[ParameterName(name = 'x')] kotlin.String?, kotlin.Int?>
GET_VAR 'x: kotlin.Any declared in <root>.testGenericJavaCtor2' type=kotlin.Any origin=null
@@ -9,11 +9,11 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt
VALUE_PARAMETER name:x index:0 type:kotlin.String
BLOCK_BODY
GET_VAR 'x: kotlin.String declared in <root>.test1.<anonymous>' type=kotlin.String origin=null
FUN name:test2 visibility:public modality:FINAL <> () returnType:<root>.J<kotlin.String>
FUN name:test2 visibility:public modality:FINAL <> () returnType:<root>.J<kotlin.String?>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test2 (): <root>.J<kotlin.String> declared in <root>'
CALL 'public final fun J <T> (block: kotlin.Function1<T of <root>.J?, T of <root>.J?>): <root>.J<T of <root>.J> declared in <root>' type=<root>.J<kotlin.String> origin=null
<T>: kotlin.String
RETURN type=kotlin.Nothing from='public final fun test2 (): <root>.J<kotlin.String?> declared in <root>'
CALL 'public final fun J <T> (block: kotlin.Function1<T of <root>.J?, T of <root>.J?>): <root>.J<T of <root>.J> declared in <root>' type=<root>.J<kotlin.String?> origin=null
<T>: kotlin.String?
block: FUN_EXPR type=kotlin.Function1<kotlin.String, kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (x:kotlin.String) returnType:kotlin.String
VALUE_PARAMETER name:x index:0 type:kotlin.String
@@ -23,7 +23,7 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test3 (): kotlin.Unit declared in <root>'
CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit [operator] declared in <root>.H' type=kotlin.Unit origin=null
<X>: kotlin.String
<X>: kotlin.String?
j: FUN_EXPR type=kotlin.Function1<kotlin.String, kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (x:kotlin.String) returnType:kotlin.String
VALUE_PARAMETER name:x index:0 type:kotlin.String
@@ -35,7 +35,7 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt
TYPE_OP type=<root>.J<kotlin.String> origin=CAST typeOperand=<root>.J<kotlin.String>
GET_VAR 'a: kotlin.Any declared in <root>.test4' type=kotlin.Any origin=null
CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit [operator] declared in <root>.H' type=kotlin.Unit origin=null
<X>: kotlin.String
<X>: kotlin.String?
j: GET_VAR 'a: kotlin.Any declared in <root>.test4' type=<root>.J<kotlin.String> origin=null
FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Any
@@ -43,14 +43,14 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt
TYPE_OP type=kotlin.Function1<kotlin.String, kotlin.String> origin=CAST typeOperand=kotlin.Function1<kotlin.String, kotlin.String>
GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Any origin=null
CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit [operator] declared in <root>.H' type=kotlin.Unit origin=null
<X>: kotlin.String
<X>: kotlin.String?
j: GET_VAR 'a: kotlin.Any declared in <root>.test5' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null
FUN name:test6 visibility:public modality:FINAL <T> (a:kotlin.Function1<T of <root>.test6, T of <root>.test6>) returnType:kotlin.Unit
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
VALUE_PARAMETER name:a index:0 type:kotlin.Function1<T of <root>.test6, T of <root>.test6>
BLOCK_BODY
CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit [operator] declared in <root>.H' type=kotlin.Unit origin=null
<X>: T of <root>.test6
<X>: T of <root>.test6?
j: GET_VAR 'a: kotlin.Function1<T of <root>.test6, T of <root>.test6> declared in <root>.test6' type=kotlin.Function1<T of <root>.test6, T of <root>.test6> origin=null
FUN name:test7 visibility:public modality:FINAL <T> (a:kotlin.Any) returnType:kotlin.Unit
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
@@ -59,24 +59,24 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt
TYPE_OP type=kotlin.Function1<T of <root>.test7, T of <root>.test7> origin=CAST typeOperand=kotlin.Function1<T of <root>.test7, T of <root>.test7>
GET_VAR 'a: kotlin.Any declared in <root>.test7' type=kotlin.Any origin=null
CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit [operator] declared in <root>.H' type=kotlin.Unit origin=null
<X>: T of <root>.test7
<X>: T of <root>.test7?
j: GET_VAR 'a: kotlin.Any declared in <root>.test7' type=kotlin.Function1<T of <root>.test7, T of <root>.test7> origin=null
FUN name:test8 visibility:public modality:FINAL <> (efn:kotlin.Function1<kotlin.String, kotlin.String>) returnType:<root>.J<kotlin.String>
FUN name:test8 visibility:public modality:FINAL <> (efn:kotlin.Function1<kotlin.String, kotlin.String>) returnType:<root>.J<kotlin.String?>
VALUE_PARAMETER name:efn index:0 type:kotlin.Function1<kotlin.String, kotlin.String>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test8 (efn: kotlin.Function1<kotlin.String, kotlin.String>): <root>.J<kotlin.String> declared in <root>'
CALL 'public final fun J <T> (block: kotlin.Function1<T of <root>.J?, T of <root>.J?>): <root>.J<T of <root>.J> declared in <root>' type=<root>.J<kotlin.String> origin=null
<T>: kotlin.String
RETURN type=kotlin.Nothing from='public final fun test8 (efn: kotlin.Function1<kotlin.String, kotlin.String>): <root>.J<kotlin.String?> declared in <root>'
CALL 'public final fun J <T> (block: kotlin.Function1<T of <root>.J?, T of <root>.J?>): <root>.J<T of <root>.J> declared in <root>' type=<root>.J<kotlin.String?> origin=null
<T>: kotlin.String?
block: GET_VAR 'efn: kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test8' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null
FUN name:test9 visibility:public modality:FINAL <> (efn:kotlin.Function1<kotlin.String, kotlin.String>) returnType:kotlin.Unit
VALUE_PARAMETER name:efn index:0 type:kotlin.Function1<kotlin.String, kotlin.String>
BLOCK_BODY
CALL 'public open fun bar <X> (j: <root>.J<X of <root>.H.bar?>?): kotlin.Unit [operator] declared in <root>.H' type=kotlin.Unit origin=null
<X>: kotlin.String
<X>: kotlin.String?
j: GET_VAR 'efn: kotlin.Function1<kotlin.String, kotlin.String> declared in <root>.test9' type=kotlin.Function1<kotlin.String, kotlin.String> origin=null
FUN name:test10 visibility:public modality:FINAL <> (fn:kotlin.Function1<kotlin.Int, kotlin.String>) returnType:kotlin.Unit
VALUE_PARAMETER name:fn index:0 type:kotlin.Function1<kotlin.Int, kotlin.String>
BLOCK_BODY
CALL 'public open fun bar2x <Y> (j2x: <root>.J2X<Y of <root>.H.bar2x?>?): kotlin.Unit [operator] declared in <root>.H' type=kotlin.Unit origin=null
<Y>: kotlin.Int
<Y>: kotlin.Int?
j2x: GET_VAR 'fn: kotlin.Function1<kotlin.Int, kotlin.String> declared in <root>.test10' type=kotlin.Function1<kotlin.Int, kotlin.String> origin=null
@@ -82,10 +82,9 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
FUN name:test8 visibility:public modality:FINAL <> (a:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Function0<kotlin.Unit>
BLOCK_BODY
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit [operator] declared in <root>.J' type=kotlin.Unit origin=null
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
r: CALL 'public open fun id <T> (x: T of <root>.J.id?): T of <root>.J.id? [operator] declared in <root>.J' type=kotlin.Function0<kotlin.Unit> origin=null
<T>: kotlin.Function0<kotlin.Unit>
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [/J.run1]>#' type=IrErrorType
CALL 'public open fun id <T> (x: T of <root>.J.id?): T of <root>.J.id? [operator] declared in <root>.J' type=kotlin.Function0<kotlin.Unit>? origin=null
<T>: kotlin.Function0<kotlin.Unit>?
x: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test8' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY