...

Source file src/internal/types/testdata/fixedbugs/issue49541.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  type S[A, B any] struct {
     8  	f int
     9  }
    10  
    11  func (S[A, B]) m() {}
    12  
    13  // TODO(gri): with type-type inference enabled we should only report one error
    14  // below. See issue #50588.
    15  
    16  func _[A any](s S /* ERROR "not enough type arguments for type S: have 1, want 2" */ [A]) {
    17  	// we should see no follow-on errors below
    18  	s.f = 1
    19  	s.m()
    20  }
    21  
    22  // another test case from the issue
    23  
    24  func _() {
    25  	X /* ERROR "cannot infer Q" */ (Interface[*F /* ERROR "not enough type arguments for type F: have 1, want 2" */ [string]](Impl{}))
    26  }
    27  
    28  func X[Q Qer](fs Interface[Q]) {
    29  }
    30  
    31  type Impl struct{}
    32  
    33  func (Impl) M() {}
    34  
    35  type Interface[Q Qer] interface {
    36  	M()
    37  }
    38  
    39  type Qer interface {
    40  	Q()
    41  }
    42  
    43  type F[A, B any] struct{}
    44  
    45  func (f *F[A, B]) Q() {}
    46  

View as plain text