Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile/bind: cannot generate proxy interface using unexported types #12330

Closed
crawshaw opened this issue Aug 25, 2015 · 2 comments
Closed

x/mobile/bind: cannot generate proxy interface using unexported types #12330

crawshaw opened this issue Aug 25, 2015 · 2 comments

Comments

@crawshaw
Copy link
Member

Attempting to bind

package p

type I interface {
    f()
}

fails to compile with

go_pmain.go:20: v.f undefined (cannot refer to unexported field or method f)

The problem is the bind code generates a proxy implementation of the interface I, which is impossible:

type proxyI seq.Ref

func (p *proxyI) f() {
    in := new(seq.Buffer)
    seq.Transact((*seq.Ref)(p), "go.p.I", proxyI_f_Code, in)
}

For types like this we need to avoid generating a proxy.

@crawshaw crawshaw self-assigned this Aug 26, 2015
@crawshaw
Copy link
Member Author

I'm going to start with the reasonable restriction:

  • interfaces which depend on an unexported type do not generate Stub classses

and the overly broad restriction:

  • methods which depend on an unexported type do not generate bindings

The second is overly broad because in Go a package can declare

package p

func F() unexported

func G(u unexported)

and then another package can call p.G(p.F()). But we can relax that later.

/cc @hyangah

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/13946 mentions this issue.

@golang golang locked and limited conversation to collaborators Sep 4, 2016
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Fixes golang/go#12330

Change-Id: I1568d04b7e48242105a7028ca471e2138f684eeb
Reviewed-on: https://go-review.googlesource.com/13946
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Fixes golang/go#12330

Change-Id: I1568d04b7e48242105a7028ca471e2138f684eeb
Reviewed-on: https://go-review.googlesource.com/13946
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants