Skip to content

Commit 67af97c

Browse files
committed
[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.
1 parent 5c03918 commit 67af97c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,8 @@ ConstraintSystem::getTypeOfMemberReference(
12871287
// If self is a value type and the base type is an lvalue, wrap it in an
12881288
// inout type.
12891289
auto selfFlags = ParameterTypeFlags();
1290-
if (!outerDC->getDeclaredInterfaceType()->hasReferenceSemantics() &&
1290+
if (isInstance &&
1291+
!outerDC->getDeclaredInterfaceType()->hasReferenceSemantics() &&
12911292
baseTy->is<LValueType>() &&
12921293
!selfTy->hasError())
12931294
selfFlags = selfFlags.withInOut(true);

0 commit comments

Comments
 (0)