File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -582,10 +582,10 @@ class TypeRefinementContextBuilder : private ASTWalker {
582
582
// This rule is a convenience for library authors who have written
583
583
// extensions without specifying availabilty on the extension itself.
584
584
if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
585
- auto *Nominal = ED->getExtendedNominal ();
586
- if (Nominal && !hasActiveAvailableAttribute (D, Context)) {
585
+ auto ET = ED->getExtendedType ();
586
+ if (ET && !hasActiveAvailableAttribute (D, Context)) {
587
587
EffectiveAvailability.intersectWith (
588
- swift::AvailabilityInference::availableRange (Nominal, Context ));
588
+ swift::AvailabilityInference::inferForType (ET ));
589
589
590
590
// We want to require availability to be specified on extensions of
591
591
// types that would be potentially unavailable to the module containing
Original file line number Diff line number Diff line change @@ -1134,6 +1134,36 @@ extension AfterDeploymentTarget {
1134
1134
) { }
1135
1135
}
1136
1136
1137
+ // MARK: Extensions on nested types
1138
+
1139
+ @available ( macOS 10 . 14 . 5 , * )
1140
+ public enum BetweenTargetsEnum {
1141
+ public struct Nested { }
1142
+ }
1143
+
1144
+ extension BetweenTargetsEnum . Nested { }
1145
+
1146
+ extension BetweenTargetsEnum . Nested { // expected-note {{add @available attribute to enclosing extension}}
1147
+ func internalFuncInExtension( // expected-note {{add @available attribute to enclosing instance method}}
1148
+ _: NoAvailable ,
1149
+ _: BeforeInliningTarget ,
1150
+ _: AtInliningTarget ,
1151
+ _: BetweenTargets ,
1152
+ _: AtDeploymentTarget ,
1153
+ _: AfterDeploymentTarget // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}}
1154
+ ) { }
1155
+ }
1156
+
1157
+ extension BetweenTargetsEnum . Nested { // expected-note 2 {{add @available attribute to enclosing extension}}
1158
+ public func publicFuncInExtension( // expected-note 2 {{add @available attribute to enclosing instance method}}
1159
+ _: NoAvailable ,
1160
+ _: BeforeInliningTarget ,
1161
+ _: AtInliningTarget ,
1162
+ _: BetweenTargets ,
1163
+ _: AtDeploymentTarget , // expected-error {{'AtDeploymentTarget' is only available in macOS 10.15 or newer; clients of 'Test' may have a lower deployment target}}
1164
+ _: AfterDeploymentTarget // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}}
1165
+ ) { }
1166
+ }
1137
1167
1138
1168
// MARK: Protocol conformances
1139
1169
You can’t perform that action at this time.
0 commit comments