Skip to content

Commit fc08063

Browse files
committed
fix broken tests
1 parent 87171e7 commit fc08063

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ jobs:
9696
shell: bash
9797
run: ./gradlew test --no-daemon --stacktrace
9898

99+
- name: Report test results
100+
if: always()
101+
uses: mikepenz/action-junit-report@v4
102+
with:
103+
report_paths: de.peeeq.wurstscript/build/test-results/**/*.xml
104+
check_name: Test Results (${{ matrix.os }})
105+
fail_on_failure: false
106+
99107
- name: Upload packaged artifact (per-OS)
100108
uses: actions/upload-artifact@v4
101109
with:

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/types/FunctionSignature.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,18 @@ public static List<String> getParamNames(WParameters parameters) {
118118

119119
public static FunctionSignature fromNameLink(FuncLink f) {
120120
VariableBinding mapping = f.getVariableBinding();
121-
// Only add the function definition's own type parameters as type variables
122-
// for inference. Enclosing structure type params (from class/module) are
123-
// resolved through receiver type matching, not argument inference.
124121
FunctionDefinition def = f.getDef();
122+
// Only add the function's own type params that are still unbound (i.e., still in
123+
// f.getTypeParams() — withTypeArgBinding removes them as they get resolved).
124+
// We must NOT add enclosing structure (module/class) type params, which would
125+
// appear as spurious unbound inference variables.
125126
if (def instanceof AstElementWithTypeParameters) {
126-
mapping = mapping.withTypeVariables(((AstElementWithTypeParameters) def).getTypeParameters());
127+
java.util.Set<TypeParamDef> ownParams = new java.util.HashSet<>(
128+
((AstElementWithTypeParameters) def).getTypeParameters());
129+
List<TypeParamDef> unboundOwn = f.getTypeParams().stream()
130+
.filter(ownParams::contains)
131+
.collect(Collectors.toList());
132+
mapping = mapping.withTypeVariables(unboundOwn);
127133
}
128134
return new FunctionSignature(def, mapping, f.getReceiverType(), f.getName(), f.getParameterTypes(), getParamNames(def.getParameters()), f.getReturnType());
129135
}

de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/GenericsModuleTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public void genericModuleFunctionWithOwnTypeParam() {
6464
" use M<int>",
6565
" init",
6666
" C c = new C",
67-
" string r = c.map(\"hello\")",
68-
" if r == \"hello\"",
67+
" int r = c.map(42)",
68+
" if r == 42",
6969
" testSuccess()",
7070
"endpackage"
7171
);

0 commit comments

Comments
 (0)