Skip to content

Commit 3116d6e

Browse files
authored
Merge pull request #28539 from xedin/remove-constraint-handling-from-csdiag
[Diagnostics] Port diagnostics related to ambiguities and constraints
2 parents 4093a19 + 1be60a7 commit 3116d6e

28 files changed

+360
-656
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ ERROR(no_overloads_match_exactly_in_call_no_labels,none,
6969
ERROR(no_overloads_match_exactly_in_call_special,none,
7070
"no exact matches in call to %0",
7171
(DescriptiveDeclKind))
72+
ERROR(no_overloads_match_exactly_in_assignment,none,
73+
"no exact matches in assignment to %0",
74+
(DeclBaseName))
7275

7376
ERROR(ambiguous_subscript,none,
7477
"ambiguous subscript with base type %0 and index type %1",
@@ -3041,6 +3044,8 @@ ERROR(collection_literal_empty,none,
30413044
ERROR(unresolved_member_no_inference,none,
30423045
"reference to member %0 cannot be resolved without a contextual type",
30433046
(DeclName))
3047+
ERROR(cannot_infer_base_of_unresolved_member,none,
3048+
"cannot infer contextual base in reference to member %0", (DeclName))
30443049
ERROR(unresolved_collection_literal,none,
30453050
"cannot infer type for empty collection literal without a "
30463051
"contextual type", ())
@@ -3401,6 +3406,10 @@ ERROR(assignment_dynamic_property_has_immutable_base,none,
34013406
ERROR(assignment_bang_has_immutable_subcomponent,none,
34023407
"cannot assign through '!': %0", (StringRef))
34033408

3409+
NOTE(candidate_is_not_assignable,none,
3410+
"candidate is not assignable: %0 %1",
3411+
(DescriptiveDeclKind, DeclName))
3412+
34043413
NOTE(change_to_mutating,none,
34053414
"mark %select{method|accessor}0 'mutating' to make 'self' mutable",
34063415
(bool))

lib/Sema/CSBindings.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,13 @@ ConstraintSystem::getPotentialBindings(TypeVariableType *typeVar) const {
738738
if (shouldAttemptFixes() && result.Bindings.empty() &&
739739
typeVar->getImpl().canBindToHole()) {
740740
result.IsHole = true;
741+
// If the base of the unresolved member reference like `.foo`
742+
// couldn't be resolved we'd want to bind it to a hole at the
743+
// very last moment possible, just like generic parameters.
744+
auto *locator = typeVar->getImpl().getLocator();
745+
if (locator->isLastElement<LocatorPathElt::MemberRefBase>())
746+
result.PotentiallyIncomplete = true;
747+
741748
result.addPotentialBinding({getASTContext().TheUnresolvedType,
742749
AllowedBindingKind::Exact, ConstraintKind::Defaultable, nullptr,
743750
typeVar->getImpl().getLocator()});

0 commit comments

Comments
 (0)