Sema: Generalize the diagnostic about types with @_implementationOnly

This commit is contained in:
Alexis Laferrière
2025-11-04 14:17:28 -08:00
parent dd55d0d827
commit b52781e1e1
2 changed files with 13 additions and 13 deletions

View File

@@ -3848,7 +3848,7 @@ ERROR(decl_from_hidden_module,none,
"C++ types from imported module %2 do not support library evolution|"
"it was imported via the internal bridging header|"
"%2 was not imported publicly|"
"it is a struct marked '@_implementationOnly'}3",
"%0 is marked '@_implementationOnly'}3",
(const Decl *, unsigned, Identifier, unsigned))
ERROR(typealias_desugars_to_type_from_hidden_module,none,
"%0 aliases '%1.%2' and cannot be used %select{here|"
@@ -3867,7 +3867,7 @@ ERROR(typealias_desugars_to_type_from_hidden_module,none,
"C++ types from imported module %4 do not support library evolution|"
"it was imported via the internal bridging header|"
"%4 was not imported publicly|"
"it is a struct marked '@_implementationOnly'}5",
"%0 is marked '@_implementationOnly'}5",
(const TypeAliasDecl *, StringRef, StringRef, unsigned, Identifier, unsigned))
ERROR(conformance_from_implementation_only_module,none,
"cannot use conformance of %0 to %1 %select{here|as property wrapper here|"
@@ -3884,7 +3884,7 @@ ERROR(conformance_from_implementation_only_module,none,
"C++ types from imported module %3 do not support library evolution|"
"it was imported via the internal bridging header|"
"%3 was not imported publicly|"
"it is a struct marked '@_implementationOnly'}4",
"%0 is marked '@_implementationOnly'}4",
(Type, Identifier, unsigned, Identifier, unsigned))
NOTE(assoc_conformance_from_implementation_only_module,none,
"in associated type %0 (inferred as %1)", (Type, Type))
@@ -7353,7 +7353,7 @@ ERROR(inlinable_decl_ref_from_hidden_module,
"C++ APIs from imported module %2 do not support library evolution|"
"it was imported via the internal bridging header|"
"%2 was not imported publicly|"
"it is a struct marked '@_implementationOnly'}3",
"%0 is marked '@_implementationOnly'}3",
(const ValueDecl *, unsigned, Identifier, unsigned))
ERROR(inlinable_typealias_desugars_to_type_from_hidden_module,
@@ -7366,7 +7366,7 @@ ERROR(inlinable_typealias_desugars_to_type_from_hidden_module,
"C++ types from imported module %4 do not support library evolution|"
"it was imported via the internal bridging header|"
"%4 was not imported publicly|"
"it is a struct marked '@_implementationOnly'}5",
"%0 is marked '@_implementationOnly'}5",
(const TypeAliasDecl *, StringRef, StringRef, unsigned, Identifier, unsigned))
NOTE(missing_import_inserted,

View File

@@ -120,7 +120,7 @@ public func implicitlyInlinablePublic() {
let _: ExposedLayoutPublic = ExposedLayoutPublic()
let _: ExposedLayoutPrivate = ExposedLayoutPrivate()
let _: HiddenLayout = HiddenLayout()
// expected-embedded-opt-in-error @-1 2 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because it is a struct marked '@_implementationOnly'}}
// expected-embedded-opt-in-error @-1 2 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenLayout' is marked '@_implementationOnly'}}
let _: ExposedEnumPublic = ExposedEnumPublic.A
let _: ExposedEnumPrivate = ExposedEnumPrivate.A
@@ -130,7 +130,7 @@ private func implicitlyInlinablePrivate() {
let _: ExposedLayoutPublic = ExposedLayoutPublic()
let _: ExposedLayoutPrivate = ExposedLayoutPrivate()
let _: HiddenLayout = HiddenLayout()
// expected-embedded-opt-in-error @-1 2 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because it is a struct marked '@_implementationOnly'}}
// expected-embedded-opt-in-error @-1 2 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenLayout' is marked '@_implementationOnly'}}
let _: ExposedEnumPublic = ExposedEnumPublic.A
let _: ExposedEnumPrivate = ExposedEnumPrivate.A
@@ -169,10 +169,10 @@ public struct ExposedLayoutPublicUser {
private var b: ExposedLayoutPrivate
private var c: HiddenLayout
// expected-opt-in-error @-1 {{cannot use struct 'HiddenLayout' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is a struct marked '@_implementationOnly'}}
// expected-opt-in-error @-1 {{cannot use struct 'HiddenLayout' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenLayout' is marked '@_implementationOnly'}}
private func privateFunc(h: HiddenLayout) {}
// expected-embedded-opt-in-error @-1 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because it is a struct marked '@_implementationOnly'}}
// expected-embedded-opt-in-error @-1 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenLayout' is marked '@_implementationOnly'}}
}
internal struct ExposedLayoutInternalUser {
@@ -184,10 +184,10 @@ internal struct ExposedLayoutInternalUser {
private var aa: ExposedLayoutInternal
private var b: ExposedLayoutPrivate
private var c: HiddenLayout
// expected-opt-in-error @-1 {{cannot use struct 'HiddenLayout' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is a struct marked '@_implementationOnly'}}
// expected-opt-in-error @-1 {{cannot use struct 'HiddenLayout' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenLayout' is marked '@_implementationOnly'}}
private func privateFunc(h: HiddenLayout) {}
// expected-embedded-opt-in-error @-1 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because it is a struct marked '@_implementationOnly'}}
// expected-embedded-opt-in-error @-1 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenLayout' is marked '@_implementationOnly'}}
}
private struct ExposedLayoutPrivateUser {
@@ -199,10 +199,10 @@ private struct ExposedLayoutPrivateUser {
private var aa: ExposedLayoutInternal
private var b: ExposedLayoutPrivate
private var c: HiddenLayout
// expected-opt-in-error @-1 {{cannot use struct 'HiddenLayout' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; it is a struct marked '@_implementationOnly'}}
// expected-opt-in-error @-1 {{cannot use struct 'HiddenLayout' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenLayout' is marked '@_implementationOnly'}}
private func privateFunc(h: HiddenLayout) {}
// expected-embedded-opt-in-error @-1 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because it is a struct marked '@_implementationOnly'}}
// expected-embedded-opt-in-error @-1 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenLayout' is marked '@_implementationOnly'}}
}
#if UseImplementationOnly