Source file src/cmd/compile/internal/importer/testdata/genmeth.go

     1  // Copyright 2026 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  // This file is used to generate an object file which
     6  // serves as test file for gcimporter_test.go.
     7  //
     8  // Function bodies are never read, so panics are used
     9  // for brevity. Struct contents are also never filled
    10  // in.
    11  
    12  package genmeth
    13  
    14  // monads
    15  type Either[A, B any] struct {}
    16  
    17  func (Either[A, B]) A() A { panic(42) }
    18  func (Either[A, B]) B() B { panic(42) }
    19  
    20  type Option[T any] struct {}
    21  
    22  func (Option[T]) Get() T { panic(42) }
    23  func (Option[T]) GetOrDefault[U any](u U) Either[T, U] { panic(42) }
    24  func (Option[T]) MapIfPresent[U any](f func(T) U) Option[U] { panic(42) }
    25  
    26  // pointer receiver
    27  type Box[P any] struct {}
    28  
    29  func (*Box[P]) Get() P { panic(42) }
    30  func (*Box[P]) Set(p P) { panic(42) }
    31  
    32  // streaming
    33  type List[E any] []E
    34  func (List[E]) Map[R any](f func(E) R) List[R] { panic(42) }
    35  func (List[E]) FlatMap[R any](f func(E) List[R]) List[R] { panic(42) }
    36  func (List[E1]) Zip[E2, R any](l List[E2], f func(E1, E2) R) List[R] { panic(42) }
    37  
    38  type Pair[A, B any] struct {}
    39  type BiList[A, B any] List[Pair[A, B]]
    40  
    41  func (BiList[A, B]) Flip() BiList[B, A] { panic(42) }
    42  func (BiList[A, B]) MapKeys[R any](f func(A) R) BiList[R, B] { panic(42) }
    43  func (BiList[A, B]) MapValues[R any](f func(B) R) BiList[A, R] { panic(42) }
    44  func (BiList[A, B]) FlatMapValues[R any](f func(B) List[R]) BiList[A, R] { panic(42) }
    45  func (BiList[A, B]) MapEntries[K, V any](f func(Pair[A, B]) Pair[K, V]) BiList[K, V] { panic(42) }
    46  
    47  type OrderedList[E comparable] []E
    48  func (OrderedList[E]) Min() Option[E] { panic(42) }
    49  func (OrderedList[E]) Max() Option[E] { panic(42) }
    50  

View as plain text