Skip to content

Commit 5d41865

Browse files
committed
Preserve implicit generic reachability
1 parent cdc2a90 commit 5d41865

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtranslation/EliminateGenerics.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -881,10 +881,14 @@ public void visit(ImAlloc alloc) {
881881

882882
@Override
883883
public void visit(ImFunctionCall call) {
884-
boolean dependsOnTypeVariable = typeArgumentsContainTypeVariable(call.getTypeArguments());
884+
// Empty arguments may be supplied implicitly by the enclosing generic receiver.
885+
// Only an explicit, already-concrete call is independent of the caller context.
886+
boolean dependsOnCaller = call.getTypeArguments().isEmpty()
887+
|| typeArgumentsContainTypeVariable(call.getTypeArguments());
885888
if (constructsClassOwningGenericGlobals(function, call)
886-
|| (dependsOnTypeVariable && (translator.isGenericNewMarker(call.getFunc())
887-
|| functionNeedsSpecialization(call.getFunc(), visitedFunctions, visitedMethods)))) {
889+
|| translator.isGenericNewMarker(call.getFunc())
890+
|| (dependsOnCaller
891+
&& functionNeedsSpecialization(call.getFunc(), visitedFunctions, visitedMethods))) {
888892
found[0] = true;
889893
return;
890894
}
@@ -893,7 +897,9 @@ public void visit(ImFunctionCall call) {
893897

894898
@Override
895899
public void visit(ImMethodCall call) {
896-
if (typeArgumentsContainTypeVariable(call.getTypeArguments())
900+
boolean dependsOnCaller = call.getTypeArguments().isEmpty()
901+
|| typeArgumentsContainTypeVariable(call.getTypeArguments());
902+
if (dependsOnCaller
897903
&& methodNeedsSpecialization(call.getMethod(), visitedFunctions, visitedMethods)) {
898904
found[0] = true;
899905
return;

0 commit comments

Comments
 (0)