Skip to content

Commit c00428a

Browse files
committed
[IDE] New test cases that were failing at some point during solver-based migration
1 parent f2017b8 commit c00428a

5 files changed

+65
-0
lines changed

lib/AST/ASTNode.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ SourceRange ASTNode::getSourceRange() const {
4141
if (const auto *I = this->dyn_cast<CaseLabelItem *>()) {
4242
return I->getSourceRange();
4343
}
44+
assert(!isNull() && "Null ASTNode doesn't have a source range");
4445
llvm_unreachable("unsupported AST node");
4546
}
4647

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t -enable-experimental-concurrency
3+
4+
func makeURL(withExtension ext: Int?) -> Int? {
5+
return nil
6+
}
7+
8+
func test() {
9+
let calculatorContext: Int? = {
10+
guard let url#^COMPLETE^# = makeURL(withExtension: 1),
11+
let script = url else {
12+
return nil
13+
}
14+
}()
15+
// COMPLETE-NOT: Begin completions
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
3+
4+
func buildView<T>(@MyViewBuilder _ x: () -> T) {}
5+
6+
@resultBuilder struct MyViewBuilder {
7+
static func buildBlock(_ content: MyText) -> MyText { content }
8+
}
9+
10+
struct MyText : Equatable {
11+
init(verbatim content: String) {}
12+
init<S>(_ content: S) where S : StringProtocol {}
13+
}
14+
15+
func test(text: String) {
16+
buildView {
17+
MyText(#^COMPLETE^#text)
18+
}
19+
}
20+
21+
// COMPLETE: Begin completions
22+
// COMPLETE-DAG: Decl[Constructor]/CurrNominal/Flair[ArgLabels]/TypeRelation[Convertible]: ['(']{#verbatim: String#}[')'][#MyText#];
23+
// COMPLETE-DAG: Decl[Constructor]/CurrNominal/Flair[ArgLabels]/TypeRelation[Convertible]: ['(']{#(content): StringProtocol#}[')'][#MyText#];
24+
// COMPLETE-DAG: Decl[LocalVar]/Local/TypeRelation[Convertible]: text[#String#];
25+
// COMPLETE: End completions

test/IDE/complete_in_closures.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,3 +551,15 @@ func testCompleteAfterClosureWithIfExprThatContainErrors() {
551551
// AFTER_CLOSURE_WITH_IF_EXPR_THAT_CONTAIN_ERRORS-DAG: Pattern/CurrModule/Flair[ArgLabels]: ()[#Void#]; name=()
552552
// AFTER_CLOSURE_WITH_IF_EXPR_THAT_CONTAIN_ERRORS: End completions
553553
}
554+
555+
func testVariableInClosureHasArchetype<K>(_ key: K) {
556+
func takeClosure(_ x: () -> Void) {}
557+
558+
takeClosure {
559+
var varWithArchetype = key
560+
#^VAR_WITH_ARCHETYPE^#
561+
// VAR_WITH_ARCHETYPE: Begin completions
562+
// VAR_WITH_ARCHETYPE: Decl[LocalVar]/Local: varWithArchetype[#K#];
563+
// VAR_WITH_ARCHETYPE: End completions
564+
}
565+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Check that we don't crash
2+
// RUN: %target-swift-ide-test -conforming-methods -source-filename %s -code-completion-token=TOK
3+
4+
func takeClosure(_ x: () -> Void) {}
5+
6+
func test(name: String?) {
7+
takeClosure {
8+
guard let url#^TOK^# = name else {
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)