@@ -101,7 +101,8 @@ static VarDecl *findValueProperty(ASTContext &ctx, NominalTypeDecl *nominal,
101
101
// / type.
102
102
static ConstructorDecl *
103
103
findSuitableWrapperInit (ASTContext &ctx, NominalTypeDecl *nominal,
104
- VarDecl *valueVar, PropertyWrapperInitKind initKind) {
104
+ VarDecl *valueVar, PropertyWrapperInitKind initKind,
105
+ const SmallVectorImpl<ValueDecl *> &decls) {
105
106
enum class NonViableReason {
106
107
Failable,
107
108
ParameterTypeMismatch,
@@ -111,7 +112,6 @@ findSuitableWrapperInit(ASTContext &ctx, NominalTypeDecl *nominal,
111
112
SmallVector<std::tuple<ConstructorDecl *, NonViableReason, Type>, 2 >
112
113
nonviable;
113
114
SmallVector<ConstructorDecl *, 2 > viableInitializers;
114
- SmallVector<ValueDecl *, 2 > decls;
115
115
116
116
Identifier argumentLabel;
117
117
switch (initKind) {
@@ -125,10 +125,6 @@ findSuitableWrapperInit(ASTContext &ctx, NominalTypeDecl *nominal,
125
125
break ;
126
126
}
127
127
128
- TypeChecker::addImplicitConstructors (nominal);
129
-
130
- nominal->lookupQualified (nominal, DeclNameRef::createConstructor (),
131
- NL_QualifiedDefault, decls);
132
128
for (const auto &decl : decls) {
133
129
auto init = dyn_cast<ConstructorDecl>(decl);
134
130
if (!init || init->getDeclContext () != nominal || init->isGeneric ())
@@ -351,16 +347,23 @@ PropertyWrapperTypeInfoRequest::evaluate(
351
347
352
348
// FIXME: Remove this one
353
349
(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
+
355
357
PropertyWrapperTypeInfo result;
356
358
result.valueVar = valueVar;
357
359
if (auto init = findSuitableWrapperInit (ctx, nominal, valueVar,
358
- PropertyWrapperInitKind::WrappedValue)) {
360
+ PropertyWrapperInitKind::WrappedValue, decls )) {
359
361
result.wrappedValueInit = PropertyWrapperTypeInfo::HasWrappedValueInit;
360
362
result.isWrappedValueInitUsingEscapingAutoClosure =
361
363
isEscapingAutoclosureArgument (init, ctx.Id_wrappedValue );
362
364
} else if (auto init = findSuitableWrapperInit (
363
- ctx, nominal, valueVar, PropertyWrapperInitKind::InitialValue)) {
365
+ ctx, nominal, valueVar, PropertyWrapperInitKind::InitialValue,
366
+ decls)) {
364
367
result.wrappedValueInit = PropertyWrapperTypeInfo::HasInitialValueInit;
365
368
result.isWrappedValueInitUsingEscapingAutoClosure =
366
369
isEscapingAutoclosureArgument (init, ctx.Id_initialValue );
@@ -380,7 +383,7 @@ PropertyWrapperTypeInfoRequest::evaluate(
380
383
}
381
384
382
385
if (findSuitableWrapperInit (ctx, nominal, /* valueVar=*/ nullptr ,
383
- PropertyWrapperInitKind::Default)) {
386
+ PropertyWrapperInitKind::Default, decls )) {
384
387
result.defaultInit = PropertyWrapperTypeInfo::HasDefaultValueInit;
385
388
}
386
389
0 commit comments