static bool TypeMatches(FunctionDeclaration decl, NamedTypeSpec ts, SwiftGenericArgReferenceType genArg, TypeMapper typeMap) { if (genArg.HasAssociatedTypePath) { if (!decl.IsProtocolWithAssociatedTypesFullPath(ts, typeMap)) { return(false); } var parts = ts.Name.Split('.'); // parts will have the generic part at 0, genArg will not if (parts.Length != genArg.AssociatedTypePath.Count + 1) { return(false); } var depthAndIndex = decl.GetGenericDepthAndIndex(parts [0]); if (genArg.Depth != depthAndIndex.Item1 || genArg.Index != depthAndIndex.Item2) { return(false); } for (int i = 0; i < genArg.AssociatedTypePath.Count; i++) { if (genArg.AssociatedTypePath [i] != parts [i + 1]) { return(false); } } return(true); } else { if (!decl.IsTypeSpecGeneric(ts)) { return(false); } var depthAndIndex = decl.GetGenericDepthAndIndex(ts.Name); return(genArg.Depth == depthAndIndex.Item1 && genArg.Index == depthAndIndex.Item2); } }