Skip to content

Commit

Permalink
#28 Removed unnecessary attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
angelolloqui committed Nov 5, 2017
1 parent 2160f23 commit a265759
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/SwiftKotlinFramework/KotlinTokenizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,13 @@ public class KotlinTokenizer: SwiftTokenizer {
return tokenize(type.wrappedType, node: node)
}

open override func tokenize(_ attribute: Attribute, node: ASTNode) -> [Token] {
if ["escaping", "autoclosure", "discardableResult"].contains(attribute.name) {
return []
}
return super.tokenize(attribute, node: node)
}

// MARK: - Patterns


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var completionHandlers: List<() -> Unit> = listOf()

fun someFunctionWithEscapingClosure(completionHandler: () -> Unit) {
completionHandlers.append(completionHandler)
}

fun serve(customerProvider: () -> String) {
print("Now serving ${customerProvider()}!")
}

fun collectCustomerProviders(customerProvider: () -> String) {
customerProviders.append(customerProvider)
}

fun foo(code: (() -> String)) : String {
return "foo ${bar(code)}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

// escaping
var completionHandlers: [() -> Void] = []
func someFunctionWithEscapingClosure(completionHandler: @escaping () -> Void) {
completionHandlers.append(completionHandler)
}

func serve(customer customerProvider: @autoclosure () -> String) {
print("Now serving \(customerProvider())!")
}

func collectCustomerProviders(_ customerProvider: @autoclosure @escaping () -> String) {
customerProviders.append(customerProvider)
}

@discardableResult
func foo(_ code:(() -> String)) -> String {
return "foo \(bar(code))"
}

0 comments on commit a265759

Please sign in to comment.