Skip to content

Commit

Permalink
[ConstraintSystem] Don't increase SK_Fix score when looking through…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
xedin committed Mar 25, 2020
1 parent 7410c09 commit 5f328ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 0 additions & 2 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5073,7 +5073,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
// func foo<T: BinaryInteger>(_: T) {}
// foo(Foo.bar) <- if `Foo` doesn't have `bar` there is
// no reason to complain about missing conformance.
increaseScore(SK_Fix);
return SolutionKind::Solved;
}

Expand Down Expand Up @@ -6466,7 +6465,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
baseObjTy->isHole()) {
// If base type is a "hole" there is no reason to record any
// more "member not found" fixes for chained member references.
increaseScore(SK_Fix);
markMemberTypeAsPotentialHole(memberTy);
return SolutionKind::Solved;
}
Expand Down
10 changes: 5 additions & 5 deletions test/Constraints/rdar44770297.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ protocol P {
associatedtype A
}

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

// TODO(diagnostics): This expression is truly ambiguous because there is no conformance between `Never` and `P`
// which means no associated type `A` and `nil` can't be an argument to any overload of `&` so we end
// up generating at least 3 fixes per overload of `&`. But we could at least point to where the problems are.
let _ = foo() {fatalError()} & nil // expected-error {{type of expression is ambiguous without more context}}
let _ = foo() {fatalError()} & nil // expected-error {{global function 'foo' requires that 'Never' conform to 'P'}}
// expected-error@-1 {{value of optional type 'Never.A?' must be unwrapped to a value of type 'Never.A'}}
// expected-note@-2 {{force-unwrap}}
// expected-note@-3 {{coalesce using '??'}}
3 changes: 1 addition & 2 deletions test/decl/enum/enumtest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ func test1a() -> unionSearchFlags {

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

enum MaybeInt {
Expand Down

0 comments on commit 5f328ad

Please sign in to comment.