Debian Codegraph @

apidiff/testdata/basics.go

raw symbols SCIP
1 package p
2
3 // Same type in both: OK.
4 // both
5 type A int
6
7 // Changing the type is an incompatible change.
8 // old
9 type B int
10
11 // new
12 // i B: changed from int to string
13 type B string
14
15 // Adding a new type, whether alias or not, is a compatible change.
16 // new
17 // c AA: added
18 type AA = A
19
20 // c B1: added
21 type B1 bool
22
23 // Change of type for an unexported name doesn't matter...
24 // old
25 type t int
26
27 // new
28 type t string // OK: t isn't part of the API
29
30 // ...unless it is exposed.
31 // both
32 var V2 u
33
34 // old
35 type u string
36
37 // new
38 // i u: changed from string to int
39 type u int
40
41 // An exposed, unexported type can be renamed.
42 // both
43 type u2 int
44
45 // old
46 type u1 int
47
48 var V5 u1
49
50 // new
51 var V5 u2 // OK: V5 has changed type, but old u1 corresponds to new u2
52
53 // Splitting a single type into two is an incompatible change.
54 // both
55 type u3 int
56
57 // old
58 type (
59 Split1 = u1
60 Split2 = u1
61 )
62
63 // new
64 type (
65 Split1 = u2 // OK, since old u1 corresponds to new u2
66
67 // This tries to make u1 correspond to u3
68 // i Split2: changed from u1 to u3
69 Split2 = u3
70 )
71
72 // Merging two types into one is OK.
73 // old
74 type (
75 GoodMerge1 = u2
76 GoodMerge2 = u3
77 )
78
79 // new
80 type (
81 GoodMerge1 = u3
82 GoodMerge2 = u3
83 )
84
85 // Merging isn't OK here because a method is lost.
86 // both
87 type u4 int
88
89 func (u4) M() {}
90
91 // old
92 type (
93 BadMerge1 = u3
94 BadMerge2 = u4
95 )
96
97 // new
98 type (
99 BadMerge1 = u3
100 // i u4.M: removed
101 // What's really happening here is that old u4 corresponds to new u3,
102 // and new u3's method set is not a superset of old u4's.
103 BadMerge2 = u3
104 )
105
106 // old
107 type Rem int
108
109 // new
110 // i Rem: removed