1
1
// This file is split into two packages, old and new.
2
2
// It is syntactically valid Go so that gofmt can process it.
3
3
//
4
- // If a comment begins with: Then:
5
- // old write subsequent lines to the "old" package
6
- // new write subsequent lines to the "new" package
7
- // both write subsequent lines to both packages
8
- // c expect a compatible error with the following text
9
- // i expect an incompatible error with the following text
4
+ // If a comment begins with: Then:
5
+ // old write subsequent lines to the "old" package
6
+ // new write subsequent lines to the "new" package
7
+ // both write subsequent lines to both packages
8
+ // c expect a compatible error with the following text
9
+ // i expect an incompatible error with the following text
10
10
package ignore
11
11
12
12
// both
13
13
import "io"
14
14
15
15
//////////////// Basics
16
16
17
- //// Same type in both: OK.
17
+ // Same type in both: OK.
18
18
// both
19
19
type A int
20
20
21
- //// Changing the type is an incompatible change.
21
+ // Changing the type is an incompatible change.
22
22
// old
23
23
type B int
24
24
25
25
// new
26
26
// i B: changed from int to string
27
27
type B string
28
28
29
- //// Adding a new type, whether alias or not, is a compatible change.
29
+ // Adding a new type, whether alias or not, is a compatible change.
30
30
// new
31
31
// c AA: added
32
32
type AA = A
33
33
34
34
// c B1: added
35
35
type B1 bool
36
36
37
- //// Change of type for an unexported name doesn't matter...
37
+ // Change of type for an unexported name doesn't matter...
38
38
// old
39
39
type t int
40
40
41
41
// new
42
42
type t string // OK: t isn't part of the API
43
43
44
- //// ...unless it is exposed.
44
+ // ...unless it is exposed.
45
45
// both
46
46
var V2 u
47
47
@@ -52,7 +52,7 @@ type u string
52
52
// i u: changed from string to int
53
53
type u int
54
54
55
- //// An exposed, unexported type can be renamed.
55
+ // An exposed, unexported type can be renamed.
56
56
// both
57
57
type u2 int
58
58
@@ -64,7 +64,7 @@ var V5 u1
64
64
// new
65
65
var V5 u2 // OK: V5 has changed type, but old u1 corresopnds to new u2
66
66
67
- //// Splitting a single type into two is an incompatible change.
67
+ // Splitting a single type into two is an incompatible change.
68
68
// both
69
69
type u3 int
70
70
83
83
Split2 = u3
84
84
)
85
85
86
- //// Merging two types into one is OK.
86
+ // Merging two types into one is OK.
87
87
// old
88
88
type (
89
89
GoodMerge1 = u2
96
96
GoodMerge2 = u3
97
97
)
98
98
99
- //// Merging isn't OK here because a method is lost.
99
+ // Merging isn't OK here because a method is lost.
100
100
// both
101
101
type u4 int
102
102
@@ -125,7 +125,7 @@ type Rem int
125
125
126
126
//////////////// Constants
127
127
128
- //// type changes
128
+ // type changes
129
129
// old
130
130
const (
131
131
C1 = 1
@@ -172,7 +172,7 @@ const (
172
172
173
173
//////////////// Variables
174
174
175
- //// simple type changes
175
+ // simple type changes
176
176
// old
177
177
var (
178
178
V1 string
@@ -189,7 +189,7 @@ var (
189
189
V7 chan int
190
190
)
191
191
192
- //// interface type changes
192
+ // interface type changes
193
193
// old
194
194
var (
195
195
V9 interface { M () }
@@ -210,7 +210,7 @@ var (
210
210
V11 interface { M (int ) }
211
211
)
212
212
213
- //// struct type changes
213
+ // struct type changes
214
214
// old
215
215
var (
216
216
VS1 struct { A , B int }
@@ -413,7 +413,8 @@ type I5 = io.Writer
413
413
// i I5: changed from io.Writer to I5
414
414
// In old, I5 and io.Writer are the same type; in new,
415
415
// they are different. That can break something like:
416
- // var _ func(io.Writer) = func(pkg.I6) {}
416
+ //
417
+ // var _ func(io.Writer) = func(pkg.I6) {}
417
418
type I5 io.Writer
418
419
419
420
// old
@@ -471,7 +472,9 @@ type t4 int
471
472
472
473
// i VT4: changed from int to t4
473
474
// This is incompatible because of code like
474
- // VT4 + int(1)
475
+ //
476
+ // VT4 + int(1)
477
+ //
475
478
// which works in old but fails in new.
476
479
// The difference from the above cases is that
477
480
// in those, we were merging two types into one;
@@ -627,7 +630,7 @@ type S4 struct {
627
630
* S4 // OK: same (recursive embedding)
628
631
}
629
632
630
- //// Difference between exported selectable fields and exported immediate fields.
633
+ // Difference between exported selectable fields and exported immediate fields.
631
634
// both
632
635
type S5 struct { A int }
633
636
@@ -648,7 +651,7 @@ type S6 struct {
648
651
S5
649
652
}
650
653
651
- //// Ambiguous fields can exist; they just can't be selected.
654
+ // Ambiguous fields can exist; they just can't be selected.
652
655
// both
653
656
type (
654
657
embed7a struct { E int }
@@ -870,7 +873,7 @@ type H interface {
870
873
871
874
//// Splitting types
872
875
873
- //// OK: in both old and new, {J1, K1, L1} name the same type.
876
+ // OK: in both old and new, {J1, K1, L1} name the same type.
874
877
// old
875
878
type (
876
879
J1 = K1
@@ -885,7 +888,7 @@ type (
885
888
L1 = J1
886
889
)
887
890
888
- //// Old has one type, K2; new has J2 and K2.
891
+ // Old has one type, K2; new has J2 and K2.
889
892
// both
890
893
type K2 int
891
894
0 commit comments