Files
swift-mirror/test/IDE/complete_closure_ambiguity.swift
Kathy Gray fde49b8847 Diagnostics : Increase possibility for missed property diagnostic
Impact for an unknown property access was frequently higher than other options
on ambiguous selections, by 3 to 5 points, causing fix selections that were
farther away and frequently noted to be in accurate. This commit lowers the
impact to be in a similar range to other fixes and this causes property accesses
to be selected more proprotionaly.

In the existing test suite, this changed the diagnostic only in the case of
protocol composition, which was also discovered to be a flawed binding lookup.

Tests added for the property lookup, tests updated for protocol composition
(Including correcting a likely error in a test specification)
2025-12-11 16:08:22 +00:00

32 lines
1.0 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %batch-code-completion -debug-constraints 2> %t/constraints.log
// RUN: %FileCheck %s -check-prefix CONSTRAINTS < %t/constraints.log
// RUN: %FileCheck %s -check-prefix CONSTRAINTS-NOT < %t/constraints.log
protocol P1 {}
protocol P2 {}
func foo<T: P1>(_ fn: () -> T) {}
@_disfavoredOverload
func foo<T: P2>(_ fn: () -> T) {}
func bar(_ x: Int) -> Int {}
func bar(_ x: String) -> String {}
// Make sure we eagerly prune the disfavored overload of 'foo', despite the
// ambiguity in the closure body.
foo {
let x = bar(#^COMPLETE^#)
// COMPLETE: Decl[FreeFunction]/CurrModule/Flair[ArgLabels]: ['(']{#(x): Int#}[')'][#Int#]; name=:
// COMPLETE: Decl[FreeFunction]/CurrModule/Flair[ArgLabels]: ['(']{#(x): String#}[')'][#String#]; name=:
return x
}
// CONSTRAINTS: attempting disjunction choice {{.*}}:12:6
// CONSTRAINTS: increasing 'disfavored overload' score
// CONSTRAINTS: solution {{.*}} is worse than the best solution {{.*}}
// CONSTRAINTS-NOT-NOT: increasing 'hole'