File tree Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -2641,6 +2641,12 @@ void ContextualFailure::tryFixIts(InFlightDiagnostic &diagnostic) const {
2641
2641
}
2642
2642
2643
2643
bool ContextualFailure::diagnoseMissingFunctionCall () const {
2644
+ // Don't suggest inserting a function call if the function expression
2645
+ // isn't written explicitly in the source code.
2646
+ auto *anchor = getAsExpr (simplifyLocatorToAnchor (getLocator ()));
2647
+ if (!anchor || anchor->isImplicit ())
2648
+ return false ;
2649
+
2644
2650
if (getLocator ()
2645
2651
->isLastElement <LocatorPathElt::UnresolvedMemberChainResult>())
2646
2652
return false ;
Original file line number Diff line number Diff line change @@ -3657,15 +3657,17 @@ bool ConstraintSystem::repairFailures(
3657
3657
if (!fnType)
3658
3658
return false ;
3659
3659
3660
+ // If the locator isn't anchored at an expression, or the expression is
3661
+ // implicit, don't try to insert an explicit call into the source code.
3662
+ auto *loc = getConstraintLocator (locator);
3663
+ auto *anchor = getAsExpr (simplifyLocatorToAnchor (loc));
3664
+ if (!anchor || anchor->isImplicit ())
3665
+ return false ;
3666
+
3660
3667
// If argument is a function type and all of its parameters have
3661
3668
// default values, let's see whether error is related to missing
3662
3669
// explicit call.
3663
3670
if (fnType->getNumParams () > 0 ) {
3664
- auto *loc = getConstraintLocator (locator);
3665
- auto *anchor = getAsExpr (simplifyLocatorToAnchor (loc));
3666
- if (!anchor)
3667
- return false ;
3668
-
3669
3671
auto overload = findSelectedOverloadFor (anchor);
3670
3672
if (!(overload && overload->choice .isDecl ()))
3671
3673
return false ;
Original file line number Diff line number Diff line change @@ -1011,6 +1011,17 @@ struct SR_10899_Usage {
1011
1011
@SR_10899_Wrapper var thing : Bool // expected-error{{property type 'Bool' does not match 'wrappedValue' type 'String'}}
1012
1012
}
1013
1013
1014
+ // https://bugs.swift.org/browse/SR-14730
1015
+ @propertyWrapper
1016
+ struct StringWrappedValue {
1017
+ var wrappedValue : String
1018
+ }
1019
+
1020
+ struct SR_14730 {
1021
+ // expected-error@+1 {{property type '() -> String' does not match 'wrappedValue' type 'String'}}
1022
+ @StringWrappedValue var value : ( ) -> String
1023
+ }
1024
+
1014
1025
// SR-11061 / rdar://problem/52593304 assertion with DeclContext mismatches
1015
1026
class SomeValue {
1016
1027
@SomeA ( closure: { $0 } ) var some : Int = 100
You can’t perform that action at this time.
0 commit comments