@@ -757,44 +757,6 @@ bool MemberAccessOnOptionalBaseFailure::diagnoseAsError() {
757
757
resultIsOptional, SourceRange ());
758
758
}
759
759
760
- Optional<AnyFunctionType::Param>
761
- MissingOptionalUnwrapFailure::getOperatorParameterFor (Expr *expr) const {
762
- auto *parentExpr = findParentExpr (expr);
763
- if (!parentExpr)
764
- return None;
765
-
766
- auto getArgIdx = [](TupleExpr *tuple, Expr *argExpr) -> unsigned {
767
- for (unsigned i = 0 , n = tuple->getNumElements (); i != n; ++i) {
768
- if (tuple->getElement (i) == argExpr)
769
- return i;
770
- }
771
- llvm_unreachable (" argument is not in enclosing tuple?!" );
772
- };
773
-
774
- auto *tupleExpr = dyn_cast<TupleExpr>(parentExpr);
775
- if (!(tupleExpr && tupleExpr->isImplicit ()))
776
- return None;
777
-
778
- parentExpr = findParentExpr (tupleExpr);
779
- if (!(parentExpr && isa<ApplyExpr>(parentExpr)))
780
- return None;
781
-
782
- auto &cs = getConstraintSystem ();
783
- auto *fnExpr = cast<ApplyExpr>(parentExpr)->getFn ();
784
- if (auto overload =
785
- getOverloadChoiceIfAvailable (cs.getConstraintLocator (fnExpr))) {
786
- if (auto *decl = overload->choice .getDecl ()) {
787
- if (!decl->isOperator ())
788
- return None;
789
-
790
- auto *fnType = overload->openedType ->castTo <FunctionType>();
791
- return fnType->getParams ()[getArgIdx (tupleExpr, expr)];
792
- }
793
- }
794
-
795
- return None;
796
- }
797
-
798
760
void MissingOptionalUnwrapFailure::offerDefaultValueUnwrapFixIt (
799
761
DeclContext *DC, Expr *expr) const {
800
762
auto *anchor = getAnchor ();
@@ -805,10 +767,9 @@ void MissingOptionalUnwrapFailure::offerDefaultValueUnwrapFixIt(
805
767
if (isa<InOutExpr>(anchor))
806
768
return ;
807
769
808
- if (auto param = getOperatorParameterFor (anchor)) {
809
- if (param-> isInOut ())
770
+ if (auto argApplyInfo = getFunctionArgApplyInfo ( getLocator ()))
771
+ if (argApplyInfo-> getParameterFlags (). isInOut ())
810
772
return ;
811
- }
812
773
813
774
auto diag = emitDiagnostic (expr->getLoc (), diag::unwrap_with_default_value);
814
775
0 commit comments