lang: funcs: Use more constants to build types
This commit is contained in:
@@ -348,7 +348,7 @@ func (obj *ContainsPolyFunc) Info() *interfaces.Info {
|
||||
var sig *types.Type
|
||||
if obj.Type != nil { // don't panic if called speculatively
|
||||
s := obj.Type.String()
|
||||
sig = types.NewType(fmt.Sprintf("func(needle %s, haystack []%s) bool", s, s))
|
||||
sig = types.NewType(fmt.Sprintf("func(%s %s, %s []%s) bool", containsArgNameNeedle, s, containsArgNameHaystack, s))
|
||||
}
|
||||
return &interfaces.Info{
|
||||
Pure: true,
|
||||
|
||||
@@ -500,9 +500,9 @@ func (obj *SchedulePolyFunc) Info() *interfaces.Info {
|
||||
// before you're built. Type unification may call it opportunistically.
|
||||
var typ *types.Type
|
||||
if obj.built {
|
||||
typ = types.NewType("func(namespace str) []str") // simplest form
|
||||
typ = types.NewType(fmt.Sprintf("func(%s str) []str", scheduleArgNameNamespace)) // simplest form
|
||||
if obj.Type != nil {
|
||||
typ = types.NewType(fmt.Sprintf("func(namespace str, opts %s) []str", obj.Type.String()))
|
||||
typ = types.NewType(fmt.Sprintf("func(%s str, %s %s) []str", scheduleArgNameNamespace, scheduleArgNameOpts, obj.Type.String()))
|
||||
}
|
||||
}
|
||||
return &interfaces.Info{
|
||||
|
||||
@@ -345,7 +345,7 @@ func (obj *HistoryFunc) Info() *interfaces.Info {
|
||||
var sig *types.Type
|
||||
if obj.Type != nil { // don't panic if called speculatively
|
||||
s := obj.Type.String()
|
||||
sig = types.NewType(fmt.Sprintf("func(value %s, index int) %s", s, s))
|
||||
sig = types.NewType(fmt.Sprintf("func(%s %s, %s int) %s", historyArgNameValue, s, historyArgNameIndex, s))
|
||||
}
|
||||
return &interfaces.Info{
|
||||
Pure: false, // definitely false
|
||||
|
||||
@@ -534,7 +534,7 @@ func (obj *MapLookupPolyFunc) Info() *interfaces.Info {
|
||||
// TODO: can obj.Type.Key or obj.Type.Val be nil (a partial) ?
|
||||
k := obj.Type.Key.String()
|
||||
v := obj.Type.Val.String()
|
||||
typ = types.NewType(fmt.Sprintf("func(map %s, key %s, default %s) %s", obj.Type.String(), k, v, v))
|
||||
typ = types.NewType(fmt.Sprintf("func(%s %s, %s %s, %s %s) %s", mapLookupArgNameMap, obj.Type.String(), mapLookupArgNameKey, k, mapLookupArgNameDef, v, v))
|
||||
}
|
||||
return &interfaces.Info{
|
||||
Pure: true,
|
||||
|
||||
@@ -459,7 +459,7 @@ func (obj *StructLookupPolyFunc) Info() *interfaces.Info {
|
||||
var sig *types.Type
|
||||
if obj.Type != nil { // don't panic if called speculatively
|
||||
// TODO: can obj.Out be nil (a partial) ?
|
||||
sig = types.NewType(fmt.Sprintf("func(struct %s, field str) %s", obj.Type.String(), obj.Out.String()))
|
||||
sig = types.NewType(fmt.Sprintf("func(%s %s, %s str) %s", structLookupArgNameStruct, obj.Type.String(), structLookupArgNameField, obj.Out.String()))
|
||||
}
|
||||
return &interfaces.Info{
|
||||
Pure: true,
|
||||
|
||||
Reference in New Issue
Block a user