Skip to content

Commit

Permalink
[NF] Handle importing and inheriting the same name.
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - OpenModelica/OMCompiler#2903
  • Loading branch information
perost authored and OpenModelica-Hudson committed Jan 28, 2019
1 parent 852d89e commit 247f185
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Compiler/NFFrontEnd/NFClassTree.mo
Expand Up @@ -81,6 +81,16 @@ public
input Entry entry2;
output Boolean isEqual = index(entry1) == index(entry2);
end isEqual;

function isImport
input Entry entry;
output Boolean isImport;
algorithm
isImport := match entry
case IMPORT() then true;
else false;
end match;
end isImport;
end Entry;

import BaseAvlTree;
Expand Down Expand Up @@ -1763,6 +1773,13 @@ public
Integer old_id = LookupTree.Entry.index(oldEntry);
DuplicateTree.EntryType ty;
algorithm
// Overwrite the existing entry if it's an import. This happens when a
// class both imports and inherits the same name.
if LookupTree.Entry.isImport(oldEntry) then
entry := newEntry;
return;
end if;

dups := Mutable.access(duplicates);
opt_dup_entry := DuplicateTree.getOpt(dups, name);

Expand Down

0 comments on commit 247f185

Please sign in to comment.