Skip to content

Commit 3eaa4d5

Browse files
committed
Sema: Fix duplicate property wrapper init diagnostics
1 parent c46ca07 commit 3eaa4d5

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/Sema/TypeCheckPropertyWrapper.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ findSuitableWrapperInit(ASTContext &ctx, NominalTypeDecl *nominal,
158158
if (hasExtraneousParam)
159159
continue;
160160

161+
if (initKind != PropertyWrapperInitKind::Default) {
162+
if (!argumentParam)
163+
continue;
164+
165+
if (argumentParam->isInOut() || argumentParam->isVariadic())
166+
continue;
167+
}
168+
161169
// Failable initializers cannot be used.
162170
if (init->isFailable()) {
163171
nonviable.push_back(
@@ -174,12 +182,6 @@ findSuitableWrapperInit(ASTContext &ctx, NominalTypeDecl *nominal,
174182

175183
// Additional checks for initial-value and wrapped-value initializers
176184
if (initKind != PropertyWrapperInitKind::Default) {
177-
if (!argumentParam)
178-
continue;
179-
180-
if (argumentParam->isInOut() || argumentParam->isVariadic())
181-
continue;
182-
183185
auto paramType = argumentParam->getInterfaceType();
184186
if (paramType->is<ErrorType>())
185187
continue;

test/decl/var/property_wrappers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ struct TestDefaultableIntWrapper {
19361936

19371937
@propertyWrapper
19381938
public struct NonVisibleImplicitInit {
1939-
// expected-error@-1 3{{internal initializer 'init()' cannot have more restrictive access than its enclosing property wrapper type 'NonVisibleImplicitInit' (which is public)}}
1939+
// expected-error@-1 {{internal initializer 'init()' cannot have more restrictive access than its enclosing property wrapper type 'NonVisibleImplicitInit' (which is public)}}
19401940
public var wrappedValue: Bool {
19411941
return false
19421942
}

0 commit comments

Comments
 (0)