File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -2522,6 +2522,17 @@ TypeVariableBinding::fixForHole(ConstraintSystem &cs) const {
2522
2522
FixKind::IgnoreCollectionElementContextualMismatch)) {
2523
2523
return llvm::None;
2524
2524
}
2525
+ if (dstLocator->getAnchor ().isExpr (ExprKind::CodeCompletion)) {
2526
+ // Ignore the hole if it is because the right-hand-side of the pattern
2527
+ // match is a code completion token. Assigning a high fix score to this
2528
+ // mismatch won't help. In fact, it can harm because we might have a
2529
+ // different exploration path in the constraint system that gives up
2530
+ // earlier (eg. because code completion is in a closure that doesn't
2531
+ // match the expected parameter of a function call) and might thus get a
2532
+ // better score, despite not having any information about the code
2533
+ // completion token at all.
2534
+ return llvm::None;
2535
+ }
2525
2536
// Not being able to infer the type of a variable in a pattern binding
2526
2537
// decl is more dramatic than anything that could happen inside the
2527
2538
// expression because we want to preferrably point the diagnostic to a
Original file line number Diff line number Diff line change
1
+ // RUN: %batch-code-completion
2
+
3
+ func run( execute workItem: Int ) { }
4
+ func run( execute work: ( ) -> Void ) { }
5
+
6
+ func test( myVar: Int ) {
7
+ run {
8
+ guard let data = #^COMPLETE^# else {
9
+ return
10
+ }
11
+ }
12
+ }
13
+
14
+ // COMPLETE: Decl[LocalVar]/Local: myVar[#Int#]; name=myVar
You can’t perform that action at this time.
0 commit comments