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/19fbde0e-d3e3-46c9-b727-1833a1b0bf1dn%40googlegroups.com.

Reply via email to