diff --git a/Sources/SwiftKotlinFramework/KotlinTokenizer.swift b/Sources/SwiftKotlinFramework/KotlinTokenizer.swift index b2c0c3f..326773f 100644 --- a/Sources/SwiftKotlinFramework/KotlinTokenizer.swift +++ b/Sources/SwiftKotlinFramework/KotlinTokenizer.swift @@ -608,6 +608,18 @@ public class KotlinTokenizer: SwiftTokenizer { with: [expression.newToken(.symbol, binaryOperator)]) } + open override func tokenize(_ expression: FunctionCallExpression) -> [Token] { + var tokens = super.tokenize(expression) + if (expression.postfixExpression is OptionalChainingExpression || expression.postfixExpression is ForcedValueExpression), + let startIndex = tokens.indexOf(kind: .startOfScope, after: 0) { + tokens.insert(contentsOf: [ + expression.newToken(.symbol, "."), + expression.newToken(.keyword, "invoke") + ], at: startIndex) + } + return tokens + } + open override func tokenize(_ expression: FunctionCallExpression.Argument, node: ASTNode) -> [Token] { return super.tokenize(expression, node: node) .replacing({ $0.value == ": " && $0.kind == .delimiter }, diff --git a/Tests/SwiftKotlinFrameworkTests/Tests/KotlinTokenizer/lambdas.kt b/Tests/SwiftKotlinFrameworkTests/Tests/KotlinTokenizer/lambdas.kt index 9261ac1..2608c41 100644 --- a/Tests/SwiftKotlinFrameworkTests/Tests/KotlinTokenizer/lambdas.kt +++ b/Tests/SwiftKotlinFrameworkTests/Tests/KotlinTokenizer/lambdas.kt @@ -10,3 +10,5 @@ userService.autoLinkTenant(tenantId = tenant.id).then { _ -> item.selectCallback = { option -> presenter.selectPaymentMethod(option) } +item.selectCallback?.invoke(option) +item.selectCallback!!.invoke(option) diff --git a/Tests/SwiftKotlinFrameworkTests/Tests/KotlinTokenizer/lambdas.swift b/Tests/SwiftKotlinFrameworkTests/Tests/KotlinTokenizer/lambdas.swift index 2e25711..196cd60 100644 --- a/Tests/SwiftKotlinFrameworkTests/Tests/KotlinTokenizer/lambdas.swift +++ b/Tests/SwiftKotlinFrameworkTests/Tests/KotlinTokenizer/lambdas.swift @@ -16,3 +16,6 @@ userService.autoLinkTenant(tenantId: tenant.id).then { [weak self] _ in item.selectCallback = { option in presenter.selectPaymentMethod(option) } + +item.selectCallback?(option) +item.selectCallback!(option)