Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 845a222

Browse files
Denys Smirnovdennwc
authored andcommitted
fix secondary receiver annotation
Signed-off-by: Denys Smirnov <denys@sourced.tech>
1 parent 448977a commit 845a222

3 files changed

Lines changed: 212 additions & 182 deletions

File tree

Gopkg.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

driver/normalizer/normalizer.go

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ var Normalizers = []Mapping{
148148
"varargs": Cases("varg", String("false"), String("true")),
149149
"varargsAnnotations": Is(nil),
150150
}),
151-
"receiverQualifier": Is(nil), // FIXME: handle receiver
152-
"receiverType": Is(nil),
151+
"receiverQualifier": Var("recv_name"),
152+
"receiverType": Cases("recv",
153+
Is(nil),
154+
Check(NotNil(), Var("recv_type")),
155+
),
153156
"returnType2": Cases("out_case",
154157
// no return type (constructor)
155158
Is(nil),
@@ -185,13 +188,19 @@ var Normalizers = []Mapping{
185188
"Name": Var("name"),
186189
"Node": UASTType(uast.Function{}, Obj{
187190
"Type": UASTType(uast.FunctionType{}, Obj{
188-
"Arguments": Each("args", UASTType(uast.Argument{}, Obj{
189-
uast.KeyPos: Var("apos"),
190-
"Name": Var("aname"),
191-
"Type": Var("atype"),
192-
"Init": Var("ainit"),
193-
"Variadic": Cases("varg", Bool(false), Bool(true)),
194-
})),
191+
"Arguments": Cases("recv",
192+
// default receiver
193+
argsPart,
194+
// additional receiver
195+
PrependOne(
196+
UASTType(uast.Argument{}, Obj{
197+
"Name": Var("recv_name"),
198+
"Type": Var("recv_type"),
199+
"Receiver": Bool(true),
200+
}),
201+
argsPart,
202+
),
203+
),
195204
"Returns": Cases("out_case",
196205
// no return (constructor)
197206
Is(nil),
@@ -217,3 +226,11 @@ var Normalizers = []Mapping{
217226
},
218227
)),
219228
}
229+
230+
var argsPart = Each("args", UASTType(uast.Argument{}, Obj{
231+
uast.KeyPos: Var("apos"),
232+
"Name": Var("aname"),
233+
"Type": Var("atype"),
234+
"Init": Var("ainit"),
235+
"Variadic": Cases("varg", Bool(false), Bool(true)),
236+
}))

0 commit comments

Comments
 (0)