@@ -614,11 +614,19 @@ struct SelectedOverload {
614614 // / we're referencing a member.
615615 const Type openedFullType;
616616
617+ // / The opened type of the base of the reference to this overload, adjusted
618+ // / for `@preconcurrency` or other contextual type-altering attributes.
619+ const Type adjustedOpenedFullType;
620+
617621 // / The opened type produced by referring to this overload.
618622 const Type openedType;
619623
624+ // / The opened type produced by referring to this overload, adjusted for
625+ // / `@preconcurrency` or other contextual type-altering attributes.
626+ const Type adjustedOpenedType;
627+
620628 // / The type that this overload binds. Note that this may differ from
621- // / openedType , for example it will include any IUO unwrapping that has taken
629+ // / adjustedOpenedType , for example it will include any IUO unwrapping that has taken
622630 // / place.
623631 const Type boundType;
624632};
@@ -2471,6 +2479,31 @@ struct GetClosureType {
24712479 Type operator ()(const AbstractClosureExpr *expr) const ;
24722480};
24732481
2482+ // / Describes the type produced when referencing a declaration.
2483+ struct DeclReferenceType {
2484+ // / The "opened" type, which is the type of the declaration where any
2485+ // / generic parameters have been replaced with type variables.
2486+ // /
2487+ // / The mapping from generic parameters to type variables will have been
2488+ // / recorded by \c recordOpenedTypes when this type is produced.
2489+ Type openedType;
2490+
2491+ // / The opened type, after performing contextual type adjustments such as
2492+ // / removing concurrency-related annotations for a `@preconcurrency`
2493+ // / operation.
2494+ Type adjustedOpenedType;
2495+
2496+ // / The type of the reference, based on the original opened type. This is the
2497+ // / type that the expression used to form the declaration reference would
2498+ // / have if no adjustments had been applied.
2499+ Type referenceType;
2500+
2501+ // / The type of the reference, which is the adjusted opened type after
2502+ // / (e.g.) applying the base of a member access. This is the type of the
2503+ // / expression used to form the declaration reference.
2504+ Type adjustedReferenceType;
2505+ };
2506+
24742507// / Describes a system of constraints on type variables, the
24752508// / solution of which assigns concrete types to each of the type variables.
24762509// / Constraint systems are typically generated given an (untyped) expression.
@@ -4423,10 +4456,11 @@ class ConstraintSystem {
44234456 const OpenedTypeMap &replacements);
44244457
44254458 // / Wrapper over swift::adjustFunctionTypeForConcurrency that passes along
4426- // / the appropriate closure-type extraction function .
4459+ // / the appropriate closure-type and opening extraction functions .
44274460 AnyFunctionType *adjustFunctionTypeForConcurrency (
44284461 AnyFunctionType *fnType, ValueDecl *decl, DeclContext *dc,
4429- unsigned numApplies, bool isMainDispatchQueue);
4462+ unsigned numApplies, bool isMainDispatchQueue,
4463+ OpenedTypeMap &replacements);
44304464
44314465 // / Retrieve the type of a reference to the given value declaration.
44324466 // /
@@ -4436,9 +4470,8 @@ class ConstraintSystem {
44364470 // /
44374471 // / \param decl The declarations whose type is being computed.
44384472 // /
4439- // / \returns a pair containing the full opened type (if applicable) and
4440- // / opened type of a reference to declaration.
4441- std::pair<Type, Type> getTypeOfReference (
4473+ // / \returns a description of the type of this declaration reference.
4474+ DeclReferenceType getTypeOfReference (
44424475 ValueDecl *decl,
44434476 FunctionRefKind functionRefKind,
44444477 ConstraintLocatorBuilder locator,
@@ -4486,6 +4519,14 @@ class ConstraintSystem {
44864519 return Type ();
44874520 });
44884521
4522+ // / Given the opened type and a pile of information about a member reference,
4523+ // / determine the reference type of the member reference.
4524+ Type getMemberReferenceTypeFromOpenedType (
4525+ Type &openedType, Type baseObjTy, ValueDecl *value, DeclContext *outerDC,
4526+ ConstraintLocator *locator, bool hasAppliedSelf,
4527+ bool isStaticMemberRefOnProtocol, bool isDynamicResult,
4528+ OpenedTypeMap &replacements);
4529+
44894530 // / Retrieve the type of a reference to the given value declaration,
44904531 // / as a member with a base of the given type.
44914532 // /
@@ -4496,9 +4537,8 @@ class ConstraintSystem {
44964537 // / \param isDynamicResult Indicates that this declaration was found via
44974538 // / dynamic lookup.
44984539 // /
4499- // / \returns a pair containing the full opened type (which includes the opened
4500- // / base) and opened type of a reference to this member.
4501- std::pair<Type, Type> getTypeOfMemberReference (
4540+ // / \returns a description of the type of this declaration reference.
4541+ DeclReferenceType getTypeOfMemberReference (
45024542 Type baseTy, ValueDecl *decl, DeclContext *useDC,
45034543 bool isDynamicResult,
45044544 FunctionRefKind functionRefKind,
0 commit comments