[NFC] Correct constraint system assumption

We currently assume that, if a subscript is declared within a value type’s decl, it must need `self` to be passed inout. This isn’t true for static subscripts, because even though the DeclContext is a value type, the metatype is actually a reference type. Skip this check for non-instance members.

NFC until static subscripts are added.
This commit is contained in:
Brent Royal-Gordon
2019-04-01 14:54:54 -07:00
parent 5c03918c82
commit 67af97c4db

View File

@@ -1287,7 +1287,8 @@ ConstraintSystem::getTypeOfMemberReference(
// If self is a value type and the base type is an lvalue, wrap it in an
// inout type.
auto selfFlags = ParameterTypeFlags();
if (!outerDC->getDeclaredInterfaceType()->hasReferenceSemantics() &&
if (isInstance &&
!outerDC->getDeclaredInterfaceType()->hasReferenceSemantics() &&
baseTy->is<LValueType>() &&
!selfTy->hasError())
selfFlags = selfFlags.withInOut(true);