Source file test/fixedbugs/issue66663.go

     1  // compile
     2  
     3  // Copyright 2024 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 Iterator[A any] func() (bool, A)
    10  
    11  type Range[A any] interface {
    12  	Blocks() Iterator[Block[A]]
    13  }
    14  
    15  type Block[A any] interface {
    16  	Range[A]
    17  }
    18  
    19  type rangeImpl[A any] struct{}
    20  
    21  func (r *rangeImpl[A]) Blocks() Iterator[Block[A]] {
    22  	return func() (bool, Block[A]) {
    23  		var a Block[A]
    24  		return false, a
    25  	}
    26  }
    27  
    28  func NewRange[A any]() Range[A] {
    29  	return &rangeImpl[A]{}
    30  }
    31  
    32  type AddrImpl struct{}
    33  
    34  var _ = NewRange[AddrImpl]()
    35  

View as plain text