Skip to content

Commit 0361fa2

Browse files
committed
[SourceKit] Update expression type request tests with qualified types
1 parent f60039b commit 0361fa2

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

test/IDE/expr_type.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// RUN: %target-swift-ide-test -print-expr-type -source-filename %S/Inputs/ExprType.swift -swift-version 5 | %FileCheck %s -check-prefix=CHECK-SUGAR
22
// RUN: %target-swift-ide-test -print-expr-type -source-filename %S/Inputs/ExprType.swift -swift-version 5 -canonicalize-type | %FileCheck %s -check-prefix=CHECK-CANON
33

4-
// CHECK-SUGAR: func foo() -> Int { return <expr type:"Int">1</expr> }
5-
// CHECK-SUGAR: func bar(f: Float) -> Float { return <expr type:"Float"><expr type:"(Float) -> Float">bar</expr>(f: <expr type:"Float">1</expr>)</expr> }
6-
// CHECK-SUGAR: func fooP(_ p: P) { <expr type:"()"><expr type:"(P) -> ()">fooP</expr>(<expr type:"P">p</expr>)</expr> }
7-
// CHECK-SUGAR: <expr type:"()"><expr type:"Int">_</expr> = <expr type:"Int"><expr type:"[C]">a</expr>.count</expr></expr>
8-
// CHECK-SUGAR: <expr type:"()"><expr type:"String">_</expr> = <expr type:"String"><expr type:"Int"><expr type:"(Int) -> Int"><expr type:"Int"><expr type:"String"><expr type:"[C]">a</expr>.description</expr>.count</expr>.<expr type:"(Int) -> (Int) -> Int">advanced</expr></expr>(by: <expr type:"Int">1</expr>)</expr>.description</expr></expr>
9-
// CHECK-SUGAR: <expr type:"()"><expr type:"Int?">_</expr> = <expr type:"Int?"><expr type:"Int"><expr type:"(Int) -> Int"><expr type:"Int"><expr type:"S"><expr type:"S?"><expr type:"[Int : S]">a</expr>[<expr type:"Int">2</expr>]</expr>?</expr>.val</expr>.<expr type:"(Int) -> (Int) -> Int">advanced</expr></expr>(by: <expr type:"Int">1</expr>)</expr>.byteSwapped</expr></expr>
4+
// CHECK-SUGAR: func foo() -> Int { return <expr type:"Int", qualified:"Swift.Int">1</expr> }
5+
// CHECK-SUGAR: func bar(f: Float) -> Float { return <expr type:"Float", qualified:"Swift.Float"><expr type:"(Float) -> Float", qualified:"(Swift.Float) -> Swift.Float">bar</expr>(f: <expr type:"Float", qualified:"Swift.Float">1</expr>)</expr> }
6+
// CHECK-SUGAR: func fooP(_ p: P) { <expr type:"()", qualified:"()"><expr type:"(P) -> ()", qualified:"(swift_ide_test.P) -> ()">fooP</expr>(<expr type:"P", qualified:"swift_ide_test.P">p</expr>)</expr> }
7+
// CHECK-SUGAR: <expr type:"()", qualified:"()"><expr type:"Int", qualified:"Swift.Int">_</expr> = <expr type:"Int", qualified:"Swift.Int"><expr type:"[C]", qualified:"[swift_ide_test.C]">a</expr>.count</expr></expr>
8+
// CHECK-SUGAR: <expr type:"()", qualified:"()"><expr type:"String", qualified:"Swift.String">_</expr> = <expr type:"String", qualified:"Swift.String"><expr type:"Int", qualified:"Swift.Int"><expr type:"(Int) -> Int", qualified:"(Swift.Int) -> Swift.Int"><expr type:"Int", qualified:"Swift.Int"><expr type:"String", qualified:"Swift.String"><expr type:"[C]", qualified:"[swift_ide_test.C]">a</expr>.description</expr>.count</expr>.<expr type:"(Int) -> (Int) -> Int", qualified:"(Swift.Int) -> (Swift.Int) -> Swift.Int">advanced</expr></expr>(by: <expr type:"Int", qualified:"Swift.Int">1</expr>)</expr>.description</expr></expr>
9+
// CHECK-SUGAR: <expr type:"()", qualified:"()"><expr type:"Int?", qualified:"Swift.Int?">_</expr> = <expr type:"Int?", qualified:"Swift.Int?"><expr type:"Int", qualified:"Swift.Int"><expr type:"(Int) -> Int", qualified:"(Swift.Int) -> Swift.Int"><expr type:"Int", qualified:"Swift.Int"><expr type:"S", qualified:"swift_ide_test.S"><expr type:"S?", qualified:"swift_ide_test.S?"><expr type:"[Int : S]", qualified:"[Swift.Int : swift_ide_test.S]">a</expr>[<expr type:"Int", qualified:"Swift.Int">2</expr>]</expr>?</expr>.val</expr>.<expr type:"(Int) -> (Int) -> Int", qualified:"(Swift.Int) -> (Swift.Int) -> Swift.Int">advanced</expr></expr>(by: <expr type:"Int", qualified:"Swift.Int">1</expr>)</expr>.byteSwapped</expr></expr>
1010

1111

12-
// CHECK-SUGAR: return <expr type:"MyInt"><expr type:"MyInt">a</expr> <expr type:"(Int, Int) -> Int">+</expr> <expr type:"MyInt">b</expr></expr>
13-
// CHECK-CANON: return <expr type:"Int"><expr type:"Int">a</expr> <expr type:"(Int, Int) -> Int">+</expr> <expr type:"Int">b</expr></expr>
12+
// CHECK-SUGAR: return <expr type:"MyInt", qualified:"swift_ide_test.MyInt"><expr type:"MyInt", qualified:"swift_ide_test.MyInt">a</expr> <expr type:"(Int, Int) -> Int", qualified:"(Swift.Int, Swift.Int) -> Swift.Int">+</expr> <expr type:"MyInt", qualified:"swift_ide_test.MyInt">b</expr></expr>
13+
// CHECK-CANON: return <expr type:"Int", qualified:"Swift.Int"><expr type:"Int", qualified:"Swift.Int">a</expr> <expr type:"(Int, Int) -> Int", qualified:"(Swift.Int, Swift.Int) -> Swift.Int">+</expr> <expr type:"Int", qualified:"Swift.Int">b</expr></expr>

test/IDE/expr_type_filtered.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
// EMPTY: }
1313

1414
// PROTO: class Clas: Prot {
15-
// PROTO: var value: Clas { return <expr type:"Clas">self</expr> }
16-
// PROTO: func getValue() -> Clas { return <expr type:"Clas">self</expr> }
15+
// PROTO: var value: Clas { return <expr type:"Clas", qualified:"filtered.Clas">self</expr> }
16+
// PROTO: func getValue() -> Clas { return <expr type:"Clas", qualified:"filtered.Clas">self</expr> }
1717
// PROTO: }
1818
// PROTO: struct Stru: Prot, Prot1 {
19-
// PROTO: var value: Stru { return <expr type:"Stru">self</expr> }
20-
// PROTO: func getValue() -> Stru { return <expr type:"Stru">self</expr> }
19+
// PROTO: var value: Stru { return <expr type:"Stru", qualified:"filtered.Stru">self</expr> }
20+
// PROTO: func getValue() -> Stru { return <expr type:"Stru", qualified:"filtered.Stru">self</expr> }
2121
// PROTO: }
2222

2323
// PROTO1: class Clas: Prot {
2424
// PROTO1: var value: Clas { return self }
2525
// PROTO1: func getValue() -> Clas { return self }
2626
// PROTO1: }
2727
// PROTO1: struct Stru: Prot, Prot1 {
28-
// PROTO1: var value: Stru { return <expr type:"Stru">self</expr> }
29-
// PROTO1: func getValue() -> Stru { return <expr type:"Stru">self</expr> }
28+
// PROTO1: var value: Stru { return <expr type:"Stru", qualified:"filtered.Stru">self</expr> }
29+
// PROTO1: func getValue() -> Stru { return <expr type:"Stru", qualified:"filtered.Stru">self</expr> }
3030
// PROTO1: }

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,9 +2598,14 @@ static int doPrintExpressionTypes(const CompilerInvocation &InitInvok,
25982598
// Collect all tags of expressions.
25992599
for (auto R: collectExpressionType(*CI.getPrimarySourceFile(), Usrs, Scratch,
26002600
options::CanonicalizeType, OS)) {
2601-
SortedTags.push_back({R.offset,
2602-
(llvm::Twine("<expr type:\"") + TypeBuffer.str().substr(R.typeOffset,
2603-
R.typeLength) + "\">").str()});
2601+
SortedTags.push_back(
2602+
{R.offset, (llvm::Twine("<expr type:\"") +
2603+
TypeBuffer.str().substr(R.typeOffset, R.typeLength) +
2604+
llvm::Twine("\", qualified:\"") +
2605+
TypeBuffer.str().substr(R.qualifiedTypeOffset,
2606+
R.qualifiedTypeLength) +
2607+
"\">")
2608+
.str()});
26042609
SortedTags.push_back({R.offset + R.length, "</expr>"});
26052610
}
26062611
// Sort tags by offset.

0 commit comments

Comments
 (0)