Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public static NameLink lookupMemberVar(Element node, WurstType receiverType, Str
}

if (receiverType instanceof WurstTypeClassOrInterface ct) {
Collection<DefLink> typeNameLinks = ct.nameLinks().get(name);
Collection<DefLink> typeNameLinks = ct.nameLinks(name);
DefLinkMatch candidate = findBestMemberVarMatch(typeNameLinks, receiverType, node, showErrors);
if (candidate != null && candidate.link.getVisibility().isPublic()) {
return candidate.link;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.peeeq.wurstscript.types;

import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Lists;
import de.peeeq.wurstscript.ast.*;
Expand Down Expand Up @@ -214,8 +215,21 @@ public ImmutableMultimap<String, DefLink> nameLinks() {
return res;
}

/**
* The links of one name, what {@code nameLinks().get(name)} holds: only they are bound to the type arguments,
* not every name of the class, which a member lookup on a generic type did for each lookup.
*/
public ImmutableCollection<DefLink> nameLinks(String name) {
return nameLinks().get(name);
ImmutableCollection<DefLink> links = getDef().attrNameLinks().get(name);
VariableBinding binding = getTypeArgBinding();
if (binding.isEmpty() || links.isEmpty()) {
return links;
}
ImmutableList.Builder<DefLink> bound = ImmutableList.builderWithExpectedSize(links.size());
for (DefLink link : links) {
bound.add(link.withTypeArgBinding(getDef(), binding));
}
return bound.build();
}

@Override
Expand Down
Loading