|
| 1 | +// RUN: %target-swift-ide-test -print-indexed-symbols -source-filename %s | %FileCheck %s |
| 2 | + |
| 3 | +// CHECK: [[@LINE+1]]:10 | protocol/Swift | P1 | s:14swift_ide_test2P1P | Def | |
| 4 | +protocol P1 { |
| 5 | + // CHECK: [[@LINE+1]]:18 | type-alias/associated-type/Swift | Assoc | s:14swift_ide_test2P1P5AssocQa | Def,RelChild | |
| 6 | + associatedtype Assoc |
| 7 | +} |
| 8 | + |
| 9 | +// CHECK: [[@LINE+1]]:10 | protocol/Swift | P2 | s:14swift_ide_test2P2P | Def | |
| 10 | +protocol P2 {} |
| 11 | + |
| 12 | +// MARK: - Test extening a simple generic type |
| 13 | + |
| 14 | +// CHECK: [[@LINE+4]]:7 | class/Swift | Foo | s:14swift_ide_test3FooC | Def | |
| 15 | +// CHECK: [[@LINE+3]]:11 | type-alias/generic-type-param/Swift | OtherParam | s:14swift_ide_test3FooC10OtherParamxmfp | Def,RelChild | |
| 16 | +// CHECK: [[@LINE+2]]:23 | type-alias/generic-type-param/Swift | Bar | s:14swift_ide_test3FooC3Barq_mfp | Def,RelChild | |
| 17 | +// CHECK: [[@LINE+1]]:28 | protocol/Swift | P1 | s:14swift_ide_test2P1P | Ref | |
| 18 | +class Foo<OtherParam, Bar: P1> {} |
| 19 | + |
| 20 | +// CHECK: [[@LINE+4]]:11 | extension/ext-class/Swift | Foo | s:e:s:14swift_ide_test3FooCA2A2P2R_rlE3foo1xyq__tF | Def | |
| 21 | +// CHECK: [[@LINE+3]]:11 | class/Swift | Foo | s:14swift_ide_test3FooC | Ref,RelExt | |
| 22 | +// CHECK: [[@LINE+2]]:21 | type-alias/generic-type-param/Swift | Bar | s:14swift_ide_test3FooC3Barq_mfp | Ref | |
| 23 | +// CHECK: [[@LINE+1]]:26 | protocol/Swift | P2 | s:14swift_ide_test2P2P | Ref | |
| 24 | +extension Foo where Bar: P2 { |
| 25 | +// CHECK: [[@LINE+1]]:15 | type-alias/generic-type-param/Swift | Bar | s:14swift_ide_test3FooC3Barq_mfp | Ref,RelCont | |
| 26 | + func foo(x: Bar) {} |
| 27 | + |
| 28 | +// CHECK: [[@LINE+2]]:15 | type-alias/generic-type-param/Swift | Bar | s:14swift_ide_test3FooC3Barq_mfp | Ref,RelCont | |
| 29 | +// CHECK: [[@LINE+1]]:19 | type-alias/associated-type/Swift | Assoc | s:14swift_ide_test2P1P5AssocQa | Ref,RelCont | |
| 30 | + func bar(x: Bar.Assoc) {} |
| 31 | +} |
| 32 | + |
| 33 | +// MARK: - Test extending a generic type in a generic context |
| 34 | + |
| 35 | +// CHECK: [[@LINE+1]]:15 | type-alias/generic-type-param/Swift | WrapperParam | s:14swift_ide_test7WrapperC0D5Paramxmfp | Def,RelChild | |
| 36 | +class Wrapper<WrapperParam> { |
| 37 | +// CHECK: [[@LINE+2]]:9 | class/Swift | Wrapped | s:14swift_ide_test7WrapperC7WrappedC | Def,RelChild | |
| 38 | +// CHECK: [[@LINE+1]]:29 | type-alias/generic-type-param/Swift | Bar | s:14swift_ide_test7WrapperC7WrappedC3Barqd_0_mfp | Def,RelChild | |
| 39 | + class Wrapped<OtherParam, Bar: P1> {} |
| 40 | +} |
| 41 | + |
| 42 | +// MARK: Extension restricted on param of inner type |
| 43 | + |
| 44 | +// CHECK: [[@LINE+1]]:33 | type-alias/generic-type-param/Swift | Bar | s:14swift_ide_test7WrapperC7WrappedC3Barqd_0_mfp | Ref | |
| 45 | +extension Wrapper.Wrapped where Bar: P2 { |
| 46 | +// CHECK: [[@LINE+1]]:15 | type-alias/generic-type-param/Swift | Bar | s:14swift_ide_test7WrapperC7WrappedC3Barqd_0_mfp | Ref,RelCont | |
| 47 | + func foo(x: Bar) {} |
| 48 | + |
| 49 | +// CHECK: [[@LINE+2]]:15 | type-alias/generic-type-param/Swift | Bar | s:14swift_ide_test7WrapperC7WrappedC3Barqd_0_mfp | Ref,RelCont | |
| 50 | +// CHECK: [[@LINE+1]]:19 | type-alias/associated-type/Swift | Assoc | s:14swift_ide_test2P1P5AssocQa | Ref,RelCont | |
| 51 | + func bar(x: Bar.Assoc) {} |
| 52 | +} |
| 53 | + |
| 54 | +// MARK: Extension restricted on generic param of outer type |
| 55 | + |
| 56 | +// CHECK: [[@LINE+1]]:33 | type-alias/generic-type-param/Swift | WrapperParam | s:14swift_ide_test7WrapperC0D5Paramxmfp | Ref | |
| 57 | +extension Wrapper.Wrapped where WrapperParam: P2 { |
| 58 | +// CHECK: [[@LINE+1]]:15 | type-alias/generic-type-param/Swift | Bar | s:14swift_ide_test7WrapperC7WrappedC3Barqd_0_mfp | Ref,RelCont | |
| 59 | + func foo(x: Bar) {} |
| 60 | + |
| 61 | +// CHECK: [[@LINE+2]]:15 | type-alias/generic-type-param/Swift | Bar | s:14swift_ide_test7WrapperC7WrappedC3Barqd_0_mfp | Ref,RelCont | |
| 62 | +// CHECK: [[@LINE+1]]:19 | type-alias/associated-type/Swift | Assoc | s:14swift_ide_test2P1P5AssocQa | Ref,RelCont | |
| 63 | + func bar(x: Bar.Assoc) {} |
| 64 | +} |
| 65 | + |
| 66 | +// MARK: - Test extening a non-generic type in a generic context |
| 67 | + |
| 68 | +// CHECK: [[@LINE+1]]:16 | type-alias/generic-type-param/Swift | Wrapper2Param | s:14swift_ide_test8Wrapper2C0D5Paramxmfp | Def,RelChild | |
| 69 | +class Wrapper2<Wrapper2Param> { |
| 70 | + class NonGenericWrapped {} |
| 71 | +} |
| 72 | + |
| 73 | +// CHECK: [[@LINE+1]]:44 | type-alias/generic-type-param/Swift | Wrapper2Param | s:14swift_ide_test8Wrapper2C0D5Paramxmfp | Ref | |
| 74 | +extension Wrapper2.NonGenericWrapped where Wrapper2Param: P1 { |
| 75 | +// CHECK: [[@LINE+1]]:15 | type-alias/generic-type-param/Swift | Wrapper2Param | s:14swift_ide_test8Wrapper2C0D5Paramxmfp | Ref,RelCont | |
| 76 | + func foo(x: Wrapper2Param) {} |
| 77 | + |
| 78 | +// CHECK: [[@LINE+2]]:15 | type-alias/generic-type-param/Swift | Wrapper2Param | s:14swift_ide_test8Wrapper2C0D5Paramxmfp | Ref,RelCont | |
| 79 | +// CHECK: [[@LINE+1]]:29 | type-alias/associated-type/Swift | Assoc | s:14swift_ide_test2P1P5AssocQa | Ref,RelCont | |
| 80 | + func bar(x: Wrapper2Param.Assoc) {} |
| 81 | +} |
| 82 | + |
| 83 | +// MARK: - Test extending an unkown type |
| 84 | + |
| 85 | +// Check that we don't crash. We don't expect the generic params to show up in the index. |
| 86 | +extension MyUnknownType where Wrapper2Param: P1 { |
| 87 | + func foo(x: Wrapper2Param) {} |
| 88 | +} |
0 commit comments