@@ -1189,6 +1189,21 @@ ConstraintSystem::getTypeOfMemberReference(
1189
1189
OpenedTypeMap *replacementsPtr) {
1190
1190
// Figure out the instance type used for the base.
1191
1191
Type baseObjTy = getFixedTypeRecursive (baseTy, /* wantRValue=*/ true );
1192
+
1193
+ ParameterTypeFlags baseFlags;
1194
+ // FIXME(diagnostics): `InOutType` could appear here as a result
1195
+ // of successful re-typecheck of the one of the sub-expressions e.g.
1196
+ // `let _: Int = { (s: inout S) in s.bar() }`. On the first
1197
+ // attempt to type-check whole expression `s.bar()` - is going
1198
+ // to have a base which points directly to declaration of `S`.
1199
+ // But when diagnostics attempts to type-check `s.bar()` standalone
1200
+ // its base would be tranformed into `InOutExpr -> DeclRefExr`,
1201
+ // and `InOutType` is going to be recorded in constraint system.
1202
+ if (auto objType = baseObjTy->getInOutObjectType ()) {
1203
+ baseObjTy = objType;
1204
+ baseFlags = baseFlags.withInOut (true );
1205
+ }
1206
+
1192
1207
bool isInstance = true ;
1193
1208
if (auto baseMeta = baseObjTy->getAs <AnyMetatypeType>()) {
1194
1209
baseObjTy = baseMeta->getInstanceType ();
@@ -1200,7 +1215,7 @@ ConstraintSystem::getTypeOfMemberReference(
1200
1215
return getTypeOfReference (value, functionRefKind, locator, useDC, base);
1201
1216
}
1202
1217
1203
- FunctionType::Param baseObjParam (baseObjTy);
1218
+ FunctionType::Param baseObjParam (baseObjTy, Identifier (), baseFlags );
1204
1219
1205
1220
// Don't open existentials when accessing typealias members of
1206
1221
// protocols.
0 commit comments