Skip to content

Commit 5ff1e46

Browse files
committed
Sema: Update more tests with more precise message about exported conformances
1 parent 67694c2 commit 5ff1e46

7 files changed

+16
-16
lines changed

test/SPI/implementation_only_spi_import_exposability.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public protocol IOIProtocol {}
3232
@_spi(B) public func leakSPIStruct(_ a: SPIStruct) -> SPIStruct { fatalError() } // expected-warning 2 {{cannot use struct 'SPIStruct' here; 'Lib' has been imported as implementation-only}}
3333
@_spi(B) public func leakIOIStruct(_ a: IOIStruct) -> IOIStruct { fatalError() } // expected-warning 2 {{cannot use struct 'IOIStruct' here; 'Lib' has been imported as implementation-only}}
3434

35-
public struct PublicStruct : IOIProtocol, SPIProtocol { // expected-error {{cannot use protocol 'IOIProtocol' here; 'Lib' has been imported as implementation-only}}
36-
// expected-error @-1 {{cannot use protocol 'SPIProtocol' here; 'Lib' has been imported as implementation-only}}
35+
public struct PublicStruct : IOIProtocol, SPIProtocol { // expected-error {{cannot use protocol 'IOIProtocol' in an exported conformance; 'Lib' has been imported as implementation-only}}
36+
// expected-error @-1 {{cannot use protocol 'SPIProtocol' in an exported conformance; 'Lib' has been imported as implementation-only}}
3737
public var spiStruct = SPIStruct() // expected-error {{cannot use struct 'SPIStruct' here; 'Lib' has been imported as implementation-only}}
3838
public var ioiStruct = IOIStruct() // expected-error {{cannot use struct 'IOIStruct' here; 'Lib' has been imported as implementation-only}}
3939

@@ -49,8 +49,8 @@ public struct PublicStruct : IOIProtocol, SPIProtocol { // expected-error {{cann
4949
}
5050

5151
@_spi(B)
52-
public struct LocalSPIStruct : IOIProtocol, SPIProtocol { // expected-warning {{cannot use protocol 'IOIProtocol' here; 'Lib' has been imported as implementation-only}}
53-
// expected-warning @-1 {{cannot use protocol 'SPIProtocol' here; 'Lib' has been imported as implementation-only}}
52+
public struct LocalSPIStruct : IOIProtocol, SPIProtocol { // expected-warning {{cannot use protocol 'IOIProtocol' in an exported conformance; 'Lib' has been imported as implementation-only}}
53+
// expected-warning @-1 {{cannot use protocol 'SPIProtocol' in an exported conformance; 'Lib' has been imported as implementation-only}}
5454
}
5555

5656
#endif

test/SPI/local_spi_decls.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private protocol PrivateProtocol {} // expected-note {{type declared here}}
7070

7171
@_spi(S) public class BadSubclass : InternalClass {} // expected-error{{class cannot be declared public because its superclass is internal}}
7272
@_spi(S) public class OkSPISubclass : SPIClass {} // OK
73-
public class BadPublicClass : SPIClass {} // expected-error {{cannot use class 'SPIClass' here; it is SPI}}
73+
public class BadPublicClass : SPIClass {} // expected-error {{cannot use class 'SPIClass' in an exported conformance; it is SPI}}
7474
@_spi(S) public class BadSPIClass : PrivateClass {} // expected-error {{class cannot be declared public because its superclass is private}}
7575

7676
@_spi(s) public func genFunc<T: PrivateProtocol>(_ t: T) {} // expected-error {{global function cannot be declared public because its generic parameter uses a private type}}

test/Sema/access-level-import-typealias.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public typealias ClazzAlias = Clazz
2424
public import Aliases
2525
internal import Original // expected-note 2 {{class 'Clazz' imported as 'internal' from 'Original' here}}
2626

27-
// expected-error@+1 {{'ClazzAlias' aliases 'Original.Clazz' and cannot be used for a conformance on a public, package or '@usableFromInline' type because 'Original' was not imported publicly}}
27+
// expected-error@+1 {{'ClazzAlias' aliases 'Original.Clazz' and cannot be used in a public or '@usableFromInline' conformance because 'Original' was not imported publicly}}
2828
public class InheritsFromClazzAlias: ClazzAlias {}
2929

3030
@inlinable public func inlinableFunc() {

test/Sema/missing-import-typealias-swift6.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ public typealias ClazzAlias = Clazz
2828

2929
public import Aliases
3030

31-
// expected-error@+1 {{'ClazzAlias' aliases 'Original.Clazz' and cannot be used here because 'Original' was not imported by this file}}
31+
// expected-error@+1 {{'ClazzAlias' aliases 'Original.Clazz' and cannot be used in a public or '@usableFromInline' conformance because 'Original' was not imported by this file}}
3232
public class InheritsFromClazzAlias: ClazzAlias {}
3333

test/Sema/missing-import-typealias.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import Aliases
6666

6767
// CHECK-NON-RESILIENT-NOT: was not imported by this file
6868

69-
// expected-warning@+2 {{'ClazzAlias' aliases 'Original.Clazz' and cannot be used here because 'Original' was not imported by this file; this is an error in the Swift 6 language mode}}
69+
// expected-warning@+2 {{'ClazzAlias' aliases 'Original.Clazz' and cannot be used in a public or '@usableFromInline' conformance because 'Original' was not imported by this file; this is an error in the Swift 6 language mode}}
7070
// expected-note@+1 {{The missing import of module 'Original' will be added implicitly}}
7171
public class InheritsFromClazzAlias: ClazzAlias {}
7272

test/Sema/spi-available-local.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class MacOSSPIClass {} // expected-note {{type declared here}}
1010
public class iOSSPIClass {}
1111

1212
@available(macOS 10.10, iOS 8.0, *)
13-
public class MacOSDerived: MacOSSPIClass {} // expected-error {{cannot use class 'MacOSSPIClass' here; it is SPI}}
13+
public class MacOSDerived: MacOSSPIClass {} // expected-error {{cannot use class 'MacOSSPIClass' in a public or '@usableFromInline' conformance; it is SPI}}
1414

1515
@available(macOS 10.10, iOS 8.0, *)
1616
public class iOSDerived: iOSSPIClass {}

test/Sema/spi-in-decls.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ public struct BadWrapper { // expected-note {{type declared here}}
4646
//@_spi(X)
4747
//precedencegroup BadPrecedence {}
4848

49-
public struct TestConformance: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; it is SPI}}
49+
public struct TestConformance: BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; it is SPI}}
5050

51-
@usableFromInline struct TestConformanceUFI: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; it is SPI}}
51+
@usableFromInline struct TestConformanceUFI: BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; it is SPI}}
5252

5353
struct TestConformanceOkay: BadProto {} // ok
5454

55-
public class TestConformanceClass: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; it is SPI}}
56-
public enum TestConformanceEnum: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; it is SPI}}
55+
public class TestConformanceClass: BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; it is SPI}}
56+
public enum TestConformanceEnum: BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; it is SPI}}
5757

5858

5959
public struct TestGenericParams<T: BadProto> {} // expected-error {{cannot use protocol 'BadProto' here; it is SPI}}
@@ -105,11 +105,11 @@ public protocol TestAssocTypeWhereClause {
105105
associatedtype Assoc: Collection where Assoc.Element: BadProto // expected-error {{cannot use protocol 'BadProto' here; it is SPI}}
106106
}
107107

108-
public enum TestRawType: IntLike { // expected-error {{cannot use struct 'IntLike' here; it is SPI}}
108+
public enum TestRawType: IntLike { // expected-error {{cannot use struct 'IntLike' in a public or '@usableFromInline' conformance; it is SPI}}
109109
case x = 1
110110
}
111111

112-
public class TestSubclass: BadClass { // expected-error {{cannot use class 'BadClass' here; it is SPI}}
112+
public class TestSubclass: BadClass { // expected-error {{cannot use class 'BadClass' in a public or '@usableFromInline' conformance; it is SPI}}
113113
}
114114

115115
public typealias TestUnderlying = BadStruct // expected-error {{cannot use struct 'BadStruct' here; it is SPI}}
@@ -150,7 +150,7 @@ extension Array where Element == BadStruct {
150150
subscript(okay _: Int) -> Int { 0 } // okay
151151
}
152152

153-
extension Int: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; it is SPI}}
153+
extension Int: BadProto {} // expected-error {{cannot use protocol 'BadProto' in a public or '@usableFromInline' conformance; it is SPI}}
154154
struct TestExtensionConformanceOkay {}
155155
extension TestExtensionConformanceOkay: BadProto {} // okay
156156

0 commit comments

Comments
 (0)