@@ -658,11 +658,19 @@ struct SelectedOverload {
658658 // / we're referencing a member.
659659 const Type openedFullType;
660660
661+ // / The opened type of the base of the reference to this overload, adjusted
662+ // / for `@preconcurrency` or other contextual type-altering attributes.
663+ const Type adjustedOpenedFullType;
664+
661665 // / The opened type produced by referring to this overload.
662666 const Type openedType;
663667
668+ // / The opened type produced by referring to this overload, adjusted for
669+ // / `@preconcurrency` or other contextual type-altering attributes.
670+ const Type adjustedOpenedType;
671+
664672 // / The type that this overload binds. Note that this may differ from
665- // / openedType , for example it will include any IUO unwrapping that has taken
673+ // / adjustedOpenedType , for example it will include any IUO unwrapping that has taken
666674 // / place.
667675 const Type boundType;
668676};
@@ -2515,6 +2523,31 @@ struct GetClosureType {
25152523 Type operator ()(const AbstractClosureExpr *expr) const ;
25162524};
25172525
2526+ // / Describes the type produced when referencing a declaration.
2527+ struct DeclReferenceType {
2528+ // / The "opened" type, which is the type of the declaration where any
2529+ // / generic parameters have been replaced with type variables.
2530+ // /
2531+ // / The mapping from generic parameters to type variables will have been
2532+ // / recorded by \c recordOpenedTypes when this type is produced.
2533+ Type openedType;
2534+
2535+ // / The opened type, after performing contextual type adjustments such as
2536+ // / removing concurrency-related annotations for a `@preconcurrency`
2537+ // / operation.
2538+ Type adjustedOpenedType;
2539+
2540+ // / The type of the reference, based on the original opened type. This is the
2541+ // / type that the expression used to form the declaration reference would
2542+ // / have if no adjustments had been applied.
2543+ Type referenceType;
2544+
2545+ // / The type of the reference, which is the adjusted opened type after
2546+ // / (e.g.) applying the base of a member access. This is the type of the
2547+ // / expression used to form the declaration reference.
2548+ Type adjustedReferenceType;
2549+ };
2550+
25182551// / Describes a system of constraints on type variables, the
25192552// / solution of which assigns concrete types to each of the type variables.
25202553// / Constraint systems are typically generated given an (untyped) expression.
@@ -4467,10 +4500,11 @@ class ConstraintSystem {
44674500 const OpenedTypeMap &replacements);
44684501
44694502 // / Wrapper over swift::adjustFunctionTypeForConcurrency that passes along
4470- // / the appropriate closure-type extraction function .
4503+ // / the appropriate closure-type and opening extraction functions .
44714504 AnyFunctionType *adjustFunctionTypeForConcurrency (
44724505 AnyFunctionType *fnType, ValueDecl *decl, DeclContext *dc,
4473- unsigned numApplies, bool isMainDispatchQueue);
4506+ unsigned numApplies, bool isMainDispatchQueue,
4507+ OpenedTypeMap &replacements);
44744508
44754509 // / Retrieve the type of a reference to the given value declaration.
44764510 // /
@@ -4480,9 +4514,8 @@ class ConstraintSystem {
44804514 // /
44814515 // / \param decl The declarations whose type is being computed.
44824516 // /
4483- // / \returns a pair containing the full opened type (if applicable) and
4484- // / opened type of a reference to declaration.
4485- std::pair<Type, Type> getTypeOfReference (
4517+ // / \returns a description of the type of this declaration reference.
4518+ DeclReferenceType getTypeOfReference (
44864519 ValueDecl *decl,
44874520 FunctionRefKind functionRefKind,
44884521 ConstraintLocatorBuilder locator,
@@ -4530,6 +4563,14 @@ class ConstraintSystem {
45304563 return Type ();
45314564 });
45324565
4566+ // / Given the opened type and a pile of information about a member reference,
4567+ // / determine the reference type of the member reference.
4568+ Type getMemberReferenceTypeFromOpenedType (
4569+ Type &openedType, Type baseObjTy, ValueDecl *value, DeclContext *outerDC,
4570+ ConstraintLocator *locator, bool hasAppliedSelf,
4571+ bool isStaticMemberRefOnProtocol, bool isDynamicResult,
4572+ OpenedTypeMap &replacements);
4573+
45334574 // / Retrieve the type of a reference to the given value declaration,
45344575 // / as a member with a base of the given type.
45354576 // /
@@ -4540,9 +4581,8 @@ class ConstraintSystem {
45404581 // / \param isDynamicResult Indicates that this declaration was found via
45414582 // / dynamic lookup.
45424583 // /
4543- // / \returns a pair containing the full opened type (which includes the opened
4544- // / base) and opened type of a reference to this member.
4545- std::pair<Type, Type> getTypeOfMemberReference (
4584+ // / \returns a description of the type of this declaration reference.
4585+ DeclReferenceType getTypeOfMemberReference (
45464586 Type baseTy, ValueDecl *decl, DeclContext *useDC,
45474587 bool isDynamicResult,
45484588 FunctionRefKind functionRefKind,
0 commit comments