Files
kotlin-fork/compiler/testData/ir/irText/fakeOverrides/annotations/basicNullabilityAnnotationOverride.fir.ir.txt
Kirill Rakhman 69a7bf7f68 [FIR] Add equality constraint from expected type for some synthetic function calls
This fixes some cases where we infer some type variable inside one
of the branches to Nothing instead of the expected type because Nothing
appeared in some other branch.

Specifically, we add an equality instead of a subtype constraint during
completion of calls to synthetic functions for if/when, try and !!.
We don't do it when the call contains a (possibly nested) elvis or is
inside the RHS of an assignment.
Otherwise, we would prevent some smart-casts.

#KT-65882 Fixed
2024-03-05 17:38:59 +00:00

175 lines
13 KiB
Plaintext
Vendored

FILE fqName:<root> fileName:/1.kt
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<root>.Java1]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.Java1'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<root>.Java1]'
FUN FAKE_OVERRIDE name:bar visibility:public modality:OPEN <> ($this:<root>.Java1) returnType:@[EnhancedNullability] kotlin.String? [fake_override]
annotations:
Nullable(value = <null>)
overridden:
public open fun bar (): @[EnhancedNullability] kotlin.String? declared in <root>.Java1
$this: VALUE_PARAMETER name:<this> type:<root>.Java1
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>.Java1
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:foo visibility:public modality:OPEN <> ($this:<root>.Java1, s:@[EnhancedNullability] kotlin.String?) returnType:kotlin.Unit [fake_override]
overridden:
public open fun foo (s: @[EnhancedNullability] kotlin.String?): kotlin.Unit declared in <root>.Java1
$this: VALUE_PARAMETER name:<this> type:<root>.Java1
VALUE_PARAMETER name:s index:0 type:@[EnhancedNullability] kotlin.String?
annotations:
Nullable(value = <null>)
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>.Java1
$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>.Java1
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:B modality:FINAL visibility:public superTypes:[<root>.Java1]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.B
CONSTRUCTOR visibility:public <> () returnType:<root>.B [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.Java1'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[<root>.Java1]'
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>.Java1
$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>.Java1
$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>.Java1
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:bar visibility:public modality:OPEN <> ($this:<root>.B) returnType:kotlin.String
overridden:
public open fun bar (): @[EnhancedNullability] kotlin.String? declared in <root>.Java1
$this: VALUE_PARAMETER name:<this> type:<root>.B
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.String declared in <root>.B'
CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.String origin=EXCLEXCL
<T0>: kotlin.Nothing
arg0: CONST Null type=kotlin.Nothing? value=null
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.B, s:kotlin.String?) returnType:kotlin.Unit
overridden:
public open fun foo (s: @[EnhancedNullability] kotlin.String?): kotlin.Unit declared in <root>.Java1
$this: VALUE_PARAMETER name:<this> type:<root>.B
VALUE_PARAMETER name:s index:0 type:kotlin.String?
BLOCK_BODY
CLASS CLASS name:C modality:ABSTRACT visibility:public superTypes:[<root>.Java2]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
CONSTRUCTOR visibility:public <> () returnType:<root>.C [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:ABSTRACT visibility:public superTypes:[<root>.Java2]'
FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:<root>.Java2) returnType:@[EnhancedNullability] kotlin.String [fake_override]
annotations:
NotNull(value = <null>)
overridden:
public abstract fun bar (): @[EnhancedNullability] kotlin.String declared in <root>.Java2
$this: VALUE_PARAMETER name:<this> type:<root>.Java2
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>.Java2
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.Java2, s:@[EnhancedNullability] kotlin.String) returnType:kotlin.Unit [fake_override]
overridden:
public abstract fun foo (s: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in <root>.Java2
$this: VALUE_PARAMETER name:<this> type:<root>.Java2
VALUE_PARAMETER name:s index:0 type:@[EnhancedNullability] kotlin.String
annotations:
NotNull(value = <null>)
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>.Java2
$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>.Java2
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.Java2]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.D
CONSTRUCTOR visibility:public <> () returnType:<root>.D [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:D modality:FINAL visibility:public superTypes:[<root>.Java2]'
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>.Java2
$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>.Java2
$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>.Java2
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:bar visibility:public modality:OPEN <> ($this:<root>.D) returnType:kotlin.String
overridden:
public abstract fun bar (): @[EnhancedNullability] kotlin.String declared in <root>.Java2
$this: VALUE_PARAMETER name:<this> type:<root>.D
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.String declared in <root>.D'
CONST String type=kotlin.String value=""
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.D, s:kotlin.String) returnType:kotlin.Unit
overridden:
public abstract fun foo (s: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in <root>.Java2
$this: VALUE_PARAMETER name:<this> type:<root>.D
VALUE_PARAMETER name:s index:0 type:kotlin.String
BLOCK_BODY
FUN name:test visibility:public modality:FINAL <> (a:<root>.A, b:<root>.B, c:<root>.C, d:<root>.D) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:<root>.A
VALUE_PARAMETER name:b index:1 type:<root>.B
VALUE_PARAMETER name:c index:2 type:<root>.C
VALUE_PARAMETER name:d index:3 type:<root>.D
BLOCK_BODY
VAR name:k type:kotlin.String? [val]
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:nullableString type:@[EnhancedNullability] kotlin.String? visibility:public' type=@[EnhancedNullability] kotlin.String? origin=null
receiver: GET_VAR 'a: <root>.A declared in <root>.test' type=<root>.A origin=null
VAR name:k2 type:kotlin.String? [val]
CALL 'public open fun bar (): @[EnhancedNullability] kotlin.String? declared in <root>.A' type=@[EnhancedNullability] kotlin.String? origin=null
$this: GET_VAR 'a: <root>.A declared in <root>.test' type=<root>.A origin=null
CALL 'public open fun foo (s: @[EnhancedNullability] kotlin.String?): kotlin.Unit declared in <root>.A' type=kotlin.Unit origin=null
$this: GET_VAR 'a: <root>.A declared in <root>.test' type=<root>.A origin=null
s: CONST Null type=kotlin.Nothing? value=null
CALL 'public open fun foo (s: @[EnhancedNullability] kotlin.String?): kotlin.Unit declared in <root>.A' type=kotlin.Unit origin=null
$this: GET_VAR 'a: <root>.A declared in <root>.test' type=<root>.A origin=null
s: CONST String type=kotlin.String value=""
VAR name:k3 type:kotlin.String? [val]
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:nullableString type:@[EnhancedNullability] kotlin.String? visibility:public' type=@[EnhancedNullability] kotlin.String? origin=null
receiver: GET_VAR 'b: <root>.B declared in <root>.test' type=<root>.B origin=null
VAR name:k4 type:kotlin.String [val]
CALL 'public open fun bar (): kotlin.String declared in <root>.B' type=kotlin.String origin=null
$this: GET_VAR 'b: <root>.B declared in <root>.test' type=<root>.B origin=null
CALL 'public open fun foo (s: kotlin.String?): kotlin.Unit declared in <root>.B' type=kotlin.Unit origin=null
$this: GET_VAR 'b: <root>.B declared in <root>.test' type=<root>.B origin=null
s: CONST Null type=kotlin.Nothing? value=null
CALL 'public open fun foo (s: kotlin.String?): kotlin.Unit declared in <root>.B' type=kotlin.Unit origin=null
$this: GET_VAR 'b: <root>.B declared in <root>.test' type=<root>.B origin=null
s: CONST String type=kotlin.String value=""
VAR name:k5 type:kotlin.String [val]
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
CALL 'public abstract fun bar (): @[EnhancedNullability] kotlin.String declared in <root>.C' type=@[EnhancedNullability] kotlin.String origin=null
$this: GET_VAR 'c: <root>.C declared in <root>.test' type=<root>.C origin=null
CALL 'public abstract fun foo (s: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in <root>.C' type=kotlin.Unit origin=null
$this: GET_VAR 'c: <root>.C declared in <root>.test' type=<root>.C origin=null
s: CONST String type=kotlin.String value=""
VAR name:k6 type:kotlin.String [val]
CALL 'public open fun bar (): kotlin.String declared in <root>.D' type=kotlin.String origin=null
$this: GET_VAR 'd: <root>.D declared in <root>.test' type=<root>.D origin=null
CALL 'public open fun foo (s: kotlin.String): kotlin.Unit declared in <root>.D' type=kotlin.Unit origin=null
$this: GET_VAR 'd: <root>.D declared in <root>.test' type=<root>.D origin=null
s: CONST String type=kotlin.String value=""