@@ -191,58 +191,6 @@ TypeChecker::lookupPrecedenceGroupForInfixOperator(DeclContext *DC, Expr *E,
191191 return nullptr ;
192192}
193193
194- // / Find LHS as if we append binary operator to existing pre-folded expression.
195- // / Returns found expression, or \c nullptr if the operator is not applicable.
196- // /
197- // / For example, given '(== R (* A B))':
198- // / 'findLHS(DC, expr, "+")' returns '(* A B)'.
199- // / 'findLHS(DC, expr, "<<")' returns 'B'.
200- // / 'findLHS(DC, expr, '==')' returns nullptr.
201- Expr *TypeChecker::findLHS (DeclContext *DC, Expr *E, Identifier name) {
202- auto right = lookupPrecedenceGroupForOperator (DC, name, E->getEndLoc ());
203- if (!right)
204- return nullptr ;
205-
206- while (true ) {
207-
208- // Look through implicit conversions.
209- if (auto ICE = dyn_cast<ImplicitConversionExpr>(E)) {
210- E = ICE->getSyntacticSubExpr ();
211- continue ;
212- }
213- if (auto ACE = dyn_cast<AutoClosureExpr>(E)) {
214- E = ACE->getSingleExpressionBody ();
215- continue ;
216- }
217-
218- auto left = lookupPrecedenceGroupForInfixOperator (DC, E, /* diagnose=*/ true );
219- if (!left)
220- // LHS is not binary expression.
221- return E;
222- switch (DC->getASTContext ().associateInfixOperators (left, right)) {
223- case swift::Associativity::None:
224- return nullptr ;
225- case swift::Associativity::Left:
226- return E;
227- case swift::Associativity::Right:
228- break ;
229- }
230- // Find the RHS of the current binary expr.
231- if (auto *assignExpr = dyn_cast<AssignExpr>(E)) {
232- E = assignExpr->getSrc ();
233- } else if (auto *ternary = dyn_cast<TernaryExpr>(E)) {
234- E = ternary->getElseExpr ();
235- } else if (auto *binaryExpr = dyn_cast<BinaryExpr>(E)) {
236- E = binaryExpr->getRHS ();
237- } else {
238- // E.g. 'fn() as Int << 2'.
239- // In this case '<<' has higher precedence than 'as', but the LHS should
240- // be 'fn() as Int' instead of 'Int'.
241- return E;
242- }
243- }
244- }
245-
246194// The way we compute isEndOfSequence relies on the assumption that
247195// the sequence-folding algorithm never recurses with a prefix of the
248196// entire sequence.
0 commit comments