Skip to content

Commit 1719be1

Browse files
committed
[Sema] Don’t allow unresolved type variables if LeaveBraceStmtBodyUnchecked is true
According to Pavel, we want to eliminate allowing unresolved variables as much as possible. Removing this flag doesn’t break any test cases (at least not in a meaningful way) and fixes a crasher, so it seems reasonable to remove it. Fixes rdar://76686564
1 parent b244fa6 commit 1719be1

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,6 @@ void StmtChecker::typeCheckASTNode(ASTNode &node) {
15061506
options |= TypeCheckExprFlags::IsDiscarded;
15071507
if (LeaveBraceStmtBodyUnchecked) {
15081508
options |= TypeCheckExprFlags::LeaveClosureBodyUnchecked;
1509-
options |= TypeCheckExprFlags::AllowUnresolvedTypeVariables;
15101509
}
15111510

15121511
auto resultTy =

test/IDE/complete_call_arg.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ func curry<T1, T2, R>(_ f: @escaping (T1, T2) -> R) -> (T1) -> (T2) -> R {
439439
return { t1 in { t2 in f(#^NESTED_CLOSURE^#, t2) } }
440440
// NESTED_CLOSURE: Begin completions
441441
// FIXME: Should be '/TypeRelation[Invalid]: t2[#T2#]'
442-
// NESTED_CLOSURE: Decl[LocalVar]/Local: t2[#_#]; name=t2
442+
// NESTED_CLOSURE: Decl[LocalVar]/Local: t2; name=t2
443443
// NESTED_CLOSURE: Decl[LocalVar]/Local: t1[#T1#]; name=t1
444444
}
445445

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-swift-ide-test --conforming-methods -code-completion-token=COMPLETE --conforming-methods-expected-types=s:14swift_ide_test10MySequenceP -source-filename %s
2+
3+
protocol MySequence {
4+
associatedtype Element
5+
}
6+
7+
struct Foo<X>: MySequence {
8+
typealias Element = X
9+
}
10+
11+
struct ArgumentDefinition {
12+
fileprivate func bashCompletionWords() -> Foo<String> { fatalError() }
13+
}
14+
15+
func myFlatMap<SegmentOfResult: MySequence>(_ transform: (ArgumentDefinition) -> SegmentOfResult) -> Foo<SegmentOfResult.Element> {
16+
fatalError()
17+
}
18+
19+
func generateArgumentWords() {
20+
_ = myFlatMap { $0.#^COMPLETE^# } as Foo<String>
21+
}

0 commit comments

Comments
 (0)