...

Source file src/internal/types/testdata/fixedbugs/issue47796.go

Documentation: internal/types/testdata/fixedbugs

     1  // Copyright 2021 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package p
     6  
     7  // parameterized types with self-recursive constraints
     8  type (
     9  	T1 /* ERROR "invalid recursive type" */ [P T1[P]]                            interface{}
    10  	T2 /* ERROR "invalid recursive type" */ [P, Q T2[P, Q]]                      interface{}
    11  	T3[P T2[P, Q], Q interface{ ~string }] interface{}
    12  
    13  	T4a /* ERROR "invalid recursive type" */ [P T4a[P]]                                                        interface{ ~int }
    14  	T4b /* ERROR "invalid recursive type" */ [P T4b[int]]                                                      interface{ ~int }
    15  	T4c /* ERROR "invalid recursive type" */ [P T4c[string]] interface{ ~int }
    16  
    17  	// mutually recursive constraints
    18  	T5 /* ERROR "invalid recursive type" */ [P T6[P]] interface{ int }
    19  	T6[P T5[P]] interface{ int }
    20  )
    21  
    22  // verify that constraints are checked as expected
    23  var (
    24  	_ T1[int]
    25  	_ T2[int, string]
    26  	_ T3[int, string]
    27  )
    28  
    29  // test case from issue
    30  
    31  type Eq /* ERROR "invalid recursive type" */ [a Eq[a]] interface {
    32  	Equal(that a) bool
    33  }
    34  

View as plain text