@@ -614,11 +614,19 @@ struct SelectedOverload {
614
614
// / we're referencing a member.
615
615
const Type openedFullType;
616
616
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
+
617
621
// / The opened type produced by referring to this overload.
618
622
const Type openedType;
619
623
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
+
620
628
// / 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
622
630
// / place.
623
631
const Type boundType;
624
632
};
@@ -2471,6 +2479,31 @@ struct GetClosureType {
2471
2479
Type operator ()(const AbstractClosureExpr *expr) const ;
2472
2480
};
2473
2481
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
+
2474
2507
// / Describes a system of constraints on type variables, the
2475
2508
// / solution of which assigns concrete types to each of the type variables.
2476
2509
// / Constraint systems are typically generated given an (untyped) expression.
@@ -4423,10 +4456,11 @@ class ConstraintSystem {
4423
4456
const OpenedTypeMap &replacements);
4424
4457
4425
4458
// / Wrapper over swift::adjustFunctionTypeForConcurrency that passes along
4426
- // / the appropriate closure-type extraction function .
4459
+ // / the appropriate closure-type and opening extraction functions .
4427
4460
AnyFunctionType *adjustFunctionTypeForConcurrency (
4428
4461
AnyFunctionType *fnType, ValueDecl *decl, DeclContext *dc,
4429
- unsigned numApplies, bool isMainDispatchQueue);
4462
+ unsigned numApplies, bool isMainDispatchQueue,
4463
+ OpenedTypeMap &replacements);
4430
4464
4431
4465
// / Retrieve the type of a reference to the given value declaration.
4432
4466
// /
@@ -4436,9 +4470,8 @@ class ConstraintSystem {
4436
4470
// /
4437
4471
// / \param decl The declarations whose type is being computed.
4438
4472
// /
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 (
4442
4475
ValueDecl *decl,
4443
4476
FunctionRefKind functionRefKind,
4444
4477
ConstraintLocatorBuilder locator,
@@ -4486,6 +4519,14 @@ class ConstraintSystem {
4486
4519
return Type ();
4487
4520
});
4488
4521
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
+
4489
4530
// / Retrieve the type of a reference to the given value declaration,
4490
4531
// / as a member with a base of the given type.
4491
4532
// /
@@ -4496,9 +4537,8 @@ class ConstraintSystem {
4496
4537
// / \param isDynamicResult Indicates that this declaration was found via
4497
4538
// / dynamic lookup.
4498
4539
// /
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 (
4502
4542
Type baseTy, ValueDecl *decl, DeclContext *useDC,
4503
4543
bool isDynamicResult,
4504
4544
FunctionRefKind functionRefKind,
0 commit comments