Closed
Description
Filing a bug as per #15292 (comment).
If a function is called that takes an argument of a generic type that in turn has its own type parameter, the inference of the subtype fails. For example,
package main
type Getter(type T) interface {
Get() T
}
type Impl struct {
v string
}
func (i Impl) Get() string {
return i.v
}
func Bug(type G Getter(T), T interface{})(g G) {
}
func main() {
i := Impl{v: "example"}
Bug(i)
}
Output:
type checking failed for main
prog.go2:20:7: cannot infer T (prog.go2:15:28)
This code works if the call to Bug
is changed to Bug(Impl, string)
.