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

     1  package p
     2  
     3  // old
     4  type SM struct {
     5  	embedm
     6  	Embedm
     7  }
     8  
     9  func (SM) V1() {}
    10  func (SM) V2() {}
    11  func (SM) V3() {}
    12  func (SM) V4() {}
    13  func (SM) v()  {}
    14  
    15  func (*SM) P1() {}
    16  func (*SM) P2() {}
    17  func (*SM) P3() {}
    18  func (*SM) P4() {}
    19  func (*SM) p()  {}
    20  
    21  type embedm int
    22  
    23  func (embedm) EV1()  {}
    24  func (embedm) EV2()  {}
    25  func (embedm) EV3()  {}
    26  func (*embedm) EP1() {}
    27  func (*embedm) EP2() {}
    28  func (*embedm) EP3() {}
    29  
    30  type Embedm struct {
    31  	A int
    32  }
    33  
    34  func (Embedm) FV()  {}
    35  func (*Embedm) FP() {}
    36  
    37  type RepeatEmbedm struct {
    38  	Embedm
    39  }
    40  
    41  // new
    42  type SM struct {
    43  	embedm2
    44  	embedm3
    45  	Embedm
    46  	// i SM.A: changed from int to bool
    47  }
    48  
    49  // c SMa: added
    50  type SMa = SM
    51  
    52  func (SM) V1() {} // OK: same
    53  
    54  // func (SM) V2() {}
    55  // i SM.V2: removed
    56  
    57  // i SM.V3: changed from func() to func(int)
    58  func (SM) V3(int) {}
    59  
    60  // c SM.V5: added
    61  func (SM) V5() {}
    62  
    63  func (SM) v(int) {} // OK: unexported method change
    64  func (SM) v2()   {} // OK: unexported method added
    65  
    66  func (*SM) P1() {} // OK: same
    67  //func (*SM) P2() {}
    68  // i (*SM).P2: removed
    69  
    70  // i (*SM).P3: changed from func() to func(int)
    71  func (*SMa) P3(int) {}
    72  
    73  // c (*SM).P5: added
    74  func (*SM) P5() {}
    75  
    76  // func (*SM) p() {}  // OK: unexported method removed
    77  
    78  // Changing from a value to a pointer receiver or vice versa
    79  // just looks like adding and removing a method.
    80  
    81  // i SM.V4: removed
    82  // i (*SM).V4: changed from func() to func(int)
    83  func (*SM) V4(int) {}
    84  
    85  // c SM.P4: added
    86  // P4 is not removed from (*SM) because value methods
    87  // are in the pointer method set.
    88  func (SM) P4() {}
    89  
    90  type embedm2 int
    91  
    92  // i embedm.EV1: changed from func() to func(int)
    93  func (embedm2) EV1(int) {}
    94  
    95  // i embedm.EV2, method set of SM: removed
    96  // i embedm.EV2, method set of *SM: removed
    97  
    98  // i (*embedm).EP2, method set of *SM: removed
    99  func (*embedm2) EP1() {}
   100  
   101  type embedm3 int
   102  
   103  func (embedm3) EV3()  {} // OK: compatible with old embedm.EV3
   104  func (*embedm3) EP3() {} // OK: compatible with old (*embedm).EP3
   105  
   106  type Embedm struct {
   107  	// i Embedm.A: changed from int to bool
   108  	A bool
   109  }
   110  
   111  // i Embedm.FV: changed from func() to func(int)
   112  func (Embedm) FV(int) {}
   113  func (*Embedm) FP()   {}
   114  
   115  type RepeatEmbedm struct {
   116  	// i RepeatEmbedm.A: changed from int to bool
   117  	Embedm
   118  }