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/cmd/gobind: exported interface function with struct pointer produces invalid generated code #9487

Closed
ChrisSmith opened this issue Jan 2, 2015 · 0 comments
Milestone

Comments

@ChrisSmith
Copy link

What version of Go are you using
go version devel +c7eb966 Wed Dec 24 07:30:28 2014 +0000 darwin/amd64

What operating system and processor architecture are you using?
osx 10.9.5 cross compiled for arm on Android 5.0.1 Nexus 5

What did you do?
Export interface with a function that returns a struct pointer

What did you expect to see?
Correctly generated code

What did you see instead?
Invalid code, line 19. The type reference is incorrect.

func (p *proxyIStringStruct) GetIt() (res_0 *golang.org/x/mobile/example/libhello/hi.StringStruct) {

full output https://gist.github.com/ChrisSmith/95e149597df2b88a5cde

To reproduce, modify libhello's hi package like so

package hi

type IStringStruct interface {
    GetIt() *StringStruct
}

type StringStruct struct {
    Name string
}

func (ss StringStruct) GetIt() *StringStruct {
    return &ss
}

func verifyImplements() {
    var _ IStringStruct = StringStruct{
        Name: "Test",
    }
}

run gobind, it will fail with

19:56: expected ')', found '/'
@minux minux added this to the Go1.5 milestone Jan 2, 2015
@hyangah hyangah self-assigned this Jan 2, 2015
@mikioh mikioh changed the title mobile/gobind: exported interface function with struct pointer produces invalid generated code cmd/gobind: exported interface function with struct pointer produces invalid generated code Jan 4, 2015
@mikioh mikioh changed the title cmd/gobind: exported interface function with struct pointer produces invalid generated code x/mobile/cmd/gobind: exported interface function with struct pointer produces invalid generated code Aug 5, 2015
@golang golang locked and limited conversation to collaborators Aug 5, 2016
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
This change makes gobind to generate proper Go-side proxy code to
handle interface methods that have parameters and return values.

It allows gobind to accept struct pointer types as parameters
or a return value of a method.

Fixes golang/go#9487, golang/go#9488.

Change-Id: Id243c42ee0701d40e3871e392140368c2f8f9bc6
Reviewed-on: https://go-review.googlesource.com/2348
Reviewed-by: David Crawshaw <crawshaw@golang.org>
@rsc rsc unassigned hyangah Jun 23, 2022
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

4 participants