mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 08:52:18 +01:00
Clean up tcheckDot
This commit is contained in:
1 parent
1255b162ea
commit
8b0c63df09
2 files changed
+25
-22
No files matched your search
@@ -134,8 +134,9 @@ func (c *Checker) resolveFunc(typ *a.TypeExpr) (*a.Func, error) {
|
|||||||
if typ.Decorator().Key() != t.KeyOpenParen {
|
if typ.Decorator().Key() != t.KeyOpenParen {
|
||||||
return nil, fmt.Errorf("check: resolveFunc cannot look up non-func TypeExpr %q", typ.Str(c.tm))
|
return nil, fmt.Errorf("check: resolveFunc cannot look up non-func TypeExpr %q", typ.Str(c.tm))
|
||||||
}
|
}
|
||||||
qid := t.QID{typ.Receiver().Name(), typ.Name()}
|
lTyp := typ.Receiver()
|
||||||
switch lTyp := typ.Receiver(); lTyp.Decorator().Key() {
|
qid := t.QID{lTyp.Name(), typ.Name()}
|
||||||
|
switch lTyp.Decorator().Key() {
|
||||||
case 0:
|
case 0:
|
||||||
if f, err := c.builtInFunc(qid); err != nil {
|
if f, err := c.builtInFunc(qid); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -147,6 +148,7 @@ func (c *Checker) resolveFunc(typ *a.TypeExpr) (*a.Func, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case t.KeyColon:
|
case t.KeyColon:
|
||||||
|
// lTyp is a slice.
|
||||||
qid[0] = t.IDDiamond
|
qid[0] = t.IDDiamond
|
||||||
if f, err := c.builtInSliceFunc(qid); err != nil {
|
if f, err := c.builtInSliceFunc(qid); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -155,6 +157,7 @@ func (c *Checker) resolveFunc(typ *a.TypeExpr) (*a.Func, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
// lTyp is from a used package: `use "foo"` followed by `foo.bar`.
|
||||||
u := c.usees[lTyp.Decorator()]
|
u := c.usees[lTyp.Decorator()]
|
||||||
if u == nil {
|
if u == nil {
|
||||||
return nil, fmt.Errorf("check: cannot resolve %q in type %q",
|
return nil, fmt.Errorf("check: cannot resolve %q in type %q",
|
||||||
|
|||||||
+20
-20
@@ -681,35 +681,35 @@ func (q *checker) tcheckDot(n *a.Expr, depth uint32) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
lTyp := lhs.MType().Pointee()
|
lTyp := lhs.MType().Pointee()
|
||||||
|
qid := t.QID{lTyp.Name(), n.ID1()}
|
||||||
|
switch lTyp.Decorator().Key() {
|
||||||
|
case 0:
|
||||||
|
// No-op.
|
||||||
|
|
||||||
if lTyp.Decorator() != 0 {
|
case t.KeyColon:
|
||||||
if lTyp.IsSliceType() {
|
// lTyp is a slice.
|
||||||
f, err := q.c.builtInSliceFunc(t.QID{t.IDDiamond, n.ID1()})
|
qid[0] = t.IDDiamond
|
||||||
if err != nil {
|
if f, err := q.c.builtInSliceFunc(qid); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
} else if f == nil {
|
||||||
if f == nil {
|
return fmt.Errorf("check: no slice method %q", n.ID1().Str(q.tm))
|
||||||
return fmt.Errorf("check: no slice method %q", n.ID1().Str(q.tm))
|
|
||||||
}
|
|
||||||
n.SetMType(a.NewTypeExpr(t.IDOpenParen, n.ID1(), lTyp.Node(), nil, nil))
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
n.SetMType(a.NewTypeExpr(t.IDOpenParen, n.ID1(), lTyp.Node(), nil, nil))
|
||||||
|
return nil
|
||||||
|
|
||||||
|
default:
|
||||||
// lTyp is from a used package: `use "foo"` followed by `foo.bar`.
|
// lTyp is from a used package: `use "foo"` followed by `foo.bar`.
|
||||||
u := q.c.usees[lTyp.Decorator()]
|
if u := q.c.usees[lTyp.Decorator()]; u == nil {
|
||||||
if u == nil {
|
|
||||||
return fmt.Errorf("check: cannot resolve %q in type %q for expression %q",
|
return fmt.Errorf("check: cannot resolve %q in type %q for expression %q",
|
||||||
lTyp.Decorator().Str(q.tm), lTyp.Str(q.tm), lhs.Str(q.tm))
|
lTyp.Decorator().Str(q.tm), lTyp.Str(q.tm), lhs.Str(q.tm))
|
||||||
|
} else if u.funcs[qid] == nil {
|
||||||
|
return fmt.Errorf("check: no method named %q found in type %q for expression %q",
|
||||||
|
n.ID1().Str(q.tm), lTyp.Str(q.tm), n.Str(q.tm))
|
||||||
}
|
}
|
||||||
if f := u.funcs[t.QID{lTyp.Name(), n.ID1()}]; f != nil {
|
n.SetMType(a.NewTypeExpr(t.IDOpenParen, n.ID1(), lTyp.Node(), nil, nil))
|
||||||
n.SetMType(a.NewTypeExpr(t.IDOpenParen, n.ID1(), lTyp.Node(), nil, nil))
|
return nil
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return fmt.Errorf("check: no method named %q found in type %q for expression %q",
|
|
||||||
n.ID1().Str(q.tm), lTyp.Str(q.tm), n.Str(q.tm))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qid := t.QID{lTyp.Name(), n.ID1()}
|
|
||||||
f, err := q.c.builtInFunc(qid)
|
f, err := q.c.builtInFunc(qid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in new issue
Block a user