Skip to content

[code-complete] Update literal protocol to show "" for Character #12293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/IDE/CodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ protocolForLiteralKind(CodeCompletionLiteralKind kind) {
case CodeCompletionLiteralKind::NilLiteral:
return KnownProtocolKind::ExpressibleByNilLiteral;
case CodeCompletionLiteralKind::StringLiteral:
return KnownProtocolKind::ExpressibleByStringLiteral;
return KnownProtocolKind::ExpressibleByUnicodeScalarLiteral;
case CodeCompletionLiteralKind::Tuple:
llvm_unreachable("no such protocol kind");
}
Expand Down
23 changes: 23 additions & 0 deletions test/IDE/complete_value_literals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=STRING_0 | %FileCheck %s -check-prefix=STRING_0
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=STRING_1 | %FileCheck %s -check-prefix=STRING_1
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=STRING_2 | %FileCheck %s -check-prefix=STRING_2
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=STRING_3 | %FileCheck %s -check-prefix=STRING_3
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=STRING_4 | %FileCheck %s -check-prefix=STRING_4
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=STRING_5 | %FileCheck %s -check-prefix=STRING_5
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=ARRAY_0 | %FileCheck %s -check-prefix=ARRAY_0
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=ARRAY_1 | %FileCheck %s -check-prefix=ARRAY_1
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=ARRAY_2 | %FileCheck %s -check-prefix=ARRAY_2
Expand Down Expand Up @@ -62,6 +65,13 @@ struct MyString1: ExpressibleByStringLiteral {
init(extendedGraphemeClusterLiteral value: String) {}
init(stringLiteral value: String) {}
}
struct MyUnicodeScalar1: ExpressibleByUnicodeScalarLiteral {
init(unicodeScalarLiteral value: Character) {}
}
struct MyCharacter1: ExpressibleByExtendedGraphemeClusterLiteral {
init(unicodeScalarLiteral value: Character) {}
init(extendedGraphemeClusterLiteral value: String) {}
}
struct MyArray1<Element>: ExpressibleByArrayLiteral {
init(arrayLiteral value: Element...) {}
}
Expand Down Expand Up @@ -154,6 +164,19 @@ func testString2() {
}
// STRING_2: Literal[String]/None/TypeRelation[Identical]: "{#(abc)#}"[#String#];

func testString3() {
let x: MyUnicodeScalar1 = #^STRING_3^#
}
// STRING_3: Literal[String]/None/TypeRelation[Identical]: "{#(abc)#}"[#MyUnicodeScalar1#];
func testString4() {
let x: MyCharacter1 = #^STRING_4^#
}
// STRING_4: Literal[String]/None/TypeRelation[Identical]: "{#(abc)#}"[#MyCharacter1#];
func testString5() {
let x: Character = #^STRING_5^#
}
// STRING_5: Literal[String]/None/TypeRelation[Identical]: "{#(abc)#}"[#Character#];

func testArray0() {
let x: Int = #^ARRAY_0^#
}
Expand Down