Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5ac4a1a

Browse files
make ast.Node return *nature.Nature (#849)
1 parent 3d0aec6 commit 5ac4a1a

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

‎ast/node.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var (
1515
type Node interface {
1616
Location() file.Location
1717
SetLocation(file.Location)
18-
Nature() nature.Nature
18+
Nature() *nature.Nature
1919
SetNature(nature.Nature)
2020
Type() reflect.Type
2121
SetType(reflect.Type)
@@ -47,8 +47,8 @@ func (n *base) SetLocation(loc file.Location) {
4747
}
4848

4949
// Nature returns the nature of the node.
50-
func (n *base) Nature() nature.Nature {
51-
return n.nature
50+
func (n *base) Nature() *nature.Nature {
51+
return &n.nature
5252
}
5353

5454
// SetNature sets the nature of the node.

‎checker/checker.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,7 @@ func (v *Checker) callNode(node *ast.CallNode) Nature {
635635
// checker pass we should replace anyType on method node
636636
// with new correct function return type.
637637
if typ := node.Type(); typ != nil && typ != anyType {
638-
nt := node.Nature()
639-
return nt
638+
return *node.Nature()
640639
}
641640

642641
nt := v.visit(node.Callee)

‎checker/info.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ func FieldIndex(c *Cache, env Nature, node ast.Node) (bool, []int, string) {
1515
return true, idx, n.Value
1616
}
1717
case *ast.MemberNode:
18-
base := n.Node.Nature()
19-
base = base.Deref(c)
18+
base := n.Node.Nature().Deref(c)
2019
if base.Kind == reflect.Struct {
2120
if prop, ok := n.Property.(*ast.StringNode); ok {
2221
if idx, ok := base.FieldIndex(c, prop.Value); ok {

‎compiler/compiler.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,7 @@ func (c *compiler) BuiltinNode(node *ast.BuiltinNode) {
10881088
for i, arg := range node.Arguments {
10891089
c.compile(arg)
10901090
argType := arg.Type()
1091-
argNature := arg.Nature()
1092-
if argType.Kind() == reflect.Ptr || argNature.IsUnknown(c.ntCache) {
1091+
if argType.Kind() == reflect.Ptr || arg.Nature().IsUnknown(c.ntCache) {
10931092
if f.Deref == nil {
10941093
// By default, builtins expect arguments to be dereferenced.
10951094
c.emit(OpDeref)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /