diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index 834e62243b824..27ed43036d043 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -2388,16 +2388,15 @@ NOTE(construct_raw_representable_from_unwrapped_value,none, "construct %0 from unwrapped %1 value", (Type, Type)) ERROR(decl_from_implementation_only_module,none, - "cannot use %0 here; %1 has been imported as " - "'@_implementationOnly'", - (DeclName, Identifier)) + "cannot use %0 %1 here; %2 has been imported as implementation-only", + (DescriptiveDeclKind, DeclName, Identifier)) ERROR(conformance_from_implementation_only_module,none, "cannot use conformance of %0 to %1 here; %2 has been imported as " - "'@_implementationOnly'", + "implementation-only", (Type, DeclName, Identifier)) ERROR(assoc_conformance_from_implementation_only_module,none, "cannot use conformance of %0 to %1 in associated type %3 (inferred as " - "%4); %2 has been imported as '@_implementationOnly'", + "%4); %2 has been imported as implementation-only", (Type, DeclName, Identifier, Type, Type)) // Derived conformances @@ -4084,9 +4083,9 @@ WARNING(resilience_decl_unavailable_warn, (DescriptiveDeclKind, DeclName, AccessLevel, unsigned, bool)) ERROR(inlinable_decl_ref_implementation_only, - none, "%0 %1 cannot be used in an inlinable " - "function because its module was imported implementation-only", - (DescriptiveDeclKind, DeclName)) + none, "%0 %1 cannot be used in " FRAGILE_FUNC_KIND "2 " + "because %3 was imported implementation-only", + (DescriptiveDeclKind, DeclName, unsigned, Identifier)) #undef FRAGILE_FUNC_KIND diff --git a/lib/Sema/ResilienceDiagnostics.cpp b/lib/Sema/ResilienceDiagnostics.cpp index bb626d0670bf7..764ca3f3bddf9 100644 --- a/lib/Sema/ResilienceDiagnostics.cpp +++ b/lib/Sema/ResilienceDiagnostics.cpp @@ -119,8 +119,11 @@ bool TypeChecker::diagnoseInlinableDeclRef(SourceLoc loc, return true; // Check whether the declaration comes from a publically-imported module. - if (diagnoseDeclRefExportability(loc, declRef, DC)) - return true; + // Skip this check for accessors because the associated property or subscript + // will also be checked, and will provide a better error message. + if (!isa(D)) + if (diagnoseDeclRefExportability(loc, declRef, DC, Kind)) + return true; return false; } @@ -208,7 +211,8 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc, } static bool diagnoseDeclExportability(SourceLoc loc, const ValueDecl *D, - const SourceFile &userSF) { + const SourceFile &userSF, + FragileFunctionKind fragileKind) { auto definingModule = D->getModuleContext(); if (!userSF.isImportedImplementationOnly(definingModule)) return false; @@ -216,7 +220,9 @@ static bool diagnoseDeclExportability(SourceLoc loc, const ValueDecl *D, // TODO: different diagnostics ASTContext &ctx = definingModule->getASTContext(); ctx.Diags.diagnose(loc, diag::inlinable_decl_ref_implementation_only, - D->getDescriptiveKind(), D->getFullName()); + D->getDescriptiveKind(), D->getFullName(), + static_cast(fragileKind), + definingModule->getName()); return true; } @@ -288,9 +294,11 @@ void TypeChecker::diagnoseGenericTypeExportability(const TypeLoc &TL, })); } -bool TypeChecker::diagnoseDeclRefExportability(SourceLoc loc, - ConcreteDeclRef declRef, - const DeclContext *DC) { +bool +TypeChecker::diagnoseDeclRefExportability(SourceLoc loc, + ConcreteDeclRef declRef, + const DeclContext *DC, + FragileFunctionKind fragileKind) { // We're only interested in diagnosing uses from source files. auto userSF = DC->getParentSourceFile(); if (!userSF) @@ -305,7 +313,7 @@ bool TypeChecker::diagnoseDeclRefExportability(SourceLoc loc, return false; const ValueDecl *D = declRef.getDecl(); - if (diagnoseDeclExportability(loc, D, *userSF)) + if (diagnoseDeclExportability(loc, D, *userSF, fragileKind)) return true; if (diagnoseGenericArgumentsExportability(loc, declRef.getSubstitutions(), *userSF)) { diff --git a/lib/Sema/TypeCheckAccess.cpp b/lib/Sema/TypeCheckAccess.cpp index 552123d6fa217..aed26925b1561 100644 --- a/lib/Sema/TypeCheckAccess.cpp +++ b/lib/Sema/TypeCheckAccess.cpp @@ -1401,19 +1401,18 @@ class UsableFromInlineChecker : public AccessControlCheckerBase, } }; -class ImplementationOnlyImportChecker - : public DeclVisitor { - using CheckImplementationOnlyTypeCallback = +class ExportabilityChecker : public DeclVisitor { + using CheckExportabilityTypeCallback = llvm::function_ref; - using CheckImplementationOnlyConformanceCallback = + using CheckExportabilityConformanceCallback = llvm::function_ref; TypeChecker &TC; void checkTypeImpl( Type type, const TypeRepr *typeRepr, const SourceFile &SF, - CheckImplementationOnlyTypeCallback diagnoseType, - CheckImplementationOnlyConformanceCallback diagnoseConformance) { + CheckExportabilityTypeCallback diagnoseType, + CheckExportabilityConformanceCallback diagnoseConformance) { // Don't bother checking errors. if (type && type->hasError()) return; @@ -1448,13 +1447,13 @@ class ImplementationOnlyImportChecker class ProblematicTypeFinder : public TypeDeclFinder { const SourceFile &SF; - CheckImplementationOnlyTypeCallback diagnoseType; - CheckImplementationOnlyConformanceCallback diagnoseConformance; + CheckExportabilityTypeCallback diagnoseType; + CheckExportabilityConformanceCallback diagnoseConformance; public: ProblematicTypeFinder( const SourceFile &SF, - CheckImplementationOnlyTypeCallback diagnoseType, - CheckImplementationOnlyConformanceCallback diagnoseConformance) + CheckExportabilityTypeCallback diagnoseType, + CheckExportabilityConformanceCallback diagnoseConformance) : SF(SF), diagnoseType(diagnoseType), diagnoseConformance(diagnoseConformance) {} @@ -1510,8 +1509,8 @@ class ImplementationOnlyImportChecker void checkType( Type type, const TypeRepr *typeRepr, const Decl *context, - CheckImplementationOnlyTypeCallback diagnoseType, - CheckImplementationOnlyConformanceCallback diagnoseConformance) { + CheckExportabilityTypeCallback diagnoseType, + CheckExportabilityConformanceCallback diagnoseConformance) { auto *SF = context->getDeclContext()->getParentSourceFile(); assert(SF && "checking a non-source declaration?"); return checkTypeImpl(type, typeRepr, *SF, diagnoseType, @@ -1520,8 +1519,8 @@ class ImplementationOnlyImportChecker void checkType( const TypeLoc &TL, const Decl *context, - CheckImplementationOnlyTypeCallback diagnoseType, - CheckImplementationOnlyConformanceCallback diagnoseConformance) { + CheckExportabilityTypeCallback diagnoseType, + CheckExportabilityConformanceCallback diagnoseConformance) { checkType(TL.getType(), TL.getTypeRepr(), context, diagnoseType, diagnoseConformance); } @@ -1558,6 +1557,7 @@ class ImplementationOnlyImportChecker const TypeRepr *complainRepr) { ModuleDecl *M = offendingType->getModuleContext(); auto diag = TC.diagnose(D, diag::decl_from_implementation_only_module, + offendingType->getDescriptiveKind(), offendingType->getFullName(), M->getName()); highlightOffendingType(TC, diag, complainRepr); } @@ -1573,11 +1573,11 @@ class ImplementationOnlyImportChecker static_assert( std::is_convertible::value, + CheckExportabilityTypeCallback>::value, "DiagnoseGenerically has wrong call signature"); static_assert( std::is_convertible::value, + CheckExportabilityConformanceCallback>::value, "DiagnoseGenerically has wrong call signature for conformance diags"); DiagnoseGenerically getDiagnoseCallback(const Decl *D) { @@ -1585,7 +1585,7 @@ class ImplementationOnlyImportChecker } public: - explicit ImplementationOnlyImportChecker(TypeChecker &TC) : TC(TC) {} + explicit ExportabilityChecker(TypeChecker &TC) : TC(TC) {} static bool shouldSkipChecking(const ValueDecl *VD) { // Is this part of the module's API or ABI? @@ -1620,7 +1620,7 @@ class ImplementationOnlyImportChecker if (shouldSkipChecking(VD)) return; - DeclVisitor::visit(D); + DeclVisitor::visit(D); if (auto *extension = dyn_cast(D->getDeclContext())) { checkType(extension->getExtendedTypeLoc(), extension, @@ -1830,7 +1830,8 @@ class ImplementationOnlyImportChecker return; auto diag = TC.diagnose(diagLoc, diag::decl_from_implementation_only_module, - PGD->getName(), M->getName()); + PGD->getDescriptiveKind(), PGD->getName(), + M->getName()); if (refRange.isValid()) diag.highlight(refRange); diag.flush(); @@ -1904,5 +1905,5 @@ void swift::checkAccessControl(TypeChecker &TC, Decl *D) { checkExtensionGenericParamAccess(TC, ED); } - ImplementationOnlyImportChecker(TC).visit(D); + ExportabilityChecker(TC).visit(D); } diff --git a/lib/Sema/TypeCheckProtocol.cpp b/lib/Sema/TypeCheckProtocol.cpp index 77f1e2f47a417..89773977b97d7 100644 --- a/lib/Sema/TypeCheckProtocol.cpp +++ b/lib/Sema/TypeCheckProtocol.cpp @@ -3643,17 +3643,17 @@ void ConformanceChecker::ensureRequirementsAreSatisfied( std::function writer = Conformance->populateSignatureConformances(); - SourceFile *fileForCheckingImplementationOnlyUse = nullptr; + SourceFile *fileForCheckingExportability = nullptr; if (getRequiredAccessScope().isPublic() || isUsableFromInlineRequired()) - fileForCheckingImplementationOnlyUse = DC->getParentSourceFile(); + fileForCheckingExportability = DC->getParentSourceFile(); class GatherConformancesListener : public GenericRequirementsCheckListener { NormalProtocolConformance *conformanceBeingChecked; SourceFile *SF; std::function &writer; - void checkForImplementationOnlyUse(Type depTy, Type replacementTy, - const ProtocolConformance *conformance) { + void checkExportability(Type depTy, Type replacementTy, + const ProtocolConformance *conformance) { if (!SF) return; @@ -3662,8 +3662,7 @@ void ConformanceChecker::ensureRequirementsAreSatisfied( for (auto &subConformance : subs.getConformances()) { if (!subConformance.isConcrete()) continue; - checkForImplementationOnlyUse(depTy, replacementTy, - subConformance.getConcrete()); + checkExportability(depTy, replacementTy, subConformance.getConcrete()); } const RootProtocolConformance *rootConformance = @@ -3695,9 +3694,9 @@ void ConformanceChecker::ensureRequirementsAreSatisfied( GatherConformancesListener( NormalProtocolConformance *conformance, std::function &writer, - SourceFile *fileForCheckingImplementationOnlyUse) + SourceFile *fileForCheckingExportability) : conformanceBeingChecked(conformance), - SF(fileForCheckingImplementationOnlyUse), writer(writer) { } + SF(fileForCheckingExportability), writer(writer) { } void satisfiedConformance(Type depTy, Type replacementTy, ProtocolConformanceRef conformance) override { @@ -3720,8 +3719,7 @@ void ConformanceChecker::ensureRequirementsAreSatisfied( conformance = ProtocolConformanceRef(concreteConformance); } - checkForImplementationOnlyUse(depTy, replacementTy, - concreteConformance); + checkExportability(depTy, replacementTy, concreteConformance); } writer(conformance); @@ -3737,7 +3735,7 @@ void ConformanceChecker::ensureRequirementsAreSatisfied( return false; } - } listener(Conformance, writer, fileForCheckingImplementationOnlyUse); + } listener(Conformance, writer, fileForCheckingExportability); auto result = TC.checkGenericArguments( DC, Loc, Loc, diff --git a/lib/Sema/TypeChecker.h b/lib/Sema/TypeChecker.h index e8314d7a1d7f5..285ce08770f6e 100644 --- a/lib/Sema/TypeChecker.h +++ b/lib/Sema/TypeChecker.h @@ -1891,7 +1891,8 @@ class TypeChecker final : public LazyResolver { /// exposes it in the interface of the current module, diagnose if it cannot /// reasonably be shared. bool diagnoseDeclRefExportability(SourceLoc loc, ConcreteDeclRef declRef, - const DeclContext *DC); + const DeclContext *DC, + FragileFunctionKind fragileKind); public: /// Given that a type is used from a particular context which diff --git a/test/Sema/implementation-only-import-in-decls.swift b/test/Sema/implementation-only-import-in-decls.swift index e266cdf839860..958ce361bd199 100644 --- a/test/Sema/implementation-only-import-in-decls.swift +++ b/test/Sema/implementation-only-import-in-decls.swift @@ -7,93 +7,93 @@ import NormalLibrary @_implementationOnly import BADLibrary -public struct TestConformance: BadProto {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public struct TestConformance: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} -@usableFromInline struct TestConformanceUFI: BadProto {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +@usableFromInline struct TestConformanceUFI: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} struct TestConformanceOkay: BadProto {} // ok -public class TestConformanceClass: BadProto {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public enum TestConformanceEnum: BadProto {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public class TestConformanceClass: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} +public enum TestConformanceEnum: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} -public struct TestGenericParams {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public struct TestGenericParams {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} -public struct TestGenericParamsWhereClause where T: BadProto {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public struct TestGenericParamsWhereClause where T: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} public enum TestCase { - case x(BadStruct) // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - case y(Int, BadStruct) // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + case x(BadStruct) // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + case y(Int, BadStruct) // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} } -public func testGenericParams(_: T) {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public func testGenericParamsWhereClause(_: T) where T: BadProto {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public func testGenericParams(_: T) {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} +public func testGenericParamsWhereClause(_: T) where T: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} public func testParams(_: BadStruct, _: BadProto) {} -// expected-error@-1 {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -// expected-error@-2 {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public func testResult() -> BadStruct? { return nil } // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +// expected-error@-1 {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} +// expected-error@-2 {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} +public func testResult() -> BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} public struct TestSubscript { - public subscript(_: T) -> Int { return 0 } // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - public subscript(where _: T) -> Int where T: BadProto { return 0 } // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - public subscript(_: BadStruct) -> Int { return 0 } // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - public subscript(_: Int) -> BadStruct? { return nil } // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + public subscript(_: T) -> Int { return 0 } // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} + public subscript(where _: T) -> Int where T: BadProto { return 0 } // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} + public subscript(_: BadStruct) -> Int { return 0 } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + public subscript(_: Int) -> BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} } public struct TestInit { - public init(_: BadStruct) {} // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - public init(_: T) {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - public init(where _: T) where T: BadProto {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + public init(_: BadStruct) {} // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} + public init(_: T) {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} + public init(where _: T) where T: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} } -public protocol TestInherited: BadProto {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public protocol TestInherited: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} public protocol TestConstraintBase { associatedtype Assoc } -public protocol TestConstraint: TestConstraintBase where Assoc: BadProto {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public protocol TestConstraintEq: TestConstraintBase where Assoc == BadStruct {} // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public protocol TestConstraint: TestConstraintBase where Assoc: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} +public protocol TestConstraintEq: TestConstraintBase where Assoc == BadStruct {} // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} public protocol TestAssocType { - associatedtype Assoc: BadProto // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + associatedtype Assoc: BadProto // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} } public protocol TestAssocTypeWhereClause { - associatedtype Assoc: Collection where Assoc.Element: BadProto // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + associatedtype Assoc: Collection where Assoc.Element: BadProto // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} } -public enum TestRawType: IntLike { // expected-error {{cannot use 'IntLike' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public enum TestRawType: IntLike { // expected-error {{cannot use struct 'IntLike' here; 'BADLibrary' has been imported as implementation-only}} case x = 1 - // FIXME: expected-error@-1 {{cannot use conformance of 'IntLike' to 'Equatable' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + // FIXME: expected-error@-1 {{cannot use conformance of 'IntLike' to 'Equatable' here; 'BADLibrary' has been imported as implementation-only}} } -public class TestSubclass: BadClass { // expected-error {{cannot use 'BadClass' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public class TestSubclass: BadClass { // expected-error {{cannot use class 'BadClass' here; 'BADLibrary' has been imported as implementation-only}} } -public typealias TestUnderlying = BadStruct // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public typealias TestGenericParamsAliasWhereClause = T where T: BadProto // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public typealias TestUnderlying = BadStruct // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} +public typealias TestGenericParamsAliasWhereClause = T where T: BadProto // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} -public typealias TestGenericParamsAlias = T // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +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 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public var testBadTypeInferred = Optional.none // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public var testBadTypePartiallyInferred: Optional = Optional.none // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +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 (testBadTypeTuple1, testBadTypeTuple2): (BadStruct?, BadClass?) = (nil, nil) -// expected-error@-1 {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -// expected-error@-2 {{cannot use 'BadClass' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public var (testBadTypeTuplePartlyInferred1, testBadTypeTuplePartlyInferred2): (Optional, Optional) = (Optional.none, Optional.none) // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public var (testBadTypeTuplePartlyInferred3, testBadTypeTuplePartlyInferred4): (Optional, Optional) = (Optional.none, Optional.none) // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public var testMultipleBindings1: Int? = nil, testMultipleBindings2: BadStruct? = nil // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public var testMultipleBindings3: BadStruct? = nil, testMultipleBindings4: Int? = nil // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - -extension BadStruct { // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +// 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}} + +extension BadStruct { // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} public func testExtensionOfBadType() {} // FIXME: Should complain here instead of at the extension decl. } extension BadStruct { func testExtensionOfOkayType() {} } -extension Array where Element == BadStruct { // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +extension Array where Element == BadStruct { // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} public func testExtensionWithBadRequirement() {} // FIXME: Should complain here instead of at the extension decl. } @@ -101,71 +101,71 @@ extension Array where Element == BadStruct { func testExtensionWithOkayRequirement() {} // okay } -extension Int: BadProto {} // expected-error {{cannot use 'BadProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +extension Int: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} struct TestExtensionConformanceOkay {} extension TestExtensionConformanceOkay: BadProto {} // okay public protocol TestConstrainedExtensionProto {} -extension Array: TestConstrainedExtensionProto where Element == BadStruct { // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +extension Array: TestConstrainedExtensionProto where Element == BadStruct { // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} } -infix operator !!!!!!: BadPrecedence // expected-error {{cannot use 'BadPrecedence' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +infix operator !!!!!!: BadPrecedence // expected-error {{cannot use precedence group 'BadPrecedence' here; 'BADLibrary' has been imported as implementation-only}} precedencegroup TestLowerThan { - lowerThan: BadPrecedence // expected-error {{cannot use 'BadPrecedence' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + lowerThan: BadPrecedence // expected-error {{cannot use precedence group 'BadPrecedence' here; 'BADLibrary' has been imported as implementation-only}} } precedencegroup TestHigherThan { - higherThan: BadPrecedence // expected-error {{cannot use 'BadPrecedence' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + higherThan: BadPrecedence // expected-error {{cannot use precedence group 'BadPrecedence' here; 'BADLibrary' has been imported as implementation-only}} } public struct PublicStructStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - internal var internallyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private var privatelyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + 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}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} } @usableFromInline internal struct UFIStructStoredProperties { - @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - internal var internallyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private var privatelyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @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}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} } public class PublicClassStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - internal var internallyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private var privatelyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private let letIsLikeVar = [BadStruct]() // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + 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}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} } public typealias NormalProtoAssoc = T.Assoc -public func testConformanceInTypealias(_: NormalProtoAssoc) {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public func testConformanceInTypealias(_: NormalProtoAssoc) {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} public struct NormalProtoAssocHolder { public var value: T.Assoc } -public func testConformanceInBoundGeneric(_: NormalProtoAssocHolder) {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public func testConformanceInBoundGeneric(_: NormalProtoAssocHolder) {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} public class SubclassOfNormalClass: NormalClass {} -public func testInheritedConformance(_: NormalProtoAssocHolder) {} // expected-error {{cannot use conformance of 'NormalClass' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} -public func testSpecializedConformance(_: NormalProtoAssocHolder>) {} // expected-error {{cannot use conformance of 'GenericStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public func testInheritedConformance(_: NormalProtoAssocHolder) {} // expected-error {{cannot use conformance of 'NormalClass' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} +public func testSpecializedConformance(_: NormalProtoAssocHolder>) {} // expected-error {{cannot use conformance of 'GenericStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} -extension Array where Element == NormalProtoAssocHolder { // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +extension Array where Element == NormalProtoAssocHolder { // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} public func testConstrainedExtensionUsingBadConformance() {} } @@ -173,7 +173,7 @@ public struct ConditionalGenericStruct {} extension ConditionalGenericStruct: NormalProto where T: NormalProto { public typealias Assoc = Int } -public func testConditionalGeneric(_: NormalProtoAssocHolder>) {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public func testConditionalGeneric(_: NormalProtoAssocHolder>) {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} public protocol PublicAssociatedTypeProto { associatedtype Assoc: NormalProto @@ -191,15 +191,15 @@ protocol InternalAssociatedTypeProto { public struct PublicInferredAssociatedTypeImpl { public func takesAssoc(_: NormalStruct) {} } -extension PublicInferredAssociatedTypeImpl: PublicAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as '@_implementationOnly'}} -extension PublicInferredAssociatedTypeImpl: UFIAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as '@_implementationOnly'}} +extension PublicInferredAssociatedTypeImpl: PublicAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as implementation-only}} +extension PublicInferredAssociatedTypeImpl: UFIAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as implementation-only}} extension PublicInferredAssociatedTypeImpl: InternalAssociatedTypeProto {} // okay @usableFromInline struct UFIInferredAssociatedTypeImpl { public func takesAssoc(_: NormalStruct) {} } -extension UFIInferredAssociatedTypeImpl: PublicAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as '@_implementationOnly'}} -extension UFIInferredAssociatedTypeImpl: UFIAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as '@_implementationOnly'}} +extension UFIInferredAssociatedTypeImpl: PublicAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as implementation-only}} +extension UFIInferredAssociatedTypeImpl: UFIAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as implementation-only}} extension UFIInferredAssociatedTypeImpl: InternalAssociatedTypeProto {} // okay struct InternalInferredAssociatedTypeImpl { @@ -213,8 +213,8 @@ public struct PublicExplicitAssociatedTypeImpl { public typealias Assoc = NormalStruct public func takesAssoc(_: NormalStruct) {} } -extension PublicExplicitAssociatedTypeImpl: PublicAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as '@_implementationOnly'}} -extension PublicExplicitAssociatedTypeImpl: UFIAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as '@_implementationOnly'}} +extension PublicExplicitAssociatedTypeImpl: PublicAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as implementation-only}} +extension PublicExplicitAssociatedTypeImpl: UFIAssociatedTypeProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as implementation-only}} extension PublicExplicitAssociatedTypeImpl: InternalAssociatedTypeProto {} // okay @@ -225,33 +225,33 @@ public protocol BaseProtoWithNoRequirement { public protocol RefinedProto: BaseProtoWithNoRequirement where Assoc: NormalProto { } -public struct RefinedProtoImpl: RefinedProto { // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as '@_implementationOnly'}} +public struct RefinedProtoImpl: RefinedProto { // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as implementation-only}} public func takesAssoc(_: NormalStruct) {} } public protocol RefinedSelfProto where Self: NormalProto {} -extension NormalStruct: RefinedSelfProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +extension NormalStruct: RefinedSelfProto {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} public protocol RefinedSelfProtoInheritance: NormalProto {} -extension NormalStruct: RefinedSelfProtoInheritance {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +extension NormalStruct: RefinedSelfProtoInheritance {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} public protocol SlightlyMoreComplicatedRequirement { associatedtype Assoc: Collection where Assoc.Element: NormalProto func takesAssoc(_: Assoc) } -public struct SlightlyMoreComplicatedRequirementImpl: SlightlyMoreComplicatedRequirement { // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc.Element' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as '@_implementationOnly'}} +public struct SlightlyMoreComplicatedRequirementImpl: SlightlyMoreComplicatedRequirement { // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc.Element' (inferred as 'NormalStruct'); 'BADLibrary' has been imported as implementation-only}} public func takesAssoc(_: [NormalStruct]) {} } -public struct RequirementsHandleSubclassesToo: SlightlyMoreComplicatedRequirement { // expected-error {{cannot use conformance of 'NormalClass' to 'NormalProto' in associated type 'Self.Assoc.Element' (inferred as 'SubclassOfNormalClass'); 'BADLibrary' has been imported as '@_implementationOnly'}} +public struct RequirementsHandleSubclassesToo: SlightlyMoreComplicatedRequirement { // expected-error {{cannot use conformance of 'NormalClass' to 'NormalProto' in associated type 'Self.Assoc.Element' (inferred as 'SubclassOfNormalClass'); 'BADLibrary' has been imported as implementation-only}} public func takesAssoc(_: [SubclassOfNormalClass]) {} } -public struct RequirementsHandleSpecializationsToo: SlightlyMoreComplicatedRequirement { // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc.Element' (inferred as 'ConditionalGenericStruct'); 'BADLibrary' has been imported as '@_implementationOnly'}} +public struct RequirementsHandleSpecializationsToo: SlightlyMoreComplicatedRequirement { // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in associated type 'Self.Assoc.Element' (inferred as 'ConditionalGenericStruct'); 'BADLibrary' has been imported as implementation-only}} public func takesAssoc(_: [ConditionalGenericStruct]) {} } -public struct ClassConstrainedGenericArg: PublicAssociatedTypeProto { // expected-error {{cannot use conformance of 'NormalClass' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'T'); 'BADLibrary' has been imported as '@_implementationOnly'}} +public struct ClassConstrainedGenericArg: PublicAssociatedTypeProto { // expected-error {{cannot use conformance of 'NormalClass' to 'NormalProto' in associated type 'Self.Assoc' (inferred as 'T'); 'BADLibrary' has been imported as implementation-only}} public func takesAssoc(_: T) {} } diff --git a/test/Sema/implementation-only-import-inlinable-conformances.swift b/test/Sema/implementation-only-import-inlinable-conformances.swift index 7cfc7b37e628c..8ebbdfc8e5fab 100644 --- a/test/Sema/implementation-only-import-inlinable-conformances.swift +++ b/test/Sema/implementation-only-import-inlinable-conformances.swift @@ -12,9 +12,9 @@ public typealias X = Int public typealias NormalProtoAssoc = T.Assoc @inlinable func testConformanceInTypealias() { - let x: NormalProtoAssoc? = nil // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + let x: NormalProtoAssoc? = nil // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} _ = x - _ = NormalProtoAssoc() // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + _ = NormalProtoAssoc() // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} } func internalConformanceInTypealias() { @@ -29,11 +29,11 @@ public struct NormalProtoAssocHolder { public init(_ value: T?) {} } @inlinable func testConformanceInBoundGeneric() { - let x: NormalProtoAssocHolder? = nil // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + let x: NormalProtoAssocHolder? = nil // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} _ = x // FIXME: We get this error twice: once for the TypeExpr and once for the implicit init. - _ = NormalProtoAssocHolder() // expected-error 2 {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - _ = NormalProtoAssocHolder(nil as NormalStruct?) // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + _ = NormalProtoAssocHolder() // expected-error 2 {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} + _ = NormalProtoAssocHolder(nil as NormalStruct?) // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} } func internalConformanceInBoundGeneric() { @@ -44,8 +44,8 @@ func internalConformanceInBoundGeneric() { } @inlinable func testDowncast(_ x: Any) -> Bool { - let normal = x is NormalProtoAssocHolder // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - let alias = x is NormalProtoAssoc // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + let normal = x is NormalProtoAssocHolder // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} + let alias = x is NormalProtoAssoc // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} return normal || alias } @@ -57,10 +57,10 @@ func internalDowncast(_ x: Any) -> Bool { @inlinable func testSwitch(_ x: Any) { switch x { - case let holder as NormalProtoAssocHolder: // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + case let holder as NormalProtoAssocHolder: // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} _ = holder break - case is NormalProtoAssoc: // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + case is NormalProtoAssoc: // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} break default: break @@ -85,10 +85,10 @@ public enum NormalProtoEnumUser { @inlinable func testEnum() { // FIXME: We get this error twice: once for the pattern and once for the implicit TypeExpr. - let x: NormalProtoEnumUser = .a // expected-error 2 {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + let x: NormalProtoEnumUser = .a // expected-error 2 {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} _ = x // FIXME: We get this error twice: once for the TypeExpr and once for the case. - _ = NormalProtoEnumUser.a // expected-error 2 {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + _ = NormalProtoEnumUser.a // expected-error 2 {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} } func internalEnum() { @@ -100,7 +100,7 @@ func internalEnum() { @usableFromInline func testFuncImpl(_: T.Type) {} @inlinable func testFunc() { - testFuncImpl(NormalStruct.self) // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + testFuncImpl(NormalStruct.self) // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} } func internalFunc() { @@ -120,14 +120,14 @@ public struct ForTestingMembers { } @inlinable func testMembers() { - _ = ForTestingMembers(NormalStruct.self) // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - _ = ForTestingMembers.init(NormalStruct.self) // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + _ = ForTestingMembers(NormalStruct.self) // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} + _ = ForTestingMembers.init(NormalStruct.self) // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} - _ = ForTestingMembers()[NormalStruct.self] // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + _ = ForTestingMembers()[NormalStruct.self] // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} var instance = ForTestingMembers() - instance[NormalStruct.self] = 1 // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + instance[NormalStruct.self] = 1 // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} - ForTestingMembers().method(NormalStruct.self) // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + ForTestingMembers().method(NormalStruct.self) // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} } extension NormalProtoAssocHolder { @@ -136,35 +136,35 @@ extension NormalProtoAssocHolder { @inlinable func testMultipleConformances() { _ = NormalProtoAssocHolder.testAnotherConformance(NormalClass.self) - // expected-error@-1 2 {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - // expected-error@-2 {{cannot use conformance of 'NormalClass' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + // expected-error@-1 2 {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} + // expected-error@-2 {{cannot use conformance of 'NormalClass' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} } @inlinable func localTypeAlias() { - typealias LocalUser = NormalProtoAssocHolder // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - typealias LocalGenericUser = (T, NormalProtoAssocHolder) // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + typealias LocalUser = NormalProtoAssocHolder // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} + typealias LocalGenericUser = (T, NormalProtoAssocHolder) // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} typealias LocalProtoAssoc = T.Assoc - _ = LocalProtoAssoc() // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + _ = LocalProtoAssoc() // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} } @inlinable func localFunctions() { - func local(_: NormalProtoAssocHolder) {} // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - func localReturn() -> NormalProtoAssocHolder { fatalError() } // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - let _ = { (_: NormalProtoAssocHolder) in return } // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - let _ = { () -> NormalProtoAssocHolder in fatalError() } // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + func local(_: NormalProtoAssocHolder) {} // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} + func localReturn() -> NormalProtoAssocHolder { fatalError() } // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} + let _ = { (_: NormalProtoAssocHolder) in return } // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} + let _ = { () -> NormalProtoAssocHolder in fatalError() } // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} } -@inlinable public func signatureOfInlinable(_: NormalProtoAssocHolder) {} // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +@inlinable public func signatureOfInlinable(_: NormalProtoAssocHolder) {} // expected-error{{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} -public func testDefaultArgument(_: Int = NormalProtoAssoc()) {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} +public func testDefaultArgument(_: Int = NormalProtoAssoc()) {} // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} public class SubclassOfNormalClass: NormalClass {} @inlinable public func testInheritedConformance() { - _ = NormalProtoAssocHolder.self // expected-error {{cannot use conformance of 'NormalClass' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + _ = NormalProtoAssocHolder.self // expected-error {{cannot use conformance of 'NormalClass' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} } @inlinable public func testSpecializedConformance() { - _ = NormalProtoAssocHolder>.self // expected-error {{cannot use conformance of 'GenericStruct' to 'NormalProto' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + _ = NormalProtoAssocHolder>.self // expected-error {{cannot use conformance of 'GenericStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} } diff --git a/test/Sema/implementation-only-import-inlinable-indirect.swift b/test/Sema/implementation-only-import-inlinable-indirect.swift index c577ea9cf8532..398726a0b9d56 100644 --- a/test/Sema/implementation-only-import-inlinable-indirect.swift +++ b/test/Sema/implementation-only-import-inlinable-indirect.swift @@ -10,34 +10,34 @@ @inlinable public func testStructFromIndirect() { - _ = StructFromIndirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = StructFromIndirect() // expected-error {{struct 'StructFromIndirect' cannot be used in an '@inlinable' function because 'indirects' was imported implementation-only}} } @inlinable public func testAliasFromIndirect() { - _ = AliasFromIndirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = AliasFromIndirect() // expected-error {{type alias 'AliasFromIndirect' cannot be used in an '@inlinable' function because 'indirects' was imported implementation-only}} } @inlinable public func testGenericAliasFromIndirect() { - _ = GenericAliasFromIndirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = GenericAliasFromIndirect() // expected-error {{type alias 'GenericAliasFromIndirect' cannot be used in an '@inlinable' function because 'indirects' was imported implementation-only}} } // Functions @inlinable public func testFunctionFromIndirect() { - globalFunctionFromIndirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + globalFunctionFromIndirect() // expected-error {{global function 'globalFunctionFromIndirect()' cannot be used in an '@inlinable' function because 'indirects' was imported implementation-only}} } // Variables @inlinable public func testVariableFromIndirect_get() { - _ = globalVariableFromIndirect // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = globalVariableFromIndirect // expected-error {{var 'globalVariableFromIndirect' cannot be used in an '@inlinable' function because 'indirects' was imported implementation-only}} } @inlinable public func testVariableFromIndirect_set() { - globalVariableFromIndirect = 5 // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + globalVariableFromIndirect = 5 // expected-error {{var 'globalVariableFromIndirect' cannot be used in an '@inlinable' function because 'indirects' was imported implementation-only}} } diff --git a/test/Sema/implementation-only-import-inlinable-multifile.swift b/test/Sema/implementation-only-import-inlinable-multifile.swift index 53bc5ffdc0a37..a28dc9216a78c 100644 --- a/test/Sema/implementation-only-import-inlinable-multifile.swift +++ b/test/Sema/implementation-only-import-inlinable-multifile.swift @@ -11,7 +11,7 @@ @inlinable public func testStructFromDirect() { - _ = StructFromDirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = StructFromDirect() // expected-error {{struct 'StructFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -21,7 +21,7 @@ public func testStructFromIndirect() { @inlinable public func testAliasFromDirect() { - _ = AliasFromDirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = AliasFromDirect() // expected-error {{type alias 'AliasFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -31,7 +31,7 @@ public func testAliasFromIndirect() { @inlinable public func testGenericAliasFromDirect() { - _ = GenericAliasFromDirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = GenericAliasFromDirect() // expected-error {{type alias 'GenericAliasFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -44,7 +44,7 @@ public func testGenericAliasFromIndirect() { @inlinable public func testFunctionFromDirect() { - globalFunctionFromDirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + globalFunctionFromDirect() // expected-error {{global function 'globalFunctionFromDirect()' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -56,7 +56,7 @@ public func testFunctionFromIndirect() { @inlinable public func testVariableFromDirect_get() { - _ = globalVariableFromDirect // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = globalVariableFromDirect // expected-error {{var 'globalVariableFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -66,7 +66,7 @@ public func testVariableFromIndirect_get() { @inlinable public func testVariableFromDirect_set() { - globalVariableFromDirect = 5 // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + globalVariableFromDirect = 5 // expected-error {{var 'globalVariableFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -78,27 +78,25 @@ public func testVariableFromIndirect_set() { @inlinable public func testExtensionMethod(s: inout StructFromIndirect) { - s.extensionMethodFromDirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + s.extensionMethodFromDirect() // expected-error {{instance method 'extensionMethodFromDirect()' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable public func testExtensionProperty_get(s: inout StructFromIndirect) { - _ = s.extensionPropertyFromDirect // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = s.extensionPropertyFromDirect // expected-error {{property 'extensionPropertyFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable public func testExtensionProperty_set(s: inout StructFromIndirect) { - s.extensionPropertyFromDirect = 5 // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + s.extensionPropertyFromDirect = 5 // expected-error {{property 'extensionPropertyFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable public func testExtensionSubscript_get(s: inout StructFromIndirect) { - // FIXME: why is this error being double-emitted? - _ = s[extensionSubscript: 0] // expected-error 2 {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = s[extensionSubscript: 0] // expected-error {{cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable public func testExtensionSubscript_set(s: inout StructFromIndirect) { - // FIXME: why is this error being double-emitted? - s[extensionSubscript: 0] = 5 // expected-error 2 {{cannot be used in an inlinable function because its module was imported implementation-only}} + s[extensionSubscript: 0] = 5 // expected-error {{cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } diff --git a/test/Sema/implementation-only-import-inlinable.swift b/test/Sema/implementation-only-import-inlinable.swift index e843cafcd2cd1..c457545e9132e 100644 --- a/test/Sema/implementation-only-import-inlinable.swift +++ b/test/Sema/implementation-only-import-inlinable.swift @@ -11,7 +11,7 @@ import indirects @inlinable public func testStructFromDirect() { - _ = StructFromDirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = StructFromDirect() // expected-error {{struct 'StructFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -21,7 +21,7 @@ public func testStructFromIndirect() { @inlinable public func testAliasFromDirect() { - _ = AliasFromDirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = AliasFromDirect() // expected-error {{type alias 'AliasFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -31,7 +31,7 @@ public func testAliasFromIndirect() { @inlinable public func testGenericAliasFromDirect() { - _ = GenericAliasFromDirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = GenericAliasFromDirect() // expected-error {{type alias 'GenericAliasFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -44,7 +44,7 @@ public func testGenericAliasFromIndirect() { @inlinable public func testFunctionFromDirect() { - globalFunctionFromDirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + globalFunctionFromDirect() // expected-error {{global function 'globalFunctionFromDirect()' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -56,7 +56,7 @@ public func testFunctionFromIndirect() { @inlinable public func testVariableFromDirect_get() { - _ = globalVariableFromDirect // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = globalVariableFromDirect // expected-error {{var 'globalVariableFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -66,7 +66,7 @@ public func testVariableFromIndirect_get() { @inlinable public func testVariableFromDirect_set() { - globalVariableFromDirect = 5 // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + globalVariableFromDirect = 5 // expected-error {{var 'globalVariableFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable @@ -78,27 +78,25 @@ public func testVariableFromIndirect_set() { @inlinable public func testExtensionMethod(s: inout StructFromIndirect) { - s.extensionMethodFromDirect() // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + s.extensionMethodFromDirect() // expected-error {{instance method 'extensionMethodFromDirect()' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable public func testExtensionProperty_get(s: inout StructFromIndirect) { - _ = s.extensionPropertyFromDirect // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = s.extensionPropertyFromDirect // expected-error {{property 'extensionPropertyFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable public func testExtensionProperty_set(s: inout StructFromIndirect) { - s.extensionPropertyFromDirect = 5 // expected-error {{cannot be used in an inlinable function because its module was imported implementation-only}} + s.extensionPropertyFromDirect = 5 // expected-error {{property 'extensionPropertyFromDirect' cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable public func testExtensionSubscript_get(s: inout StructFromIndirect) { - // FIXME: why is this error being double-emitted? - _ = s[extensionSubscript: 0] // expected-error 2 {{cannot be used in an inlinable function because its module was imported implementation-only}} + _ = s[extensionSubscript: 0] // expected-error {{cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } @inlinable public func testExtensionSubscript_set(s: inout StructFromIndirect) { - // FIXME: why is this error being double-emitted? - s[extensionSubscript: 0] = 5 // expected-error 2 {{cannot be used in an inlinable function because its module was imported implementation-only}} + s[extensionSubscript: 0] = 5 // expected-error {{cannot be used in an '@inlinable' function because 'directs' was imported implementation-only}} } diff --git a/test/Sema/implementation-only-import-library-evolution.swift b/test/Sema/implementation-only-import-library-evolution.swift index 1877162d8a04b..44df3dc474308 100644 --- a/test/Sema/implementation-only-import-library-evolution.swift +++ b/test/Sema/implementation-only-import-library-evolution.swift @@ -7,72 +7,72 @@ @_implementationOnly import BADLibrary public struct PublicStructStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; '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 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} } @usableFromInline internal struct UFIStructStoredProperties { - @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; '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 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} } public class PublicClassStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + public var publiclyBad: BadStruct? // expected-error {{cannot use struct 'BadStruct' here; '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 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} } // MARK: Frozen types @_fixed_layout public struct FrozenPublicStructStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - internal var internallyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private var privatelyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + 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}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} } @_fixed_layout @usableFromInline internal struct FrozenUFIStructStoredProperties { - @usableFromInline var publiclyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - internal var internallyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private var privatelyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @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}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} } @_fixed_layout public class FrozenPublicClassStoredProperties { - public var publiclyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - internal var internallyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private var privatelyBad: BadStruct? // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} - private let letIsLikeVar: [BadStruct] = [] // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + 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}} private var computedIsOkay: BadStruct? { return nil } // okay private static var staticIsOkay: BadStruct? // okay - @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use 'BadStruct' here; 'BADLibrary' has been imported as '@_implementationOnly'}} + @usableFromInline internal var computedUFIIsNot: BadStruct? { return nil } // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} }