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

     1  // Copyright 2024 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 "io"
     8  
     9  // test using struct with invalid embedded field
    10  var _ io.Writer = W{} // no error expected here because W has invalid embedded field
    11  
    12  type W struct {
    13  	*bufio /* ERROR "undefined: bufio" */ .Writer
    14  }
    15  
    16  // test using an invalid type
    17  var _ interface{ m() } = &M{} // no error expected here because M is invalid
    18  
    19  type M undefined // ERROR "undefined: undefined"
    20  
    21  // test using struct with invalid embedded field and containing a self-reference (cycle)
    22  var _ interface{ m() } = &S{} // no error expected here because S is invalid
    23  
    24  type S struct {
    25  	*S
    26  	undefined // ERROR "undefined: undefined"
    27  }
    28  
    29  // test using a generic struct with invalid embedded field and containing a self-reference (cycle)
    30  var _ interface{ m() } = &G[int]{} // no error expected here because S is invalid
    31  
    32  type G[P any] struct {
    33  	*G[P]
    34  	undefined // ERROR "undefined: undefined"
    35  }
    36  

View as plain text