github.com/remobjects/goldbaselibrary@v0.0.0-20230924164425-d458680a936b/Source/Gold/types/testdata/cycles2.src (about)

     1  // Copyright 2013 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  import "unsafe"
     8  
     9  // Test case for issue 5090
    10  
    11  type t interface {
    12  	f(u)
    13  }
    14  
    15  type u interface {
    16  	t
    17  }
    18  
    19  func _() {
    20  	var t t
    21  	var u u
    22  
    23  	t.f(t)
    24  	t.f(u)
    25  	
    26  	u.f(t)
    27  	u.f(u)
    28  }
    29  
    30  
    31  // Test case for issue 6589.
    32  
    33  type A interface {
    34  	a() interface {
    35  		AB
    36  	}
    37  }
    38  
    39  type B interface {
    40  	a() interface {
    41  		AB
    42  	}
    43  }
    44  
    45  type AB interface {
    46  	a() interface {
    47  		A
    48  		B /* ERROR a redeclared */
    49  	}
    50  	b() interface {
    51  		A
    52  		B /* ERROR a redeclared */
    53  	}
    54  }
    55  
    56  var x AB
    57  var y interface {
    58  	A
    59  	B /* ERROR a redeclared */
    60  }
    61  var _ = x /* ERROR cannot compare */ == y
    62  
    63  
    64  // Test case for issue 6638.
    65  
    66  type T interface {
    67  	m() [T /* ERROR no value */ (nil).m()[0]]int
    68  }
    69  
    70  // Variations of this test case.
    71  
    72  type T1 /* ERROR cycle */ interface {
    73  	m() [x1.m()[0]]int
    74  }
    75  
    76  var x1 T1
    77  
    78  type T2 /* ERROR cycle */ interface {
    79  	m() [len(x2.m())]int
    80  }
    81  
    82  var x2 T2
    83  
    84  type T3 /* ERROR cycle */ interface {
    85  	m() [unsafe.Sizeof(x3.m)]int
    86  }
    87  
    88  var x3 T3
    89  
    90  type T4 /* ERROR cycle */ interface {
    91  	m() [unsafe.Sizeof(cast4(x4.m))]int // cast is invalid but we have a cycle, so all bets are off
    92  }
    93  
    94  var x4 T4
    95  var _ = cast4(x4.m)
    96  
    97  type cast4 func()