You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/Sema/accessibility.swift
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -869,3 +869,13 @@ public extension ObjCSub {
869
869
set{}
870
870
}
871
871
}
872
+
873
+
publicstructTestGenericSubscripts{
874
+
// We'd like these to be errors in a future version of Swift, but they weren't
875
+
// in Swift 5.0.
876
+
public subscript<T:PrivateProto>(_:T)->Int{return0} // expected-warning {{subscript should not be declared public because its generic parameter uses a private type}} {{none}}
877
+
public subscript<T>(where _:T)->Intwhere T:PrivateProto{return0} // expected-warning {{subscript should not be declared public because its generic requirement uses a private type}} {{none}}
878
+
}
879
+
880
+
publictypealiasTestGenericAlias<T:PrivateProto>=T // expected-warning {{type alias should not be declared public because its generic parameter uses a private type}}
881
+
publictypealiasTestGenericAliasWhereClause<T>=T where T: PrivateProto // expected-warning {{type alias should not be declared public because its generic requirement uses a private type}}
// expected-error@-1 {{type referenced from the underlying type of a '@usableFromInline' type alias must be '@usableFromInline' or public}}
88
88
89
89
protocolInternalProtocol{
90
-
// expected-note@-1 4{{type declared here}}
90
+
// expected-note@-1 * {{type declared here}}
91
91
associatedtypeT
92
92
}
93
93
@@ -147,3 +147,11 @@ enum BadEnum {
147
147
@usableFromInline
148
148
classBadClass:InternalClass{}
149
149
// expected-error@-1 {{type referenced from the superclass of a '@usableFromInline' class must be '@usableFromInline' or public}}
150
+
151
+
publicstructTestGenericSubscripts{
152
+
@usableFromInline subscript<T:InternalProtocol>(_:T)->Int{return0} // expected-warning {{type referenced from a generic parameter of a '@usableFromInline' subscript should be '@usableFromInline' or public}}
153
+
@usableFromInline subscript<T>(where _:T)->Intwhere T:InternalProtocol{return0} // expected-warning {{type referenced from a generic requirement of a '@usableFromInline' subscript should be '@usableFromInline' or public}}
154
+
}
155
+
156
+
@usableFromInlinetypealiasTestGenericAlias<T:InternalProtocol>=T // expected-warning {{type referenced from a generic parameter of a '@usableFromInline' type alias should be '@usableFromInline' or public}}
157
+
@usableFromInlinetypealiasTestGenericAliasWhereClause<T>=T where T: InternalProtocol // expected-warning {{type referenced from a generic requirement of a '@usableFromInline' type alias should be '@usableFromInline' or public}}
0 commit comments