@@ -47,6 +47,76 @@ public void biggerModule() {
4747 );
4848 }
4949
50+ // Regression: FuncLink.create() was seeding the mapping with ALL visible type params
51+ // (including enclosing module/class type params), causing them to appear as unbound
52+ // inference variables on generic function calls. Only the function's own type params
53+ // should be seeded; module type params are resolved via receiver type matching.
54+ @ Test
55+ public void genericModuleFunctionWithOwnTypeParam () {
56+ testAssertOkLines (false ,
57+ "package test" ,
58+ " native testSuccess()" ,
59+ " module M<T>" ,
60+ " T value" ,
61+ " function map<S>(S s) returns S" ,
62+ " return s" ,
63+ " class C" ,
64+ " use M<int>" ,
65+ " init" ,
66+ " C c = new C" ,
67+ " string r = c.map(\" hello\" )" ,
68+ " if r == \" hello\" " ,
69+ " testSuccess()" ,
70+ "endpackage"
71+ );
72+ }
73+
74+ // Regression: FuncLink.withTypeArgBinding() only detected structural type changes,
75+ // missing the case where a type param is bound to itself (e.g. T→T in a generic class
76+ // using a generic module). The FuncLink was not updated, leaving stale type params.
77+ @ Test
78+ public void genericModuleInGenericClassGet () {
79+ testAssertOkLines (false ,
80+ "package test" ,
81+ " native testSuccess()" ,
82+ " module M<T>" ,
83+ " T value" ,
84+ " function get() returns T" ,
85+ " return value" ,
86+ " class C<S>" ,
87+ " use M<S>" ,
88+ " init" ,
89+ " C<int> c = new C<int>" ,
90+ " c.value = 42" ,
91+ " int v = c.get()" ,
92+ " if v == 42" ,
93+ " testSuccess()" ,
94+ "endpackage"
95+ );
96+ }
97+
98+ // Regression: static generic function in a generic module caused NPE due to
99+ // duplicate matchAgainstSupertype call passing potentially-null mapping to the
100+ // second call. FunctionSignature.fromNameLink also incorrectly added enclosing
101+ // module type params as inference variables.
102+ @ Test
103+ public void staticGenericFunctionInGenericModule () {
104+ testAssertOkLines (false ,
105+ "package test" ,
106+ " native testSuccess()" ,
107+ " module M<T>" ,
108+ " static function wrap<S>(S s) returns S" ,
109+ " return s" ,
110+ " class C" ,
111+ " use M<int>" ,
112+ " init" ,
113+ " int x = C.wrap(99)" ,
114+ " if x == 99" ,
115+ " testSuccess()" ,
116+ "endpackage"
117+ );
118+ }
119+
50120 @ Test
51121 public void genericInception () {
52122 testAssertOkLines (false ,
0 commit comments