golang.org/x/exp@v0.0.0-20240506185415-9bf2ced13842/apidiff/testdata/functions.go (about)

     1  package p
     2  
     3  // old
     4  type u1 int
     5  
     6  // both
     7  type A int
     8  type u2 int
     9  
    10  // new
    11  // c AA: added
    12  type AA = A
    13  
    14  // old
    15  func F1(a int, b string) map[u1]A { return nil }
    16  func F2(int)                      {}
    17  func F3(int)                      {}
    18  func F4(int) int                  { return 0 }
    19  func F5(int) int                  { return 0 }
    20  func F6(int)                      {}
    21  func F7(interface{})              {}
    22  
    23  // new
    24  func F1(c int, d string) map[u2]AA { return nil } //OK: same (since u1 corresponds to u2)
    25  
    26  // i F2: changed from func(int) to func(int) bool
    27  func F2(int) bool { return true }
    28  
    29  // i F3: changed from func(int) to func(int, int)
    30  func F3(int, int) {}
    31  
    32  // i F4: changed from func(int) int to func(bool) int
    33  func F4(bool) int { return 0 }
    34  
    35  // i F5: changed from func(int) int to func(int) string
    36  func F5(int) string { return "" }
    37  
    38  // i F6: changed from func(int) to func(...int)
    39  func F6(...int) {}
    40  
    41  // i F7: changed from func(interface{}) to func(interface{x()})
    42  func F7(a interface{ x() }) {}
    43  
    44  // old
    45  func F8(bool) {}
    46  
    47  // new
    48  // c F8: changed from func to var
    49  var F8 func(bool)
    50  
    51  // old
    52  var F9 func(int)
    53  
    54  // new
    55  // i F9: changed from var to func
    56  func F9(int) {}
    57  
    58  // both
    59  // OK, even though new S is incompatible with old S (see below)
    60  func F10(S) {}
    61  
    62  // old
    63  type S struct {
    64  	A int
    65  }
    66  
    67  // new
    68  type S struct {
    69  	// i S.A: changed from int to bool
    70  	A bool
    71  }