Files
swift-mirror/test/SourceKit/CodeComplete/complete_group_overloads.swift
Ted Kremenek b8bbed8c13 [WIP] Implement SE-0039 (Modernizing Playground Literals) (#2215)
* Implement the majority of parsing support for SE-0039.

* Parse old object literals names using new syntax and provide FixIt.

For example, parse "#Image(imageLiteral:...)" and provide a FixIt to
change it to "#imageLiteral(resourceName:...)".  Now we see something like:

test.swift:4:9: error: '#Image' has been renamed to '#imageLiteral
var y = #Image(imageLiteral: "image.jpg")
        ^~~~~~ ~~~~~~~~~~~~
        #imageLiteral resourceName

Handling the old syntax, and providing a FixIt for that, will be handled in a separate
commit.

Needs tests.  Will be provided in later commit once full parsing support is done.

* Add back pieces of syntax map for object literals.

* Add parsing support for old object literal syntax.

... and provide fixits to new syntax.

Full tests to come in later commit.

* Improve parsing of invalid object literals with old syntax.

* Do not include bracket in code completion results.

* Remove defunct code in SyntaxModel.

* Add tests for migration fixits.

* Add literals to code completion overload tests.

@akyrtzi told me this should be fine.

* Clean up response tests not to include full paths.

* Further adjust offsets.

* Mark initializer for _ColorLiteralConvertible in UIKit as @nonobjc.

* Put attribute in the correct place.
2016-04-25 07:19:26 -07:00

113 lines
2.8 KiB
Swift

struct A {}
struct B {}
func aaa() {}
func aaa(_ x: A) {}
func aaa(_ x: B) {}
func aaa(_ x: B, y: B) {}
func aaa(x x: B, y: B) {}
func aab() {}
func test001() {
#^TOP_LEVEL_0,aa^#
}
// RUN: %complete-test -group=overloads -tok=TOP_LEVEL_0 %s | FileCheck -check-prefix=TOP_LEVEL_0 %s
// TOP_LEVEL_0-LABEL: aaa:
// TOP_LEVEL_0-NEXT: aaa()
// TOP_LEVEL_0-NEXT: aaa(x: A)
// TOP_LEVEL_0-NEXT: aaa(x: B)
// TOP_LEVEL_0-NEXT: aaa(x: B, y: B)
// TOP_LEVEL_0-NEXT: aaa(x: B, y: B)
// TOP_LEVEL_0-NEXT: #colorLiteral(red: Float, green: Float, blue: Float, alpha: Float)
// TOP_LEVEL_0-NEXT: #imageLiteral(resourceName: String)
// TOP_LEVEL_0-NEXT: aab()
struct Foo {
func aaa() {}
func aaa(_ x: A) {}
func aaa(_ x: B) {}
func aaa(_ x: B, y: B) {}
func aaa(x x: B, y: B) {}
func aab() {}
}
func test002() {
Foo().#^FOO_INSTANCE_0^#
}
// RUN: %complete-test -group=overloads -tok=FOO_INSTANCE_0 %s | FileCheck -check-prefix=FOO_INSTANCE_0 %s
// FOO_INSTANCE_0-LABEL: aaa:
// FOO_INSTANCE_0-NEXT: aaa()
// FOO_INSTANCE_0-NEXT: aaa(x: A)
// FOO_INSTANCE_0-NEXT: aaa(x: B)
// FOO_INSTANCE_0-NEXT: aaa(x: B, y: B)
// FOO_INSTANCE_0-NEXT: aaa(x: B, y: B)
// FOO_INSTANCE_0-NEXT: aab()
extension Foo {
static func bbb() {}
static func bbb(_ x: A) {}
static func bbc() {}
}
func test003() {
Foo.#^FOO_QUAL_0^#
}
// RUN: %complete-test -group=overloads -tok=FOO_QUAL_0 %s | FileCheck -check-prefix=FOO_QUAL_0 %s
// FOO_QUAL_0-LABEL: bbb:
// FOO_QUAL_0-NEXT: bbb()
// FOO_QUAL_0-NEXT: bbb(x: A)
// FOO_QUAL_0-NEXT: bbc()
extension Foo {
subscript(x: A) -> A { return A() }
subscript(x: B) -> B { return B() }
}
func test004() {
Foo()#^FOO_SUBSCRIPT_0^#
}
// RUN: %complete-test -group=overloads -tok=FOO_SUBSCRIPT_0 %s | FileCheck -check-prefix=FOO_SUBSCRIPT_0 %s
// FOO_SUBSCRIPT_0-LABEL: [:
// FOO_SUBSCRIPT_0-NEXT: [A]
// FOO_SUBSCRIPT_0-NEXT: [B]
struct Bar {
init() {}
init(x: A) {}
init(x: B) {}
}
func test005() {
Bar#^BAR_INIT_0^#
}
// Inline a lonely group
// RUN: %complete-test -group=overloads -add-inner-results -no-inner-operators -tok=BAR_INIT_0 %s | FileCheck -check-prefix=BAR_INIT_0 %s
// BAR_INIT_0-NOT: (:
// BAR_INIT_0: ()
// BAR_INIT_0-NEXT: (x: A)
// BAR_INIT_0-NEXT: (x: B)
extension Bar {
func foo()
}
func test006() {
Bar#^BAR_INIT_1^#
}
// RUN: %complete-test -group=overloads -add-inner-results -no-inner-operators -tok=BAR_INIT_1 %s | FileCheck -check-prefix=BAR_INIT_1 %s
// BAR_INIT_1-LABEL: (:
// BAR_INIT_1-NEXT: ()
// BAR_INIT_1-NEXT: (x: A)
// BAR_INIT_1-NEXT: (x: B)
// BAR_INIT_1-NEXT: foo(self: Bar)
func test007() {
#^BAR_INIT_2^#
// RUN: %complete-test -add-inits-to-top-level -group=overloads -tok=BAR_INIT_2 %s | FileCheck -check-prefix=BAR_INIT_2 %s
// BAR_INIT_2-LABEL: Bar:
// BAR_INIT_2-NEXT: Bar
// BAR_INIT_2-NEXT: Bar()
// BAR_INIT_2-NEXT: Bar(x: A)
// BAR_INIT_2-NEXT: Bar(x: B)