Skip to content

Commit a670911

Browse files
committed
Allow non-collection types to be used as Swift output
1 parent 47341f6 commit a670911

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Sources/plutil/PLULiteralOutput.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ private func _swiftLiteralDataWithPropertyList(_ plist: Any, depth: Int, indent:
198198
// Previous implementation would attempt to determine dynamically if the type annotation was by checking if there was a collection of different types. For now, this just always adds it.
199199
result.append("let \(varName(from: originalFilename))")
200200

201+
// Dictionaries and Arrays need to check for specific type annotation, in case they contain different types. Other types do not.
201202
if let dictionary = plist as? [String: Any] {
202203
var lastType: PlutilExpectType?
203204
var needsAnnotation = false
@@ -232,8 +233,6 @@ private func _swiftLiteralDataWithPropertyList(_ plist: Any, depth: Int, indent:
232233
if needsAnnotation {
233234
result.append(" : [Any]")
234235
}
235-
} else {
236-
throw PLUContextError.invalidPropertyListObject("Swift literal syntax does not support classes of type \(type(of: plist))")
237236
}
238237

239238
result.append(" = ")

0 commit comments

Comments
 (0)