https://kotlinlang.org logo
#touchlab-tools
Title
# touchlab-tools
m

Mike Welsh

09/26/2023, 8:53 PM
Hi! I’m having some issues trying to use the default arguments. 🧵
I have the following configuration:
Copy code
skie {
    features {
        group {
            DefaultArgumentInterop.Enabled(true)
            SealedInterop.Enabled(true)
            EnumInterop.Enabled(true)
            FlowInterop.Enabled(false)
            SuspendInterop.Enabled(false)
        }
    }
}
And the Kotlin function:
Copy code
fun testWithOptionalParamsClick(
    product: String,
    param1: String,
    param2: String,
    param3: String = "testDefaultValueParam3",
    address: String,
  ): PETEEvent {
     val creationTime = timestampProvider.currentTimeMillis()
     val sourceEventProperty = sourceEventPropertyProvider.getSourceEventProperty(
          eventKey = EventKey.ParentEvent("test-with_optional_params-click"),
       )
     return PETEEventImpl(
       eventKey = "test-with_optional_params-click",
       parameterTokens = listOf(product, param1, param2, param3, address),
       clientCreatedAt = creationTime,
       path = "test-with_optional_params-click",
       sourceEventHash = sourceEventProperty.sourceEventHash,
       duration = null,
     )
  }
But when I look at the ObjC header, I only see:
Copy code
- (id<KMMPETEEvent>)testWithOptionalParamsClickProduct:(NSString *)product param1:(NSString *)param1 param2:(NSString *)param2 param3:(NSString *)param3 address:(NSString *)address __attribute__((swift_name("testWithOptionalParamsClick(product:param1:param2:param3:address:)")));
Should I expect that two methods get generated to provide the override for the param3 ?
Found it, under a completely different name:
Copy code
- (id<KMMPETEEvent>)testWithOptionalParamsClick__Skie_DefaultArguments__7Product:(NSString *)product param1:(NSString *)param1 param2:(NSString *)param2 address:(NSString *)address __attribute__((swift_name("testWithOptionalParamsClick__Skie_DefaultArguments__7(product:param1:param2:address:)")));
f

Filip Dolník

09/27/2023, 8:25 AM
Hi! Yeah, the generated functions have this weird name in Obj-C to prevent name collisions. They are then renamed by SKIE, so they have the correct name in Swift. In your case only one additional method will get generated the one with the “param3” missing (SKIE reuses the original method that has all parameters).
thank you color 1
8 Views