@@ -12,16 +12,17 @@ var (
12
12
)
13
13
14
14
type Nature struct {
15
- Type reflect.Type // Type of the value. If nil, then value is unknown.
16
- Func * builtin.Function // Used to pass function type from callee to CallNode.
17
- ArrayOf * Nature // Elem nature of array type (usually Type is []any, but ArrayOf can be any nature).
18
- PredicateOut * Nature // Out nature of predicate.
19
- Fields map [string ]Nature // Fields of map type.
20
- Strict bool // If map is types.StrictMap.
21
- Nil bool // If value is nil.
22
- Method bool // If value retrieved from method. Usually used to determine amount of in arguments.
23
- MethodIndex int // Index of method in type.
24
- FieldIndex []int // Index of field in type.
15
+ Type reflect.Type // Type of the value. If nil, then value is unknown.
16
+ Func * builtin.Function // Used to pass function type from callee to CallNode.
17
+ ArrayOf * Nature // Elem nature of array type (usually Type is []any, but ArrayOf can be any nature).
18
+ PredicateOut * Nature // Out nature of predicate.
19
+ Fields map [string ]Nature // Fields of map type.
20
+ DefaultMapValue * Nature // Default value of map type.
21
+ Strict bool // If map is types.StrictMap.
22
+ Nil bool // If value is nil.
23
+ Method bool // If value retrieved from method. Usually used to determine amount of in arguments.
24
+ MethodIndex int // Index of method in type.
25
+ FieldIndex []int // Index of field in type.
25
26
}
26
27
27
28
func (n Nature ) String () string {
@@ -54,7 +55,12 @@ func (n Nature) Key() Nature {
54
55
55
56
func (n Nature ) Elem () Nature {
56
57
switch n .Kind () {
57
- case reflect .Map , reflect .Ptr :
58
+ case reflect .Ptr :
59
+ return Nature {Type : n .Type .Elem ()}
60
+ case reflect .Map :
61
+ if n .DefaultMapValue != nil {
62
+ return * n .DefaultMapValue
63
+ }
58
64
return Nature {Type : n .Type .Elem ()}
59
65
case reflect .Array , reflect .Slice :
60
66
if n .ArrayOf != nil {
0 commit comments