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

     1  // -lang=go1.26
     2  
     3  // Copyright 2022 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  // The parser does not accept type parameters for interface methods.
    10  // In the past, type checking the code below led to a crash (#50427).
    11  
    12  type T interface{ m[ /* ERROR "must have no type parameters" */ P any]() }
    13  
    14  func _(t T) {
    15  	var _ interface{ m[ /* ERROR "must have no type parameters" */ P any](); n() } = t /* ERROR "does not implement" */
    16  }
    17  
    18  // Type parameters on concrete methods are not permitted before Go 1.27.
    19  
    20  type S struct{}
    21  
    22  func (S) m[P /* ERROR "generic method requires go1.27 or later" */ any]() {}
    23  
    24  func _(s S) {
    25  	var _ interface{ m[ /* ERROR "must have no type parameters" */ P any](); n() } = s /* ERROR "does not implement" */
    26  
    27  }
    28  

View as plain text