Skip to content

Commit 44d151d

Browse files
committed
compiler/natives/src/reflect: Set pkgPath for new implements checks.
In Go 1.9, specifically commit golang/go@2ddc3e9, reflect.implements was modified to look at pkgPath in more cases. Previously, GopherJS didn't always set pkgPath in some places. This caused panics and failures in TestImplements and TestAssignableTo. This change fixes that, allowing all reflect tests to pass. Fixes: $ go install -tags=gopherjsdev -v && touch $(which gopherjs) && gopherjs test --short reflect --- FAIL: TestImplements (0.00s) /Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/gopherjs/gopherjs/test.903476986:1412 throw new Error(msg); ^ Error: runtime error: invalid memory address or nil pointer dereference ... FAIL reflect 4.658s
1 parent 640751f commit 44d151d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

compiler/natives/src/reflect/reflect.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func reflectType(typ *js.Object) *rtype {
122122
}
123123
setKindType(rt, &interfaceType{
124124
rtype: *rt,
125+
pkgPath: newName(internalStr(typ.Get("pkg")), "", "", false),
125126
methods: imethods,
126127
})
127128
case Map:

compiler/prelude/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ var $newType = function(size, kind, string, named, pkg, exported, constructor) {
234234
case $kindStruct:
235235
typ = function(v) { this.$val = v; };
236236
typ.wrapped = true;
237-
typ.ptr = $newType(4, $kindPtr, "*" + string, false, "", exported, constructor);
237+
typ.ptr = $newType(4, $kindPtr, "*" + string, false, pkg, exported, constructor);
238238
typ.ptr.elem = typ;
239239
typ.ptr.prototype.$get = function() { return this; };
240240
typ.ptr.prototype.$set = function(v) { typ.copy(this, v); };

0 commit comments

Comments
 (0)