bind: skip incompatible constructors in ObjC bindings
Fixes golang/go#21523 Change-Id: I1244e296ac4eeb0d10847e73216e4a25a3533292 Reviewed-on: https://go-review.googlesource.com/101115 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
parent
c922c29296
commit
70293e6c50
@ -1161,6 +1161,10 @@ func (g *ObjcGen) genStructM(obj *types.TypeName, t *types.Struct) {
|
||||
cons := g.constructors[obj]
|
||||
if oinf == nil {
|
||||
for _, f := range cons {
|
||||
if !g.isSigSupported(f.Type()) {
|
||||
g.Printf("// skipped constructor %s.%s with unsupported parameter or return types\n\n", obj, f.Name())
|
||||
continue
|
||||
}
|
||||
g.genInitM(obj, f)
|
||||
}
|
||||
}
|
||||
|
9
bind/testdata/testpkg/testpkg.go
vendored
9
bind/testdata/testpkg/testpkg.go
vendored
@ -9,6 +9,7 @@ package testpkg
|
||||
//go:generate gobind -lang=go -outdir=go_testpkg .
|
||||
//go:generate gobind -lang=java -outdir=. .
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
@ -609,3 +610,11 @@ func TestSIGPIPE() {
|
||||
type Testpkg interface{}
|
||||
|
||||
func ClashingParameterFromOtherPackage(_ *secondpkg.Secondpkg) {}
|
||||
|
||||
type MyStruct struct {
|
||||
}
|
||||
|
||||
// Test that constructors with incompatible signatures are ignored.
|
||||
func NewMyStruct(ctx context.Context) *MyStruct {
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user