bind: accept null objects as nil pointers

Currently the generated bindings assume that any object
passed to Go as a method argument is actually a valid one
originating from Go. The `null` object is however a corner
case to this assumption, which should be accepted for Go
pointer types, since they can cleanly convert into `nil`.

This CL modifies the generated wrapper code so any `nil`
reference is permitted for Go pointer types, which until
now produced a nil pointer dereference error.

Fixes golang/go#20330

Change-Id: If1ab9cf9df7ac3808486d23ccf2db8d32fb89426
Reviewed-on: https://go-review.googlesource.com/43253
Reviewed-by: Elias Naur <elias.naur@gmail.com>
This commit is contained in:
Péter Szilágyi
2017-05-24 10:27:38 +00:00
committed by Elias Naur
parent 0f3174026e
commit 44a54e9b78
7 changed files with 37 additions and 12 deletions
+5 -2
View File
@@ -448,8 +448,11 @@ public class SeqTest extends InstrumentationTestCase {
return null;
}
}));
assertEquals("Go nil interface is null", null, Testpkg.newNullInterface());
assertEquals("Go nil struct pointer is null", null, Testpkg.newNullStruct());
assertEquals("Go nil interface is null", null, Testpkg.newNullInterface());
assertEquals("Go nil struct pointer is null", null, Testpkg.newNullStruct());
Issue20330 nullArger = new Issue20330();
assertTrue(nullArger.callWithNull(null));
}
public void testPassByteArray() {