@@ -12,16 +12,17 @@ var (
1212)
1313
1414type 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.
2526}
2627
2728func (n Nature ) String () string {
@@ -54,7 +55,12 @@ func (n Nature) Key() Nature {
5455
5556func (n Nature ) Elem () Nature {
5657 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+ }
5864 return Nature {Type : n .Type .Elem ()}
5965 case reflect .Array , reflect .Slice :
6066 if n .ArrayOf != nil {
0 commit comments