Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 804 Bytes

Functions with value class parameter.md

File metadata and controls

28 lines (19 loc) · 804 Bytes

Functions with value class parameter

The function appears in the .h file, but the inline class argument is turned into a basic type.

Explanations

Let's describe a function that takes a value class as input:

//FunctionWithValueClassParameter.kt

@JvmInline
value class ValueClassExample(val t: Int)

fun valueClassUsageExample(v: ValueClassExample): String {
    return "Value class usage example | ${v.t}"
}

On the Swift side, the function valueClassUsageExample is present, but since the value class itself is not included in the .h file, the argument is expanded into separate primitives:

//Type of v is Int32
FunctionWithValueClassParameterKt.valueClassUsageExample(v: 40)

Table of contents