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

go 1.18 generics support #369

Open
JILeXanDR opened this issue Apr 5, 2022 · 3 comments
Open

go 1.18 generics support #369

JILeXanDR opened this issue Apr 5, 2022 · 3 comments

Comments

@JILeXanDR
Copy link

I use v0.7.7, code with generics fails:

Error parsing model.go: model.go:41:27: expected ';', found '[' (and 2 more errors)
model.go:1: running "easyjson": exit status 1

Any plans to have generics support in the near future?

@skhokhlov
Copy link

+1
Do you have any plans for it?

@dgoodine
Copy link

dgoodine commented Sep 1, 2022

+1
At the very least generic types should be skipped for processing (potentially with a warning) instead of erroring.

@thekudryash
Copy link

thekudryash commented Dec 16, 2022

Are there any updates ?
There are some problems with types when try to generate code that contains generics with pointer types.


Example:

package some_package;

//easyjson:json
type SecondNested struct {
	SomeField bool `json:"someField"`
}

type NestedStruct[U json.Unmarshaler] struct {
	SecondNested U `json:"secondNested"`
}

type Main[U json.Unmarshaler] struct {
	NestedStructs NestedStruct[U] `json:"nested"`
}

//easyjson:json
type SomeType struct {
	Main[*SecondNested]
}

Generated code:

func easyjson<...>SecondNested(in *jlexer.Lexer, out *NestedStruct[*some_package.SecondNested]) {}
func easyjson<...>SecondNested(out *jwriter.Writer, in NestedStruct[*some_package.SecondNested]) {}

Problem is at this type *some_package.SecondNested, there must not be some_package in type declaration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants