FIR: Unignore all Fir2IrText tests on context receivers

This commit is contained in:
Denis.Zharkov
2022-03-28 18:47:29 +03:00
committed by teamcity
parent 55159eba45
commit 66bd8dccfa
75 changed files with 4710 additions and 62 deletions
@@ -0,0 +1,119 @@
FILE fqName:<root> fileName:/canvas.kt
CLASS INTERFACE name:Canvas modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Canvas
PROPERTY name:suffix visibility:public modality:ABSTRACT [val]
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-suffix> visibility:public modality:ABSTRACT <> ($this:<root>.Canvas) returnType:kotlin.String
correspondingProperty: PROPERTY name:suffix visibility:public modality:ABSTRACT [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Canvas
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:<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 INTERFACE name:Shape modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Shape
FUN name:draw visibility:public modality:ABSTRACT <> ($this:<root>.Shape, _context_receiver_0:<root>.Canvas) returnType:kotlin.String
$this: VALUE_PARAMETER name:<this> type:<root>.Shape
contextReceiverParametersCount: 1
VALUE_PARAMETER name:_context_receiver_0 index:0 type:<root>.Canvas
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:<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:Circle modality:FINAL visibility:public superTypes:[<root>.Shape]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Circle
CONSTRUCTOR visibility:public <> () returnType:<root>.Circle [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Circle modality:FINAL visibility:public superTypes:[<root>.Shape]'
FUN name:draw visibility:public modality:FINAL <> ($this:<root>.Circle, _context_receiver_0:<root>.Canvas) returnType:kotlin.String
overridden:
public abstract fun draw (_context_receiver_0: <root>.Canvas): kotlin.String declared in <root>.Shape
$this: VALUE_PARAMETER name:<this> type:<root>.Circle
contextReceiverParametersCount: 1
VALUE_PARAMETER name:_context_receiver_0 index:0 type:<root>.Canvas
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun draw (_context_receiver_0: <root>.Canvas): kotlin.String declared in <root>.Circle'
CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS
$this: CONST String type=kotlin.String value="OK"
other: CALL 'public abstract fun <get-suffix> (): kotlin.String declared in <root>.Canvas' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR '_context_receiver_0: <root>.Canvas declared in <root>.Circle.draw' type=<root>.Canvas 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 [fake_override,operator] declared in <root>.Shape
$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 [fake_override] declared in <root>.Shape
$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 [fake_override] declared in <root>.Shape
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[<root>.Canvas]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MyCanvas
CONSTRUCTOR visibility:private <> () returnType:<root>.MyCanvas [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[<root>.Canvas]'
PROPERTY name:suffix visibility:public modality:FINAL [val]
overridden:
public abstract suffix: kotlin.String [val]
FIELD PROPERTY_BACKING_FIELD name:suffix type:kotlin.String visibility:private [final]
EXPRESSION_BODY
CONST String type=kotlin.String value=""
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-suffix> visibility:public modality:FINAL <> ($this:<root>.MyCanvas) returnType:kotlin.String
correspondingProperty: PROPERTY name:suffix visibility:public modality:FINAL [val]
overridden:
public abstract fun <get-suffix> (): kotlin.String declared in <root>.Canvas
$this: VALUE_PARAMETER name:<this> type:<root>.MyCanvas
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-suffix> (): kotlin.String declared in <root>.MyCanvas'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:suffix type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
receiver: GET_VAR '<this>: <root>.MyCanvas declared in <root>.MyCanvas.<get-suffix>' type=<root>.MyCanvas 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 [fake_override,operator] declared in <root>.Canvas
$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 [fake_override] declared in <root>.Canvas
$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 [fake_override] declared in <root>.Canvas
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CALL 'public final fun with <T, R> (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.StandardKt.with, R of kotlin.StandardKt.with>): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null
<T>: <root>.MyCanvas
<R>: kotlin.String
receiver: GET_OBJECT 'CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[<root>.Canvas]' type=<root>.MyCanvas
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<<root>.MyCanvas, kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.MyCanvas) returnType:kotlin.String
$receiver: VALUE_PARAMETER name:$this$with type:<root>.MyCanvas
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.String declared in <root>.box'
CALL 'public final fun draw (_context_receiver_0: <root>.Canvas): kotlin.String declared in <root>.Circle' type=kotlin.String origin=null
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Circle' type=<root>.Circle origin=null
_context_receiver_0: GET_VAR '$this$with: <root>.MyCanvas declared in <root>.box.<anonymous>' type=<root>.MyCanvas origin=null
@@ -0,0 +1,43 @@
interface Canvas {
abstract val suffix: String
abstract get
}
interface Shape {
abstract fun draw(_context_receiver_0: Canvas): String
}
class Circle : Shape {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
override fun draw(_context_receiver_0: Canvas): String {
return "OK".plus(other = _context_receiver_0.<get-suffix>())
}
}
object MyCanvas : Canvas {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
override val suffix: String
field = ""
override get
}
fun box(): String {
return with<MyCanvas, String>(receiver = MyCanvas, block = local fun MyCanvas.<anonymous>(): String {
return Circle().draw(_context_receiver_0 = $this$with)
}
)
}
@@ -1,6 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
interface Canvas {
val suffix: String
@@ -20,4 +19,4 @@ object MyCanvas : Canvas {
override val suffix = ""
}
fun box() = with(MyCanvas) { Circle().draw() }
fun box() = with(MyCanvas) { Circle().draw() }
@@ -0,0 +1,246 @@
FILE fqName:<root> fileName:/compareTo.kt
CLASS CLASS name:Pair modality:FINAL visibility:public [data] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Pair<A of <root>.Pair, B of <root>.Pair>
TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?] reified:false
TYPE_PARAMETER name:B index:1 variance: superTypes:[kotlin.Any?] reified:false
CONSTRUCTOR visibility:public <> (first:A of <root>.Pair, second:B of <root>.Pair) returnType:<root>.Pair<A of <root>.Pair, B of <root>.Pair> [primary]
VALUE_PARAMETER name:first index:0 type:A of <root>.Pair
VALUE_PARAMETER name:second index:1 type:B of <root>.Pair
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Pair modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
PROPERTY name:first visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:first type:A of <root>.Pair visibility:private [final]
EXPRESSION_BODY
GET_VAR 'first: A of <root>.Pair declared in <root>.Pair.<init>' type=A of <root>.Pair origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-first> visibility:public modality:FINAL <> ($this:<root>.Pair<A of <root>.Pair, B of <root>.Pair>) returnType:A of <root>.Pair
correspondingProperty: PROPERTY name:first visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Pair<A of <root>.Pair, B of <root>.Pair>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-first> (): A of <root>.Pair declared in <root>.Pair'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of <root>.Pair visibility:private [final]' type=A of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.<get-first>' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
PROPERTY name:second visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:second type:B of <root>.Pair visibility:private [final]
EXPRESSION_BODY
GET_VAR 'second: B of <root>.Pair declared in <root>.Pair.<init>' type=B of <root>.Pair origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-second> visibility:public modality:FINAL <> ($this:<root>.Pair<A of <root>.Pair, B of <root>.Pair>) returnType:B of <root>.Pair
correspondingProperty: PROPERTY name:second visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Pair<A of <root>.Pair, B of <root>.Pair>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-second> (): B of <root>.Pair declared in <root>.Pair'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of <root>.Pair visibility:private [final]' type=B of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.<get-second>' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
FUN name:component1 visibility:public modality:FINAL <> ($this:<root>.Pair<A of <root>.Pair, B of <root>.Pair>) returnType:A of <root>.Pair [operator]
$this: VALUE_PARAMETER name:<this> type:<root>.Pair<A of <root>.Pair, B of <root>.Pair>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component1 (): A of <root>.Pair [operator] declared in <root>.Pair'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of <root>.Pair visibility:private [final]' type=A of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.component1' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
FUN name:component2 visibility:public modality:FINAL <> ($this:<root>.Pair<A of <root>.Pair, B of <root>.Pair>) returnType:B of <root>.Pair [operator]
$this: VALUE_PARAMETER name:<this> type:<root>.Pair<A of <root>.Pair, B of <root>.Pair>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component2 (): B of <root>.Pair [operator] declared in <root>.Pair'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of <root>.Pair visibility:private [final]' type=B of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.component2' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.Pair<A of <root>.Pair, B of <root>.Pair>, first:A of <root>.Pair, second:B of <root>.Pair) returnType:<root>.Pair<A of <root>.Pair, B of <root>.Pair>
$this: VALUE_PARAMETER name:<this> type:<root>.Pair<A of <root>.Pair, B of <root>.Pair>
VALUE_PARAMETER name:first index:0 type:A of <root>.Pair
EXPRESSION_BODY
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of <root>.Pair visibility:private [final]' type=A of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.copy' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
VALUE_PARAMETER name:second index:1 type:B of <root>.Pair
EXPRESSION_BODY
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of <root>.Pair visibility:private [final]' type=B of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.copy' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun copy (first: A of <root>.Pair, second: B of <root>.Pair): <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair'
CONSTRUCTOR_CALL 'public constructor <init> (first: A of <root>.Pair, second: B of <root>.Pair) [primary] declared in <root>.Pair' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
<class: A>: kotlin.Any
<class: B>: kotlin.Any
first: GET_VAR 'first: A of <root>.Pair declared in <root>.Pair.copy' type=A of <root>.Pair origin=null
second: GET_VAR 'second: B of <root>.Pair declared in <root>.Pair.copy' type=B of <root>.Pair origin=null
FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:<root>.Pair<A of <root>.Pair, B of <root>.Pair>, other:kotlin.Any?) returnType:kotlin.Boolean
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:<this> type:<root>.Pair<A of <root>.Pair, B of <root>.Pair>
VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any?
BLOCK_BODY
WHEN type=kotlin.Unit origin=null
BRANCH
if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ
arg0: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.equals' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
arg1: GET_VAR 'other: kotlin.Any? declared in <root>.Pair.equals' type=kotlin.Any? origin=null
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Pair'
CONST Boolean type=kotlin.Boolean value=true
WHEN type=kotlin.Unit origin=null
BRANCH
if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=<root>.Pair<A of <root>.Pair, B of <root>.Pair>
GET_VAR 'other: kotlin.Any? declared in <root>.Pair.equals' type=kotlin.Any? origin=null
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Pair'
CONST Boolean type=kotlin.Boolean value=false
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.Pair<A of <root>.Pair, B of <root>.Pair> [val]
TYPE_OP type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=CAST typeOperand=<root>.Pair<A of <root>.Pair, B of <root>.Pair>
GET_VAR 'other: kotlin.Any? declared in <root>.Pair.equals' type=kotlin.Any? origin=null
WHEN type=kotlin.Unit origin=null
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of <root>.Pair visibility:private [final]' type=A of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.equals' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of <root>.Pair visibility:private [final]' type=A of <root>.Pair origin=null
receiver: GET_VAR 'val tmp_0: <root>.Pair<A of <root>.Pair, B of <root>.Pair> [val] declared in <root>.Pair.equals' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Pair'
CONST Boolean type=kotlin.Boolean value=false
WHEN type=kotlin.Unit origin=null
BRANCH
if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of <root>.Pair visibility:private [final]' type=B of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.equals' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of <root>.Pair visibility:private [final]' type=B of <root>.Pair origin=null
receiver: GET_VAR 'val tmp_0: <root>.Pair<A of <root>.Pair, B of <root>.Pair> [val] declared in <root>.Pair.equals' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Pair'
CONST Boolean type=kotlin.Boolean value=false
RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Pair'
CONST Boolean type=kotlin.Boolean value=true
FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:<root>.Pair<A of <root>.Pair, B of <root>.Pair>) returnType:kotlin.Int
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:<this> type:<root>.Pair<A of <root>.Pair, B of <root>.Pair>
BLOCK_BODY
VAR name:result type:kotlin.Int [var]
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_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of <root>.Pair visibility:private [final]' type=A of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.hashCode' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CONST Int type=kotlin.Int value=0
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of <root>.Pair visibility:private [final]' type=A of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.hashCode' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
SET_VAR 'var result: kotlin.Int [var] declared in <root>.Pair.hashCode' type=kotlin.Unit origin=EQ
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 times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'var result: kotlin.Int [var] declared in <root>.Pair.hashCode' type=kotlin.Int origin=null
other: CONST Int type=kotlin.Int value=31
other: 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_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of <root>.Pair visibility:private [final]' type=B of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.hashCode' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CONST Int type=kotlin.Int value=0
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of <root>.Pair visibility:private [final]' type=B of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.hashCode' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in <root>.Pair'
GET_VAR 'var result: kotlin.Int [var] declared in <root>.Pair.hashCode' type=kotlin.Int origin=null
FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:<root>.Pair<A of <root>.Pair, B of <root>.Pair>) returnType:kotlin.String
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:<this> type:<root>.Pair<A of <root>.Pair, B of <root>.Pair>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in <root>.Pair'
STRING_CONCATENATION type=kotlin.String
CONST String type=kotlin.String value="Pair("
CONST String type=kotlin.String value="first="
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of <root>.Pair visibility:private [final]' type=A of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.toString' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
CONST String type=kotlin.String value=", "
CONST String type=kotlin.String value="second="
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of <root>.Pair visibility:private [final]' type=B of <root>.Pair origin=null
receiver: GET_VAR '<this>: <root>.Pair<A of <root>.Pair, B of <root>.Pair> declared in <root>.Pair.toString' type=<root>.Pair<A of <root>.Pair, B of <root>.Pair> origin=null
CONST String type=kotlin.String value=")"
FUN name:compareTo visibility:public modality:FINAL <T> ($receiver:T of <root>.compareTo, _context_receiver_0:java.util.Comparator<T of <root>.compareTo>, other:T of <root>.compareTo) returnType:kotlin.Int [operator,infix]
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
contextReceiverParametersCount: 1
$receiver: VALUE_PARAMETER name:<this> type:T of <root>.compareTo
VALUE_PARAMETER name:_context_receiver_0 index:0 type:java.util.Comparator<T of <root>.compareTo>
VALUE_PARAMETER name:other index:1 type:T of <root>.compareTo
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun compareTo <T> (_context_receiver_0: java.util.Comparator<T of <root>.compareTo>, other: T of <root>.compareTo): kotlin.Int [operator,infix] declared in <root>'
CALL 'public abstract fun compare (p0: @[FlexibleNullability] T of java.util.Comparator?, p1: @[FlexibleNullability] T of java.util.Comparator?): kotlin.Int declared in java.util.Comparator' type=kotlin.Int origin=null
$this: GET_VAR '_context_receiver_0: java.util.Comparator<T of <root>.compareTo> declared in <root>.compareTo' type=java.util.Comparator<T of <root>.compareTo> origin=null
p0: GET_VAR '<this>: T of <root>.compareTo declared in <root>.compareTo' type=T of <root>.compareTo origin=null
p1: GET_VAR 'other: T of <root>.compareTo declared in <root>.compareTo' type=T of <root>.compareTo origin=null
PROPERTY name:min visibility:public modality:FINAL [val]
FUN name:<get-min> visibility:public modality:FINAL <T> ($receiver:<root>.Pair<T of <root>.<get-min>, T of <root>.<get-min>>, _context_receiver_0:java.util.Comparator<T of <root>.<get-min>>) returnType:T of <root>.<get-min>
correspondingProperty: PROPERTY name:min visibility:public modality:FINAL [val]
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
contextReceiverParametersCount: 1
$receiver: VALUE_PARAMETER name:<this> type:<root>.Pair<T of <root>.<get-min>, T of <root>.<get-min>>
VALUE_PARAMETER name:_context_receiver_0 index:0 type:java.util.Comparator<T of <root>.<get-min>>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-min> <T> (_context_receiver_0: java.util.Comparator<T of <root>.<get-min>>): T of <root>.<get-min> declared in <root>'
WHEN type=T of <root>.<get-min> origin=IF
BRANCH
if: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT
arg0: CALL 'public final fun compareTo <T> (_context_receiver_0: java.util.Comparator<T of <root>.compareTo>, other: T of <root>.compareTo): kotlin.Int [operator,infix] declared in <root>' type=kotlin.Int origin=null
<T>: T of <root>.<get-min>
$receiver: CALL 'public final fun <get-first> (): A of <root>.Pair declared in <root>.Pair' type=T of <root>.<get-min> origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Pair<T of <root>.<get-min>, T of <root>.<get-min>> declared in <root>.<get-min>' type=<root>.Pair<T of <root>.<get-min>, T of <root>.<get-min>> origin=null
_context_receiver_0: GET_VAR '_context_receiver_0: java.util.Comparator<T of <root>.<get-min>> declared in <root>.<get-min>' type=java.util.Comparator<T of <root>.<get-min>> origin=null
other: CALL 'public final fun <get-second> (): B of <root>.Pair declared in <root>.Pair' type=T of <root>.<get-min> origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Pair<T of <root>.<get-min>, T of <root>.<get-min>> declared in <root>.<get-min>' type=<root>.Pair<T of <root>.<get-min>, T of <root>.<get-min>> origin=null
arg1: CONST Int type=kotlin.Int value=0
then: CALL 'public final fun <get-first> (): A of <root>.Pair declared in <root>.Pair' type=T of <root>.<get-min> origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Pair<T of <root>.<get-min>, T of <root>.<get-min>> declared in <root>.<get-min>' type=<root>.Pair<T of <root>.<get-min>, T of <root>.<get-min>> origin=null
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: CALL 'public final fun <get-second> (): B of <root>.Pair declared in <root>.Pair' type=T of <root>.<get-min> origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Pair<T of <root>.<get-min>, T of <root>.<get-min>> declared in <root>.<get-min>' type=<root>.Pair<T of <root>.<get-min>, T of <root>.<get-min>> origin=null
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
VAR name:comparator type:java.util.Comparator<@[FlexibleNullability] kotlin.String?> [val]
TYPE_OP type=java.util.Comparator<@[FlexibleNullability] kotlin.String?> origin=SAM_CONVERSION typeOperand=java.util.Comparator<@[FlexibleNullability] kotlin.String?>
FUN_EXPR type=kotlin.Function2<@[FlexibleNullability] kotlin.String?, @[FlexibleNullability] kotlin.String?, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (a:@[FlexibleNullability] kotlin.String?, b:@[FlexibleNullability] kotlin.String?) returnType:kotlin.Int
VALUE_PARAMETER name:a index:0 type:@[FlexibleNullability] kotlin.String?
VALUE_PARAMETER name:b index:1 type:@[FlexibleNullability] kotlin.String?
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (a: @[FlexibleNullability] kotlin.String?, b: @[FlexibleNullability] kotlin.String?): kotlin.Int declared in <root>.box'
WHEN type=kotlin.Int origin=IF
BRANCH
if: WHEN type=kotlin.Boolean origin=OROR
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 'a: @[FlexibleNullability] kotlin.String? declared in <root>.box.<anonymous>' type=@[FlexibleNullability] kotlin.String? origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CONST Boolean type=kotlin.Boolean value=true
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: 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 'b: @[FlexibleNullability] kotlin.String? declared in <root>.box.<anonymous>' type=@[FlexibleNullability] kotlin.String? origin=null
arg1: CONST Null type=kotlin.Nothing? value=null
then: CONST Int type=kotlin.Int value=0
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: CALL 'public open fun compareTo (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
$this: CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR 'a: @[FlexibleNullability] kotlin.String? declared in <root>.box.<anonymous>' type=@[FlexibleNullability] kotlin.String? origin=null
other: CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR 'b: @[FlexibleNullability] kotlin.String? declared in <root>.box.<anonymous>' type=@[FlexibleNullability] kotlin.String? origin=null
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CALL 'public final fun with <T, R> (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.StandardKt.with, R of kotlin.StandardKt.with>): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null
<T>: java.util.Comparator<@[FlexibleNullability] kotlin.String?>
<R>: kotlin.String
receiver: GET_VAR 'val comparator: java.util.Comparator<@[FlexibleNullability] kotlin.String?> [val] declared in <root>.box' type=java.util.Comparator<@[FlexibleNullability] kotlin.String?> origin=null
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<java.util.Comparator<@[FlexibleNullability] kotlin.String?>, kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:java.util.Comparator<@[FlexibleNullability] kotlin.String?>) returnType:kotlin.String
$receiver: VALUE_PARAMETER name:$this$with type:java.util.Comparator<@[FlexibleNullability] kotlin.String?>
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.String declared in <root>.box'
CALL 'public final fun <get-min> <T> (_context_receiver_0: java.util.Comparator<T of <root>.<get-min>>): T of <root>.<get-min> declared in <root>' type=kotlin.String origin=GET_PROPERTY
<T>: kotlin.String
$receiver: CONSTRUCTOR_CALL 'public constructor <init> (first: A of <root>.Pair, second: B of <root>.Pair) [primary] declared in <root>.Pair' type=<root>.Pair<kotlin.String, kotlin.String> origin=null
<class: A>: kotlin.String
<class: B>: kotlin.String
first: CONST String type=kotlin.String value="OK"
second: CONST String type=kotlin.String value="fail"
_context_receiver_0: GET_VAR '$this$with: java.util.Comparator<@[FlexibleNullability] kotlin.String?> declared in <root>.box.<anonymous>' type=java.util.Comparator<@[FlexibleNullability] kotlin.String?> origin=null
@@ -0,0 +1,90 @@
data class Pair<A : Any?, B : Any?> {
constructor(first: A, second: B) /* primary */ {
super/*Any*/()
/* <init>() */
}
val first: A
field = first
get
val second: B
field = second
get
operator fun component1(): A {
return <this>.#first
}
operator fun component2(): B {
return <this>.#second
}
fun copy(first: A = <this>.#first, second: B = <this>.#second): Pair<A, B> {
return Pair<Any, Any>(first = first, second = second)
}
override fun equals(other: Any?): Boolean {
when {
EQEQEQ(arg0 = <this>, arg1 = other) -> return true
}
when {
other !is Pair<A, B> -> return false
}
val tmp0_other_with_cast: Pair<A, B> = other as Pair<A, B>
when {
EQEQ(arg0 = <this>.#first, arg1 = tmp0_other_with_cast.#first).not() -> return false
}
when {
EQEQ(arg0 = <this>.#second, arg1 = tmp0_other_with_cast.#second).not() -> return false
}
return true
}
override fun hashCode(): Int {
var result: Int = when {
EQEQ(arg0 = <this>.#first, arg1 = null) -> 0
else -> <this>.#first.hashCode()
}
result = result.times(other = 31).plus(other = when {
EQEQ(arg0 = <this>.#second, arg1 = null) -> 0
else -> <this>.#second.hashCode()
})
return result
}
override fun toString(): String {
return "Pair(" + "first=" + <this>.#first + ", " + "second=" + <this>.#second + ")"
}
}
infix operator fun <T : Any?> T.compareTo(_context_receiver_0: Comparator<T>, other: T): Int {
return _context_receiver_0.compare(p0 = <this>, p1 = other)
}
val <T : Any?> Pair<T, T>.min: T
get(_context_receiver_0: Comparator<T>): T {
return when {
less(arg0 = <this>.<get-first>().compareTo<T>(_context_receiver_0 = _context_receiver_0, other = <this>.<get-second>()), arg1 = 0) -> <this>.<get-first>()
else -> <this>.<get-second>()
}
}
fun box(): String {
val comparator: Comparator<@FlexibleNullability String?> = local fun <anonymous>(a: @FlexibleNullability String?, b: @FlexibleNullability String?): Int {
return when {
when {
EQEQ(arg0 = a, arg1 = null) -> true
else -> EQEQ(arg0 = b, arg1 = null)
} -> 0
else -> a.<get-length>().compareTo(other = b.<get-length>())
}
}
/*-> Comparator<@FlexibleNullability String?> */
return with<Comparator<@FlexibleNullability String?>, String>(receiver = comparator, block = local fun Comparator<@FlexibleNullability String?>.<anonymous>(): String {
return Pair<String, String>(first = "OK", second = "fail").<get-min><String>(_context_receiver_0 = $this$with)
}
)
}
@@ -1,6 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
data class Pair<A, B>(val first: A, val second: B)
@@ -17,4 +16,4 @@ fun box(): String {
return with(comparator) {
Pair("OK", "fail").min
}
}
}
@@ -0,0 +1,83 @@
FILE fqName:<root> fileName:/dp.kt
CLASS CLASS name:View modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.View
CONSTRUCTOR visibility:public <> () returnType:<root>.View [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:View modality:FINAL visibility:public superTypes:[kotlin.Any]'
PROPERTY name:coefficient visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:coefficient type:kotlin.Int visibility:private [final]
EXPRESSION_BODY
CONST Int type=kotlin.Int value=42
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-coefficient> visibility:public modality:FINAL <> ($this:<root>.View) returnType:kotlin.Int
correspondingProperty: PROPERTY name:coefficient visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.View
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-coefficient> (): kotlin.Int declared in <root>.View'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:coefficient type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
receiver: GET_VAR '<this>: <root>.View declared in <root>.View.<get-coefficient>' type=<root>.View 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:<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
PROPERTY name:dp visibility:public modality:FINAL [val]
FUN name:<get-dp> visibility:public modality:FINAL <> ($receiver:kotlin.Int, _context_receiver_0:<root>.View) returnType:kotlin.Int
correspondingProperty: PROPERTY name:dp visibility:public modality:FINAL [val]
contextReceiverParametersCount: 1
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Int
VALUE_PARAMETER name:_context_receiver_0 index:0 type:<root>.View
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-dp> (_context_receiver_0: <root>.View): kotlin.Int declared in <root>'
CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL
$this: CALL 'public final fun <get-coefficient> (): kotlin.Int declared in <root>.View' type=kotlin.Int origin=GET_PROPERTY
$this: GET_VAR '_context_receiver_0: <root>.View declared in <root>.<get-dp>' type=<root>.View origin=null
other: GET_VAR '<this>: kotlin.Int declared in <root>.<get-dp>' type=kotlin.Int origin=null
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
CALL 'public final fun with <T, R> (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.StandardKt.with, R of kotlin.StandardKt.with>): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null
<T>: <root>.View
<R>: kotlin.Nothing
receiver: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.View' type=<root>.View origin=null
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<<root>.View, kotlin.Nothing> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.View) returnType:kotlin.Nothing
$receiver: VALUE_PARAMETER name:$this$with type:<root>.View
BLOCK_BODY
WHEN type=kotlin.Unit origin=IF
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: CALL 'public final fun map <T, R> (transform: kotlin.Function1<T of kotlin.collections.CollectionsKt.map, R of kotlin.collections.CollectionsKt.map>): kotlin.collections.List<R of kotlin.collections.CollectionsKt.map> [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<kotlin.Int> origin=null
<T>: kotlin.Int
<R>: kotlin.Int
$receiver: CALL 'public final fun listOf <T> (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List<T of kotlin.collections.CollectionsKt.listOf> declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<kotlin.Int> origin=null
<T>: kotlin.Int
elements: VARARG type=kotlin.Array<out kotlin.Int> varargElementType=kotlin.Int
CONST Int type=kotlin.Int value=1
CONST Int type=kotlin.Int value=2
CONST Int type=kotlin.Int value=10
transform: FUN_EXPR type=kotlin.Function1<kotlin.Int, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.Int) returnType:kotlin.Int
VALUE_PARAMETER name:it index:0 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (it: kotlin.Int): kotlin.Int declared in <root>.box.<anonymous>'
CALL 'public final fun <get-dp> (_context_receiver_0: <root>.View): kotlin.Int declared in <root>' type=kotlin.Int origin=GET_PROPERTY
$receiver: GET_VAR 'it: kotlin.Int declared in <root>.box.<anonymous>.<anonymous>' type=kotlin.Int origin=null
_context_receiver_0: GET_VAR '$this$with: <root>.View declared in <root>.box.<anonymous>' type=<root>.View origin=null
arg1: CALL 'public final fun listOf <T> (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List<T of kotlin.collections.CollectionsKt.listOf> declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<kotlin.Int> origin=null
<T>: kotlin.Int
elements: VARARG type=kotlin.Array<out kotlin.Int> varargElementType=kotlin.Int
CONST Int type=kotlin.Int value=42
CONST Int type=kotlin.Int value=84
CONST Int type=kotlin.Int value=420
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="OK"
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CONST String type=kotlin.String value="fail"
@@ -0,0 +1,30 @@
class View {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
val coefficient: Int
field = 42
get
}
val Int.dp: Int
get(_context_receiver_0: View): Int {
return _context_receiver_0.<get-coefficient>().times(other = <this>)
}
fun box(): String {
with<View, Nothing>(receiver = View(), block = local fun View.<anonymous>(): Nothing {
when {
EQEQ(arg0 = listOf<Int>(elements = [1, 2, 10]).map<Int, Int>(transform = local fun <anonymous>(it: Int): Int {
return it.<get-dp>(_context_receiver_0 = $this$with)
}
), arg1 = listOf<Int>(elements = [42, 84, 420])) -> return "OK"
}
return "fail"
}
)
}
@@ -1,6 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_STDLIB
class View {
@@ -16,4 +15,4 @@ fun box(): String {
}
return "fail"
}
}
}
@@ -0,0 +1,122 @@
FILE fqName:<root> fileName:/functionalType.kt
CLASS CLASS name:Param modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Param
CONSTRUCTOR visibility:public <> () returnType:<root>.Param [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Param 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:<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:O modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.O
CONSTRUCTOR visibility:public <> () returnType:<root>.O [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:O modality:FINAL visibility:public superTypes:[kotlin.Any]'
PROPERTY name:o visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:o type:kotlin.String visibility:private [final]
EXPRESSION_BODY
CONST String type=kotlin.String value="O"
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-o> visibility:public modality:FINAL <> ($this:<root>.O) returnType:kotlin.String
correspondingProperty: PROPERTY name:o visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.O
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-o> (): kotlin.String declared in <root>.O'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:o type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
receiver: GET_VAR '<this>: <root>.O declared in <root>.O.<get-o>' type=<root>.O 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:<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:K modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.K
CONSTRUCTOR visibility:public <> () returnType:<root>.K [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K modality:FINAL visibility:public superTypes:[kotlin.Any]'
PROPERTY name:k visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:k type:kotlin.String visibility:private [final]
EXPRESSION_BODY
CONST String type=kotlin.String value="K"
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-k> visibility:public modality:FINAL <> ($this:<root>.K) returnType:kotlin.String
correspondingProperty: PROPERTY name:k visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.K
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-k> (): kotlin.String declared in <root>.K'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:k type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
receiver: GET_VAR '<this>: <root>.K declared in <root>.K.<get-k>' type=<root>.K 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:<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
FUN name:f visibility:public modality:FINAL <T> ($receiver:<root>.K, _context_receiver_0:<root>.O, g:@[ExtensionFunctionType] kotlin.Function3<<root>.O, <root>.K, <root>.Param, T of <root>.f>) returnType:T of <root>.f
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
contextReceiverParametersCount: 1
$receiver: VALUE_PARAMETER name:<this> type:<root>.K
VALUE_PARAMETER name:_context_receiver_0 index:0 type:<root>.O
VALUE_PARAMETER name:g index:1 type:@[ExtensionFunctionType] kotlin.Function3<<root>.O, <root>.K, <root>.Param, T of <root>.f>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun f <T> (_context_receiver_0: <root>.O, g: @[ExtensionFunctionType] kotlin.Function3<<root>.O, <root>.K, <root>.Param, T of <root>.f>): T of <root>.f declared in <root>'
CALL 'public abstract fun invoke (p1: P1 of kotlin.Function3, p2: P2 of kotlin.Function3, p3: P3 of kotlin.Function3): R of kotlin.Function3 [operator] declared in kotlin.Function3' type=T of <root>.f origin=INVOKE
$this: GET_VAR 'g: @[ExtensionFunctionType] kotlin.Function3<<root>.O, <root>.K, <root>.Param, T of <root>.f> declared in <root>.f' type=@[ExtensionFunctionType] kotlin.Function3<<root>.O, <root>.K, <root>.Param, T of <root>.f> origin=VARIABLE_AS_FUNCTION
p1: GET_VAR '_context_receiver_0: <root>.O declared in <root>.f' type=<root>.O origin=null
p2: GET_VAR '<this>: <root>.K declared in <root>.f' type=<root>.K origin=null
p3: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Param' type=<root>.Param origin=null
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CALL 'public final fun with <T, R> (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.StandardKt.with, R of kotlin.StandardKt.with>): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null
<T>: <root>.O
<R>: kotlin.String
receiver: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.O' type=<root>.O origin=null
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<<root>.O, kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.O) returnType:kotlin.String
$receiver: VALUE_PARAMETER name:$this$with type:<root>.O
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.String declared in <root>.box'
CALL 'public final fun f <T> (_context_receiver_0: <root>.O, g: @[ExtensionFunctionType] kotlin.Function3<<root>.O, <root>.K, <root>.Param, T of <root>.f>): T of <root>.f declared in <root>' type=kotlin.String origin=null
<T>: kotlin.String
$receiver: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.K' type=<root>.K origin=null
_context_receiver_0: GET_VAR '$this$with: <root>.O declared in <root>.box.<anonymous>' type=<root>.O origin=null
g: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function3<<root>.O, <root>.K, <root>.Param, kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.K, _context_receiver_0:<root>.O, it:<root>.Param) returnType:kotlin.String
contextReceiverParametersCount: 1
$receiver: VALUE_PARAMETER name:$this$f type:<root>.K
VALUE_PARAMETER name:_context_receiver_0 index:0 type:<root>.O
VALUE_PARAMETER name:it index:1 type:<root>.Param
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (_context_receiver_0: <root>.O, it: <root>.Param): kotlin.String declared in <root>.box.<anonymous>'
CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS
$this: CALL 'public final fun <get-o> (): kotlin.String declared in <root>.O' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR '$this$with: <root>.O declared in <root>.box.<anonymous>' type=<root>.O origin=null
other: CALL 'public final fun <get-k> (): kotlin.String declared in <root>.K' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR '$this$f: <root>.K declared in <root>.box.<anonymous>.<anonymous>' type=<root>.K origin=null
@@ -0,0 +1,48 @@
class Param {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
class O {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
val o: String
field = "O"
get
}
class K {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
val k: String
field = "K"
get
}
fun <T : Any?> K.f(_context_receiver_0: O, g: @ExtensionFunctionType Function3<O, K, Param, T>): T {
return g.invoke(p1 = _context_receiver_0, p2 = <this>, p3 = Param())
}
fun box(): String {
return with<O, String>(receiver = O(), block = local fun O.<anonymous>(): String {
return K().f<String>(_context_receiver_0 = $this$with, g = local fun K.<anonymous>(_context_receiver_0: O, it: Param): String {
return $this$with.<get-o>().plus(other = $this$f.<get-k>())
}
)
}
)
}
@@ -1,6 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
class Param
class O {
@@ -15,4 +14,4 @@ fun <T> K.f(g: context(O) K.(Param) -> T) = g(this@O, this@K, Param())
fun box() = with(O()) {
K().f { o + k }
}
}
@@ -0,0 +1,199 @@
FILE fqName:<root> fileName:/monoidSum.kt
CLASS INTERFACE name:Semigroup modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Semigroup<T of <root>.Semigroup>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
FUN name:combine visibility:public modality:ABSTRACT <> ($this:<root>.Semigroup<T of <root>.Semigroup>, $receiver:T of <root>.Semigroup, other:T of <root>.Semigroup) returnType:T of <root>.Semigroup [infix]
$this: VALUE_PARAMETER name:<this> type:<root>.Semigroup<T of <root>.Semigroup>
$receiver: VALUE_PARAMETER name:<this> type:T of <root>.Semigroup
VALUE_PARAMETER name:other index:0 type:T of <root>.Semigroup
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:<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 INTERFACE name:Monoid modality:ABSTRACT visibility:public superTypes:[<root>.Semigroup<T of <root>.Monoid>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Monoid<T of <root>.Monoid>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
PROPERTY name:unit visibility:public modality:ABSTRACT [val]
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-unit> visibility:public modality:ABSTRACT <> ($this:<root>.Monoid<T of <root>.Monoid>) returnType:T of <root>.Monoid
correspondingProperty: PROPERTY name:unit visibility:public modality:ABSTRACT [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Monoid<T of <root>.Monoid>
FUN FAKE_OVERRIDE name:combine visibility:public modality:ABSTRACT <> ($this:<root>.Semigroup<T of <root>.Semigroup>, $receiver:T of <root>.Monoid, other:T of <root>.Monoid) returnType:T of <root>.Monoid [fake_override,infix]
overridden:
public abstract fun combine (other: T of <root>.Semigroup): T of <root>.Semigroup [infix] declared in <root>.Semigroup
$this: VALUE_PARAMETER name:<this> type:<root>.Semigroup<T of <root>.Semigroup>
$receiver: VALUE_PARAMETER name:<this> type:T of <root>.Monoid
VALUE_PARAMETER name:other index:0 type:T of <root>.Monoid
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 <root>.Semigroup
$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 [fake_override] declared in <root>.Semigroup
$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 [fake_override] declared in <root>.Semigroup
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[<root>.Monoid<kotlin.Int>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.IntMonoid
CONSTRUCTOR visibility:private <> () returnType:<root>.IntMonoid [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[<root>.Monoid<kotlin.Int>]'
FUN name:combine visibility:public modality:FINAL <> ($this:<root>.IntMonoid, $receiver:kotlin.Int, other:kotlin.Int) returnType:kotlin.Int [infix]
overridden:
public abstract fun combine (other: T of <root>.Monoid): T of <root>.Monoid [fake_override,infix] declared in <root>.Monoid
$this: VALUE_PARAMETER name:<this> type:<root>.IntMonoid
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Int
VALUE_PARAMETER name:other index:0 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun combine (other: kotlin.Int): kotlin.Int [infix] declared in <root>.IntMonoid'
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS
$this: GET_VAR '<this>: kotlin.Int declared in <root>.IntMonoid.combine' type=kotlin.Int origin=null
other: GET_VAR 'other: kotlin.Int declared in <root>.IntMonoid.combine' type=kotlin.Int origin=null
PROPERTY name:unit visibility:public modality:FINAL [val]
overridden:
public abstract unit: T of <root>.Monoid [val]
FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.Int visibility:private [final]
EXPRESSION_BODY
CONST Int type=kotlin.Int value=0
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-unit> visibility:public modality:FINAL <> ($this:<root>.IntMonoid) returnType:kotlin.Int
correspondingProperty: PROPERTY name:unit visibility:public modality:FINAL [val]
overridden:
public abstract fun <get-unit> (): T of <root>.Monoid declared in <root>.Monoid
$this: VALUE_PARAMETER name:<this> type:<root>.IntMonoid
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-unit> (): kotlin.Int declared in <root>.IntMonoid'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null
receiver: GET_VAR '<this>: <root>.IntMonoid declared in <root>.IntMonoid.<get-unit>' type=<root>.IntMonoid 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 [fake_override,operator] declared in <root>.Monoid
$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 [fake_override] declared in <root>.Monoid
$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 [fake_override] declared in <root>.Monoid
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[<root>.Monoid<kotlin.String>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.StringMonoid
CONSTRUCTOR visibility:private <> () returnType:<root>.StringMonoid [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[<root>.Monoid<kotlin.String>]'
FUN name:combine visibility:public modality:FINAL <> ($this:<root>.StringMonoid, $receiver:kotlin.String, other:kotlin.String) returnType:kotlin.String [infix]
overridden:
public abstract fun combine (other: T of <root>.Monoid): T of <root>.Monoid [fake_override,infix] declared in <root>.Monoid
$this: VALUE_PARAMETER name:<this> type:<root>.StringMonoid
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
VALUE_PARAMETER name:other index:0 type:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun combine (other: kotlin.String): kotlin.String [infix] declared in <root>.StringMonoid'
CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS
$this: GET_VAR '<this>: kotlin.String declared in <root>.StringMonoid.combine' type=kotlin.String origin=null
other: GET_VAR 'other: kotlin.String declared in <root>.StringMonoid.combine' type=kotlin.String origin=null
PROPERTY name:unit visibility:public modality:FINAL [val]
overridden:
public abstract unit: T of <root>.Monoid [val]
FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.String visibility:private [final]
EXPRESSION_BODY
CONST String type=kotlin.String value=""
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-unit> visibility:public modality:FINAL <> ($this:<root>.StringMonoid) returnType:kotlin.String
correspondingProperty: PROPERTY name:unit visibility:public modality:FINAL [val]
overridden:
public abstract fun <get-unit> (): T of <root>.Monoid declared in <root>.Monoid
$this: VALUE_PARAMETER name:<this> type:<root>.StringMonoid
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-unit> (): kotlin.String declared in <root>.StringMonoid'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
receiver: GET_VAR '<this>: <root>.StringMonoid declared in <root>.StringMonoid.<get-unit>' type=<root>.StringMonoid 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 [fake_override,operator] declared in <root>.Monoid
$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 [fake_override] declared in <root>.Monoid
$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 [fake_override] declared in <root>.Monoid
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:sum visibility:public modality:FINAL <T> ($receiver:kotlin.collections.List<T of <root>.sum>, _context_receiver_0:<root>.Monoid<T of <root>.sum>) returnType:T of <root>.sum
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
contextReceiverParametersCount: 1
$receiver: VALUE_PARAMETER name:<this> type:kotlin.collections.List<T of <root>.sum>
VALUE_PARAMETER name:_context_receiver_0 index:0 type:<root>.Monoid<T of <root>.sum>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun sum <T> (_context_receiver_0: <root>.Monoid<T of <root>.sum>): T of <root>.sum declared in <root>'
CALL 'public final fun fold <T, R> (initial: R of kotlin.collections.CollectionsKt.fold, operation: kotlin.Function2<R of kotlin.collections.CollectionsKt.fold, T of kotlin.collections.CollectionsKt.fold, R of kotlin.collections.CollectionsKt.fold>): R of kotlin.collections.CollectionsKt.fold [inline] declared in kotlin.collections.CollectionsKt' type=T of <root>.sum origin=null
<T>: T of <root>.sum
<R>: T of <root>.sum
$receiver: GET_VAR '<this>: kotlin.collections.List<T of <root>.sum> declared in <root>.sum' type=kotlin.collections.List<T of <root>.sum> origin=null
initial: CALL 'public abstract fun <get-unit> (): T of <root>.Monoid declared in <root>.Monoid' type=T of <root>.sum origin=GET_PROPERTY
$this: GET_VAR '_context_receiver_0: <root>.Monoid<T of <root>.sum> declared in <root>.sum' type=<root>.Monoid<T of <root>.sum> origin=null
operation: FUN_EXPR type=kotlin.Function2<T of <root>.sum, T of <root>.sum, T of <root>.sum> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (acc:T of <root>.sum, e:T of <root>.sum) returnType:T of <root>.sum
VALUE_PARAMETER name:acc index:0 type:T of <root>.sum
VALUE_PARAMETER name:e index:1 type:T of <root>.sum
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (acc: T of <root>.sum, e: T of <root>.sum): T of <root>.sum declared in <root>.sum'
CALL 'public abstract fun combine (other: T of <root>.Monoid): T of <root>.Monoid [fake_override,infix] declared in <root>.Monoid' type=T of <root>.sum origin=null
$this: GET_VAR '_context_receiver_0: <root>.Monoid<T of <root>.sum> declared in <root>.sum' type=<root>.Monoid<T of <root>.sum> origin=null
$receiver: GET_VAR 'acc: T of <root>.sum declared in <root>.sum.<anonymous>' type=T of <root>.sum origin=null
other: GET_VAR 'e: T of <root>.sum declared in <root>.sum.<anonymous>' type=T of <root>.sum origin=null
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CALL 'public final fun with <T, R> (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.StandardKt.with, R of kotlin.StandardKt.with>): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null
<T>: <root>.IntMonoid
<R>: kotlin.Int
receiver: GET_OBJECT 'CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[<root>.Monoid<kotlin.Int>]' type=<root>.IntMonoid
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<<root>.IntMonoid, kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.IntMonoid) returnType:kotlin.Int
$receiver: VALUE_PARAMETER name:$this$with type:<root>.IntMonoid
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.box'
CALL 'public final fun sum <T> (_context_receiver_0: <root>.Monoid<T of <root>.sum>): T of <root>.sum declared in <root>' type=kotlin.Int origin=null
<T>: kotlin.Int
$receiver: CALL 'public final fun listOf <T> (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List<T of kotlin.collections.CollectionsKt.listOf> declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<kotlin.Int> origin=null
<T>: kotlin.Int
elements: VARARG type=kotlin.Array<out kotlin.Int> varargElementType=kotlin.Int
CONST Int type=kotlin.Int value=1
CONST Int type=kotlin.Int value=2
CONST Int type=kotlin.Int value=3
_context_receiver_0: GET_VAR '$this$with: <root>.IntMonoid declared in <root>.box.<anonymous>' type=<root>.IntMonoid origin=null
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
CALL 'public final fun with <T, R> (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.StandardKt.with, R of kotlin.StandardKt.with>): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null
<T>: <root>.StringMonoid
<R>: kotlin.String
receiver: GET_OBJECT 'CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[<root>.Monoid<kotlin.String>]' type=<root>.StringMonoid
block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<<root>.StringMonoid, kotlin.String> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.StringMonoid) returnType:kotlin.String
$receiver: VALUE_PARAMETER name:$this$with type:<root>.StringMonoid
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.String declared in <root>.box'
CALL 'public final fun sum <T> (_context_receiver_0: <root>.Monoid<T of <root>.sum>): T of <root>.sum declared in <root>' type=kotlin.String origin=null
<T>: kotlin.String
$receiver: CALL 'public final fun listOf <T> (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List<T of kotlin.collections.CollectionsKt.listOf> declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<kotlin.String> origin=null
<T>: kotlin.String
elements: VARARG type=kotlin.Array<out kotlin.String> varargElementType=kotlin.String
CONST String type=kotlin.String value="O"
CONST String type=kotlin.String value="K"
_context_receiver_0: GET_VAR '$this$with: <root>.StringMonoid declared in <root>.box.<anonymous>' type=<root>.StringMonoid origin=null
@@ -0,0 +1,62 @@
interface Semigroup<T : Any?> {
abstract infix fun T.combine(other: T): T
}
interface Monoid<T : Any?> : Semigroup<T> {
abstract val unit: T
abstract get
}
object IntMonoid : Monoid<Int> {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
override infix fun Int.combine(other: Int): Int {
return <this>.plus(other = other)
}
override val unit: Int
field = 0
override get
}
object StringMonoid : Monoid<String> {
private constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
override infix fun String.combine(other: String): String {
return <this>.plus(other = other)
}
override val unit: String
field = ""
override get
}
fun <T : Any?> List<T>.sum(_context_receiver_0: Monoid<T>): T {
return <this>.fold<T, T>(initial = _context_receiver_0.<get-unit>(), operation = local fun <anonymous>(acc: T, e: T): T {
return (_context_receiver_0, acc).combine(other = e)
}
)
}
fun box(): String {
with<IntMonoid, Int>(receiver = IntMonoid, block = local fun IntMonoid.<anonymous>(): Int {
return listOf<Int>(elements = [1, 2, 3]).sum<Int>(_context_receiver_0 = $this$with)
}
) /*~> Unit */
return with<StringMonoid, String>(receiver = StringMonoid, block = local fun StringMonoid.<anonymous>(): String {
return listOf<String>(elements = ["O", "K"]).sum<String>(_context_receiver_0 = $this$with)
}
)
}
@@ -1,6 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_STDLIB
interface Semigroup<T> {
@@ -29,4 +28,4 @@ fun box(): String {
return with(StringMonoid) {
listOf("O", "K").sum()
}
}
}