C#: Handle non-unique type arguments when computing generics strings

This commit is contained in:
Tom Hvitved
2025-06-16 14:32:53 +02:00
parent 30ab9b7b84
commit a188adc09b
2 changed files with 8 additions and 2 deletions

View File

@@ -110,9 +110,12 @@ private string getTypeArgumentsToString(ConstructedGeneric cg) {
strictconcat(Type t, int i | t = cg.getTypeArgument(i) | t.toStringWithTypes(), ", " order by i)
}
language[monotonicAggregates]
pragma[nomagic]
private string getTypeArgumentName(ConstructedGeneric cg, int i) {
result = cg.getTypeArgument(i).getName()
// Normally, `cg.getTypeArgument(i)` will be unique, and in those cases the line below
// is simply the same as `result = cg.getTypeArgument(i).getName()`.
result = strictconcat(Type t | t = cg.getTypeArgument(i) | t.getName(), "/")
}
/** Gets the concatenation of the `getName()` of type arguments. */

View File

@@ -48,9 +48,12 @@ module QualifiedName<QualifiedNameInputSig Input> {
)
}
language[monotonicAggregates]
pragma[nomagic]
private string getTypeArgumentsQualifiedName(ConstructedGeneric cg, int i) {
result = getFullName(cg.getTypeArgument(i))
// Normally, `cg.getTypeArgument(i)` will be unique, and in those cases the line below
// is simply the same as `result = getFullName(cg.getTypeArgument(i))`.
result = strictconcat(Type t | t = cg.getTypeArgument(i) | getFullName(t), "/")
}
/** Gets the concatenation of the `getFullName` of type arguments. */