...

Source file src/internal/types/testdata/fixedbugs/issue47968.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  type T[P any] struct{}
     8  
     9  func (T[P]) m1()
    10  
    11  type A1 = T // ERROR "cannot use generic type"
    12  
    13  func (A1[P]) m2() {}
    14  
    15  type A2 = T[int]
    16  
    17  func (A2 /* ERRORx `cannot define new methods on instantiated type (T\[int\]|A2)` */) m3()   {}
    18  func (_ /* ERRORx `cannot define new methods on instantiated type (T\[int\]|A2)` */ A2) m4() {}
    19  
    20  func (T[int]) m5()                                     {} // int is the type parameter name, not an instantiation
    21  func (T[* /* ERROR "must be an identifier" */ int]) m6() {} // syntax error
    22  

View as plain text