diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java index 95067f1369a..f012a4f6bc5 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java @@ -2840,6 +2840,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI runTest("compiler/testData/ir/irText/firProblems/throwableStackTrace.kt"); } + @Test + @TestMetadata("timesInBuilder.kt") + public void testTimesInBuilder() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/timesInBuilder.kt"); + } + @Test @TestMetadata("TypeParameterBounds.kt") public void testTypeParameterBounds() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java index 7f293bce704..8567238c27f 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java @@ -2840,6 +2840,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest { runTest("compiler/testData/ir/irText/firProblems/throwableStackTrace.kt"); } + @Test + @TestMetadata("timesInBuilder.kt") + public void testTimesInBuilder() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/timesInBuilder.kt"); + } + @Test @TestMetadata("TypeParameterBounds.kt") public void testTypeParameterBounds() throws Exception { diff --git a/compiler/testData/ir/irText/firProblems/timesInBuilder.ir.txt b/compiler/testData/ir/irText/firProblems/timesInBuilder.ir.txt new file mode 100644 index 00000000000..9a47a888146 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/timesInBuilder.ir.txt @@ -0,0 +1,155 @@ +FILE fqName: fileName:/timesInBuilder.kt + FUN name:test visibility:private modality:FINAL <> (x:kotlin.Long) returnType:kotlin.Unit + VALUE_PARAMETER name:x index:0 type:kotlin.Long + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun test (x: kotlin.Long): kotlin.Unit declared in ' + CALL 'private final fun countIssues (restrictionsBuilder: @[ExtensionFunctionType] kotlin.Function1<.ArgumentsBuilder, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + restrictionsBuilder: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.ArgumentsBuilder, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.ArgumentsBuilder) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$countIssues type:.ArgumentsBuilder + BLOCK_BODY + CALL 'public final fun unaryPlus (): kotlin.Unit [operator] declared in .ArgumentsBuilder' type=kotlin.Unit origin=UPLUS + $this: GET_VAR '$this$countIssues: .ArgumentsBuilder declared in .test.' type=.ArgumentsBuilder origin=null + $receiver: CALL 'public final fun lessEq (t: T of .lessEq): .Expression [infix] declared in ' type=.Expression origin=null + : kotlin.Int + $receiver: CALL 'public final fun (): .Column declared in ' type=.Column origin=GET_PROPERTY + t: CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL + $this: CONST Int type=kotlin.Int value=2 + other: CONST Int type=kotlin.Int value=60 + CALL 'public final fun unaryPlus (): kotlin.Unit [operator] declared in .ArgumentsBuilder' type=kotlin.Unit origin=UPLUS + $this: GET_VAR '$this$countIssues: .ArgumentsBuilder declared in .test.' type=.ArgumentsBuilder origin=null + $receiver: CALL 'public final fun lessEq (t: T of .lessEq): .Expression [infix] declared in ' type=.Expression origin=null + : kotlin.Int + $receiver: CALL 'public final fun (): .Column declared in ' type=.Column origin=GET_PROPERTY + t: CALL 'public final fun id (arg: I of .id): I of .id declared in ' type=kotlin.Int origin=null + : kotlin.Int + arg: CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL + $this: CONST Int type=kotlin.Int value=2 + other: CONST Int type=kotlin.Int value=60 + CALL 'public final fun unaryPlus (): kotlin.Unit [operator] declared in .ArgumentsBuilder' type=kotlin.Unit origin=UPLUS + $this: GET_VAR '$this$countIssues: .ArgumentsBuilder declared in .test.' type=.ArgumentsBuilder origin=null + $receiver: CALL 'public final fun select (t: T of .select, r: T of .select): .Expression declared in ' type=.Expression origin=null + : kotlin.Long + $receiver: CALL 'public final fun (): .Column declared in ' type=.Column origin=GET_PROPERTY + t: CALL 'public open fun toLong (): kotlin.Long declared in kotlin.Int' type=kotlin.Long origin=null + $this: CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL + $this: CONST Int type=kotlin.Int value=2 + other: CONST Int type=kotlin.Int value=60 + r: GET_VAR 'x: kotlin.Long declared in .test' type=kotlin.Long origin=null + PROPERTY name:spentTime visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:spentTime type:.Column visibility:private [final,static] + EXPRESSION_BODY + CALL 'public final fun integer (name: kotlin.String): .Column declared in ' type=.Column origin=null + name: CONST String type=kotlin.String value="spentTime" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:.Column + correspondingProperty: PROPERTY name:spentTime visibility:public modality:FINAL [val] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .Column declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:spentTime type:.Column visibility:private [final,static]' type=.Column origin=null + FUN name:integer visibility:public modality:FINAL <> (name:kotlin.String) returnType:.Column + VALUE_PARAMETER name:name index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun integer (name: kotlin.String): .Column declared in ' + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Column' type=.Column origin=null + FUN name:id visibility:public modality:FINAL (arg:I of .id) returnType:I of .id + TYPE_PARAMETER name:I index:0 variance: superTypes:[kotlin.Any?] reified:false + VALUE_PARAMETER name:arg index:0 type:I of .id + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun id (arg: I of .id): I of .id declared in ' + GET_VAR 'arg: I of .id declared in .id' type=I of .id origin=null + FUN name:lessEq visibility:public modality:FINAL ($receiver:.Column, t:T of .lessEq) returnType:.Expression [infix] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Comparable.lessEq>] reified:false + $receiver: VALUE_PARAMETER name: type:.Column + VALUE_PARAMETER name:t index:0 type:T of .lessEq + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun lessEq (t: T of .lessEq): .Expression [infix] declared in ' + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Expression' type=.Expression origin=null + FUN name:select visibility:public modality:FINAL ($receiver:.Column, t:T of .select, r:T of .select) returnType:.Expression + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Comparable.select>] reified:false + $receiver: VALUE_PARAMETER name: type:.Column + VALUE_PARAMETER name:t index:0 type:T of .select + VALUE_PARAMETER name:r index:1 type:T of .select + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun select (t: T of .select, r: T of .select): .Expression declared in ' + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Expression' type=.Expression origin=null + CLASS CLASS name:Expression modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Expression + CONSTRUCTOR visibility:public <> () returnType:.Expression [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Expression 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 CLASS name:Column modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Column + CONSTRUCTOR visibility:public <> () returnType:.Column [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Column 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 CLASS name:ArgumentsBuilder modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ArgumentsBuilder + CONSTRUCTOR visibility:public <> () returnType:.ArgumentsBuilder [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ArgumentsBuilder modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:arguments visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:arguments type:kotlin.collections.MutableList<.Expression> visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun mutableListOf (): kotlin.collections.MutableList [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.MutableList<.Expression> origin=null + : .Expression + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.ArgumentsBuilder) returnType:kotlin.collections.MutableList<.Expression> + correspondingProperty: PROPERTY name:arguments visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.ArgumentsBuilder + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.collections.MutableList<.Expression> declared in .ArgumentsBuilder' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:arguments type:kotlin.collections.MutableList<.Expression> visibility:private [final]' type=kotlin.collections.MutableList<.Expression> origin=null + receiver: GET_VAR ': .ArgumentsBuilder declared in .ArgumentsBuilder.' type=.ArgumentsBuilder origin=null + FUN name:unaryPlus visibility:public modality:FINAL <> ($this:.ArgumentsBuilder, $receiver:.Expression) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER name: type:.ArgumentsBuilder + $receiver: VALUE_PARAMETER name: type:.Expression + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public abstract fun add (element: E of kotlin.collections.MutableList): kotlin.Boolean declared in kotlin.collections.MutableList' type=kotlin.Boolean origin=null + $this: CALL 'public final fun (): kotlin.collections.MutableList<.Expression> declared in .ArgumentsBuilder' type=kotlin.collections.MutableList<.Expression> origin=GET_PROPERTY + $this: GET_VAR ': .ArgumentsBuilder declared in .ArgumentsBuilder.unaryPlus' type=.ArgumentsBuilder origin=null + element: GET_VAR ': .Expression declared in .ArgumentsBuilder.unaryPlus' type=.Expression origin=null + 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:countIssues visibility:private modality:FINAL <> (restrictionsBuilder:@[ExtensionFunctionType] kotlin.Function1<.ArgumentsBuilder, kotlin.Unit>) returnType:kotlin.Unit + VALUE_PARAMETER name:restrictionsBuilder index:0 type:@[ExtensionFunctionType] kotlin.Function1<.ArgumentsBuilder, kotlin.Unit> + BLOCK_BODY diff --git a/compiler/testData/ir/irText/firProblems/timesInBuilder.kt b/compiler/testData/ir/irText/firProblems/timesInBuilder.kt new file mode 100644 index 00000000000..88c50893243 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/timesInBuilder.kt @@ -0,0 +1,31 @@ +// TARGET_BACKEND: JVM +// WITH_STDLIB +private fun test(x: Long) = + countIssues { + +(spentTime lessEq 2 * 60) + +(spentTime lessEq id(2 * 60)) + +(spentTime.select(2 * 60, x)) + } + +val spentTime = integer("spentTime") + +fun integer(name: String) = Column() + +fun id(arg: I): I = arg + +infix fun > Column.lessEq(t: T) = Expression() +fun > Column.select(t: T, r: T) = Expression() + +class Expression + +class Column + +class ArgumentsBuilder { + val arguments = mutableListOf() + + operator fun Expression.unaryPlus() { + arguments.add(this) + } +} + +private fun countIssues(restrictionsBuilder: ArgumentsBuilder.() -> Unit) {} diff --git a/compiler/testData/ir/irText/firProblems/timesInBuilder.kt.txt b/compiler/testData/ir/irText/firProblems/timesInBuilder.kt.txt new file mode 100644 index 00000000000..324b8e1547b --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/timesInBuilder.kt.txt @@ -0,0 +1,66 @@ +private fun test(x: Long) { + return countIssues(restrictionsBuilder = local fun ArgumentsBuilder.() { + ($this$countIssues, ().lessEq(t = 2.times(other = 60))).unaryPlus() + ($this$countIssues, ().lessEq(t = id(arg = 2.times(other = 60)))).unaryPlus() + ($this$countIssues, ().select(t = 2.times(other = 60).toLong(), r = x)).unaryPlus() + } +) +} + +val spentTime: Column + field = integer(name = "spentTime") + get + +fun integer(name: String): Column { + return Column() +} + +fun id(arg: I): I { + return arg +} + +infix fun > Column.lessEq(t: T): Expression { + return Expression() +} + +fun > Column.select(t: T, r: T): Expression { + return Expression() +} + +class Expression { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +class Column { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +class ArgumentsBuilder { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val arguments: MutableList + field = mutableListOf() + get + + operator fun Expression.unaryPlus() { + .().add(element = ) /*~> Unit */ + } + +} + +private fun countIssues(restrictionsBuilder: @ExtensionFunctionType Function1) { +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java index 9e206e66473..acedf77b1bb 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java @@ -2840,6 +2840,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest runTest("compiler/testData/ir/irText/firProblems/throwableStackTrace.kt"); } + @Test + @TestMetadata("timesInBuilder.kt") + public void testTimesInBuilder() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/timesInBuilder.kt"); + } + @Test @TestMetadata("TypeParameterBounds.kt") public void testTypeParameterBounds() throws Exception {