@@ -117,7 +117,7 @@ private static <T extends NameLink> ImmutableCollection<T> removeDuplicates(List
117117
118118 public static ImmutableCollection <FuncLink > lookupMemberFuncs (Element node , WurstType receiverType , String name , boolean showErrors ) {
119119 if (!showErrors ) {
120- GlobalCaches .CacheKey key = new GlobalCaches .CacheKey (node , name + "@" + receiverType , GlobalCaches .LookupType .MEMBER_FUNC );
120+ GlobalCaches .CacheKey key = new GlobalCaches .CacheKey (node , name + "@" + receiverType . getFullName () , GlobalCaches .LookupType .MEMBER_FUNC );
121121 @ SuppressWarnings ("unchecked" )
122122 ImmutableCollection <FuncLink > cached = (ImmutableCollection <FuncLink >) GlobalCaches .lookupCache .get (key );
123123 if (cached != null ) {
@@ -155,7 +155,7 @@ public static ImmutableCollection<FuncLink> lookupMemberFuncs(Element node, Wurs
155155 ImmutableCollection <FuncLink > immutableResult = removeDuplicates (result );
156156
157157 if (!showErrors ) {
158- GlobalCaches .CacheKey key = new GlobalCaches .CacheKey (node , name + "@" + receiverType , GlobalCaches .LookupType .MEMBER_FUNC );
158+ GlobalCaches .CacheKey key = new GlobalCaches .CacheKey (node , name + "@" + receiverType . getFullName () , GlobalCaches .LookupType .MEMBER_FUNC );
159159 GlobalCaches .lookupCache .put (key , immutableResult );
160160 }
161161
@@ -252,7 +252,7 @@ public static NameLink lookupVarNoConfig(Element node, String name, boolean show
252252
253253 public static NameLink lookupMemberVar (Element node , WurstType receiverType , String name , boolean showErrors ) {
254254 if (!showErrors ) {
255- GlobalCaches .CacheKey key = new GlobalCaches .CacheKey (node , name + "@" + receiverType , GlobalCaches .LookupType .MEMBER_VAR );
255+ GlobalCaches .CacheKey key = new GlobalCaches .CacheKey (node , name + "@" + receiverType . getFullName () , GlobalCaches .LookupType .MEMBER_VAR );
256256 NameLink cached = (NameLink ) GlobalCaches .lookupCache .get (key );
257257 if (cached != null ) {
258258 return cached ;
@@ -286,7 +286,7 @@ public static NameLink lookupMemberVar(Element node, WurstType receiverType, Str
286286
287287 if (bestMatch != null ) {
288288 if (!showErrors ) {
289- GlobalCaches .CacheKey key = new GlobalCaches .CacheKey (node , name + "@" + receiverType , GlobalCaches .LookupType .MEMBER_VAR );
289+ GlobalCaches .CacheKey key = new GlobalCaches .CacheKey (node , name + "@" + receiverType . getFullName () , GlobalCaches .LookupType .MEMBER_VAR );
290290 GlobalCaches .lookupCache .put (key , bestMatch .link );
291291 }
292292 return bestMatch .link ;
@@ -413,13 +413,30 @@ private DefLinkMatch(DefLink link, int distance) {
413413
414414 public static DefLink matchDefLinkReceiver (DefLink n , WurstType receiverType , Element node , boolean showErrors ) {
415415 WurstType n_receiverType = n .getReceiverType ();
416- if (n_receiverType == null ) {
417- return null ;
418- }
419- VariableBinding mapping = receiverType .matchAgainstSupertype (n_receiverType , node , VariableBinding .emptyMapping ().withTypeVariables (n .getTypeParams ()), VariablePosition .RIGHT );
420- if (mapping == null ) {
421- return null ;
416+ if (n_receiverType == null ) return null ;
417+
418+ VariableBinding vb = VariableBinding .emptyMapping ();
419+
420+ // 1) include type params from the receiver type (class/interface/module instantiation)
421+ if (n_receiverType instanceof WurstTypeClassOrInterface wtc ) {
422+ if (wtc .getDef () instanceof AstElementWithTypeParameters tpOwner ) {
423+ vb = vb .withTypeVariables (tpOwner .getTypeParameters ());
424+ }
425+ } else if (n_receiverType instanceof WurstTypeModuleInstanciation mins ) {
426+ ClassDef cd = mins .getDef ().attrNearestClassDef ();
427+ if (cd != null ) {
428+ vb = vb .withTypeVariables (cd .getTypeParameters ());
429+ }
422430 }
431+
432+ // 2) include function/extension type params as before
433+ vb = vb .withTypeVariables (n .getTypeParams ());
434+
435+ VariableBinding mapping =
436+ receiverType .matchAgainstSupertype (n_receiverType , node , vb , VariablePosition .RIGHT );
437+
438+ if (mapping == null ) return null ;
439+
423440 if (showErrors ) {
424441 if (n .getVisibility () == Visibility .PRIVATE_OTHER ) {
425442 node .addError (Utils .printElement (n .getDef ()) + " is private and cannot be used here." );
0 commit comments