Skip to content

Commit 5f328ad

Browse files
committed
[ConstraintSystem] Don't increase SK_Fix score when looking through holes
`SK_Fix` was used to indicate that solver has encountered a hole along the current path but since there is `SK_Hole` now, increasing `SK_Fix` no longer makes sense.
1 parent 7410c09 commit 5f328ad

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5073,7 +5073,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
50735073
// func foo<T: BinaryInteger>(_: T) {}
50745074
// foo(Foo.bar) <- if `Foo` doesn't have `bar` there is
50755075
// no reason to complain about missing conformance.
5076-
increaseScore(SK_Fix);
50775076
return SolutionKind::Solved;
50785077
}
50795078

@@ -6466,7 +6465,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
64666465
baseObjTy->isHole()) {
64676466
// If base type is a "hole" there is no reason to record any
64686467
// more "member not found" fixes for chained member references.
6469-
increaseScore(SK_Fix);
64706468
markMemberTypeAsPotentialHole(memberTy);
64716469
return SolutionKind::Solved;
64726470
}

test/Constraints/rdar44770297.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ protocol P {
44
associatedtype A
55
}
66

7-
func foo<T: P>(_: () throws -> T) -> T.A? {
7+
func foo<T: P>(_: () throws -> T) -> T.A? { // expected-note {{where 'T' = 'Never'}}
88
fatalError()
99
}
1010

11-
// TODO(diagnostics): This expression is truly ambiguous because there is no conformance between `Never` and `P`
12-
// which means no associated type `A` and `nil` can't be an argument to any overload of `&` so we end
13-
// up generating at least 3 fixes per overload of `&`. But we could at least point to where the problems are.
14-
let _ = foo() {fatalError()} & nil // expected-error {{type of expression is ambiguous without more context}}
11+
let _ = foo() {fatalError()} & nil // expected-error {{global function 'foo' requires that 'Never' conform to 'P'}}
12+
// expected-error@-1 {{value of optional type 'Never.A?' must be unwrapped to a value of type 'Never.A'}}
13+
// expected-note@-2 {{force-unwrap}}
14+
// expected-note@-3 {{coalesce using '??'}}

test/decl/enum/enumtest.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ func test1a() -> unionSearchFlags {
3636

3737
func test1b(_ b : Bool) {
3838
_ = 123
39-
_ = .description == 1 // expected-error {{instance member 'description' cannot be used on type 'Int'}}
40-
// expected-error@-1 {{member 'description' in 'Int' produces result of type 'String', but context expects 'Int'}}
39+
_ = .description == 1 // expected-error {{cannot infer contextual base in reference to member 'description'}}
4140
}
4241

4342
enum MaybeInt {

0 commit comments

Comments
 (0)