Skip to content

Commit 50333b6

Browse files
author
Greg Titus
committed
Raise impact of DefineMemberBasedOnUse to 4, lower RemoveInvalidCall to 3.
1 parent a079c5c commit 50333b6

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11115,7 +11115,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
1111511115

1111611116
auto instanceTy = baseObjTy->getMetatypeInstanceType();
1111711117

11118-
auto impact = 2;
11118+
auto impact = 4;
1111911119
// Impact is higher if the base type is any function type
1112011120
// because function types can't have any members other than self
1112111121
if (instanceTy->is<AnyFunctionType>()) {
@@ -13392,7 +13392,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyApplicableFnConstraint(
1339213392
// Let's make this fix as high impact so if there is a function or member
1339313393
// overload with e.g. argument-to-parameter type mismatches it would take
1339413394
// a higher priority.
13395-
return recordFix(fix, /*impact=*/10) ? SolutionKind::Error
13395+
return recordFix(fix, /*impact=*/3) ? SolutionKind::Error
1339613396
: SolutionKind::Solved;
1339713397
}
1339813398

test/Constraints/diagnostics.swift

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,7 @@ func rdar20142523() {
170170
// <rdar://problem/21080030> Bad diagnostic for invalid method call in boolean expression: (_, ExpressibleByIntegerLiteral)' is not convertible to 'ExpressibleByIntegerLiteral
171171
func rdar21080030() {
172172
var s = "Hello"
173-
// https://github.com/apple/swift/issues/50141
174-
// This should be 'cannot_call_non_function_value'.
175-
if s.count() == 0 {}
176-
// expected-error@-1 {{generic parameter 'E' could not be inferred}}
177-
// expected-error@-2 {{missing argument for parameter 'where' in call}}
173+
if s.count() == 0 {} // expected-error {{cannot call value of non-function type 'Int'}}
178174
}
179175

180176
// <rdar://problem/21248136> QoI: problem with return type inference mis-diagnosed as invalid arguments
@@ -1537,9 +1533,7 @@ func issue63746() {
15371533
}
15381534

15391535
func rdar86611718(list: [Int]) {
1540-
String(list.count())
1541-
// expected-error@-1 {{missing argument for parameter 'where' in call}}
1542-
// expected-error@-2 {{generic parameter 'E' could not be inferred}}
1536+
String(list.count()) // expected-error {{cannot call value of non-function type 'Int'}}
15431537
}
15441538

15451539
// rdar://108977234 - failed to produce diagnostic when argument to AnyHashable parameter doesn't conform to Hashable protocol
@@ -1558,17 +1552,28 @@ func testNilCoalescingOperatorRemoveFix() {
15581552
let _ = "" /* This is a comment */ ?? "" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{13-43=}}
15591553

15601554
let _ = "" // This is a comment
1561-
?? "" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1560:13-1561:10=}}
1555+
?? "" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1554:13-1555:10=}}
15621556

15631557
let _ = "" // This is a comment
15641558
/*
15651559
* The blank line below is part of the test case, do not delete it
15661560
*/
1567-
?? "" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1563:13-1567:10=}}
1561+
?? "" // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1557:13-1561:10=}}
15681562

1569-
if ("" ?? // This is a comment // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{9-1570:9=}}
1563+
if ("" ?? // This is a comment // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{9-1564:9=}}
15701564
"").isEmpty {}
15711565

15721566
if ("" // This is a comment
1573-
?? "").isEmpty {} // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1572:9-1573:12=}}
1567+
?? "").isEmpty {} // expected-warning {{left side of nil coalescing operator '??' has non-optional type 'String', so the right side is never used}} {{1566:9-1567:12=}}
1568+
}
1569+
1570+
// https://github.com/apple/swift/issues/74617
1571+
struct Foo_74617 {
1572+
public var bar: Float { 123 }
1573+
public static func + (lhs: Self, rhs: Self) -> Self { Self() }
1574+
}
1575+
func testAddMemberVsRemoveCall() {
1576+
let a = Foo_74617()
1577+
let b = Foo_74617()
1578+
let c = (a + b).bar() // expected-error {{cannot call value of non-function type 'Float'}} {{22-24=}}
15741579
}

0 commit comments

Comments
 (0)