From bd31cbaebfb09c7305fae7c0a90da3d345d719f4 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 2 Feb 2022 17:59:40 +0300 Subject: [PATCH] Unmute some FIR2IR tests --- .../caoWithAdaptationForSam.fir.ir.txt | 235 ++++++++++++++++++ .../caoWithAdaptationForSam.fir.kt.txt | 103 ++++++++ .../caoWithAdaptationForSam.kt | 2 - .../safeCallWithIncrementDecrement.fir.ir.txt | 117 +++++++++ .../safeCallWithIncrementDecrement.fir.kt.txt | 65 +++++ .../safeCallWithIncrementDecrement.kt | 1 - 6 files changed, 520 insertions(+), 3 deletions(-) create mode 100644 compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt create mode 100644 compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt create mode 100644 compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.ir.txt create mode 100644 compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.kt.txt diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt new file mode 100644 index 00000000000..456baed1a12 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.ir.txt @@ -0,0 +1,235 @@ +FILE fqName: fileName:/caoWithAdaptationForSam.kt + CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo + FUN name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo, i:kotlin.Int) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.IFoo + VALUE_PARAMETER name:i index:0 type:kotlin.Int + 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 [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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: 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: type:kotlin.Any + CLASS INTERFACE name:IFoo2 modality:ABSTRACT visibility:public [fun] superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo2 + FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo, i:kotlin.Int) returnType:kotlin.Unit [fake_override] + overridden: + public abstract fun foo (i: kotlin.Int): kotlin.Unit declared in .IFoo + $this: VALUE_PARAMETER name: type:.IFoo + VALUE_PARAMETER name:i index:0 type:kotlin.Int + 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 [fake_override,operator] declared in .IFoo + $this: VALUE_PARAMETER name: 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 [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: 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 [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + CONSTRUCTOR visibility:private <> () returnType:.A [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' + 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 [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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: 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: type:kotlin.Any + CLASS OBJECT name:B modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + CONSTRUCTOR visibility:private <> () returnType:.B [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:B modality:FINAL visibility:public superTypes:[kotlin.Any]' + 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 [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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: 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: type:kotlin.Any + FUN name:get visibility:public modality:FINAL <> ($receiver:.A, i:.IFoo) returnType:kotlin.Int [operator] + $receiver: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:i index:0 type:.IFoo + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' + CONST Int type=kotlin.Int value=1 + FUN name:set visibility:public modality:FINAL <> ($receiver:.A, i:.IFoo, newValue:kotlin.Int) returnType:kotlin.Unit [operator] + $receiver: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:i index:0 type:.IFoo + VALUE_PARAMETER name:newValue index:1 type:kotlin.Int + BLOCK_BODY + FUN name:get visibility:public modality:FINAL <> ($receiver:.B, i:.IFoo) returnType:kotlin.Int [operator] + $receiver: VALUE_PARAMETER name: type:.B + VALUE_PARAMETER name:i index:0 type:.IFoo + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' + CONST Int type=kotlin.Int value=1 + FUN name:set visibility:public modality:FINAL <> ($receiver:.B, i:.IFoo2, newValue:kotlin.Int) returnType:kotlin.Unit [operator] + $receiver: VALUE_PARAMETER name: type:.B + VALUE_PARAMETER name:i index:0 type:.IFoo2 + VALUE_PARAMETER name:newValue index:1 type:kotlin.Int + BLOCK_BODY + FUN name:withVararg visibility:public modality:FINAL <> (xs:kotlin.IntArray) returnType:kotlin.Int + VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=42 + FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.A [val] + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.reflect.KFunction1 [val] + FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in ' type=kotlin.Int origin=null + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .test1.withVararg' type=kotlin.Int origin=null + CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_0: .A [val] declared in .test1' type=.A origin=null + i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo + GET_VAR 'val tmp_1: kotlin.reflect.KFunction1 [val] declared in .test1' type=kotlin.reflect.KFunction1 origin=null + newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_0: .A [val] declared in .test1' type=.A origin=null + i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo + GET_VAR 'val tmp_1: kotlin.reflect.KFunction1 [val] declared in .test1' type=kotlin.reflect.KFunction1 origin=null + other: CONST Int type=kotlin.Int value=1 + FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.B [val] + GET_OBJECT 'CLASS OBJECT name:B modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.B + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.reflect.KFunction1 [val] + FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.Int declared in ' type=kotlin.Int origin=null + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .test2.withVararg' type=kotlin.Int origin=null + CALL 'public final fun set (i: .IFoo2, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_2: .B [val] declared in .test2' type=.B origin=null + i: TYPE_OP type=.IFoo2 origin=SAM_CONVERSION typeOperand=.IFoo2 + GET_VAR 'val tmp_3: kotlin.reflect.KFunction1 [val] declared in .test2' type=kotlin.reflect.KFunction1 origin=null + newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_2: .B [val] declared in .test2' type=.B origin=null + i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo + GET_VAR 'val tmp_3: kotlin.reflect.KFunction1 [val] declared in .test2' type=kotlin.reflect.KFunction1 origin=null + other: CONST Int type=kotlin.Int value=1 + FUN name:test3 visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit + VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 + BLOCK_BODY + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:.A [val] + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Function1 [val] + GET_VAR 'fn: kotlin.Function1 declared in .test3' type=kotlin.Function1 origin=null + CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_4: .A [val] declared in .test3' type=.A origin=null + i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo + GET_VAR 'val tmp_5: kotlin.Function1 [val] declared in .test3' type=kotlin.Function1 origin=null + newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_4: .A [val] declared in .test3' type=.A origin=null + i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo + GET_VAR 'val tmp_5: kotlin.Function1 [val] declared in .test3' type=kotlin.Function1 origin=null + other: CONST Int type=kotlin.Int value=1 + FUN name:test4 visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit + VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 + BLOCK_BODY + WHEN type=kotlin.Unit origin=IF + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.IFoo + GET_VAR 'fn: kotlin.Function1 declared in .test4' type=kotlin.Function1 origin=null + then: BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:.A [val] + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A + VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:.IFoo [val] + TYPE_OP type=.IFoo origin=IMPLICIT_CAST typeOperand=.IFoo + GET_VAR 'fn: kotlin.Function1 declared in .test4' type=kotlin.Function1 origin=null + CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_6: .A [val] declared in .test4' type=.A origin=null + i: GET_VAR 'val tmp_7: .IFoo [val] declared in .test4' type=.IFoo origin=null + newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_6: .A [val] declared in .test4' type=.A origin=null + i: GET_VAR 'val tmp_7: .IFoo [val] declared in .test4' type=.IFoo origin=null + other: CONST Int type=kotlin.Int value=1 + FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit + VALUE_PARAMETER name:a index:0 type:kotlin.Any + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + TYPE_OP type=kotlin.Function1 origin=CAST typeOperand=kotlin.Function1 + GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_8 type:.A [val] + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A + VAR IR_TEMPORARY_VARIABLE name:tmp_9 type:kotlin.Function1 [val] + TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null + CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_8: .A [val] declared in .test5' type=.A origin=null + i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo + GET_VAR 'val tmp_9: kotlin.Function1 [val] declared in .test5' type=kotlin.Function1 origin=null + newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_8: .A [val] declared in .test5' type=.A origin=null + i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo + GET_VAR 'val tmp_9: kotlin.Function1 [val] declared in .test5' type=kotlin.Function1 origin=null + other: CONST Int type=kotlin.Int value=1 + FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit + VALUE_PARAMETER name:a index:0 type:kotlin.Any + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + TYPE_OP type=kotlin.Function1 origin=CAST typeOperand=kotlin.Function1 + GET_VAR 'a: kotlin.Any declared in .test6' type=kotlin.Any origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + TYPE_OP type=.IFoo origin=CAST typeOperand=.IFoo + TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'a: kotlin.Any declared in .test6' type=kotlin.Any origin=null + BLOCK type=kotlin.Unit origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_10 type:.A [val] + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A + VAR IR_TEMPORARY_VARIABLE name:tmp_11 type:kotlin.Function1 [val] + TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'a: kotlin.Any declared in .test6' type=kotlin.Any origin=null + CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_10: .A [val] declared in .test6' type=.A origin=null + i: GET_VAR 'val tmp_11: kotlin.Function1 [val] declared in .test6' type=kotlin.Function1 origin=null + newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_10: .A [val] declared in .test6' type=.A origin=null + i: GET_VAR 'val tmp_11: kotlin.Function1 [val] declared in .test6' type=kotlin.Function1 origin=null + other: CONST Int type=kotlin.Int value=1 diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt new file mode 100644 index 00000000000..d5463ad08ef --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt @@ -0,0 +1,103 @@ +fun interface IFoo { + abstract fun foo(i: Int) + +} + +fun interface IFoo2 : IFoo { + +} + +object A { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +object B { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +operator fun A.get(i: IFoo): Int { + return 1 +} + +operator fun A.set(i: IFoo, newValue: Int) { +} + +operator fun B.get(i: IFoo): Int { + return 1 +} + +operator fun B.set(i: IFoo2, newValue: Int) { +} + +fun withVararg(vararg xs: Int): Int { + return 42 +} + +fun test1() { + { // BLOCK + val <>: A = A + val <>: KFunction1 = local fun withVararg(p0: Int) { + withVararg(xs = [p0]) + } + + <>.set(i = <> /*-> IFoo */, newValue = <>.get(i = <> /*-> IFoo */).plus(other = 1)) + } +} + +fun test2() { + { // BLOCK + val <>: B = B + val <>: KFunction1 = local fun withVararg(p0: Int) { + withVararg(xs = [p0]) + } + + <>.set(i = <> /*-> IFoo2 */, newValue = <>.get(i = <> /*-> IFoo */).plus(other = 1)) + } +} + +fun test3(fn: Function1) { + { // BLOCK + val <>: A = A + val <>: Function1 = fn + <>.set(i = <> /*-> IFoo */, newValue = <>.get(i = <> /*-> IFoo */).plus(other = 1)) + } +} + +fun test4(fn: Function1) { + when { + fn is IFoo -> { // BLOCK + val <>: A = A + val <>: IFoo = fn /*as IFoo */ + <>.set(i = <>, newValue = <>.get(i = <>).plus(other = 1)) + } + } +} + +fun test5(a: Any) { + a as Function1 /*~> Unit */ + { // BLOCK + val <>: A = A + val <>: Function1 = a /*as Function1 */ + <>.set(i = <> /*-> IFoo */, newValue = <>.get(i = <> /*-> IFoo */).plus(other = 1)) + } +} + +fun test6(a: Any) { + a as Function1 /*~> Unit */ + a /*as Function1 */ as IFoo /*~> Unit */ + { // BLOCK + val <>: A = A + val <>: Function1 = a /*as Function1 */ + <>.set(i = <>, newValue = <>.get(i = <>).plus(other = 1)) + } +} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.kt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.kt index 490ae877d27..af7678f8a54 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.kt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - fun interface IFoo { fun foo(i: Int) } diff --git a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.ir.txt b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.ir.txt new file mode 100644 index 00000000000..83d887d8548 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.ir.txt @@ -0,0 +1,117 @@ +FILE fqName:test fileName:/safeCallWithIncrementDecrement.kt + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:test.C + CONSTRUCTOR visibility:public <> () returnType:test.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' + 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 [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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: 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: type:kotlin.Any + PROPERTY name:p visibility:public modality:FINAL [var] + FUN name: visibility:public modality:FINAL <> ($receiver:test.C?) returnType:kotlin.Int + correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [var] + $receiver: VALUE_PARAMETER name: type:test.C? + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in test' + CONST Int type=kotlin.Int value=42 + FUN name: visibility:public modality:FINAL <> ($receiver:test.C?, value:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [var] + $receiver: VALUE_PARAMETER name: type:test.C? + VALUE_PARAMETER name:value index:0 type:kotlin.Int + BLOCK_BODY + FUN name:inc visibility:public modality:FINAL <> ($receiver:kotlin.Int?) returnType:kotlin.Int? [operator] + $receiver: VALUE_PARAMETER name: type:kotlin.Int? + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun inc (): kotlin.Int? [operator] declared in test' + BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int? [val] + GET_VAR ': kotlin.Int? declared in test.inc' type=kotlin.Int? origin=null + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: kotlin.Int? [val] declared in test.inc' type=kotlin.Int? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_0: kotlin.Int? [val] declared in test.inc' type=kotlin.Int? origin=null + FUN name:get visibility:public modality:FINAL <> ($receiver:kotlin.Int?, index:kotlin.Int) returnType:kotlin.Int [operator] + $receiver: VALUE_PARAMETER name: type:kotlin.Int? + VALUE_PARAMETER name:index index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun get (index: kotlin.Int): kotlin.Int [operator] declared in test' + CONST Int type=kotlin.Int value=42 + FUN name:set visibility:public modality:FINAL <> ($receiver:kotlin.Int?, index:kotlin.Int, value:kotlin.Int) returnType:kotlin.Unit [operator] + $receiver: VALUE_PARAMETER name: type:kotlin.Int? + VALUE_PARAMETER name:index index:0 type:kotlin.Int + VALUE_PARAMETER name:value index:1 type:kotlin.Int + BLOCK_BODY + FUN name:testProperty visibility:public modality:FINAL <> (nc:test.C?) returnType:kotlin.Unit + VALUE_PARAMETER name:nc index:0 type:test.C? + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:test.C? [val] + GET_VAR 'nc: test.C? declared in test.testProperty' type=test.C? origin=null + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: test.C? [val] declared in test.testProperty' type=test.C? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:test.C [val] + GET_VAR 'val tmp_1: test.C? [val] declared in test.testProperty' type=test.C? origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + CALL 'public final fun (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY + $receiver: GET_VAR 'val tmp_2: test.C [val] declared in test.testProperty' type=test.C origin=null + CALL 'public final fun (value: kotlin.Int): kotlin.Unit declared in test' type=kotlin.Unit origin=EQ + $receiver: GET_VAR 'val tmp_2: test.C [val] declared in test.testProperty' type=test.C origin=null + value: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_3: kotlin.Int [val] declared in test.testProperty' type=kotlin.Int origin=null + GET_VAR 'val tmp_3: kotlin.Int [val] declared in test.testProperty' type=kotlin.Int origin=null + FUN name:testArrayAccess visibility:public modality:FINAL <> (nc:test.C?) returnType:kotlin.Unit + VALUE_PARAMETER name:nc index:0 type:test.C? + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + BLOCK type=kotlin.Int? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:test.C? [val] + GET_VAR 'nc: test.C? declared in test.testArrayAccess' type=test.C? origin=null + WHEN type=kotlin.Int? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_4: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val] + CALL 'public final fun (): kotlin.Int declared in test' type=kotlin.Int origin=GET_PROPERTY + $receiver: GET_VAR 'val tmp_4: test.C? [val] declared in test.testArrayAccess' type=test.C? origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Int [val] + CALL 'public final fun get (index: kotlin.Int): kotlin.Int [operator] declared in test' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_5: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + index: GET_VAR 'val tmp_6: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit [operator] declared in test' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val tmp_5: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + index: GET_VAR 'val tmp_6: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + value: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_7: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null + GET_VAR 'val tmp_7: kotlin.Int [val] declared in test.testArrayAccess' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.kt.txt b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.kt.txt new file mode 100644 index 00000000000..645c0a39bf5 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.fir.kt.txt @@ -0,0 +1,65 @@ +package test + +class C { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +var C?.p: Int + get(): Int { + return 42 + } + set(value: Int) { + } + +operator fun Int?.inc(): Int? { + return { // BLOCK + val tmp0_safe_receiver: Int? = + when { + EQEQ(arg0 = tmp0_safe_receiver, arg1 = null) -> null + else -> tmp0_safe_receiver.inc() + } + } +} + +operator fun Int?.get(index: Int): Int { + return 42 +} + +operator fun Int?.set(index: Int, value: Int) { +} + +fun testProperty(nc: C?) { + { // BLOCK + val tmp1_safe_receiver: C? = nc + when { + EQEQ(arg0 = tmp1_safe_receiver, arg1 = null) -> null + else -> { // BLOCK + val : C = tmp1_safe_receiver + val : Int = .() + .(value = .inc()) + + } + } + } /*~> Unit */ +} + +fun testArrayAccess(nc: C?) { + { // BLOCK + val tmp2_safe_receiver: C? = nc + when { + EQEQ(arg0 = tmp2_safe_receiver, arg1 = null) -> null + else -> { // BLOCK + val : Int = tmp2_safe_receiver.() + val : Int = 0 + val : Int = .get(index = ) + .set(index = , value = .inc()) + + } + } + } /*~> Unit */ +} diff --git a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.kt b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.kt index 05a67e3abe6..8e9c8073621 100644 --- a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.kt +++ b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: ANY package test class C