Skip to content

Commit 1729b59

Browse files
authored
Merge pull request #1188 from nevkontakte/generics2
Refactoring and readability improvements to function/method generation code
2 parents b35dce2 + ccda918 commit 1729b59

File tree

4 files changed

+435
-311
lines changed

4 files changed

+435
-311
lines changed

compiler/expressions.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (fc *funcContext) translateExpr(expr ast.Expr) *expression {
177177
}
178178

179179
case *ast.FuncLit:
180-
_, fun := translateFunction(e.Type, nil, e.Body, fc, exprType.(*types.Signature), fc.pkgCtx.FuncLitInfos[e], "")
180+
fun := fc.nestedFunctionContext(fc.pkgCtx.FuncLitInfos[e], exprType.(*types.Signature)).translateFunctionBody(e.Type, nil, e.Body, "")
181181
if len(fc.pkgCtx.escapingVars) != 0 {
182182
names := make([]string, 0, len(fc.pkgCtx.escapingVars))
183183
for obj := range fc.pkgCtx.escapingVars {
@@ -691,10 +691,7 @@ func (fc *funcContext) translateExpr(expr ast.Expr) *expression {
691691
}
692692
}
693693

694-
methodName := sel.Obj().Name()
695-
if reservedKeywords[methodName] {
696-
methodName += "$"
697-
}
694+
methodName := fc.methodName(sel.Obj().(*types.Func))
698695
return fc.translateCall(e, sig, fc.formatExpr("%s.%s", recv, methodName))
699696

700697
case types.FieldVal:

0 commit comments

Comments
 (0)