Skip to content

Commit 564155e

Browse files
authored
Merge pull request #76377 from xedin/dont-discriminate-against-any-and-anyobject
[CSSimplify] Don't increase impact if member doesn't exist on Any/Any…
2 parents e0a3572 + 97f284a commit 564155e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11024,9 +11024,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
1102411024
impact += 10;
1102511025
}
1102611026

11027-
if (instanceTy->isAny() || instanceTy->isAnyObject())
11028-
impact += 5;
11029-
1103011027
auto *anchorExpr = getAsExpr(locator->getAnchor());
1103111028
if (anchorExpr) {
1103211029
if (auto *UDE = dyn_cast<UnresolvedDotExpr>(anchorExpr)) {

test/Constraints/members.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,3 +826,14 @@ do {
826826
// expected-error@-1 {{value of type 'any BinaryInteger' has no member 'op'}}
827827
}
828828
}
829+
830+
do {
831+
func test<T>(_: T) -> T? { nil }
832+
func test<U>(_: U) -> Int { 0 }
833+
834+
func compute(x: Any) {
835+
test(x)!.unknown()
836+
// expected-error@-1 {{value of type 'Any' has no member 'unknown'}}
837+
// expected-note@-2 {{cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members}}
838+
}
839+
}

0 commit comments

Comments
 (0)