Skip to content
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
5 changes: 1 addition & 4 deletions lib/IDE/CodeCompletionStringBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ using namespace swift;
using namespace swift::ide;

Type ide::eraseArchetypes(Type type, GenericSignature genericSig) {
if (!genericSig)
return type;

if (auto *genericFuncType = type->getAs<GenericFunctionType>()) {
assert(genericFuncType->getGenericSignature()->isEqual(genericSig) &&
"if not, just use the GFT's signature instead below");
Expand Down Expand Up @@ -64,7 +61,7 @@ Type ide::eraseArchetypes(Type type, GenericSignature genericSig) {
return upperBound;
}

if (t->isTypeParameter()) {
if (t->isTypeParameter() && genericSig) {
auto upperBound =
genericSig->getUpperBound(t,
/*forExistentialSelf=*/false,
Expand Down
4 changes: 2 additions & 2 deletions test/IDE/complete_after_sself.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ extension MyProto {
Self.#^SSELF_DOT_IN_STATICMETHOD_MyProto^#
}
// CHECK-MyProto: Begin completions, 5 items
// CHECK-MyProto-DAG: Keyword[self]/CurrNominal: self[#Self.Type#];
// CHECK-MyProto-DAG: Keyword/CurrNominal: Type[#Self.Type#];
// CHECK-MyProto-DAG: Keyword[self]/CurrNominal: self[#MyProto.Type#];
// CHECK-MyProto-DAG: Keyword/CurrNominal: Type[#MyProto.Type#];
// CHECK-MyProto-DAG: Decl[Constructor]/CurrNominal: init()[#MyProto#];
// CHECK-MyProto-DAG: Decl[InstanceMethod]/CurrNominal: instanceMethod({#(self): MyProto#})[#() -> Void#];
// CHECK-MyProto-DAG: Decl[StaticMethod]/CurrNominal: staticMethod()[#Void#];
Expand Down
8 changes: 6 additions & 2 deletions test/IDE/complete_keypath_member_lookup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ func testGenericUnderconstrained1<G: P>(r: G) {
r.#^testGenericUnderconstrained1^#
}
// testGenericUnderconstrained1-NOT: CurrNominal
// testGenericUnderconstrained1: Keyword[self]/CurrNominal: self[#{{any P|G}}#];
// testGenericUnderconstrained1: Keyword[self]/CurrNominal: self[#P#];
// testGenericUnderconstrained1-NOT: CurrNominal

func testExistential1(r: P) {
r.#^testExistential1?check=testGenericUnderconstrained1^#
r.#^testExistential1^#
}

// testExistential1-NOT: CurrNominal
// testExistential1: Keyword[self]/CurrNominal: self[#any P#];
// testExistential1-NOT: CurrNominal

@dynamicMemberLookup
protocol E {
subscript<U>(dynamicMember member: KeyPath<Point, U>) -> U
Expand Down
4 changes: 2 additions & 2 deletions test/IDE/complete_members_optional.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ func optionalMembers2<T : HasOptionalMembers1>(_ a: T) {
// OPTIONAL_MEMBERS_2-DAG: Decl[InstanceMethod]/CurrNominal: optionalInstanceFunc?({#(self): HasOptionalMembers1#})[#() -> Int#]{{; name=.+$}}
// OPTIONAL_MEMBERS_2-DAG: Decl[StaticMethod]/CurrNominal: optionalClassFunc?()[#Int#]{{; name=.+$}}
// OPTIONAL_MEMBERS_2-DAG: Decl[StaticVar]/CurrNominal: optionalClassProperty[#Int?#]{{; name=.+$}}
// OPTIONAL_MEMBERS_2-DAG: Keyword[self]/CurrNominal: self[#T.Type#]; name=self
// OPTIONAL_MEMBERS_2-DAG: Keyword/CurrNominal: Type[#T.Type#]; name=Type
// OPTIONAL_MEMBERS_2-DAG: Keyword[self]/CurrNominal: self[#HasOptionalMembers1.Type#]; name=self
// OPTIONAL_MEMBERS_2-DAG: Keyword/CurrNominal: Type[#HasOptionalMembers1.Type#]; name=Type
10 changes: 5 additions & 5 deletions test/IDE/complete_operators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func testPostfix9<G: P where G.T == Int>(x: G) {
func testPostfix10<G: P where G.T : Fooable>(x: G) {
x.foo()#^POSTFIX_10^#
}
// POSTFIX_10: Decl[PostfixOperatorFunction]/CurrModule: ***[#G.T#]
// POSTFIX_10: Decl[PostfixOperatorFunction]/CurrModule: ***[#Fooable#]

func testPostfixSpace(x: inout S) {
x #^S_POSTFIX_SPACE^#
Expand Down Expand Up @@ -172,7 +172,7 @@ func ****<T: Fooable>(x: T, y: T) -> T { return x }
func testInfix9<T: P where T.T: Fooable>(x: T) {
x.foo()#^INFIX_9?check=FOOABLE_INFIX^#
}
// FOOABLE_INFIX: Decl[InfixOperatorFunction]/CurrModule: **** {#T.T#}[#T.T#]
// FOOABLE_INFIX: Decl[InfixOperatorFunction]/CurrModule: **** {#T.T#}[#Fooable#]

func testInfix10<T: P where T.T: Fooable>(x: T) {
(x.foo() **** x.foo())#^INFIX_10?check=FOOABLE_INFIX^#
Expand Down Expand Up @@ -210,8 +210,8 @@ func testInfix15<T: P where T.T == S2>() {
// INFIX_15: Begin completions, 6 items
// INFIX_15-DAG: Decl[AssociatedType]/CurrNominal: .T; name=T
// INFIX_15-DAG: Decl[InstanceMethod]/CurrNominal: .foo({#(self): P#})[#() -> S2#]; name=foo(:)
// INFIX_15-DAG: Keyword[self]/CurrNominal: .self[#T.Type#]; name=self
// INFIX_15-DAG: Keyword/CurrNominal: .Type[#T.Type#]; name=Type
// INFIX_15-DAG: Keyword[self]/CurrNominal: .self[#P.Type#]; name=self
// INFIX_15-DAG: Keyword/CurrNominal: .Type[#P.Type#]; name=Type
// INFIX_15-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]/IsSystem: != {#(any (~Copyable & ~Escapable).Type)?#}[#Bool#];
// INFIX_15-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]/IsSystem: == {#(any (~Copyable & ~Escapable).Type)?#}[#Bool#];

Expand All @@ -221,7 +221,7 @@ func testInfix16<T: P where T.T == S2>() {

// INFIX_16: Begin completions, 2 items
// INFIX_16-DAG: Decl[InstanceMethod]/CurrNominal/Flair[ArgLabels]: ({#(self): P#})[#() -> S2#]; name=(:)
// INFIX_16-DAG: Keyword[self]/CurrNominal: .self[#(T) -> () -> S2#]; name=self
// INFIX_16-DAG: Keyword[self]/CurrNominal: .self[#(P) -> () -> S2#]; name=self

func testInfix17(x: Void) {
x#^INFIX_17?check=VOID_OPERATORS^#
Expand Down
2 changes: 1 addition & 1 deletion test/IDE/complete_protocol_static_member.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func test<T: FontStyle>(x: T) {
}

// EXTENSION_NOT_APPLIED: Begin completions, 1 item
// EXTENSION_NOT_APPLIED-DAG: Keyword[self]/CurrNominal: self[#T#];
// EXTENSION_NOT_APPLIED-DAG: Keyword[self]/CurrNominal: self[#FontStyle#];
// EXTENSION_NOT_APPLIED-NOT: variableDeclaredInConstraintExtension

struct WrapperStruct<T: FontStyle> {
Expand Down
2 changes: 1 addition & 1 deletion test/IDE/complete_subscript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func testSubscriptCallSig<T>(val: MyStruct1<T>) {
val[#^LABELED_SUBSCRIPT^#
// LABELED_SUBSCRIPT: Begin completions, 2 items
// LABELED_SUBSCRIPT-DAG: Decl[Subscript]/CurrNominal/Flair[ArgLabels]: ['[']{#idx1: Int#}, {#idx2: Comparable#}[']'][#Int!#];
// LABELED_SUBSCRIPT-DAG: Pattern/CurrNominal/Flair[ArgLabels]: ['[']{#keyPath: KeyPath<MyStruct1<T>, Value>#}[']'][#Value#];
// LABELED_SUBSCRIPT-DAG: Pattern/CurrNominal/Flair[ArgLabels]: ['[']{#keyPath: KeyPath<MyStruct1<Comparable>, Value>#}[']'][#Value#];
}

func testSubcscriptTuple(val: (x: Int, String)) {
Expand Down
4 changes: 2 additions & 2 deletions test/IDE/complete_type.swift
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ func testTypeIdentifierGeneric1<

// TYPE_IDENTIFIER_GENERIC_1: Begin completions, 2 items
// TYPE_IDENTIFIER_GENERIC_1-DAG: Decl[AssociatedType]/CurrNominal: FooTypeAlias1{{; name=.+$}}
// TYPE_IDENTIFIER_GENERIC_1-DAG: Keyword/None: Type[#GenericFoo.Type#]
// TYPE_IDENTIFIER_GENERIC_1-DAG: Keyword/None: Type[#FooProtocol.Type#]

func testTypeIdentifierGeneric2<
GenericFoo : FooProtocol & BarProtocol
Expand All @@ -631,7 +631,7 @@ func testTypeIdentifierGeneric2<
// TYPE_IDENTIFIER_GENERIC_2: Begin completions, 3 items
// TYPE_IDENTIFIER_GENERIC_2-DAG: Decl[AssociatedType]/CurrNominal: BarTypeAlias1{{; name=.+$}}
// TYPE_IDENTIFIER_GENERIC_2-DAG: Decl[AssociatedType]/CurrNominal: FooTypeAlias1{{; name=.+$}}
// TYPE_IDENTIFIER_GENERIC_2-DAG: Keyword/None: Type[#GenericFoo.Type#]
// TYPE_IDENTIFIER_GENERIC_2-DAG: Keyword/None: Type[#(BarProtocol & FooProtocol).Type#]

func testTypeIdentifierGeneric3<
GenericFoo>(a: GenericFoo.#^TYPE_IDENTIFIER_GENERIC_3^#
Expand Down
4 changes: 2 additions & 2 deletions test/IDE/complete_type_subscript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extension G6 {
subscript(b x: Int) -> T.#^GEN_EXT_RETURN_6^# { return 0 }
}
// GEN_PARAM_6-DAG: Decl[AssociatedType]/CurrNominal: Assoc;
// GEN_PARAM_6-DAG: Keyword/None: Type[#T.Type#];
// GEN_PARAM_6-DAG: Keyword/None: Type[#It.Type#];

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENPROTO_PARAM_1 | %FileCheck %s -check-prefix=GENPROTO_1
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENPROTO_RETURN_1 | %FileCheck %s -check-prefix=GENPROTO_1
Expand All @@ -117,4 +117,4 @@ extension GP1 {
subscript(b x: Int) -> I.#^GENPROTO_EXT_RETURN_1^# { return 1 }
}
// GENPROTO_1-DAG: Decl[AssociatedType]/CurrNominal: Assoc;
// GENPROTO_1-DAG: Keyword/None: Type[#Self.I.Type#];
// GENPROTO_1-DAG: Keyword/None: Type[#It.Type#];
20 changes: 10 additions & 10 deletions test/IDE/complete_value_expr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ class TestResolveFuncParam2 {

func testResolveFuncParam3<Foo : FooProtocol>(_ foo: Foo) {
foo.#^RESOLVE_FUNC_PARAM_3^#
// RESOLVE_FUNC_PARAM_3-DAG: Keyword[self]/CurrNominal: self[#Foo#]; name=self
// RESOLVE_FUNC_PARAM_3-DAG: Keyword[self]/CurrNominal: self[#FooProtocol#]; name=self
// RESOLVE_FUNC_PARAM_3-DAG: Decl[InstanceVar]/CurrNominal: fooInstanceVar1[#Int#]{{; name=.+$}}
// RESOLVE_FUNC_PARAM_3-DAG: Decl[InstanceVar]/CurrNominal: fooInstanceVar2[#Int#]{{; name=.+$}}
// RESOLVE_FUNC_PARAM_3-DAG: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc0()[#Double#]{{; name=.+$}}
Expand All @@ -784,7 +784,7 @@ func testResolveFuncParam3<Foo : FooProtocol>(_ foo: Foo) {

func testResolveFuncParam4<FooBar : FooProtocol & BarProtocol>(_ fooBar: FooBar) {
fooBar.#^RESOLVE_FUNC_PARAM_4^#
// RESOLVE_FUNC_PARAM_4-DAG: Keyword[self]/CurrNominal: self[#FooBar#]; name=self
// RESOLVE_FUNC_PARAM_4-DAG: Keyword[self]/CurrNominal: self[#BarProtocol & FooProtocol#]; name=self
// RESOLVE_FUNC_PARAM_4-DAG: Decl[InstanceVar]/CurrNominal: barInstanceVar[#Int#]{{; name=.+$}}
// RESOLVE_FUNC_PARAM_4-DAG: Decl[InstanceMethod]/CurrNominal: barInstanceFunc0()[#Double#]{{; name=.+$}}
// RESOLVE_FUNC_PARAM_4-DAG: Decl[InstanceMethod]/CurrNominal: barInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}}
Expand All @@ -796,7 +796,7 @@ func testResolveFuncParam4<FooBar : FooProtocol & BarProtocol>(_ fooBar: FooBar)

func testResolveFuncParam5<FooExBarEx : FooExProtocol & BarExProtocol>(_ a: FooExBarEx) {
a.#^RESOLVE_FUNC_PARAM_5^#
// RESOLVE_FUNC_PARAM_5-DAG: Keyword[self]/CurrNominal: self[#FooExBarEx#]; name=self
// RESOLVE_FUNC_PARAM_5-DAG: Keyword[self]/CurrNominal: self[#BarExProtocol & FooExProtocol#]; name=self
// RESOLVE_FUNC_PARAM_5-DAG: Decl[InstanceMethod]/CurrNominal: barExInstanceFunc0()[#Double#]{{; name=.+$}}
// RESOLVE_FUNC_PARAM_5-DAG: Decl[InstanceVar]/Super: barInstanceVar[#Int#]{{; name=.+$}}
// RESOLVE_FUNC_PARAM_5-DAG: Decl[InstanceMethod]/Super: barInstanceFunc0()[#Double#]{{; name=.+$}}
Expand All @@ -810,7 +810,7 @@ func testResolveFuncParam5<FooExBarEx : FooExProtocol & BarExProtocol>(_ a: FooE

func testResolveFuncParam6<Foo : FooProtocol where Foo : FooClass>(_ foo: Foo) {
foo.#^RESOLVE_FUNC_PARAM_6^#
// RESOLVE_FUNC_PARAM_6-DAG: Keyword[self]/CurrNominal: self[#Foo#]; name=self
// RESOLVE_FUNC_PARAM_6-DAG: Keyword[self]/CurrNominal: self[#FooClass & FooProtocol#]; name=self
// RESOLVE_FUNC_PARAM_6-DAG: Decl[InstanceVar]/CurrNominal: fooInstanceVar1[#Int#]{{; name=.+$}}
// RESOLVE_FUNC_PARAM_6-DAG: Decl[InstanceVar]/CurrNominal: fooInstanceVar2[#Int#]{{; name=.+$}}
// RESOLVE_FUNC_PARAM_6-DAG: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc0()[#Double#]{{; name=.+$}}
Expand All @@ -829,7 +829,7 @@ class TestResolveConstructorParam1 {
class TestResolveConstructorParam2 {
init<Foo : FooProtocol>(foo: Foo) {
foo.#^RESOLVE_CONSTRUCTOR_PARAM_2^#
// RESOLVE_CONSTRUCTOR_PARAM_2-DAG: Keyword[self]/CurrNominal: self[#Foo#]; name=self
// RESOLVE_CONSTRUCTOR_PARAM_2-DAG: Keyword[self]/CurrNominal: self[#FooProtocol#]; name=self
// RESOLVE_CONSTRUCTOR_PARAM_2-DAG: Decl[InstanceVar]/CurrNominal: fooInstanceVar1[#Int#]{{; name=.+$}}
// RESOLVE_CONSTRUCTOR_PARAM_2-DAG: Decl[InstanceVar]/CurrNominal: fooInstanceVar2[#Int#]{{; name=.+$}}
// RESOLVE_CONSTRUCTOR_PARAM_2-DAG: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc0()[#Double#]{{; name=.+$}}
Expand All @@ -840,7 +840,7 @@ class TestResolveConstructorParam2 {
class TestResolveConstructorParam3<Foo : FooProtocol> {
init(foo: Foo) {
foo.#^RESOLVE_CONSTRUCTOR_PARAM_3^#
// RESOLVE_CONSTRUCTOR_PARAM_3-DAG: Keyword[self]/CurrNominal: self[#Foo#]; name=self
// RESOLVE_CONSTRUCTOR_PARAM_3-DAG: Keyword[self]/CurrNominal: self[#FooProtocol#]; name=self
// RESOLVE_CONSTRUCTOR_PARAM_3-DAG: Decl[InstanceVar]/CurrNominal: fooInstanceVar1[#Int#]{{; name=.+$}}
// RESOLVE_CONSTRUCTOR_PARAM_3-DAG: Decl[InstanceVar]/CurrNominal: fooInstanceVar2[#Int#]{{; name=.+$}}
// RESOLVE_CONSTRUCTOR_PARAM_3-DAG: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc0()[#Double#]{{; name=.+$}}
Expand Down Expand Up @@ -953,7 +953,7 @@ func testResolveGenericParams2<Foo : FooProtocol>(_ foo: Foo) {
// RESOLVE_GENERIC_PARAMS_2-DAG: Decl[InstanceMethod]/CurrNominal: .fooVoidInstanceFunc1({#(a): FooProtocol#})[#Void#]{{; name=.+$}}
// RESOLVE_GENERIC_PARAMS_2-DAG: Decl[InstanceMethod]/CurrNominal: .fooTInstanceFunc1({#(a): FooProtocol#})[#FooProtocol#]{{; name=.+$}}
// RESOLVE_GENERIC_PARAMS_2-DAG: Decl[InstanceMethod]/CurrNominal: .fooUInstanceFunc1({#(a): U#})[#U#]{{; name=.+$}}
// RESOLVE_GENERIC_PARAMS_2-DAG: Keyword[self]/CurrNominal: .self[#FooGenericStruct<Foo>#]; name=self
// RESOLVE_GENERIC_PARAMS_2-DAG: Keyword[self]/CurrNominal: .self[#FooGenericStruct<FooProtocol>#]; name=self

FooGenericStruct<Foo>#^RESOLVE_GENERIC_PARAMS_2_STATIC^#
// RESOLVE_GENERIC_PARAMS_2_STATIC-DAG: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ()[#FooGenericStruct<FooProtocol>#]; name=()
Expand All @@ -966,8 +966,8 @@ func testResolveGenericParams2<Foo : FooProtocol>(_ foo: Foo) {
// RESOLVE_GENERIC_PARAMS_2_STATIC-DAG: Decl[StaticMethod]/CurrNominal: .fooVoidStaticFunc1({#(a): FooProtocol#})[#Void#]{{; name=.+$}}
// RESOLVE_GENERIC_PARAMS_2_STATIC-DAG: Decl[StaticMethod]/CurrNominal: .fooTStaticFunc1({#(a): FooProtocol#})[#FooProtocol#]{{; name=.+$}}
// RESOLVE_GENERIC_PARAMS_2_STATIC-DAG: Decl[StaticMethod]/CurrNominal: .fooUInstanceFunc1({#(a): U#})[#U#]{{; name=.+$}}
// RESOLVE_GENERIC_PARAMS_2_STATIC-DAG: Keyword[self]/CurrNominal: .self[#FooGenericStruct<Foo>.Type#]; name=self
// RESOLVE_GENERIC_PARAMS_2_STATIC-DAG: Keyword/CurrNominal: .Type[#FooGenericStruct<Foo>.Type#]; name=Type
// RESOLVE_GENERIC_PARAMS_2_STATIC-DAG: Keyword[self]/CurrNominal: .self[#FooGenericStruct<FooProtocol>.Type#]; name=self
// RESOLVE_GENERIC_PARAMS_2_STATIC-DAG: Keyword/CurrNominal: .Type[#FooGenericStruct<FooProtocol>.Type#]; name=Type

}

Expand Down Expand Up @@ -1571,7 +1571,7 @@ func testDeDuped3<T : dedupP where T.T == Int>(_ x: T) {
// PROTOCOL_EXT_DEDUP_3-DAG: Decl[InstanceMethod]/CurrNominal: .foo()[#Int#]; name=foo()
// PROTOCOL_EXT_DEDUP_3-DAG: Decl[InstanceVar]/CurrNominal: .bar[#Int#]; name=bar
// PROTOCOL_EXT_DEDUP_3-DAG: Decl[Subscript]/CurrNominal: [{#(x): Int#}][#Int#]; name=[:]
// PROTOCOL_EXT_DEDUP_3-DAG: Keyword[self]/CurrNominal: .self[#T#]; name=self
// PROTOCOL_EXT_DEDUP_3-DAG: Keyword[self]/CurrNominal: .self[#dedupP#]; name=self
}

//===--- Check calls that may throw
Expand Down
Loading