Source file test/fixedbugs/issue56103.go

     1  // errorcheck
     2  
     3  // Copyright 2022 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  // Self recursion.
    10  type i interface{ m() interface{ i } } // ERROR "invalid recursive type"
    11  type _ interface{ i }                  // no redundant error
    12  
    13  // Mutual recursion.
    14  type j interface{ m() interface{ k } } // ERROR "invalid recursive type"
    15  type k interface{ m() interface{ j } }
    16  
    17  // Both self and mutual recursion.
    18  type (
    19  	a interface { // ERROR "invalid recursive type"
    20  		m() interface {
    21  			a
    22  			b
    23  		}
    24  	}
    25  	b interface {
    26  		m() interface {
    27  			a
    28  			b
    29  		}
    30  	}
    31  )
    32  
    33  // Self recursion through other types.
    34  func _() { type i interface{ m() *interface{ i } } }        // ERROR "invalid recursive type"
    35  func _() { type i interface{ m() []interface{ i } } }       // ERROR "invalid recursive type"
    36  func _() { type i interface{ m() [0]interface{ i } } }      // ERROR "invalid recursive type"
    37  func _() { type i interface{ m() chan interface{ i } } }    // ERROR "invalid recursive type"
    38  func _() { type i interface{ m() map[interface{ i }]int } } // ERROR "invalid recursive type"
    39  func _() { type i interface{ m() map[int]interface{ i } } } // ERROR "invalid recursive type"
    40  func _() { type i interface{ m() func(interface{ i }) } }   // ERROR "invalid recursive type"
    41  func _() { type i interface{ m() func() interface{ i } } }  // ERROR "invalid recursive type"
    42  func _() {
    43  	type i interface { // ERROR "invalid recursive type"
    44  		m() struct{ i interface{ i } }
    45  	}
    46  }
    47  

View as plain text