Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 247f185

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Handle importing and inheriting the same name.
Belonging to [master]: - #2903
1 parent 852d89e commit 247f185

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Compiler/NFFrontEnd/NFClassTree.mo

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ public
8181
input Entry entry2;
8282
output Boolean isEqual = index(entry1) == index(entry2);
8383
end isEqual;
84+
85+
function isImport
86+
input Entry entry;
87+
output Boolean isImport;
88+
algorithm
89+
isImport := match entry
90+
case IMPORT() then true;
91+
else false;
92+
end match;
93+
end isImport;
8494
end Entry;
8595

8696
import BaseAvlTree;
@@ -1763,6 +1773,13 @@ public
17631773
Integer old_id = LookupTree.Entry.index(oldEntry);
17641774
DuplicateTree.EntryType ty;
17651775
algorithm
1776+
// Overwrite the existing entry if it's an import. This happens when a
1777+
// class both imports and inherits the same name.
1778+
if LookupTree.Entry.isImport(oldEntry) then
1779+
entry := newEntry;
1780+
return;
1781+
end if;
1782+
17661783
dups := Mutable.access(duplicates);
17671784
opt_dup_entry := DuplicateTree.getOpt(dups, name);
17681785

0 commit comments

Comments
 (0)