@@ -2571,31 +2571,24 @@ static VarDecl *synthesizePropertyWrapperProjectionVar(
2571
2571
2572
2572
static void typeCheckSynthesizedWrapperInitializer (VarDecl *wrappedVar,
2573
2573
Expr *&initializer) {
2574
- // Figure out the context in which the initializer was written.
2575
- auto *parentPBD = wrappedVar->getParentPatternBinding ();
2576
- auto i = parentPBD->getPatternEntryIndexForVarDecl (wrappedVar);
2577
- DeclContext *originalDC = parentPBD->getDeclContext ();
2578
- if (!originalDC->isLocalContext ()) {
2579
- auto initContext =
2580
- cast_or_null<PatternBindingInitializer>(parentPBD->getInitContext (i));
2581
- if (initContext)
2582
- originalDC = initContext;
2583
- }
2574
+ auto *dc = wrappedVar->getInnermostDeclContext ();
2575
+ auto &ctx = wrappedVar->getASTContext ();
2576
+ auto *initContext = new (ctx) PropertyWrapperInitializer (
2577
+ dc, wrappedVar, PropertyWrapperInitializer::Kind::WrappedValue);
2584
2578
2585
2579
// Type-check the initialization.
2586
- auto *pattern = parentPBD->getPattern (i);
2587
- TypeChecker::typeCheckBinding (pattern, initializer, originalDC,
2588
- wrappedVar->getType (), parentPBD, i);
2580
+ using namespace constraints ;
2581
+ auto target = SolutionApplicationTarget::forPropertyWrapperInitializer (
2582
+ wrappedVar, initContext, initializer);
2583
+ auto result = TypeChecker::typeCheckExpression (target);
2584
+ if (!result)
2585
+ return ;
2589
2586
2590
- if (auto initializerContext =
2591
- dyn_cast_or_null<Initializer>(parentPBD->getInitContext (i))) {
2592
- TypeChecker::contextualizeInitializer (initializerContext, initializer);
2593
- }
2587
+ initializer = result->getAsExpr ();
2594
2588
2595
- auto *backingVar = wrappedVar->getPropertyWrapperBackingProperty ();
2596
- auto *backingPBD = backingVar->getParentPatternBinding ();
2597
- checkPropertyWrapperActorIsolation (backingPBD, initializer);
2598
- TypeChecker::checkPropertyWrapperEffects (backingPBD, initializer);
2589
+ TypeChecker::contextualizeInitializer (initContext, initializer);
2590
+ checkPropertyWrapperActorIsolation (wrappedVar, initializer);
2591
+ TypeChecker::checkInitializerEffects (initContext, initializer);
2599
2592
}
2600
2593
2601
2594
static PropertyWrapperMutability::Value
@@ -2954,21 +2947,7 @@ PropertyWrapperInitializerInfoRequest::evaluate(Evaluator &evaluator,
2954
2947
!var->getName ().hasDollarPrefix ()) {
2955
2948
wrappedValueInit = PropertyWrapperValuePlaceholderExpr::create (
2956
2949
ctx, var->getSourceRange (), var->getType (), /* wrappedValue=*/ nullptr );
2957
-
2958
- if (auto *param = dyn_cast<ParamDecl>(var)) {
2959
- wrappedValueInit = buildPropertyWrapperInitCall (
2960
- var, storageType, wrappedValueInit, PropertyWrapperInitKind::WrappedValue);
2961
- TypeChecker::typeCheckExpression (wrappedValueInit, dc);
2962
-
2963
- // Check initializer effects.
2964
- auto *initContext = new (ctx) PropertyWrapperInitializer (
2965
- dc, param, PropertyWrapperInitializer::Kind::WrappedValue);
2966
- TypeChecker::contextualizeInitializer (initContext, wrappedValueInit);
2967
- checkInitializerActorIsolation (initContext, wrappedValueInit);
2968
- TypeChecker::checkInitializerEffects (initContext, wrappedValueInit);
2969
- } else {
2970
- typeCheckSynthesizedWrapperInitializer (var, wrappedValueInit);
2971
- }
2950
+ typeCheckSynthesizedWrapperInitializer (var, wrappedValueInit);
2972
2951
}
2973
2952
2974
2953
return PropertyWrapperInitializerInfo (wrappedValueInit, projectedValueInit);
0 commit comments