You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sema: Fix isExported() for extension decls in order to correct availability diagnostics when -target-min-inlining-version min is specified.
Previously, an extension decl was always considered exported (externally visible to module clients) as long as it extended an exported type. Extensions need to either contain some externally visible member (e.g. a public method) or implement a conformance to a public protcol, though, to actually be exported. Without this fix, the compiler incorrectly requires internal extensions to types that are always available at runtime to have declared availability which would be a nuisance for library authors.
As part of testing this change, I expanded the attr_inlinable_available.swift test case significantly and that prompted me to scrap the copy of the test specific to macCatalyst as it seemed like needing to keep the two tests in sync was going to be a liability going forward. I replaced the deleted test with a couple of more targeted tests that use `-dump-type-refinement-contexts` to verify the effect of `-target-min-inlining-version min` on the root refinement context. Again a macCatalyst version of the test is required because we don't have bots that are configured to make the macCatalyst runtime the "target" OS.
Resolves rdar://91382040
// OK, extensions on internal types are never visible externally.
635
+
extensionBetweenTargetsInternal{}
636
+
extensionBetweenTargetsInternal{
637
+
publicfunc publicFunc(){}
638
+
}
639
+
640
+
// expected-error@+1 {{'AfterDeploymentTarget' is only available in}} expected-note@+1 {{add @available attribute to enclosing extension}}
641
+
extensionAfterDeploymentTarget{}
642
+
643
+
// expected-error@+1 {{'AfterDeploymentTarget' is only available in}} expected-note@+1 {{add @available attribute to enclosing extension}}
644
+
extensionAfterDeploymentTarget{
645
+
internalfunc internalFunc1(){}
646
+
privatefunc privateFunc1(){}
647
+
fileprivatefunc fileprivateFunc1(){}
648
+
}
649
+
650
+
// expected-error@+1 {{'AfterDeploymentTarget' is only available in}} expected-note@+1 {{add @available attribute to enclosing extension}}
651
+
extensionAfterDeploymentTarget{
652
+
publicfunc publicFunc1(){}
653
+
}
654
+
655
+
656
+
// MARK: Protocol conformances
657
+
658
+
internalprotocolInternalProto{}
659
+
660
+
extensionNoAvailable:InternalProto{}
661
+
extensionBeforeInliningTarget:InternalProto{}
662
+
extensionAtInliningTarget:InternalProto{}
663
+
extensionBetweenTargets:InternalProto{}
664
+
extensionAtDeploymentTarget:InternalProto{}
665
+
extensionAfterDeploymentTarget:InternalProto{} // expected-error {{'AfterDeploymentTarget' is only available in}} expected-note {{add @available attribute to enclosing extension}}
666
+
667
+
publicprotocolPublicProto{}
668
+
669
+
extensionNoAvailable:PublicProto{}
670
+
extensionBeforeInliningTarget:PublicProto{}
671
+
extensionAtInliningTarget:PublicProto{}
672
+
extensionBetweenTargets:PublicProto{} // expected-error {{'BetweenTargets' is only available in}} expected-note {{add @available attribute to enclosing extension}}
673
+
extensionAtDeploymentTarget:PublicProto{} // expected-error {{'AtDeploymentTarget' is only available in}} expected-note {{add @available attribute to enclosing extension}}
674
+
extensionAfterDeploymentTarget:PublicProto{} // expected-error {{'AfterDeploymentTarget' is only available in}} expected-note {{add @available attribute to enclosing extension}}
0 commit comments