@@ -658,11 +658,19 @@ struct SelectedOverload {
658
658
// / we're referencing a member.
659
659
const Type openedFullType;
660
660
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
+
661
665
// / The opened type produced by referring to this overload.
662
666
const Type openedType;
663
667
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
+
664
672
// / 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
666
674
// / place.
667
675
const Type boundType;
668
676
};
@@ -2515,6 +2523,31 @@ struct GetClosureType {
2515
2523
Type operator ()(const AbstractClosureExpr *expr) const ;
2516
2524
};
2517
2525
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
+
2518
2551
// / Describes a system of constraints on type variables, the
2519
2552
// / solution of which assigns concrete types to each of the type variables.
2520
2553
// / Constraint systems are typically generated given an (untyped) expression.
@@ -4467,10 +4500,11 @@ class ConstraintSystem {
4467
4500
const OpenedTypeMap &replacements);
4468
4501
4469
4502
// / Wrapper over swift::adjustFunctionTypeForConcurrency that passes along
4470
- // / the appropriate closure-type extraction function .
4503
+ // / the appropriate closure-type and opening extraction functions .
4471
4504
AnyFunctionType *adjustFunctionTypeForConcurrency (
4472
4505
AnyFunctionType *fnType, ValueDecl *decl, DeclContext *dc,
4473
- unsigned numApplies, bool isMainDispatchQueue);
4506
+ unsigned numApplies, bool isMainDispatchQueue,
4507
+ OpenedTypeMap &replacements);
4474
4508
4475
4509
// / Retrieve the type of a reference to the given value declaration.
4476
4510
// /
@@ -4480,9 +4514,8 @@ class ConstraintSystem {
4480
4514
// /
4481
4515
// / \param decl The declarations whose type is being computed.
4482
4516
// /
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 (
4486
4519
ValueDecl *decl,
4487
4520
FunctionRefKind functionRefKind,
4488
4521
ConstraintLocatorBuilder locator,
@@ -4530,6 +4563,14 @@ class ConstraintSystem {
4530
4563
return Type ();
4531
4564
});
4532
4565
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
+
4533
4574
// / Retrieve the type of a reference to the given value declaration,
4534
4575
// / as a member with a base of the given type.
4535
4576
// /
@@ -4540,9 +4581,8 @@ class ConstraintSystem {
4540
4581
// / \param isDynamicResult Indicates that this declaration was found via
4541
4582
// / dynamic lookup.
4542
4583
// /
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 (
4546
4586
Type baseTy, ValueDecl *decl, DeclContext *useDC,
4547
4587
bool isDynamicResult,
4548
4588
FunctionRefKind functionRefKind,
0 commit comments