Skip to content

Commit 1e1c3fe

Browse files
committed
Add tests to fix wrong fixit when the type doesn't conform to a public protocol
1 parent 79ebc53 commit 1e1c3fe

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/attr/accessibility.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,20 @@ public struct AdoptViaCombinedProtocol : ProtoWithReqs, ReqProvider2 {
252252
// expected-error@-1 {{method 'foo()' must be declared public because it matches a requirement in public protocol 'ProtoWithReqs'}} {{none}}
253253
public typealias Assoc = Int
254254
}
255+
256+
public protocol PublicInitProto {
257+
var value: Int { get }
258+
init(value: Int)
259+
}
260+
public struct NonPublicInitStruct: PublicInitProto {
261+
public var value: Int
262+
init(value: Int) {
263+
// expected-error@-1 {{initializer 'init(value:)' must be declared public because it matches a requirement in public protocol 'PublicInitProto'}}
264+
// expected-note@-2 {{mark the initializer as 'public' to satisfy the requirement}}
265+
self.value = value
266+
}
267+
}
268+
public struct NonPublicMemberwiseInitStruct: PublicInitProto {
269+
// expected-error@-1 {{initializer 'init(value:)' must be declared public because it matches a requirement in public protocol 'PublicInitProto'}}
270+
public var value: Int
271+
}

0 commit comments

Comments
 (0)