Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Completion doesn't work in go 1.9 for type aliases #1277

Closed
esemplastic opened this issue Oct 12, 2017 · 3 comments
Closed

Completion doesn't work in go 1.9 for type aliases #1277

esemplastic opened this issue Oct 12, 2017 · 3 comments

Comments

@esemplastic
Copy link

esemplastic commented Oct 12, 2017

iris.C 's origin type is mvc.C: https://github.com/kataras/iris/blob/master/mvc/controller.go#L39
iris.C type alias definition: https://github.com/kataras/iris/blob/master/go19.go#L148

The mvc.C looks like the following:

type C struct {
	Name string
	Ctx context.Context
}

func (c *C) BeginRequest(ctx context.Context) { c.Ctx = ctx }

But when embedding the type in other type, auto completion doesn't work:

problem1

Same for non-embedding, i.e return a struct that derives from a type alias:

problem2

Is this a bug, is it a feature request? I don't know but please try to look on this and fix that as soon as possible!


This issue is also posted at nsf/gocode repository: nsf/gocode#479

@ramya-rao-a
Copy link
Contributor

@esemplastic Can you provide a smaller code sample that I can try to repro this on?

@esemplastic
Copy link
Author

Sure!

file: mypackage/original/embedded_struct.go

package original

type C struct {
	Field  string
	Field2 int
}

func (c *C) BeginRequest() {

}

file: mypackage/original/return_type.go

package original

type Result interface {
	DoSomething()
}

type Response struct {
	Text string
}

func (r Response) DoSomething() {

}

file: mypackage/mypackage.go

package mypackage

import (
	"esemplastic/mypackage/original"
)

type (
	C        = original.C
	Result   = original.Result
	Response = original.Response
)

file: main.go

package main

import (
	"esemplastic/mypackage"
)

type ExampleController struct {
	mypackage.C
}

func (ex *ExampleController) Get() {
	// `ex.` doesn't give completion for the mypackage.C's:
	//	     Field  string
	//       Field2 int
	// neither the function `BeginRequest()`,
	// it only shows the field `C` and its own function `Get`.
	// but `ex.Field` or `ex.BeginRequest` is compiled and ran without errors.
	// The `ex.C.` gives completion help.
}

func (ex *ExampleController) ReturnSomething() mypackage.Result {
	return mypackage.Response{
	// field: Text string is not shown to completion help,
	// nothing except the built go functions like `append`...
	}
}

func main() {

}

@ramya-rao-a
Copy link
Contributor

Thanks @esemplastic, I can repro

The issue lies with gocode and I see that the corresponding issue there is being looked at.

Will close this issue as you have the upstream one to track the problem.

When gocode is fixed for working with type alias, please drop a comment here so that others who might encounter the same issue will know to update gocode

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants