Skip to content

Commit c46ca07

Browse files
committed
Sema: Diagnose inaccessible implicit property wrapper inits again
DeclContext::lookupQualified() no longer calls addImplicitContructors(), so we have to do it ourselves here, otherwise we accept code that used to be rejected in Swift 5.2.
1 parent 6ea4b5e commit c46ca07

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

lib/Sema/TypeCheckPropertyWrapper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ findSuitableWrapperInit(ASTContext &ctx, NominalTypeDecl *nominal,
125125
break;
126126
}
127127

128+
TypeChecker::addImplicitConstructors(nominal);
129+
128130
nominal->lookupQualified(nominal, DeclNameRef::createConstructor(),
129131
NL_QualifiedDefault, decls);
130132
for (const auto &decl : decls) {

test/SILGen/Inputs/property_wrappers_multifile_other.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public class MyClass {
77

88
@propertyWrapper
99
public struct PropertyWrapper {
10+
public init() { }
11+
1012
public var projectedValue: PropertyWrapper {
1113
get {
1214
return self

test/SILGen/property_wrappers_final.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class MyClass {
1717

1818
@propertyWrapper
1919
public struct PropertyWrapper {
20+
public init() { }
21+
2022
public var projectedValue: PropertyWrapper {
2123
get {
2224
return self

test/decl/var/property_wrappers.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,5 +1934,10 @@ struct TestDefaultableIntWrapper {
19341934
}
19351935
}
19361936

1937-
1938-
1937+
@propertyWrapper
1938+
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)}}
1940+
public var wrappedValue: Bool {
1941+
return false
1942+
}
1943+
}

0 commit comments

Comments
 (0)