From e3b9fd7496141c4d706e6f8f76ecedb7f9dc98da Mon Sep 17 00:00:00 2001 From: Robert Widmann Date: Tue, 3 May 2022 19:49:33 -0700 Subject: [PATCH 1/4] Add a Recursive Type Bit for Parameterized Existentials --- include/swift/AST/Types.h | 16 ++- lib/AST/ASTContext.cpp | 8 +- ...ailability_parameterized_existential.swift | 108 ++++++++++++++++++ 3 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 test/Sema/availability_parameterized_existential.swift diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h index 1a493d783c689..abe377d97c344 100644 --- a/include/swift/AST/Types.h +++ b/include/swift/AST/Types.h @@ -163,7 +163,10 @@ class RecursiveTypeProperties { /// type sequence HasTypeSequence = 0x1000, - Last_Property = HasTypeSequence + /// This type contains a parameterized existential type \c any P. + HasParameterizedExistential = 0x2000, + + Last_Property = HasParameterizedExistential }; enum { BitWidth = countBitsUsed(Property::Last_Property) }; @@ -223,6 +226,12 @@ class RecursiveTypeProperties { bool hasTypeSequence() const { return Bits & HasTypeSequence; } + /// Does a type with these properties structurally contain a + /// parameterized existential type? + bool hasParameterizedExistential() const { + return Bits & HasParameterizedExistential; + } + /// Returns the set of properties present in either set. friend RecursiveTypeProperties operator|(Property lhs, Property rhs) { return RecursiveTypeProperties(unsigned(lhs) | unsigned(rhs)); @@ -626,6 +635,11 @@ class alignas(1 << TypeAlignInBits) TypeBase return getRecursiveProperties().hasTypeSequence(); } + /// Determine whether the type involves a parameterized existential type. + bool hasParameterizedExistential() const { + return getRecursiveProperties().hasParameterizedExistential(); + } + /// Determine whether the type involves the given opened existential /// archetype. bool hasOpenedExistentialWithRoot(const OpenedArchetypeType *root) const; diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index e49f8750f4c64..c42054a7d12a4 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -3440,6 +3440,8 @@ ExistentialMetatypeType::get(Type T, Optional repr, T = existential->getConstraintType(); auto properties = T->getRecursiveProperties(); + if (T->is()) + properties |= RecursiveTypeProperties::HasParameterizedExistential; auto arena = getArena(properties); unsigned reprKey; @@ -3535,7 +3537,7 @@ isAnyFunctionTypeCanonical(ArrayRef params, static RecursiveTypeProperties getGenericFunctionRecursiveProperties(ArrayRef params, Type result) { - static_assert(RecursiveTypeProperties::BitWidth == 13, + static_assert(RecursiveTypeProperties::BitWidth == 14, "revisit this if you add new recursive type properties"); RecursiveTypeProperties properties; @@ -4124,7 +4126,7 @@ CanSILFunctionType SILFunctionType::get( void *mem = ctx.Allocate(bytes, alignof(SILFunctionType)); RecursiveTypeProperties properties; - static_assert(RecursiveTypeProperties::BitWidth == 13, + static_assert(RecursiveTypeProperties::BitWidth == 14, "revisit this if you add new recursive type properties"); for (auto ¶m : params) properties |= param.getInterfaceType()->getRecursiveProperties(); @@ -4242,6 +4244,8 @@ Type ExistentialType::get(Type constraint, bool forceExistential) { assert(constraint->isConstraintType()); auto properties = constraint->getRecursiveProperties(); + if (constraint->is()) + properties |= RecursiveTypeProperties::HasParameterizedExistential; auto arena = getArena(properties); auto &entry = C.getImpl().getArena(arena).ExistentialTypes[constraint]; diff --git a/test/Sema/availability_parameterized_existential.swift b/test/Sema/availability_parameterized_existential.swift new file mode 100644 index 0000000000000..afdba829153c9 --- /dev/null +++ b/test/Sema/availability_parameterized_existential.swift @@ -0,0 +1,108 @@ +// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.50 -disable-objc-attr-requires-foundation-module -enable-parameterized-existential-types +// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -disable-objc-attr-requires-foundation-module -enable-parameterized-existential-types -typecheck %s 2>&1 | %FileCheck %s '--implicit-check-not=:0' + +// Make sure we do not emit availability errors or warnings when -disable-availability-checking is passed +// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -typecheck -disable-objc-attr-requires-foundation-module -enable-parameterized-existential-types -disable-availability-checking %s 2>&1 | %FileCheck %s '--implicit-check-not=error:' + +func hedge() { + struct Value {} + + // We rely on not allowing nesting of extensions, so test to make sure + // this emits an error. + // CHECK:error: declaration is only valid at file scope + extension Value { } // expected-error {{declaration is only valid at file scope}} +} + +protocol P { + associatedtype T +} + +struct Wrapper {} + +func identity(_ x: any P) -> any P { return x } // OK +func unwrapUnwrap(_ x: (any P)???) -> (any P)? { return x!! } // OK + +func erase(_ x: any P) -> Any { return x } // expected-error {{runtime support for parameterized protocol types is only available in}} +// expected-note@-1 {{add @available attribute to enclosing global function}} +// expected-note@-2 {{add 'if #available' version check}} + +func eraseOptional(_ x: (any P)?) -> Any { return x } +// expected-note@-1 {{add @available attribute to enclosing global function}} +// expected-error@-2 {{runtime support for parameterized protocol types is only available in}} +// expected-note@-3 {{add 'if #available' version check}} +// expected-warning@-4 {{expression implicitly coerced from '(any P)?' to 'Any'}} +// expected-note@-5 {{provide a default value to avoid this warning}} +// expected-note@-6 {{force-unwrap the value to avoid this warning}} +// expected-note@-7 {{explicitly cast to 'Any' with 'as Any' to silence this warning}} + +func eraseOptional2(_ x: (any P)?) -> Any { return x as Any } +// expected-note@-1 {{add @available attribute to enclosing global function}} +// expected-error@-2 {{runtime support for parameterized protocol types is only available in}} +// expected-note@-3 {{add 'if #available' version check}} + +func tupleOut() -> (any P, Int) { return tupleOut() } // expected-error {{runtime support for parameterized protocol types is only available in}} +// expected-note@-1 {{add @available attribute to enclosing global function}} +func tupleIn(_ xs: (any P, Int)) -> Int { return tupleIn(xs) } // expected-error {{runtime support for parameterized protocol types is only available in}} +// expected-note@-1 {{add @available attribute to enclosing global function}} +func wrap(_ x: any P) -> Wrapper> { return wrap(x) } // expected-error {{runtime support for parameterized protocol types is only available in}} +// expected-note@-1 {{add @available attribute to enclosing global function}} +func optionalWrap(_ x: any P) -> Wrapper<(any P)?> { return optionalWrap(x) } // expected-error {{runtime support for parameterized protocol types is only available in}} +// expected-note@-1 {{add @available attribute to enclosing global function}} + +struct UnavailableWitness: P { // expected-note {{add @available attribute to enclosing struct}} + typealias T = any P // expected-error {{runtime support for parameterized protocol types is only available in}} + // expected-note@-1 {{add @available attribute to enclosing type alias}} +} + +struct UnavailableOptionalWitness: P { // expected-note {{add @available attribute to enclosing struct}} + typealias T = (any P)? // expected-error {{runtime support for parameterized protocol types is only available in}} + // expected-note@-1 {{add @available attribute to enclosing type alias}} +} + +struct UnavailableWrappedWitness: P { // expected-note 2 {{add @available attribute to enclosing struct}} + typealias T = Wrapper> // expected-error 2 {{runtime support for parameterized protocol types is only available in}} + // expected-note@-1 2 {{add @available attribute to enclosing type alias}} +} + +struct ParameterizedMembers { // expected-note {{add @available attribute to enclosing struct}} + var ok: any P + var okOptional: (any P)? + + var broken: Wrapper<(any P)?> // expected-error {{runtime support for parameterized protocol types is only available in}} +} + +func casts() { // expected-note 5 {{add @available attribute to enclosing global function}} + struct Value: P { typealias T = String } + + let _ = Value() as any P // OK + let _ = Value() as! any P + // expected-warning@-1 {{forced cast from 'Value' to 'any P' always succeeds; did you mean to use 'as'?}} + // expected-error@-2 {{runtime support for parameterized protocol types is only available in}} + // expected-note@-3 {{add 'if #available' version check}} + + let _ = Value() is any P + // expected-warning@-1 {{'is' test is always true}} + // expected-error@-2 {{runtime support for parameterized protocol types is only available in}} + // expected-note@-3 {{add 'if #available' version check}} + + let _ = Value() is (any P)??? + // expected-warning@-1 {{'is' test is always true}} + // expected-error@-2 {{runtime support for parameterized protocol types is only available in}} + // expected-note@-3 {{add 'if #available' version check}} + + let _ = Value() as! (any P, Int) + // expected-warning@-1 {{cast from 'Value' to unrelated type '(any P, Int)' always fails}} + // expected-error@-2 2 {{runtime support for parameterized protocol types is only available in}} + // expected-note@-3 2 {{add 'if #available' version check}} +} + +// FIXME: It's a little aggressive to also ban metatypes. +func metatypes(_ x: T.Type) { // expected-note 2 {{add @available attribute to enclosing global function}} + metatypes((any P).self) + // expected-error@-1 {{runtime support for parameterized protocol types is only available in}} + // expected-note@-2 {{add 'if #available' version check}} + + metatypes((any P.Type).self) + // expected-error@-1 {{runtime support for parameterized protocol types is only available in}} + // expected-note@-2 {{add 'if #available' version check}} +} From ed3264fd0e8df6189efcd812095b94b6b0789890 Mon Sep 17 00:00:00 2001 From: Robert Widmann Date: Tue, 3 May 2022 19:50:27 -0700 Subject: [PATCH 2/4] Availability Bounds for Parameterized Existential Runtime Metadata Functions --- include/swift/AST/ASTContext.h | 4 ++++ lib/AST/Availability.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/include/swift/AST/ASTContext.h b/include/swift/AST/ASTContext.h index ace4054f014ba..a30fc661fa2bd 100644 --- a/include/swift/AST/ASTContext.h +++ b/include/swift/AST/ASTContext.h @@ -868,6 +868,10 @@ class ASTContext final { /// swift_isUniquelyReferenced functions. AvailabilityContext getObjCIsUniquelyReferencedAvailability(); + /// Get the runtime availability of metadata manipulation runtime functions + /// for extended existential types. + AvailabilityContext getParameterizedExistentialRuntimeAvailability(); + /// Get the runtime availability of features introduced in the Swift 5.2 /// compiler for the target platform. AvailabilityContext getSwift52Availability(); diff --git a/lib/AST/Availability.cpp b/lib/AST/Availability.cpp index b7b2472629717..05b738b541106 100644 --- a/lib/AST/Availability.cpp +++ b/lib/AST/Availability.cpp @@ -394,6 +394,11 @@ AvailabilityContext ASTContext::getObjCIsUniquelyReferencedAvailability() { return getSwift56Availability(); } +AvailabilityContext +ASTContext::getParameterizedExistentialRuntimeAvailability() { + return getSwift57Availability(); +} + AvailabilityContext ASTContext::getSwift52Availability() { auto target = LangOpts.Target; From d0c40c0a033ca8df5fb141ad9e7fa4754f6f18cc Mon Sep 17 00:00:00 2001 From: Robert Widmann Date: Tue, 3 May 2022 19:57:22 -0700 Subject: [PATCH 3/4] Diagnose Availability for Parameterized Existential Types Usages of parameterized existential types that involve runtime type metadata to resolve must be gated on the appropriate OS version in which those features have landed. This means the following usage classes must appear gated: - Checked casts (is, as?, as!) - As arguments to generic types (Foo>) - As type witnesses to protocol conformances - In erasure expressions (and optional-to-any erasure expressions) - In metatypes - Tuples What does this leave? - Concrete usages - any P as a parameter or result type - Any amount of optional types around existential types - Static casts (as) It's worth calling out the fact that usages of parameterized existential types in tuples are banned but usages in struct members are not. This is due to the fact that Tuple identity and runtime layout is determined by a metadata query against each component type. Whereas for a struct, the opaque type layout does not depend upon the type metadata of the fields at runtime, and the identity of the struct is determined nominally rather than structurally. Practically, this means that one can work around the lack of tuples by defining a struct with an equivalent type structure as fields: struct AdHocEraser { var x: any P } rdar://92197245 --- include/swift/AST/DiagnosticsSema.def | 5 ++ lib/Sema/TypeCheckAvailability.cpp | 119 +++++++++++++++++++++++++- lib/Sema/TypeCheckAvailability.h | 20 +++-- lib/Sema/TypeCheckProtocol.cpp | 11 +++ 4 files changed, 144 insertions(+), 11 deletions(-) diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index 9b43ce7933970..bad93bb54c622 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -5606,6 +5606,11 @@ ERROR(availability_concurrency_only_version_newer, none, "concurrency is only available in %0 %1 or newer", (StringRef, llvm::VersionTuple)) +ERROR(availability_parameterized_protocol_only_version_newer, none, + "runtime support for parameterized protocol types is only available in " + "%0 %1 or newer", + (StringRef, llvm::VersionTuple)) + NOTE(availability_guard_with_version_check, none, "add 'if #available' version check", ()) diff --git a/lib/Sema/TypeCheckAvailability.cpp b/lib/Sema/TypeCheckAvailability.cpp index 9ed2bbb135d12..139fc73f6b9dc 100644 --- a/lib/Sema/TypeCheckAvailability.cpp +++ b/lib/Sema/TypeCheckAvailability.cpp @@ -15,11 +15,12 @@ //===----------------------------------------------------------------------===// #include "TypeCheckAvailability.h" +#include "MiscDiagnostics.h" #include "TypeCheckConcurrency.h" -#include "TypeChecker.h" #include "TypeCheckObjC.h" -#include "MiscDiagnostics.h" +#include "TypeChecker.h" #include "swift/AST/ASTWalker.h" +#include "swift/AST/GenericEnvironment.h" #include "swift/AST/Initializer.h" #include "swift/AST/NameLookup.h" #include "swift/AST/Pattern.h" @@ -2749,6 +2750,74 @@ bool isSubscriptReturningString(const ValueDecl *D, ASTContext &Context) { return resultTy->isString(); } +static bool diagnosePotentialParameterizedProtocolUnavailability( + SourceRange ReferenceRange, const DeclContext *ReferenceDC, + const UnavailabilityReason &Reason) { + ASTContext &Context = ReferenceDC->getASTContext(); + + auto RequiredRange = Reason.getRequiredOSVersionRange(); + { + auto Err = Context.Diags.diagnose( + ReferenceRange.Start, + diag::availability_parameterized_protocol_only_version_newer, + prettyPlatformString(targetPlatform(Context.LangOpts)), + Reason.getRequiredOSVersionRange().getLowerEndpoint()); + + // Direct a fixit to the error if an existing guard is nearly-correct + if (fixAvailabilityByNarrowingNearbyVersionCheck( + ReferenceRange, ReferenceDC, RequiredRange, Context, Err)) + return true; + } + fixAvailability(ReferenceRange, ReferenceDC, RequiredRange, Context); + return true; +} + +bool swift::diagnoseParameterizedProtocolAvailability( + SourceRange ReferenceRange, const DeclContext *ReferenceDC) { + // Check the availability of parameterized existential runtime support. + ASTContext &ctx = ReferenceDC->getASTContext(); + if (ctx.LangOpts.DisableAvailabilityChecking) + return false; + + if (!shouldCheckAvailability(ReferenceDC->getAsDecl())) + return false; + + auto runningOS = TypeChecker::overApproximateAvailabilityAtLocation( + ReferenceRange.Start, ReferenceDC); + auto availability = ctx.getParameterizedExistentialRuntimeAvailability(); + if (!runningOS.isContainedIn(availability)) { + return diagnosePotentialParameterizedProtocolUnavailability( + ReferenceRange, ReferenceDC, + UnavailabilityReason::requiresVersionRange( + availability.getOSVersion())); + } + return false; +} + +static void +maybeDiagParameterizedExistentialErasure(ErasureExpr *EE, + const ExportContext &Where) { + if (auto *OE = dyn_cast(EE->getSubExpr())) { + auto *OAT = OE->getType()->getAs(); + if (!OAT) + return; + + auto opened = OAT->getGenericEnvironment()->getOpenedExistentialType(); + if (!opened || !opened->hasParameterizedExistential()) + return; + + (void)diagnoseParameterizedProtocolAvailability(EE->getLoc(), + Where.getDeclContext()); + } + + if (EE->getType() && + EE->getType()->isAny() && + EE->getSubExpr()->getType()->hasParameterizedExistential()) { + (void)diagnoseParameterizedProtocolAvailability(EE->getLoc(), + Where.getDeclContext()); + } +} + bool swift::diagnoseExplicitUnavailability( const ValueDecl *D, SourceRange R, @@ -2965,6 +3034,17 @@ class ExprAvailabilityWalker : public ASTWalker { diagnoseDeclRefAvailability(Context.getRegexDecl(), Range); diagnoseDeclRefAvailability(RLE->getInitializer(), Range); } + if (auto *EE = dyn_cast(E)) { + maybeDiagParameterizedExistentialErasure(EE, Where); + } + if (auto *CC = dyn_cast(E)) { + if (!isa(CC) && + CC->getCastType()->hasParameterizedExistential()) { + SourceLoc loc = CC->getCastTypeRepr() ? CC->getCastTypeRepr()->getLoc() + : E->getLoc(); + diagnoseParameterizedProtocolAvailability(loc, Where.getDeclContext()); + } + } if (auto KP = dyn_cast(E)) { maybeDiagKeyPath(KP); } @@ -3739,7 +3819,12 @@ class ProblematicTypeFinder : public TypeDeclFinder { ModuleDecl *useModule = Where.getDeclContext()->getParentModule(); auto subs = ty->getContextSubstitutionMap(useModule, ty->getDecl()); - (void) diagnoseSubstitutionMapAvailability(Loc, subs, Where); + (void)diagnoseSubstitutionMapAvailability( + Loc, subs, Where, + /*depTy=*/Type(), + /*replacementTy=*/Type(), + /*useConformanceAvailabilityErrorsOption=*/false, + /*suppressParameterizationCheckForOptional=*/ty->isOptional()); return Action::Continue; } @@ -3771,6 +3856,19 @@ class ProblematicTypeFinder : public TypeDeclFinder { } } + if (auto *TT = T->getAs()) { + for (auto component : TT->getElementTypes()) { + // Let the walker find inner tuple types, we only want to diagnose + // non-compound components. + if (component->is()) + continue; + + if (component->hasParameterizedExistential()) + (void)diagnoseParameterizedProtocolAvailability( + Loc, Where.getDeclContext()); + } + } + return TypeDeclFinder::walkToTypePost(T); } }; @@ -3885,7 +3983,8 @@ swift::diagnoseSubstitutionMapAvailability(SourceLoc loc, SubstitutionMap subs, const ExportContext &where, Type depTy, Type replacementTy, - bool useConformanceAvailabilityErrorsOption) { + bool useConformanceAvailabilityErrorsOption, + bool suppressParameterizationCheckForOptional) { bool hadAnyIssues = false; for (ProtocolConformanceRef conformance : subs.getConformances()) { if (diagnoseConformanceAvailability(loc, conformance, where, @@ -3893,6 +3992,18 @@ swift::diagnoseSubstitutionMapAvailability(SourceLoc loc, useConformanceAvailabilityErrorsOption)) hadAnyIssues = true; } + + // If we're looking at \c (any P)? (or any other depth of optional) then + // there's no availability problem. + if (suppressParameterizationCheckForOptional) + return hadAnyIssues; + + for (auto replacement : subs.getReplacementTypes()) { + if (replacement->hasParameterizedExistential()) + if (diagnoseParameterizedProtocolAvailability(loc, + where.getDeclContext())) + hadAnyIssues = true; + } return hadAnyIssues; } diff --git a/lib/Sema/TypeCheckAvailability.h b/lib/Sema/TypeCheckAvailability.h index 11ee8cb74ece9..5d022ebeb6cb7 100644 --- a/lib/Sema/TypeCheckAvailability.h +++ b/lib/Sema/TypeCheckAvailability.h @@ -223,13 +223,14 @@ diagnoseConformanceAvailability(SourceLoc loc, Type replacementTy=Type(), bool useConformanceAvailabilityErrorsOption = false); -bool -diagnoseSubstitutionMapAvailability(SourceLoc loc, - SubstitutionMap subs, - const ExportContext &context, - Type depTy=Type(), - Type replacementTy=Type(), - bool useConformanceAvailabilityErrorsOption = false); +bool diagnoseSubstitutionMapAvailability( + SourceLoc loc, + SubstitutionMap subs, + const ExportContext &context, + Type depTy = Type(), + Type replacementTy = Type(), + bool useConformanceAvailabilityErrorsOption = false, + bool suppressParameterizationCheckForOptional = false); /// Diagnose uses of unavailable declarations. Returns true if a diagnostic /// was emitted. @@ -266,6 +267,11 @@ bool diagnoseExplicitUnavailability( const ExportContext &where, bool useConformanceAvailabilityErrorsOption = false); +/// Diagnose uses of the runtime features of parameterized protools. Returns +/// \c true if a diagnostic was emitted. +bool diagnoseParameterizedProtocolAvailability(SourceRange loc, + const DeclContext *DC); + /// Check if \p decl has a introduction version required by -require-explicit-availability void checkExplicitAvailability(Decl *decl); diff --git a/lib/Sema/TypeCheckProtocol.cpp b/lib/Sema/TypeCheckProtocol.cpp index 263d5255c1552..b4de9c8756e15 100644 --- a/lib/Sema/TypeCheckProtocol.cpp +++ b/lib/Sema/TypeCheckProtocol.cpp @@ -5053,6 +5053,17 @@ void ConformanceChecker::ensureRequirementsAreSatisfied() { if (where.isImplicit()) return; + Conformance->forEachTypeWitness([&](const AssociatedTypeDecl *assoc, + Type type, TypeDecl *typeDecl) -> bool { + // Make sure any associated type witnesses don't make reference to a + // parameterized existential type, or we're going to have trouble at + // runtime. + if (type->hasParameterizedExistential()) + (void)diagnoseParameterizedProtocolAvailability(typeDecl->getLoc(), + where.getDeclContext()); + return false; + }); + for (auto req : proto->getRequirementSignature().getRequirements()) { if (req.getKind() == RequirementKind::Conformance) { auto depTy = req.getFirstType(); From a0ce4f502c96b49d6a0393913524dbae1fd2aea6 Mon Sep 17 00:00:00 2001 From: Robert Widmann Date: Tue, 3 May 2022 19:59:40 -0700 Subject: [PATCH 4/4] Disable Availability Checking in Tests That Use Parameterized Existentials --- test/Constraints/parameterized_existential_metatypes.swift | 2 +- test/Interpreter/parameterized_existentials.swift | 2 +- test/RemoteAST/parameterized_existentials.swift | 2 +- test/SILGen/parameterized_existentials.swift | 2 +- test/SILOptimizer/cast_folding_parameterized_protocol.swift | 2 +- test/Sema/availability_parameterized_existential.swift | 2 ++ 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test/Constraints/parameterized_existential_metatypes.swift b/test/Constraints/parameterized_existential_metatypes.swift index 40394685941bf..be2e6d092b015 100644 --- a/test/Constraints/parameterized_existential_metatypes.swift +++ b/test/Constraints/parameterized_existential_metatypes.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -enable-parameterized-existential-types +// RUN: %target-typecheck-verify-swift -enable-parameterized-existential-types -disable-availability-checking // // FIXME: Merge this file with existential_metatypes.swift once -enable-parameterized-existential-types becomes the default diff --git a/test/Interpreter/parameterized_existentials.swift b/test/Interpreter/parameterized_existentials.swift index 1ec1b2650f064..331642f3cf5f4 100644 --- a/test/Interpreter/parameterized_existentials.swift +++ b/test/Interpreter/parameterized_existentials.swift @@ -1,4 +1,4 @@ -// RUN: %target-run-simple-swift(-Xfrontend -enable-parameterized-existential-types) +// RUN: %target-run-simple-swift(-Xfrontend -enable-parameterized-existential-types -Xfrontend -disable-availability-checking) // REQUIRES: executable_test import StdlibUnittest diff --git a/test/RemoteAST/parameterized_existentials.swift b/test/RemoteAST/parameterized_existentials.swift index 190a7406cc355..89973c9146ff9 100644 --- a/test/RemoteAST/parameterized_existentials.swift +++ b/test/RemoteAST/parameterized_existentials.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-remoteast-test -enable-parameterized-existential-types %s | %FileCheck %s +// RUN: %target-swift-remoteast-test -enable-parameterized-existential-types -disable-availability-checking %s | %FileCheck %s // REQUIRES: swift-remoteast-test diff --git a/test/SILGen/parameterized_existentials.swift b/test/SILGen/parameterized_existentials.swift index f078fb5dafa40..e61b4410acd3d 100644 --- a/test/SILGen/parameterized_existentials.swift +++ b/test/SILGen/parameterized_existentials.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-silgen -module-name parameterized -enable-parameterized-existential-types %s | %FileCheck %s +// RUN: %target-swift-emit-silgen -module-name parameterized -enable-parameterized-existential-types -disable-availability-checking %s | %FileCheck %s protocol P { associatedtype T diff --git a/test/SILOptimizer/cast_folding_parameterized_protocol.swift b/test/SILOptimizer/cast_folding_parameterized_protocol.swift index b35b5c12f39f4..1d8cfe92d141a 100644 --- a/test/SILOptimizer/cast_folding_parameterized_protocol.swift +++ b/test/SILOptimizer/cast_folding_parameterized_protocol.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend %s -emit-sil -enable-parameterized-existential-types -O -o - | %FileCheck %s +// RUN: %target-swift-frontend %s -emit-sil -enable-parameterized-existential-types -disable-availability-checking -O -o - | %FileCheck %s public protocol P { associatedtype T diff --git a/test/Sema/availability_parameterized_existential.swift b/test/Sema/availability_parameterized_existential.swift index afdba829153c9..23b63c65f6fcb 100644 --- a/test/Sema/availability_parameterized_existential.swift +++ b/test/Sema/availability_parameterized_existential.swift @@ -4,6 +4,8 @@ // Make sure we do not emit availability errors or warnings when -disable-availability-checking is passed // RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -typecheck -disable-objc-attr-requires-foundation-module -enable-parameterized-existential-types -disable-availability-checking %s 2>&1 | %FileCheck %s '--implicit-check-not=error:' +// REQUIRES: OS=macosx + func hedge() { struct Value {}