[FIR2IR] Consolidate type approximation
This commit gets rid of the redundant typeApproximatorConfiguration in Fir2IrTypeConverter and uses the type approximator for captured types instead of the manual approximation used before. This fixes the nullability of approximated captured types, which fixes a runtime error in WASM. This also brings K2 IR closer to K1 IR in one test. #KT-64261 Fixed
This commit is contained in:
committed by
Space Team
parent
52a1ffb312
commit
49ae1b8d01
@@ -0,0 +1,68 @@
|
||||
FILE fqName:<root> fileName:/starProjectionLambdaNullReturn.kt
|
||||
CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.I<T of <root>.I>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] reified:false
|
||||
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.I<T of <root>.I>, func:kotlin.Function0<T of <root>.I?>) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.I<T of <root>.I>
|
||||
VALUE_PARAMETER name:func index:0 type:kotlin.Function0<T of <root>.I?>
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:Impl modality:FINAL visibility:public superTypes:[<root>.I<T of <root>.Impl>]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Impl<T of <root>.Impl>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] reified:false
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Impl<T of <root>.Impl> [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Impl modality:FINAL visibility:public superTypes:[<root>.I<T of <root>.Impl>]'
|
||||
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.Impl<T of <root>.Impl>, func:kotlin.Function0<T of <root>.Impl?>) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun foo (func: kotlin.Function0<T of <root>.I?>): kotlin.Unit declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl<T of <root>.Impl>
|
||||
VALUE_PARAMETER name:func index:0 type:kotlin.Function0<T of <root>.Impl?>
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public abstract fun invoke (): R of kotlin.Function0 declared in kotlin.Function0' type=T of <root>.Impl? origin=INVOKE
|
||||
$this: GET_VAR 'func: kotlin.Function0<T of <root>.Impl?> declared in <root>.Impl.foo' type=kotlin.Function0<T of <root>.Impl?> origin=VARIABLE_AS_FUNCTION
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:foo visibility:public modality:FINAL <> ($receiver:<root>.I<*>) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.I<*>
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun foo (func: kotlin.Function0<T of <root>.I?>): kotlin.Unit declared in <root>.I' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR '<this>: <root>.I<*> declared in <root>.foo' type=<root>.I<*> origin=null
|
||||
func: FUN_EXPR type=kotlin.Function0<kotlin.Any?> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Any? declared in <root>.foo'
|
||||
CONST Null type=kotlin.Nothing? value=null
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
VAR name:foo type:<root>.Impl<kotlin.String> [val]
|
||||
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.Impl' type=<root>.Impl<kotlin.String> origin=null
|
||||
<class: T>: kotlin.String
|
||||
CALL 'public final fun foo (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
$receiver: GET_VAR 'val foo: <root>.Impl<kotlin.String> declared in <root>.box' type=<root>.Impl<kotlin.String> origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="OK"
|
||||
@@ -0,0 +1,68 @@
|
||||
FILE fqName:<root> fileName:/starProjectionLambdaNullReturn.kt
|
||||
CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.I<T of <root>.I>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] reified:false
|
||||
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.I<T of <root>.I>, func:kotlin.Function0<T of <root>.I?>) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.I<T of <root>.I>
|
||||
VALUE_PARAMETER name:func index:0 type:kotlin.Function0<T of <root>.I?>
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:Impl modality:FINAL visibility:public superTypes:[<root>.I<T of <root>.Impl>]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Impl<T of <root>.Impl>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] reified:false
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Impl<T of <root>.Impl> [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Impl modality:FINAL visibility:public superTypes:[<root>.I<T of <root>.Impl>]'
|
||||
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.Impl<T of <root>.Impl>, func:kotlin.Function0<T of <root>.Impl?>) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun foo (func: kotlin.Function0<T of <root>.I?>): kotlin.Unit declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Impl<T of <root>.Impl>
|
||||
VALUE_PARAMETER name:func index:0 type:kotlin.Function0<T of <root>.Impl?>
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public abstract fun invoke (): R of kotlin.Function0 declared in kotlin.Function0' type=T of <root>.Impl? origin=INVOKE
|
||||
$this: GET_VAR 'func: kotlin.Function0<T of <root>.Impl?> declared in <root>.Impl.foo' type=kotlin.Function0<T of <root>.Impl?> origin=VARIABLE_AS_FUNCTION
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in <root>.I
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:foo visibility:public modality:FINAL <> ($receiver:<root>.I<*>) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.I<*>
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun foo (func: kotlin.Function0<T of <root>.I?>): kotlin.Unit declared in <root>.I' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR '<this>: <root>.I<*> declared in <root>.foo' type=<root>.I<*> origin=null
|
||||
func: FUN_EXPR type=kotlin.Function0<kotlin.Nothing?> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Nothing?
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Nothing? declared in <root>.foo'
|
||||
CONST Null type=kotlin.Nothing? value=null
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
VAR name:foo type:<root>.Impl<kotlin.String> [val]
|
||||
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.Impl' type=<root>.Impl<kotlin.String> origin=null
|
||||
<class: T>: kotlin.String
|
||||
CALL 'public final fun foo (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
$receiver: GET_VAR 'val foo: <root>.Impl<kotlin.String> declared in <root>.box' type=<root>.Impl<kotlin.String> origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="OK"
|
||||
@@ -0,0 +1,21 @@
|
||||
// ISSUE: KT-64261
|
||||
// DUMP_IR
|
||||
interface I<T : Any> {
|
||||
fun foo(func: () -> T?)
|
||||
}
|
||||
|
||||
class Impl<T : Any> : I<T> {
|
||||
override fun foo(func: () -> T?) {
|
||||
func()
|
||||
}
|
||||
}
|
||||
|
||||
fun I<*>.foo() {
|
||||
foo { null }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val foo = Impl<String>()
|
||||
foo.foo()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user