@@ -100,92 +100,6 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
100
100
unsigned level : 29 ;
101
101
};
102
102
103
- // Partial applications of functions that are not permitted. This is
104
- // tracked in post-order and unraveled as subsequent applications complete
105
- // the call (or not).
106
- llvm::SmallDenseMap<Expr*, PartialApplication,2 > InvalidPartialApplications;
107
-
108
- ~DiagnoseWalker () override {
109
- for (auto &unapplied : InvalidPartialApplications) {
110
- unsigned kind = unapplied.second .kind ;
111
- if (unapplied.second .compatibilityWarning ) {
112
- TC.diagnose (unapplied.first ->getLoc (),
113
- diag::partial_application_of_function_invalid_swift4,
114
- kind);
115
- } else {
116
- TC.diagnose (unapplied.first ->getLoc (),
117
- diag::partial_application_of_function_invalid,
118
- kind);
119
- }
120
- }
121
- }
122
-
123
- // / methods are fully applied when they can't support partial application.
124
- void checkInvalidPartialApplication (Expr *E) {
125
- if (auto AE = dyn_cast<ApplyExpr>(E)) {
126
- Expr *fnExpr = AE->getSemanticFn ();
127
- if (auto forceExpr = dyn_cast<ForceValueExpr>(fnExpr))
128
- fnExpr = forceExpr->getSubExpr ()->getSemanticsProvidingExpr ();
129
- if (auto dotSyntaxExpr = dyn_cast<DotSyntaxBaseIgnoredExpr>(fnExpr))
130
- fnExpr = dotSyntaxExpr->getRHS ();
131
-
132
- // Check to see if this is a potentially unsupported partial
133
- // application of a constructor delegation.
134
- if (isa<OtherConstructorDeclRefExpr>(fnExpr)) {
135
- auto kind = AE->getArg ()->isSuperExpr ()
136
- ? PartialApplication::SuperInit
137
- : PartialApplication::SelfInit;
138
-
139
- // Partial applications of delegated initializers aren't allowed, and
140
- // don't really make sense to begin with.
141
- InvalidPartialApplications.insert (
142
- {E, {PartialApplication::Error, kind, 1 }});
143
- return ;
144
- }
145
-
146
- // If this is adding a level to an active partial application, advance
147
- // it to the next level.
148
- auto foundApplication = InvalidPartialApplications.find (fnExpr);
149
- if (foundApplication == InvalidPartialApplications.end ())
150
- return ;
151
-
152
- unsigned level = foundApplication->second .level ;
153
- auto kind = foundApplication->second .kind ;
154
- assert (level > 0 );
155
- InvalidPartialApplications.erase (foundApplication);
156
- if (level > 1 ) {
157
- // We have remaining argument clauses.
158
- // Partial applications were always diagnosed in Swift 4 and before,
159
- // so there's no need to preserve the compatibility warning bit.
160
- InvalidPartialApplications.insert (
161
- {AE, {PartialApplication::Error, kind, level - 1 }});
162
- }
163
- return ;
164
- }
165
-
166
- // / If this is a reference to a mutating method, it cannot be partially
167
- // / applied or even referenced without full application, so arrange for
168
- // / us to check that it gets fully applied.
169
- auto fnDeclRef = dyn_cast<DeclRefExpr>(E);
170
- if (!fnDeclRef)
171
- return ;
172
-
173
- auto fn = dyn_cast<FuncDecl>(fnDeclRef->getDecl ());
174
- if (!fn || !fn->isInstanceMember () || !fn->isMutating ())
175
- return ;
176
-
177
- // Swift 4 and earlier failed to diagnose a reference to a mutating method
178
- // without any applications at all, which would get miscompiled into a
179
- // function with undefined behavior. Warn for source compatibility.
180
- auto errorBehavior = TC.Context .LangOpts .isSwiftVersionAtLeast (5 )
181
- ? PartialApplication::Error
182
- : PartialApplication::CompatibilityWarning;
183
-
184
- InvalidPartialApplications.insert (
185
- {fnDeclRef, {errorBehavior,
186
- PartialApplication::MutatingMethod, 2 }});
187
- }
188
-
189
103
// Not interested in going outside a basic expression.
190
104
std::pair<bool , Stmt *> walkToStmtPre (Stmt *S) override {
191
105
return { false , S };
@@ -463,11 +377,6 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
463
377
return arg;
464
378
}
465
379
466
- Expr *walkToExprPost (Expr *E) override {
467
- checkInvalidPartialApplication (E);
468
- return E;
469
- }
470
-
471
380
void checkConvertedPointerArgument (ConcreteDeclRef callee,
472
381
unsigned uncurryLevel,
473
382
unsigned argIndex,
0 commit comments