MCPcopy Create free account
hub / github.com/golang/mobile / hasThis

Method hasThis

bind/genjava.go:394–420  ·  view source on GitHub ↗

hasThis reports whether a method has an implicit "this" parameter.

(sName string, m *types.Func)

Source from the content-addressed store, hash-verified

392
393// hasThis reports whether a method has an implicit "this" parameter.
394func (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
422func (g *JavaGen) genConstructor(f *types.Func, n string, jcls bool) {
423 g.javadoc(g.docs[f.Name()].Doc())

Callers 2

genStructMethod · 0.95
GenCMethod · 0.95

Calls 6

javaPkgNameMethod · 0.95
pkgFirstElemFunction · 0.85
classNameForFunction · 0.85
TypeMethod · 0.80
LenMethod · 0.45
errorfMethod · 0.45

Tested by

no test coverage detected