File tree Expand file tree Collapse file tree 2 files changed +33
-10
lines changed Expand file tree Collapse file tree 2 files changed +33
-10
lines changed Original file line number Diff line number Diff line change @@ -2697,15 +2697,30 @@ static std::vector<Feature> getUniqueFeaturesUsed(Decl *decl) {
2697
2697
if (features.empty ())
2698
2698
return features;
2699
2699
2700
- Decl *enclosingDecl;
2701
- if (auto accessor = dyn_cast<AccessorDecl>(decl))
2702
- enclosingDecl = accessor->getStorage ();
2703
- else
2704
- enclosingDecl = decl->getDeclContext ()->getAsDecl ();
2705
- if (!enclosingDecl)
2706
- return features;
2700
+ // Gather the features used by all enclosing declarations.
2701
+ Decl *enclosingDecl = decl;
2702
+ std::vector<Feature> enclosingFeatures;
2703
+ while (true ) {
2704
+ // Find the next outermost enclosing declaration.
2705
+ if (auto accessor = dyn_cast<AccessorDecl>(enclosingDecl))
2706
+ enclosingDecl = accessor->getStorage ();
2707
+ else
2708
+ enclosingDecl = enclosingDecl->getDeclContext ()->getAsDecl ();
2709
+ if (!enclosingDecl)
2710
+ break ;
2711
+
2712
+ auto outerEnclosingFeatures = getFeaturesUsed (enclosingDecl);
2713
+ if (outerEnclosingFeatures.empty ())
2714
+ continue ;
2715
+
2716
+ auto currentEnclosingFeatures = std::move (enclosingFeatures);
2717
+ enclosingFeatures.clear ();
2718
+ std::merge (outerEnclosingFeatures.begin (), outerEnclosingFeatures.end (),
2719
+ currentEnclosingFeatures.begin (), currentEnclosingFeatures.end (),
2720
+ std::back_inserter (enclosingFeatures));
2721
+ }
2707
2722
2708
- auto enclosingFeatures = getFeaturesUsed (enclosingDecl);
2723
+ // If there were no enclosing features, we're done.
2709
2724
if (enclosingFeatures.empty ())
2710
2725
return features;
2711
2726
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ public class OldSchool2: MP {
78
78
// CHECK: #if compiler(>=5.3) && $RethrowsProtocol
79
79
// CHECK-NEXT: @rethrows public protocol RP
80
80
@rethrows public protocol RP {
81
- func f( ) throws
81
+ func f( ) throws -> Bool
82
82
}
83
83
84
84
// CHECK: public struct UsesRP {
@@ -95,7 +95,15 @@ public struct UsesRP {
95
95
// CHECK: #if compiler(>=5.3) && $RethrowsProtocol
96
96
// CHECK-NEXT: public struct IsRP
97
97
public struct IsRP : RP {
98
- public func f( ) { }
98
+ // CHECK-NEXT: public func f()
99
+ public func f( ) -> Bool { }
100
+
101
+ // CHECK-NOT: $RethrowsProtocol
102
+ // CHECK-NEXT: public var isF:
103
+ // CHECK-NEXT: get
104
+ public var isF : Bool {
105
+ f ( )
106
+ }
99
107
}
100
108
101
109
// CHECK: #if compiler(>=5.3) && $RethrowsProtocol
You can’t perform that action at this time.
0 commit comments