Skip to content

x/mobile: function with alias type as argument or return value cannot be exported #39735

@libnat

Description

@libnat

What version of Go are you using (go version)?

$ go version
go version go1.14.4 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOOS="darwin"

What did you do?

  1. Create a demo pkg at ~/go/src/demo
  2. Add ~/go/src/demo/model/model.go
    package model
    type IntSet struct {
    }
    
  3. Add ~/go/src/demo/demo.go
    package demo
    import "demo/model"
    type IntSet = model.IntSet
    func NewIntSet() *IntSet {
        return new(IntSet)
    } 
    
  4. Generate bindings
    gomobile bind -target=ios demo

What did you expect to see?

Generate bindings:

@class DemoIntSet;
@interface DemoIntSet ... 
...
FOUNDATION_EXPORT DemoIntSet* _Nullable DemoNewIntSet(void);

What did you see instead?

@class DemoIntSet;
@interface DemoIntSet ... 
...
// skipped function NewIntSet with unsupported parameter or return types

I guess gobind doesn't use demo.IntSet as demo.NewIntSet's return value type, still use model.IntSet which is not exported.
To fix this issue, I have to define a new type like type IntSet model.IntSet, in this way, it requires to rewrite all methods because now demo.IntSet is a new type. This brings lots of work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.mobileAndroid, iOS, and x/mobile

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions