Skip to content

Commit c98b127

Browse files
authored
Merge pull request #28 from readdle/fix/swift-compiler-warning-in-generated-code
Fix swift compiler warnings in generated code
2 parents 0bb2199 + d1fd323 commit c98b127

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

compiler/src/main/java/com/readdle/codegen/SwiftFuncDescriptor.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,21 @@ public void generateCode(SwiftWriter swiftWriter, String javaFullName, String sw
116116
swiftWriter.emitStatement(String.format("let %s: %s%s", param.name, param.swiftType.swiftType, param.isOptional ? "?" : ""));
117117
}
118118

119-
boolean shouldCatchPreamble = params.size() > 0 || !isStatic;
119+
120+
boolean shouldCatchPreamble = false;
121+
if (isStatic) {
122+
for (SwiftParamDescriptor param : params) {
123+
// primitive types constructors not throw
124+
if (param.isOptional || !param.isPrimitive()) {
125+
shouldCatchPreamble = true;
126+
break;
127+
}
128+
}
129+
}
130+
else {
131+
shouldCatchPreamble = true;
132+
}
133+
120134
if (shouldCatchPreamble) {
121135
swiftWriter.emitStatement("do {");
122136
}

0 commit comments

Comments
 (0)