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

     1  // -gotypesalias=1
     2  
     3  // Copyright 2021 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package p
     8  
     9  type T[P any] struct{}
    10  
    11  func (T[P]) m1()
    12  
    13  type A1 = T // ERROR "cannot use generic type"
    14  
    15  func (A1[P]) m2() {} // don't report a follow-on error on A1
    16  
    17  type A2 = T[int]
    18  
    19  func (A2 /* ERROR "cannot define new methods on instantiated type T[int]" */) m3()   {}
    20  func (_ A2 /* ERROR "cannot define new methods on instantiated type T[int]" */) m4() {}
    21  
    22  func (T[int]) m5()                                       {} // int is the type parameter name, not an instantiation
    23  func (T[* /* ERROR "must be an identifier" */ int]) m6() {} // syntax error
    24  

View as plain text