Skip to content

Commit

Permalink
Upcalls must return MemoryAddress.NULL instead of null
Browse files Browse the repository at this point in the history
  • Loading branch information
jwharm committed Jan 11, 2023
1 parent bb9b465 commit 5d53a58
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ default void generateFunctionalInterface(SourceWriter writer, String javaName) t
}

boolean isMemoryAddress = !isVoid && Conversions.toPanamaJavaType(returnValue.type).equals("MemoryAddress");
boolean isNullable = isMemoryAddress && returnValue.nullable;
boolean isNullable = isMemoryAddress && (!returnValue.notnull);

if (isNullable) {
writer.write("if (RESULT != null) {\n");
Expand All @@ -106,7 +106,9 @@ default void generateFunctionalInterface(SourceWriter writer, String javaName) t
writer.write(";\n");
if (isNullable) {
writer.decreaseIndent();
writer.write("} else return null;\n");
writer.write("} else {\n");
writer.write(" return MemoryAddress.NULL;\n");
writer.write("}\n");
}
}
if (hasScope) {
Expand Down

0 comments on commit 5d53a58

Please sign in to comment.