all: rename `table.register_fn_generic_types` to `table.register_fn_concrete_types` (#9914)
parent
6945f987cf
commit
25d9272c84
|
@ -909,7 +909,7 @@ pub fn (t &Table) mktyp(typ Type) Type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut t Table) register_fn_generic_types(fn_name string, types []Type) {
|
pub fn (mut t Table) register_fn_concrete_types(fn_name string, types []Type) {
|
||||||
mut a := t.fn_generic_types[fn_name]
|
mut a := t.fn_generic_types[fn_name]
|
||||||
if types in a {
|
if types in a {
|
||||||
return
|
return
|
||||||
|
|
|
@ -571,5 +571,5 @@ pub fn (mut c Checker) infer_fn_generic_types(f ast.Fn, mut call_expr ast.CallEx
|
||||||
inferred_types << typ
|
inferred_types << typ
|
||||||
call_expr.concrete_types << typ
|
call_expr.concrete_types << typ
|
||||||
}
|
}
|
||||||
c.table.register_fn_generic_types(f.name, inferred_types)
|
c.table.register_fn_concrete_types(f.name, inferred_types)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1527,7 +1527,7 @@ pub fn (mut c Checker) method_call(mut call_expr ast.CallExpr) ast.Type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if has_generic {
|
if has_generic {
|
||||||
c.table.register_fn_generic_types(call_expr.name, concrete_types)
|
c.table.register_fn_concrete_types(call_expr.name, concrete_types)
|
||||||
}
|
}
|
||||||
// TODO: remove this for actual methods, use only for compiler magic
|
// TODO: remove this for actual methods, use only for compiler magic
|
||||||
// FIXME: Argument count != 1 will break these
|
// FIXME: Argument count != 1 will break these
|
||||||
|
@ -1992,9 +1992,9 @@ pub fn (mut c Checker) fn_call(mut call_expr ast.CallExpr) ast.Type {
|
||||||
if has_generic {
|
if has_generic {
|
||||||
if c.mod != '' && !fn_name.starts_with('${c.mod}.') {
|
if c.mod != '' && !fn_name.starts_with('${c.mod}.') {
|
||||||
// Need to prepend the module when adding a generic type to a function
|
// Need to prepend the module when adding a generic type to a function
|
||||||
c.table.register_fn_generic_types(c.mod + '.' + fn_name, concrete_types)
|
c.table.register_fn_concrete_types(c.mod + '.' + fn_name, concrete_types)
|
||||||
} else {
|
} else {
|
||||||
c.table.register_fn_generic_types(fn_name, concrete_types)
|
c.table.register_fn_concrete_types(fn_name, concrete_types)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if fn_name == 'json.encode' {
|
if fn_name == 'json.encode' {
|
||||||
|
|
|
@ -43,10 +43,10 @@ pub fn (mut p Parser) call_expr(language ast.Language, mod string) ast.CallExpr
|
||||||
// In case of `foo<T>()`
|
// In case of `foo<T>()`
|
||||||
// T is unwrapped and registered in the checker.
|
// T is unwrapped and registered in the checker.
|
||||||
full_generic_fn_name := if fn_name.contains('.') { fn_name } else { p.prepend_mod(fn_name) }
|
full_generic_fn_name := if fn_name.contains('.') { fn_name } else { p.prepend_mod(fn_name) }
|
||||||
has_generic_generic := concrete_types.filter(it.has_flag(.generic)).len > 0
|
has_generic := concrete_types.filter(it.has_flag(.generic)).len > 0
|
||||||
if !has_generic_generic {
|
if !has_generic {
|
||||||
// will be added in checker
|
// will be added in checker
|
||||||
p.table.register_fn_generic_types(full_generic_fn_name, concrete_types)
|
p.table.register_fn_concrete_types(full_generic_fn_name, concrete_types)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.check(.lpar)
|
p.check(.lpar)
|
||||||
|
|
|
@ -2237,10 +2237,10 @@ fn (mut p Parser) dot_expr(left ast.Expr) ast.Expr {
|
||||||
concrete_list_pos = concrete_list_pos.extend(p.prev_tok.position())
|
concrete_list_pos = concrete_list_pos.extend(p.prev_tok.position())
|
||||||
// In case of `foo<T>()`
|
// In case of `foo<T>()`
|
||||||
// T is unwrapped and registered in the checker.
|
// T is unwrapped and registered in the checker.
|
||||||
has_generic_generic := concrete_types.filter(it.has_flag(.generic)).len > 0
|
has_generic := concrete_types.filter(it.has_flag(.generic)).len > 0
|
||||||
if !has_generic_generic {
|
if !has_generic {
|
||||||
// will be added in checker
|
// will be added in checker
|
||||||
p.table.register_fn_generic_types(field_name, concrete_types)
|
p.table.register_fn_concrete_types(field_name, concrete_types)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.tok.kind == .lpar {
|
if p.tok.kind == .lpar {
|
||||||
|
|
Loading…
Reference in New Issue