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 7package p 8 9// Self recursion. 10type i interface{ m() interface{ i } } // ERROR "invalid recursive type" 11type _ interface{ i } // no redundant error 12 13// Mutual recursion. 14type j interface{ m() interface{ k } } // ERROR "invalid recursive type" 15type k interface{ m() interface{ j } } 16 17// Both self and mutual recursion. 18type ( 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. 34func _() { type i interface{ m() *interface{ i } } } // ERROR "invalid recursive type" 35func _() { type i interface{ m() []interface{ i } } } // ERROR "invalid recursive type" 36func _() { type i interface{ m() [0]interface{ i } } } // ERROR "invalid recursive type" 37func _() { type i interface{ m() chan interface{ i } } } // ERROR "invalid recursive type" 38func _() { type i interface{ m() map[interface{ i }]int } } // ERROR "invalid recursive type" 39func _() { type i interface{ m() map[int]interface{ i } } } // ERROR "invalid recursive type" 40func _() { type i interface{ m() func(interface{ i }) } } // ERROR "invalid recursive type" 41func _() { type i interface{ m() func() interface{ i } } } // ERROR "invalid recursive type" 42func _() { 43 type i interface { // ERROR "invalid recursive type" 44 m() struct{ i interface{ i } } 45 } 46} 47