@@ -101,7 +101,8 @@ static VarDecl *findValueProperty(ASTContext &ctx, NominalTypeDecl *nominal,
101101// / type.
102102static ConstructorDecl *
103103findSuitableWrapperInit (ASTContext &ctx, NominalTypeDecl *nominal,
104- VarDecl *valueVar, PropertyWrapperInitKind initKind) {
104+ VarDecl *valueVar, PropertyWrapperInitKind initKind,
105+ const SmallVectorImpl<ValueDecl *> &decls) {
105106 enum class NonViableReason {
106107 Failable,
107108 ParameterTypeMismatch,
@@ -111,7 +112,6 @@ findSuitableWrapperInit(ASTContext &ctx, NominalTypeDecl *nominal,
111112 SmallVector<std::tuple<ConstructorDecl *, NonViableReason, Type>, 2 >
112113 nonviable;
113114 SmallVector<ConstructorDecl *, 2 > viableInitializers;
114- SmallVector<ValueDecl *, 2 > decls;
115115
116116 Identifier argumentLabel;
117117 switch (initKind) {
@@ -125,10 +125,6 @@ findSuitableWrapperInit(ASTContext &ctx, NominalTypeDecl *nominal,
125125 break ;
126126 }
127127
128- TypeChecker::addImplicitConstructors (nominal);
129-
130- nominal->lookupQualified (nominal, DeclNameRef::createConstructor (),
131- NL_QualifiedDefault, decls);
132128 for (const auto &decl : decls) {
133129 auto init = dyn_cast<ConstructorDecl>(decl);
134130 if (!init || init->getDeclContext () != nominal || init->isGeneric ())
@@ -351,16 +347,23 @@ PropertyWrapperTypeInfoRequest::evaluate(
351347
352348 // FIXME: Remove this one
353349 (void )valueVar->getInterfaceType ();
354-
350+
351+ TypeChecker::addImplicitConstructors (nominal);
352+
353+ SmallVector<ValueDecl *, 2 > decls;
354+ nominal->lookupQualified (nominal, DeclNameRef::createConstructor (),
355+ NL_QualifiedDefault, decls);
356+
355357 PropertyWrapperTypeInfo result;
356358 result.valueVar = valueVar;
357359 if (auto init = findSuitableWrapperInit (ctx, nominal, valueVar,
358- PropertyWrapperInitKind::WrappedValue)) {
360+ PropertyWrapperInitKind::WrappedValue, decls )) {
359361 result.wrappedValueInit = PropertyWrapperTypeInfo::HasWrappedValueInit;
360362 result.isWrappedValueInitUsingEscapingAutoClosure =
361363 isEscapingAutoclosureArgument (init, ctx.Id_wrappedValue );
362364 } else if (auto init = findSuitableWrapperInit (
363- ctx, nominal, valueVar, PropertyWrapperInitKind::InitialValue)) {
365+ ctx, nominal, valueVar, PropertyWrapperInitKind::InitialValue,
366+ decls)) {
364367 result.wrappedValueInit = PropertyWrapperTypeInfo::HasInitialValueInit;
365368 result.isWrappedValueInitUsingEscapingAutoClosure =
366369 isEscapingAutoclosureArgument (init, ctx.Id_initialValue );
@@ -380,7 +383,7 @@ PropertyWrapperTypeInfoRequest::evaluate(
380383 }
381384
382385 if (findSuitableWrapperInit (ctx, nominal, /* valueVar=*/ nullptr ,
383- PropertyWrapperInitKind::Default)) {
386+ PropertyWrapperInitKind::Default, decls )) {
384387 result.defaultInit = PropertyWrapperTypeInfo::HasDefaultValueInit;
385388 }
386389
0 commit comments