Skip to content

Commit

Permalink
Fixed issue converting lists
Browse files Browse the repository at this point in the history
  • Loading branch information
angelolloqui committed Mar 21, 2020
1 parent 54093fc commit 7d1c0bf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions Assets/Tests/KotlinTokenizer/foundation_types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ var map: Promise<Map<Int, String>>? = null
var map: Map<Int, Promise<Map<String, String>>>
var map = mapOf(1 to "a", 2 to "b")
var map = mapOf<String , String>()
method(value = listOf("value1", "value"))
1 change: 1 addition & 0 deletions Assets/Tests/KotlinTokenizer/foundation_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ var map: Promise<[Int: String]>?
var map: [Int: Promise<[String: String]>]
var map = [1: "a", 2: "b"]
var map = [String: String]()
method(value: ["value1", "value"])
9 changes: 4 additions & 5 deletions Sources/SwiftKotlinFramework/KotlinTokenizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,11 @@ public class KotlinTokenizer: SwiftTokenizer {
case let .staticString(_, rawText):
return [expression.newToken(.string, conversionUnicodeString(rawText, node: expression))]
case .array(let exprs):
let isGenericTypeInfo = expression.lexicalParent is FunctionCallExpression
return
expression.newToken(.identifier, "listOf") +
expression.newToken(.startOfScope, isGenericTypeInfo ? "<" : "(") +
let isGenericTypeInfo = (expression.lexicalParent as? FunctionCallExpression)?.postfixExpression.textDescription.starts(with: "[") == true
return expression.newToken(.identifier, "listOf") +
expression.newToken(.startOfScope, isGenericTypeInfo ? "<" : "(") +
exprs.map { tokenize($0) }.joined(token: expression.newToken(.delimiter, ", ")) +
expression.newToken(.endOfScope, isGenericTypeInfo ? ">" : ")")
expression.newToken(.endOfScope, isGenericTypeInfo ? ">" : ")")
case .dictionary(let entries):
let isGenericTypeInfo = expression.lexicalParent is FunctionCallExpression
var entryTokens = entries.map { tokenize($0, node: expression) }.joined(token: expression.newToken(.delimiter, ", "))
Expand Down

0 comments on commit 7d1c0bf

Please sign in to comment.