Source file test/fixedbugs/issue6977.go

     1  // errorcheck
     2  
     3  // Copyright 2019 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 p
     8  
     9  import "io"
    10  
    11  // Alan's initial report.
    12  
    13  type I interface { f(); String() string }
    14  type J interface { g(); String() string }
    15  
    16  type IJ1 = interface { I; J }
    17  type IJ2 = interface { f(); g(); String() string }
    18  
    19  var _ = (*IJ1)(nil) == (*IJ2)(nil) // static assert that IJ1 and IJ2 are identical types
    20  
    21  // The canonical example.
    22  
    23  type ReadWriteCloser interface { io.ReadCloser; io.WriteCloser }
    24  
    25  // Some more cases.
    26  
    27  type M interface { m() }
    28  type M32 interface { m() int32 }
    29  type M64 interface { m() int64 }
    30  
    31  type U1 interface { m() }
    32  type U2 interface { m(); M }
    33  type U3 interface { M; m() }
    34  type U4 interface { M; M; M }
    35  type U5 interface { U1; U2; U3; U4 }
    36  
    37  type U6 interface { m(); m() } // ERROR "duplicate method .*m"
    38  type U7 interface { M32; m() } // ERROR "duplicate method .*m"
    39  type U8 interface { m(); M32 } // ERROR "duplicate method .*m"
    40  type U9 interface { M32; M64 } // ERROR "duplicate method .*m"
    41  

View as plain text