Skip to content

Commit b6ba3fe

Browse files
committed
[CSSimplify] Mark all type variables in member type as holes if base is a hole
Even if the member type variable is partially resolved, we still need to mark inner type variables (if any) as holes because they might not be connected to anything that could provide contextual type(s). Resolves: rdar://124549952
1 parent a245391 commit b6ba3fe

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10739,8 +10739,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
1073910739
// reason to perform a lookup because it wouldn't return any results.
1074010740
if (shouldAttemptFixes()) {
1074110741
auto markMemberTypeAsPotentialHole = [&](Type memberTy) {
10742-
if (auto *typeVar = memberTy->getAs<TypeVariableType>())
10743-
recordPotentialHole(typeVar);
10742+
recordAnyTypeVarAsPotentialHole(simplifyType(memberTy));
1074410743
};
1074510744

1074610745
// If this is an unresolved member ref e.g. `.foo` and its contextual base

test/Constraints/members.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,3 +816,13 @@ func test_mismatch_between_param_and_optional_chain() {
816816
}
817817
}
818818
}
819+
820+
// rdar://124549952 - incorrect "type of expression is ambiguous without a type annotation"
821+
do {
822+
func fn() -> (any BinaryInteger)? {}
823+
824+
func test() {
825+
let _ = fn()?.op().value
826+
// expected-error@-1 {{value of type 'any BinaryInteger' has no member 'op'}}
827+
}
828+
}

0 commit comments

Comments
 (0)