Source file test/fixedbugs/issue74626.go

     1  // errorcheck -goexperiment fieldtrack
     2  
     3  // Copyright 2026 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package main
     8  
     9  type Fooer interface {
    10  	Foo() string
    11  }
    12  
    13  type FooImpl struct{}
    14  
    15  //go:nointerface
    16  func (FooImpl) Foo() string { return "foo" }
    17  
    18  func toInterface[T Fooer](fooer T) Fooer {
    19  	return fooer
    20  }
    21  
    22  func main() {
    23  	var iface Fooer = toInterface(FooImpl{}) // ERROR "does not satisfy Fooer"
    24  	iface.Foo()
    25  }
    26  

View as plain text