This PR fixes #1392. In the following example, opaqueGenericParamaters was removing the T generic parameter because it appeared redundant / unused within the type definition. This behavior would have been correct if the constraint was something like where T == Int, but the constraint is actually important here since it's being constrained relative to a generic type from the parent scope.
public struct Ref<Value> {}
public extension Ref {
static func weak<Base: AnyObject, T>(
_: Base,
_: ReferenceWritableKeyPath<Base, Value>
) -> Ref<Value> where T? == Value {}
}
As a fix we can just avoid removing parameters that seem unused. If the generic type was truly redundant / unused (e.g. with a T == Int constraint) the compiler would give us a generic parameter 'T' is not used in function signature error, so we don't have to worry about supporting that sort of case.
This PR fixes #1392. In the following example,
opaqueGenericParamaters
was removing theT
generic parameter because it appeared redundant / unused within the type definition. This behavior would have been correct if the constraint was something likewhere T == Int
, but the constraint is actually important here since it's being constrained relative to a generic type from the parent scope.As a fix we can just avoid removing parameters that seem unused. If the generic type was truly redundant / unused (e.g. with a
T == Int
constraint) the compiler would give us ageneric parameter 'T' is not used in function signature
error, so we don't have to worry about supporting that sort of case.