Fix generic type constraint stubbing on overrides

This commit is contained in:
Tamas Vajk
2021-04-16 14:05:39 +02:00
parent ff4db5b8d2
commit 8cbdd30e1e

View File

@@ -433,10 +433,22 @@ private string stubConstraints(TypeParameterConstraints tpc) {
}
private string stubTypeParameterConstraints(TypeParameter tp) {
exists(TypeParameterConstraints tpc | tpc = tp.getConstraints() |
result =
" where " + tp.getName() + ": " + strictconcat(string s | s = stubConstraints(tpc) | s, ", ")
)
if
tp.getDeclaringGeneric().(Virtualizable).isOverride() or
tp.getDeclaringGeneric().(Virtualizable).implementsExplicitInterface()
then
if tp.getConstraints().hasValueTypeConstraint()
then result = " where " + tp.getName() + ": struct"
else
if tp.getConstraints().hasRefTypeConstraint()
then result = " where " + tp.getName() + ": class"
else result = ""
else
exists(TypeParameterConstraints tpc | tpc = tp.getConstraints() |
result =
" where " + tp.getName() + ": " +
strictconcat(string s | s = stubConstraints(tpc) | s, ", ")
)
}
private string stubTypeParametersConstraints(Declaration d) {