GoLand' support for generics is in alpha stage today, false negatives are pretty common and this is your case.
понедельник, 24 января 2022 г. в 20:02:09 UTC+3, ka...@swit.io: > Before the question, I'm sorry I'm not good at English > > when go 1.18 beta released, i try to test generic type > Most of the code worked, but something went wrong when implementing the > generic interface. > > This is my code > > type Repository[T any] interface { > Save(T) T > } > > type repo[T any] struct { > } > > func NewRepository[T any]() Repository[T] { > return &repo[T]{} > } > > func (r repo[T]) Save(entity T) T { > return entity > } > > This code looks fine and works normally when executed. > But, ide throw compile exception. Why? > > [image: 스크린샷 2022-01-24 오후 7.12.19.png] > > * Again, build and run is normal * > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/6d6e9cd7-6529-49dc-9209-9e64b2663aa2n%40googlegroups.com.