From 568d4b11afec1d0004bcad902229c1e8d8988d55 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 26 Apr 2023 14:20:18 +0200 Subject: [PATCH] Use 'run' function instead of 'synchronized' in KT-51036 test It should be enough to reproduce the issue and makes the test runnable on all backends --- compiler/testData/codegen/box/unit/kt51036.kt | 7 +-- .../ir/irText/expressions/kt51036.fir.ir.txt | 61 ------------------- .../ir/irText/expressions/kt51036.ir.txt | 7 +-- .../testData/ir/irText/expressions/kt51036.kt | 4 +- 4 files changed, 5 insertions(+), 74 deletions(-) delete mode 100644 compiler/testData/ir/irText/expressions/kt51036.fir.ir.txt diff --git a/compiler/testData/codegen/box/unit/kt51036.kt b/compiler/testData/codegen/box/unit/kt51036.kt index be87f454a37..af5b5d10a2d 100644 --- a/compiler/testData/codegen/box/unit/kt51036.kt +++ b/compiler/testData/codegen/box/unit/kt51036.kt @@ -1,8 +1,4 @@ // WITH_STDLIB -// IGNORE_BACKEND: WASM -// ^ Unresolved reference: synchronized -// IGNORE_BACKEND: NATIVE -// ^ Unresolved reference: synchronized fun box(): String { A().close() @@ -12,6 +8,5 @@ fun box(): String { class A { companion object; operator fun String.invoke() = Unit - @Suppress("DEPRECATION_ERROR") - fun close() = synchronized(this) { "abc" }() + fun close() = kotlin.run { "abc" }() } diff --git a/compiler/testData/ir/irText/expressions/kt51036.fir.ir.txt b/compiler/testData/ir/irText/expressions/kt51036.fir.ir.txt deleted file mode 100644 index ed71ff0de06..00000000000 --- a/compiler/testData/ir/irText/expressions/kt51036.fir.ir.txt +++ /dev/null @@ -1,61 +0,0 @@ -FILE fqName: fileName:/kt51036.kt - CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A - CONSTRUCTOR visibility:public <> () returnType:.A [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' - CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.Companion - CONSTRUCTOR visibility:private <> () returnType:.A.Companion [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] 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:invoke visibility:public modality:FINAL <> ($this:.A, $receiver:kotlin.String) returnType:kotlin.Unit [operator] - $this: VALUE_PARAMETER name: type:.A - $receiver: VALUE_PARAMETER name: type:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun invoke (): kotlin.Unit [operator] declared in .A' - GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - FUN name:close visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Unit - annotations: - Suppress(names = ['DEPRECATION_ERROR']) - $this: VALUE_PARAMETER name: type:.A - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun close (): kotlin.Unit declared in .A' - CALL 'public final fun invoke (): kotlin.Unit [operator] declared in .A' type=kotlin.Unit origin=null - $this: GET_VAR ': .A declared in .A.close' type=.A origin=null - $receiver: CALL 'public final fun synchronized (lock: kotlin.Any, block: kotlin.Function0): R of kotlin.StandardKt.synchronized [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null - : kotlin.String - lock: GET_VAR ': .A declared in .A.close' type=.A origin=null - block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .A.close' - CONST String type=kotlin.String value="Abc" - 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 diff --git a/compiler/testData/ir/irText/expressions/kt51036.ir.txt b/compiler/testData/ir/irText/expressions/kt51036.ir.txt index f6c6884b174..de270fd20bb 100644 --- a/compiler/testData/ir/irText/expressions/kt51036.ir.txt +++ b/compiler/testData/ir/irText/expressions/kt51036.ir.txt @@ -31,16 +31,13 @@ FILE fqName: fileName:/kt51036.kt RETURN type=kotlin.Nothing from='public final fun invoke (): kotlin.Unit [operator] declared in .A' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit FUN name:close visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Unit - annotations: - Suppress(names = ['DEPRECATION_ERROR']) $this: VALUE_PARAMETER name: type:.A BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun close (): kotlin.Unit declared in .A' - CALL 'public final fun invoke (): kotlin.Unit [operator] declared in .A' type=kotlin.Unit origin=INVOKE + CALL 'public final fun invoke (): kotlin.Unit [operator] declared in .A' type=kotlin.Unit origin=null $this: GET_VAR ': .A declared in .A.close' type=.A origin=null - $receiver: CALL 'public final fun synchronized (lock: kotlin.Any, block: kotlin.Function0): R of kotlin.StandardKt.synchronized [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + $receiver: CALL 'public final fun run (block: kotlin.Function0): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null : kotlin.String - lock: GET_VAR ': .A declared in .A.close' type=.A origin=null block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/kt51036.kt b/compiler/testData/ir/irText/expressions/kt51036.kt index 5e68c1acce5..04f96bfa1ca 100644 --- a/compiler/testData/ir/irText/expressions/kt51036.kt +++ b/compiler/testData/ir/irText/expressions/kt51036.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // WITH_STDLIB // IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JS_IR_ES6 @@ -6,6 +7,5 @@ class A { companion object; operator fun String.invoke() = Unit - @Suppress("DEPRECATION_ERROR") - fun close() = synchronized(this) { "Abc" }() + fun close() = kotlin.run { "Abc" }() }