Skip to content

Commit d1fd323

Browse files
committed
Dev: fix swift compiler warnings in generated code
1 parent beccdd0 commit d1fd323

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
@@ -113,7 +113,21 @@ public void generateCode(SwiftWriter swiftWriter, String javaFullName, String sw
113113
swiftWriter.emitStatement(String.format("let %s: %s%s", param.name, param.swiftType.swiftType, param.isOptional ? "?" : ""));
114114
}
115115

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

0 commit comments

Comments
 (0)