hasThis reports whether a method has an implicit "this" parameter.
(sName string, m *types.Func)
| 392 | |
| 393 | // hasThis reports whether a method has an implicit "this" parameter. |
| 394 | func (g *JavaGen) hasThis(sName string, m *types.Func) bool { |
| 395 | sig := m.Type().(*types.Signature) |
| 396 | params := sig.Params() |
| 397 | if params.Len() == 0 { |
| 398 | return false |
| 399 | } |
| 400 | v := params.At(0) |
| 401 | if v.Name() != "this" { |
| 402 | return false |
| 403 | } |
| 404 | t, ok := v.Type().(*types.Named) |
| 405 | if !ok { |
| 406 | return false |
| 407 | } |
| 408 | obj := t.Obj() |
| 409 | pkg := obj.Pkg() |
| 410 | if pkgFirstElem(pkg) != "Java" { |
| 411 | return false |
| 412 | } |
| 413 | clsName := classNameFor(t) |
| 414 | exp := g.javaPkgName(g.Pkg) + "." + sName |
| 415 | if clsName != exp { |
| 416 | g.errorf("the type %s of the `this` argument to method %s.%s is not %s", clsName, sName, m.Name(), exp) |
| 417 | return false |
| 418 | } |
| 419 | return true |
| 420 | } |
| 421 | |
| 422 | func (g *JavaGen) genConstructor(f *types.Func, n string, jcls bool) { |
| 423 | g.javadoc(g.docs[f.Name()].Doc()) |
no test coverage detected