Skip to content
← Back

src/semantic/symbols/duplicate_method_checker.ghul

1
namespace Semantic is
2
use IO.Std;
3
4
use Collections.Iterable;
5
use Collections.Iterator;
6
7
use Collections.SET;
8
9
use Pair = Collections.KeyValuePair;
10
11
use Symbols.Symbol;
12
use Symbols.Scope;
13
use Symbols.Function;
14
use Symbols.FUNCTION_GROUP;
15
16
use Types.Type;
17
18
use Ghul.Pipes;
19
20
class DUPLICATE_METHOD_CHECKER is
21
_logger: Logging.Logger;
22
23
init(logger: Logging.Logger) is
24
_logger = logger;
25
si
26
27
check(scope: Scope, message: string) is
28
for function_group in scope.symbols |> filter(s => s.is_function_group) |> map(f => cast Symbols.FUNCTION_GROUP?(f)!) do
29
check(function_group.name, function_group.functions |> filter(f => f.is_instance), message);
30
check(function_group.name, function_group.functions |> filter(f => !f.is_instance), message);
31
od
32
si
33
34
check(name: string, functions: Iterable[Function], message: string) is
35
let map = METHOD_OVERRIDE_MAP(name);
36
37
map.add(functions);
38
39
for s in map do
40
if s.count > 1 then
41
for function in s.iterable |> filter(s => !s.is_internal) do
42
_logger.error(function.location, message);
43
od
44
fi
45
od
46
si
47
si
48
si