diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index 0a767cf53a1b0..7b985b88eb1a6 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -3831,7 +3831,8 @@ ERROR(decl_from_hidden_module,none, "in an extension with public or '@usableFromInline' members|" "in an extension with conditional conformances|" "in a public or '@usableFromInline' conformance|" - "in an '@available' attribute here}1; " + "in an '@available' attribute here|" + "in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}1; " "%select{%2 has been imported as implementation-only|" "it is an SPI imported from %2|" "it is SPI|" @@ -3848,7 +3849,8 @@ ERROR(typealias_desugars_to_type_from_hidden_module,none, "in an extension with public or '@usableFromInline' members|" "in an extension with conditional conformance|" "in a public or '@usableFromInline' conformance|" - "<>}3 " + "<>|" + "in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}3 " "because %select{%4 has been imported as implementation-only|" "it is an SPI imported from %4|" "<>|" @@ -3863,7 +3865,8 @@ ERROR(conformance_from_implementation_only_module,none, "as result builder here|" "in an extension with public or '@usableFromInline' members|" "in an extension with conditional conformances|" - "<>|<>}2; " + "<>|<>|" + "in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}2; " "%select{%3 has been imported as implementation-only|" "the conformance is declared as SPI in %3|" "the conformance is declared as SPI|" diff --git a/lib/Sema/ResilienceDiagnostics.cpp b/lib/Sema/ResilienceDiagnostics.cpp index 7b785eb8f408a..b24213d8778a1 100644 --- a/lib/Sema/ResilienceDiagnostics.cpp +++ b/lib/Sema/ResilienceDiagnostics.cpp @@ -263,6 +263,7 @@ static bool shouldDiagnoseDeclAccess(const ValueDecl *D, case ExportabilityReason::General: case ExportabilityReason::ResultBuilder: case ExportabilityReason::PropertyWrapper: + case ExportabilityReason::PublicVarDecl: return false; } } diff --git a/lib/Sema/TypeCheckAccess.cpp b/lib/Sema/TypeCheckAccess.cpp index aaf0f679cedac..aaf1ebb079ce4 100644 --- a/lib/Sema/TypeCheckAccess.cpp +++ b/lib/Sema/TypeCheckAccess.cpp @@ -2376,7 +2376,8 @@ class DeclAvailabilityChecker : public DeclVisitor { if (seenVars.count(theVar)) return; - checkType(theVar->getValueInterfaceType(), /*typeRepr*/nullptr, theVar); + checkType(theVar->getValueInterfaceType(), /*typeRepr*/nullptr, theVar, + ExportabilityReason::PublicVarDecl); for (auto attr : theVar->getAttachedPropertyWrappers()) { checkType(attr->getType(), attr->getTypeRepr(), theVar, @@ -2398,7 +2399,8 @@ class DeclAvailabilityChecker : public DeclVisitor { }); checkType(TP->hasType() ? TP->getType() : Type(), - TP->getTypeRepr(), anyVar ? (Decl *)anyVar : (Decl *)PBD); + TP->getTypeRepr(), anyVar ? (Decl *)anyVar : (Decl *)PBD, + ExportabilityReason::PublicVarDecl); // Check the property wrapper types. if (anyVar) { diff --git a/lib/Sema/TypeCheckAvailability.h b/lib/Sema/TypeCheckAvailability.h index 30d5051de022a..ce74c185e80ee 100644 --- a/lib/Sema/TypeCheckAvailability.h +++ b/lib/Sema/TypeCheckAvailability.h @@ -69,7 +69,8 @@ enum class DeclAvailabilityFlag : uint8_t { using DeclAvailabilityFlags = OptionSet; // This enum must be kept in sync with -// diag::decl_from_hidden_module and +// diag::decl_from_hidden_module, +// diag::typealias_desugars_to_type_from_hidden_module, and // diag::conformance_from_implementation_only_module. enum class ExportabilityReason : unsigned { General, @@ -79,6 +80,7 @@ enum class ExportabilityReason : unsigned { ExtensionWithConditionalConformances, Inheritance, AvailableAttribute, + PublicVarDecl, }; /// A description of the restrictions on what declarations can be referenced diff --git a/test/Availability/spi-available-context.swift b/test/Availability/spi-available-context.swift index 95e99ba5e05e4..f2372b88f44c5 100644 --- a/test/Availability/spi-available-context.swift +++ b/test/Availability/spi-available-context.swift @@ -18,6 +18,6 @@ public class Bar { @available(macOS 10.10, iOS 8.0, *) public class Baz { - public var macos: MacOSSPIProto? // expected-error {{cannot use protocol 'MacOSSPIProto' here; it is SPI}} + public var macos: MacOSSPIProto? // expected-error {{cannot use protocol 'MacOSSPIProto' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} public var ios: iOSSPIProto? } diff --git a/test/Availability/spi-available-swift-module.swift b/test/Availability/spi-available-swift-module.swift index d13c9a875cb95..98e9876ba14c9 100644 --- a/test/Availability/spi-available-swift-module.swift +++ b/test/Availability/spi-available-swift-module.swift @@ -21,6 +21,6 @@ import Foo @available(macOS 10.10, iOS 8.0, *) public struct Foo { - public var macos: MacOSSPIClass // expected-error {{cannot use class 'MacOSSPIClass' here; it is an SPI imported from 'Foo'}} + public var macos: MacOSSPIClass // expected-error {{cannot use class 'MacOSSPIClass' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is an SPI imported from 'Foo'}} public var ios: iOSSPIClass } diff --git a/test/ClangImporter/availability_spi_as_unavailable.swift b/test/ClangImporter/availability_spi_as_unavailable.swift index 7affc3ea9d5e9..962f9bcaf50e5 100644 --- a/test/ClangImporter/availability_spi_as_unavailable.swift +++ b/test/ClangImporter/availability_spi_as_unavailable.swift @@ -9,8 +9,8 @@ import SPIContainer @_spi(a) public let a: SPIInterface1 = .init() @_spi(a) public let b: SPIInterface2 = .init() -public let c: SPIInterface1 = .init() // expected-error{{cannot use class 'SPIInterface1' here; it is an SPI imported from 'SPIContainer'}} -public let d: SPIInterface2 = .init() // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from 'SPIContainer'}} +public let c: SPIInterface1 = .init() // expected-error{{cannot use class 'SPIInterface1' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is an SPI imported from 'SPIContainer'}} +public let d: SPIInterface2 = .init() // expected-error{{cannot use class 'SPIInterface2' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is an SPI imported from 'SPIContainer'}} @inlinable public func inlinableUsingSPI() { @@ -21,7 +21,7 @@ public func inlinableUsingSPI() { public let e: SPIInterface2 = .init() @available(iOS, unavailable) -public let f: SPIInterface2 = .init() // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from 'SPIContainer'}} +public let f: SPIInterface2 = .init() // expected-error{{cannot use class 'SPIInterface2' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is an SPI imported from 'SPIContainer'}} @inlinable @available(macOS, unavailable) diff --git a/test/ClangImporter/availability_spi_as_unavailable_bridging_header.swift b/test/ClangImporter/availability_spi_as_unavailable_bridging_header.swift index f84d7118fc55b..e21d682705505 100644 --- a/test/ClangImporter/availability_spi_as_unavailable_bridging_header.swift +++ b/test/ClangImporter/availability_spi_as_unavailable_bridging_header.swift @@ -5,8 +5,8 @@ @_spi(a) public let a: SPIInterface1 @_spi(a) public let b: SPIInterface2 -public let c: SPIInterface1 // expected-error{{cannot use class 'SPIInterface1' here; it is an SPI imported from '__ObjC'}} -public let d: SPIInterface2 // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from '__ObjC'}} +public let c: SPIInterface1 // expected-error{{cannot use class 'SPIInterface1' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is an SPI imported from '__ObjC'}} +public let d: SPIInterface2 // expected-error{{cannot use class 'SPIInterface2' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is an SPI imported from '__ObjC'}} @inlinable public func inlinableUsingSPI() { // expected-warning{{public declarations should have an availability attribute with an introduction version}} diff --git a/test/ClangImporter/availability_spi_transitive.swift b/test/ClangImporter/availability_spi_transitive.swift index 397a981e111f8..0e9c90da3992a 100644 --- a/test/ClangImporter/availability_spi_transitive.swift +++ b/test/ClangImporter/availability_spi_transitive.swift @@ -5,4 +5,4 @@ import SPIContainerImporter @_spi(a) public let a: SPIInterface1 -public let c: SPIInterface1 // expected-error{{cannot use class 'SPIInterface1' here; it is an SPI imported from 'SPIContainer'}} +public let c: SPIInterface1 // expected-error{{cannot use class 'SPIInterface1' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is an SPI imported from 'SPIContainer'}} diff --git a/test/SPI/implementation_only_spi_import_exposability.swift b/test/SPI/implementation_only_spi_import_exposability.swift index b62354a15e1af..364abe23b6d3c 100644 --- a/test/SPI/implementation_only_spi_import_exposability.swift +++ b/test/SPI/implementation_only_spi_import_exposability.swift @@ -34,8 +34,8 @@ public protocol IOIProtocol {} public struct PublicStruct : IOIProtocol, SPIProtocol { // expected-error {{cannot use protocol 'IOIProtocol' in a public or '@usableFromInline' conformance; 'Lib' has been imported as implementation-only}} // expected-error @-1 {{cannot use protocol 'SPIProtocol' in a public or '@usableFromInline' conformance; 'Lib' has been imported as implementation-only}} - public var spiStruct = SPIStruct() // expected-error {{cannot use struct 'SPIStruct' here; 'Lib' has been imported as implementation-only}} - public var ioiStruct = IOIStruct() // expected-error {{cannot use struct 'IOIStruct' here; 'Lib' has been imported as implementation-only}} + public var spiStruct = SPIStruct() // expected-error {{cannot use struct 'SPIStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'Lib' has been imported as implementation-only}} + public var ioiStruct = IOIStruct() // expected-error {{cannot use struct 'IOIStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'Lib' has been imported as implementation-only}} @inlinable public func publicInlinable() { diff --git a/test/SPI/local_spi_decls.swift b/test/SPI/local_spi_decls.swift index d34ef079a8efe..d9350b4b3aa46 100644 --- a/test/SPI/local_spi_decls.swift +++ b/test/SPI/local_spi_decls.swift @@ -51,10 +51,10 @@ func inlinable() -> SPIClass { // expected-error {{class 'SPIClass' cannot be us // expected-error@-1 {{stored property 'spiInFrozen' cannot be declared '@_spi' in a '@frozen' struct}} var spiTypeInFrozen = SPIStruct() // expected-error {{struct 'SPIStruct' cannot be used in a property initializer in a '@frozen' type because it is SPI}} - // expected-error@-1 {{cannot use struct 'SPIStruct' here; it is SPI}} + // expected-error@-1 {{cannot use struct 'SPIStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} // expected-error@-2 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}} - private var spiTypeInFrozen1: SPIClass // expected-error {{cannot use class 'SPIClass' here; it is SPI}} + private var spiTypeInFrozen1: SPIClass // expected-error {{cannot use class 'SPIClass' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} } @_spi(S) @@ -81,8 +81,8 @@ public func genFuncBad(_ t: T) {} // expected-error {{cannot use @_spi(S) func internalCantBeSPI() {} // expected-error{{internal global function cannot be declared '@_spi' because only public and open declarations can be '@_spi'}} {{1-10=}} public struct PublicStructWithProperties { - public var a: SPIClass // expected-error {{cannot use class 'SPIClass' here; it is SPI}} - public var b = SPIClass() // expected-error {{cannot use class 'SPIClass' here; it is SPI}} + public var a: SPIClass // expected-error {{cannot use class 'SPIClass' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} + public var b = SPIClass() // expected-error {{cannot use class 'SPIClass' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} } @_spi(S) diff --git a/test/SPI/spi-only-import-exportability.swift b/test/SPI/spi-only-import-exportability.swift index 27a285e781bb2..f1116cd012191 100644 --- a/test/SPI/spi-only-import-exportability.swift +++ b/test/SPI/spi-only-import-exportability.swift @@ -149,7 +149,7 @@ public func implementationDetailsUser() { public struct ClientStruct { #if !SKIP_ERRORS - public var a: SPIOnlyStruct // expected-error {{cannot use struct 'SPIOnlyStruct' here; 'SPIOnlyImportedLib' was imported for SPI only}} + public var a: SPIOnlyStruct // expected-error {{cannot use struct 'SPIOnlyStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'SPIOnlyImportedLib' was imported for SPI only}} // expected-error@+1 {{cannot use property 'wrappedValue' here; 'SPIOnlyImportedLib' was imported for SPI only}} @SPIOnlyPropertyWrapper(42) public var aWrapped: Any // expected-error {{cannot use generic struct 'SPIOnlyPropertyWrapper' as property wrapper here; 'SPIOnlyImportedLib' was imported for SPI only}} #endif diff --git a/test/SPI/spi_members.swift b/test/SPI/spi_members.swift index 37184d30d7b04..b48249022f8fc 100644 --- a/test/SPI/spi_members.swift +++ b/test/SPI/spi_members.swift @@ -79,7 +79,7 @@ public struct ResilientStructSPIMembers { @_spi(Foo) public var computedProperty: SPIType { SPIType() } @_spi(Foo) public var storedProperty1: SPIType - // expected-error@-1 {{cannot use class 'SPIType' here; it is SPI}} + // expected-error@-1 {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} // expected-error@-2 {{stored property 'storedProperty1' cannot be declared '@_spi' in a '@frozen' struct}} @_spi(Foo) public var storedProperty2 = SPIType() @@ -89,7 +89,7 @@ public struct ResilientStructSPIMembers { // expected-error@-1 {{stored property 'lazyProperty1' cannot be declared '@_spi' in a '@frozen' struct}} @_spi(Foo) public lazy var lazyProperty2: SPIType = SPIType() - // expected-error@-1 {{cannot use class 'SPIType' here; it is SPI}} + // expected-error@-1 {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} // expected-error@-2 {{stored property 'lazyProperty2' cannot be declared '@_spi' in a '@frozen' struct}} @_spi(Foo) @Wrapper public var wrappedProperty1: SPIType @@ -108,24 +108,24 @@ public struct ResilientStructSPIMembers { public func method(_: SPIType) {} // expected-error {{cannot use class 'SPIType' here; it is SPI}} public var storedProperty1: SPIType - // expected-error@-1 {{cannot use class 'SPIType' here; it is SPI}} + // expected-error@-1 {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} public var storedProperty2 = SPIType() - // expected-error@-1 {{cannot use class 'SPIType' here; it is SPI}} + // expected-error@-1 {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} // expected-error@-2 {{class 'SPIType' cannot be used in a property initializer in a '@frozen' type because it is SPI}} // expected-error@-3 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}} - public var computedProperty: SPIType { SPIType() } // expected-error {{cannot use class 'SPIType' here; it is SPI}} + public var computedProperty: SPIType { SPIType() } // expected-error {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} - public lazy var lazyProperty1 = SPIType() // expected-error {{cannot use class 'SPIType' here; it is SPI}} + public lazy var lazyProperty1 = SPIType() // expected-error {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} - public lazy var lazyProperty2: SPIType = SPIType() // expected-error {{cannot use class 'SPIType' here; it is SPI}} + public lazy var lazyProperty2: SPIType = SPIType() // expected-error {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} @Wrapper public var wrappedProperty1: SPIType - // expected-error@-1 {{cannot use class 'SPIType' here; it is SPI}} + // expected-error@-1 {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} @Wrapper public var wrappedProperty2 = SPIType() - // expected-error@-1 {{cannot use class 'SPIType' here; it is SPI}} + // expected-error@-1 {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} // expected-error@-2 {{class 'SPIType' cannot be used in a property initializer in a '@frozen' type because it is SPI}} // expected-error@-3 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}} @@ -140,24 +140,24 @@ public struct ResilientStructSPIMembers { private func method(_: SPIType) {} private var storedProperty1: SPIType - // expected-error@-1 {{cannot use class 'SPIType' here; it is SPI}} + // expected-error@-1 {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} private var storedProperty2 = SPIType() - // expected-error@-1 {{cannot use class 'SPIType' here; it is SPI}} + // expected-error@-1 {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} // expected-error@-2 {{class 'SPIType' cannot be used in a property initializer in a '@frozen' type because it is SPI}} // expected-error@-3 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}} private var computedProperty: SPIType { SPIType() } - private lazy var lazyProperty1 = SPIType() // expected-error {{cannot use class 'SPIType' here; it is SPI}} + private lazy var lazyProperty1 = SPIType() // expected-error {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} - private lazy var lazyProperty2: SPIType = SPIType() // expected-error {{cannot use class 'SPIType' here; it is SPI}} + private lazy var lazyProperty2: SPIType = SPIType() // expected-error {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} @Wrapper private var wrappedProperty1: SPIType - // expected-error@-1 {{cannot use class 'SPIType' here; it is SPI}} + // expected-error@-1 {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} @Wrapper private var wrappedProperty2 = SPIType() - // expected-error@-1 {{cannot use class 'SPIType' here; it is SPI}} + // expected-error@-1 {{cannot use class 'SPIType' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} // expected-error@-2 {{class 'SPIType' cannot be used in a property initializer in a '@frozen' type because it is SPI}} // expected-error@-3 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}} } diff --git a/test/Sema/access-level-import-embedded.swift b/test/Sema/access-level-import-embedded.swift index b81ac9a7db56f..feae382564d98 100644 --- a/test/Sema/access-level-import-embedded.swift +++ b/test/Sema/access-level-import-embedded.swift @@ -171,7 +171,7 @@ public func legalAccessToIndirect(arg: StructFromIndirect = StructFromIndirect() public struct ExposedLayoutPublic { public var publicField: StructFromDirect // expected-error {{property cannot be declared public because its type uses an internal type}} - // expected-error @-1 {{cannot use struct 'StructFromDirect' here; 'directs' has been imported as implementation-only}} + // expected-error @-1 {{cannot use struct 'StructFromDirect' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'directs' has been imported as implementation-only}} // expected-note @-2 {{struct 'StructFromDirect' is imported by this file as 'internal' from 'directs'}} private var privateField: StructFromDirect diff --git a/test/Sema/implementation-only-import-embedded.swift b/test/Sema/implementation-only-import-embedded.swift index 831f44f946d2a..49ebf9f0aa568 100644 --- a/test/Sema/implementation-only-import-embedded.swift +++ b/test/Sema/implementation-only-import-embedded.swift @@ -200,7 +200,7 @@ public func legalAccessToIndirect(arg: StructFromIndirect = StructFromIndirect() } public struct ExposedLayoutPublic { - public var publicField: StructFromDirect // expected-error {{cannot use struct 'StructFromDirect' here; 'directs' has been imported as implementation-only}} + public var publicField: StructFromDirect // expected-error {{cannot use struct 'StructFromDirect' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'directs' has been imported as implementation-only}} private var privateField: StructFromDirect // FIXME should error } diff --git a/test/Sema/implementation-only-import-in-decls.swift b/test/Sema/implementation-only-import-in-decls.swift index bc5508157311c..2ab9a087f5d18 100644 --- a/test/Sema/implementation-only-import-in-decls.swift +++ b/test/Sema/implementation-only-import-in-decls.swift @@ -87,16 +87,16 @@ public typealias TestGenericParamsAliasWhereClause = T where T: BadProto // e public typealias TestGenericParamsAlias = T // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} -public var testBadType: BadStruct? = nil // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} -public var testBadTypeInferred = Optional.none // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} -public var testBadTypePartiallyInferred: Optional = Optional.none // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} +public var testBadType: BadStruct? = nil // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} +public var testBadTypeInferred = Optional.none // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} +public var testBadTypePartiallyInferred: Optional = Optional.none // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} public var (testBadTypeTuple1, testBadTypeTuple2): (BadStruct?, BadClass?) = (nil, nil) -// expected-error@-1 {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} -// expected-error@-2 {{cannot use class 'BadClass' here; 'BADLibrary' has been imported as implementation-only}} -public var (testBadTypeTuplePartlyInferred1, testBadTypeTuplePartlyInferred2): (Optional, Optional) = (Optional.none, Optional.none) // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} -public var (testBadTypeTuplePartlyInferred3, testBadTypeTuplePartlyInferred4): (Optional, Optional) = (Optional.none, Optional.none) // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} -public var testMultipleBindings1: Int? = nil, testMultipleBindings2: BadStruct? = nil // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} -public var testMultipleBindings3: BadStruct? = nil, testMultipleBindings4: Int? = nil // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} +// expected-error@-1 {{cannot use class 'BadClass' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} +// expected-error@-2 {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} +public var (testBadTypeTuplePartlyInferred1, testBadTypeTuplePartlyInferred2): (Optional, Optional) = (Optional.none, Optional.none) // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} +public var (testBadTypeTuplePartlyInferred3, testBadTypeTuplePartlyInferred4): (Optional, Optional) = (Optional.none, Optional.none) // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} +public var testMultipleBindings1: Int? = nil, testMultipleBindings2: BadStruct? = nil // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} +public var testMultipleBindings3: BadStruct? = nil, testMultipleBindings4: Int? = nil // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} extension BadStruct { // expected-error {{cannot use struct 'BadStruct' in an extension with public or '@usableFromInline' members; 'BADLibrary' has been imported as implementation-only}} public func testExtensionOfBadType() {} @@ -140,39 +140,39 @@ precedencegroup TestHigherThan { } @frozen public struct PublicStructStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} // expected-error@-1 {{struct 'BadStruct' cannot be used in a property initializer in a '@frozen' type because 'BADLibrary' was imported implementation-only}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} } @frozen @usableFromInline internal struct UFIStructStoredProperties { - @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} // expected-error@-1 {{struct 'BadStruct' cannot be used in a property initializer in a '@frozen' type because 'BADLibrary' was imported implementation-only}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} } @_fixed_layout public class PublicClassStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} // expected-error@-1 {{struct 'BadStruct' cannot be used in a property initializer in a '@frozen' type because 'BADLibrary' was imported implementation-only}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} } public typealias NormalProtoAssoc = T.Assoc diff --git a/test/Sema/implementation-only-import-library-evolution.swift b/test/Sema/implementation-only-import-library-evolution.swift index 24f63845f2f88..d9b52f88cbe2a 100644 --- a/test/Sema/implementation-only-import-library-evolution.swift +++ b/test/Sema/implementation-only-import-library-evolution.swift @@ -8,98 +8,98 @@ // expected-warning @-1 {{'@_implementationOnly' is deprecated, use 'internal import' instead}} public struct PublicStructStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} internal var internallyBad: BadStruct? // okay private var privatelyBad: BadStruct? // okay private let letIsLikeVar = [BadStruct]() // okay private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} } @usableFromInline internal struct UFIStructStoredProperties { - @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} internal var internallyBad: BadStruct? // okay private var privatelyBad: BadStruct? // okay private let letIsLikeVar = [BadStruct]() // okay private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} } public class PublicClassStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} internal var internallyBad: BadStruct? // okay private var privatelyBad: BadStruct? // okay private let letIsLikeVar = [BadStruct]() // okay private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} } // MARK: Frozen types @frozen public struct FrozenPublicStructStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} } @frozen @usableFromInline internal struct FrozenUFIStructStoredProperties { - @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} } @_fixed_layout // expected-warning@-1 {{'@frozen' attribute is now used for fixed-layout structs}} public struct FixedLayoutPublicStructStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} } @_fixed_layout // expected-warning@-1 {{'@frozen' attribute is now used for fixed-layout structs}} @usableFromInline internal struct FixedLayoutUFIStructStoredProperties { - @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} } @_fixed_layout public class FrozenPublicClassStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} - private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} + private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'BADLibrary' has been imported as implementation-only}} } diff --git a/test/Sema/spi-in-decls.swift b/test/Sema/spi-in-decls.swift index 33e347df4d853..fe0fafd24ab7e 100644 --- a/test/Sema/spi-in-decls.swift +++ b/test/Sema/spi-in-decls.swift @@ -118,16 +118,16 @@ public typealias TestGenericParamsAliasWhereClause = T where T: BadProto // e public typealias TestGenericParamsAlias = T // expected-error {{cannot use protocol 'BadProto' here; it is SPI}} -public var testBadType: BadStruct? = nil // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} -public var testBadTypeInferred = Optional.none // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} -public var testBadTypePartiallyInferred: Optional = Optional.none // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} +public var testBadType: BadStruct? = nil // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} +public var testBadTypeInferred = Optional.none // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} +public var testBadTypePartiallyInferred: Optional = Optional.none // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} public var (testBadTypeTuple1, testBadTypeTuple2): (BadStruct?, BadClass?) = (nil, nil) -// expected-error@-1 {{cannot use struct 'BadStruct' here; it is SPI}} -// expected-error@-2 {{cannot use class 'BadClass' here; it is SPI}} -public var (testBadTypeTuplePartlyInferred1, testBadTypeTuplePartlyInferred2): (Optional, Optional) = (Optional.none, Optional.none) // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} -public var (testBadTypeTuplePartlyInferred3, testBadTypeTuplePartlyInferred4): (Optional, Optional) = (Optional.none, Optional.none) // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} -public var testMultipleBindings1: Int? = nil, testMultipleBindings2: BadStruct? = nil // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} -public var testMultipleBindings3: BadStruct? = nil, testMultipleBindings4: Int? = nil // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} +// expected-error@-1 {{cannot use class 'BadClass' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} +// expected-error@-2 {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} +public var (testBadTypeTuplePartlyInferred1, testBadTypeTuplePartlyInferred2): (Optional, Optional) = (Optional.none, Optional.none) // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} +public var (testBadTypeTuplePartlyInferred3, testBadTypeTuplePartlyInferred4): (Optional, Optional) = (Optional.none, Optional.none) // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} +public var testMultipleBindings1: Int? = nil, testMultipleBindings2: BadStruct? = nil // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} +public var testMultipleBindings3: BadStruct? = nil, testMultipleBindings4: Int? = nil // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} extension BadStruct { public func testExtensionOfBadType() {} @@ -171,39 +171,39 @@ extension Array: TestConstrainedExtensionProto where Element == BadStruct { // e //} @frozen public struct PublicStructStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} - internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} - private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} - private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} + public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} + internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} + private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} + private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} // expected-error@-1 {{struct 'BadStruct' cannot be used in a property initializer in a '@frozen' type because it is SPI}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} } @frozen @usableFromInline internal struct UFIStructStoredProperties { - @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} - internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} - private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} - private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} + @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} + internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} + private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} + private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} // expected-error@-1 {{struct 'BadStruct' cannot be used in a property initializer in a '@frozen' type because it is SPI}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} } @_fixed_layout public class PublicClassStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} - internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} - private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} - private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} + public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} + internal var internallyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} + private var privatelyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} + private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} // expected-error@-1 {{struct 'BadStruct' cannot be used in a property initializer in a '@frozen' type because it is SPI}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; it is SPI}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is SPI}} } public typealias NormalProtoAssoc = T.Assoc diff --git a/test/Sema/superfluously-public-imports.swift b/test/Sema/superfluously-public-imports.swift index a4642d1177a78..69a20de9b0db1 100644 --- a/test/Sema/superfluously-public-imports.swift +++ b/test/Sema/superfluously-public-imports.swift @@ -228,8 +228,8 @@ extension NonPublicExtendedType { } public struct Struct { // expected-remark {{implicitly used struct 'Int' is imported via 'Swift'}} - public var propWithInferredIntType = 42 - public var propWithExplicitType: String = "Text" // expected-remark {{struct 'String' is imported via 'Swift'}} + public var propWithInferredIntType = 42 // expected-remark {{struct 'Int' is imported via 'Swift'}} + public var propWithExplicitType: String = "Text" // expected-remark 3 {{struct 'String' is imported via 'Swift'}} } public func publicFunction() { @@ -246,7 +246,7 @@ package func packageFunc(a: PackageType = packageFunc()) {} // expected-remark { public func spiFunc(a: ToUseFromSPI) {} // expected-remark {{struct 'ToUseFromSPI' is imported via 'SPIOnlyUsedInSPI'}} public protocol Countable { - var count: Int { get } // expected-remark {{struct 'Int' is imported via 'Swift'}} + var count: Int { get } // expected-remark 3 {{struct 'Int' is imported via 'Swift'}} } extension Extended: Countable { // expected-remark {{struct 'Extended' is imported via 'RetroactiveConformance'}}