...

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

Documentation: internal/types/testdata/fixedbugs

     1  // Copyright 2022 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  // simplified test case
     8  
     9  type transform[T any] struct{}
    10  type pair[S any] struct {}
    11  
    12  var _ transform[step]
    13  
    14  type box transform[step]
    15  type step = pair[box]
    16  
    17  // test case from issue
    18  
    19  type Transform[T any] struct{ hold T }
    20  type Pair[S, T any] struct {
    21  	First  S
    22  	Second T
    23  }
    24  
    25  var first Transform[Step]
    26  
    27  // This line doesn't use the Step alias, and it compiles fine if you uncomment it.
    28  var second Transform[Pair[Box, interface{}]]
    29  
    30  type Box *Transform[Step]
    31  
    32  // This line is the same as the `first` line, but it comes after the Box declaration and
    33  // does not break the compile.
    34  var third Transform[Step]
    35  
    36  type Step = Pair[Box, interface{}]
    37  
    38  // This line also does not break the compile
    39  var fourth Transform[Step]
    40  

View as plain text