Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#28 Removed unnecessary attributes #39

Merged
merged 1 commit into from
Nov 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))"
}