|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// |
| 3 | +// RUN: %target-swift-ide-test -print-indexed-symbols -source-filename %s | %FileCheck %s |
| 4 | + |
| 5 | +protocol SwiftProto { |
| 6 | +// CHECK: [[@LINE-1]]:10 | protocol/Swift | SwiftProto | [[Proto_USR:.*]] | Def | rel: 0 |
| 7 | + static func staticMethod() |
| 8 | + // CHECK: [[@LINE-1]]:15 | static-method/Swift | staticMethod() | [[ProtoStaticMethod_USR:.*]] | Def,RelChild | rel: 1 |
| 9 | +} |
| 10 | + |
| 11 | +protocol SwiftProtoSame { |
| 12 | +// CHECK: [[@LINE-1]]:10 | protocol/Swift | SwiftProtoSame | [[ProtoSame_USR:.*]] | Def | rel: 0 |
| 13 | + static func staticMethod() |
| 14 | + // CHECK: [[@LINE-1]]:15 | static-method/Swift | staticMethod() | [[ProtoSameStaticMethod_USR:.*]] | Def,RelChild | rel: 1 |
| 15 | +} |
| 16 | + |
| 17 | +protocol SwiftProtoOther {} |
| 18 | + |
| 19 | +protocol SwiftProtoComposed: SwiftProtoSame, SwiftProto, SwiftProtoOther {} |
| 20 | + |
| 21 | +class SwiftClass: SwiftProtoComposed { |
| 22 | +// CHECK: [[@LINE-1]]:7 | class/Swift | SwiftClass | [[Class_USR:.*]] | Def | rel: 0 |
| 23 | + static func staticMethod() {} |
| 24 | + // CHECK: [[@LINE-1]]:15 | static-method/Swift | staticMethod() | [[ClassStaticMethod_USR:.*]] | Def,RelChild,RelOver | rel: 3 |
| 25 | + class func classMethod() {} |
| 26 | + // CHECK: [[@LINE-1]]:14 | class-method/Swift | classMethod() | [[ClassClassMethod_USR:.*]] | Def,Dyn,RelChild | rel: 1 |
| 27 | +} |
| 28 | + |
| 29 | +struct SwiftStruct: SwiftProtoComposed { |
| 30 | +// CHECK: [[@LINE-1]]:8 | struct/Swift | SwiftStruct | [[Struct_USR:.*]] | Def | rel: 0 |
| 31 | + static func staticMethod() {} |
| 32 | + // CHECK: [[@LINE-1]]:15 | static-method/Swift | staticMethod() | [[StructStaticMethod_USR:.*]] | Def,RelChild,RelOver | rel: 3 |
| 33 | +} |
| 34 | + |
| 35 | +enum SwiftEnum: SwiftProtoComposed { |
| 36 | +// CHECK: [[@LINE-1]]:6 | enum/Swift | SwiftEnum | [[Enum_USR:.*]] | Def | rel: 0 |
| 37 | + static func staticMethod() {} |
| 38 | + // CHECK: [[@LINE-1]]:15 | static-method/Swift | staticMethod() | [[EnumStaticMethod_USR:.*]] | Def,RelChild,RelOver | rel: 3 |
| 39 | +} |
| 40 | + |
| 41 | +func directCalls() { |
| 42 | + SwiftClass.staticMethod() |
| 43 | + // CHECK: [[@LINE-1]]:14 | static-method/Swift | staticMethod() | [[ClassStaticMethod_USR]] | Ref,Call,RelRec,RelCall,RelCont | rel: 2 |
| 44 | + // CHECK-DAG: RelRec | class/Swift | SwiftClass | [[Class_USR]] |
| 45 | + SwiftClass.classMethod() |
| 46 | + // CHECK: [[@LINE-1]]:14 | class-method/Swift | classMethod() | [[ClassClassMethod_USR]] | Ref,Call,RelRec,RelCall,RelCont | rel: 2 |
| 47 | + // CHECK-DAG: RelRec | class/Swift | SwiftClass | [[Class_USR]] |
| 48 | + |
| 49 | + SwiftStruct.staticMethod() |
| 50 | + // CHECK: [[@LINE-1]]:15 | static-method/Swift | staticMethod() | [[StructStaticMethod_USR]] | Ref,Call,RelRec,RelCall,RelCont | rel: 2 |
| 51 | + // CHECK-DAG: RelRec | struct/Swift | SwiftStruct | [[Struct_USR]] |
| 52 | + |
| 53 | + SwiftEnum.staticMethod() |
| 54 | + // CHECK: [[@LINE-1]]:13 | static-method/Swift | staticMethod() | [[EnumStaticMethod_USR]] | Ref,Call,RelRec,RelCall,RelCont | rel: 2 |
| 55 | + // CHECK-DAG: RelRec | enum/Swift | SwiftEnum | [[Enum_USR]] |
| 56 | +} |
| 57 | + |
| 58 | +func typeofClass(c: SwiftClass) { |
| 59 | + type(of: c).staticMethod() |
| 60 | + // CHECK: [[@LINE-1]]:15 | static-method/Swift | staticMethod() | [[ClassStaticMethod_USR]] | Ref,Call,RelRec,RelCall,RelCont | rel: 2 |
| 61 | + // CHECK: RelRec | class/Swift | SwiftClass | [[Class_USR]] |
| 62 | + type(of: c).classMethod() |
| 63 | + // CHECK: [[@LINE-1]]:15 | class-method/Swift | classMethod() | [[ClassClassMethod_USR]] | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 2 |
| 64 | + // CHECK: RelRec | class/Swift | SwiftClass | [[Class_USR]] |
| 65 | +} |
| 66 | + |
| 67 | +func typeofStruct(s: SwiftStruct) { |
| 68 | + type(of: s).staticMethod() |
| 69 | + // CHECK: [[@LINE-1]]:15 | static-method/Swift | staticMethod() | [[StructStaticMethod_USR]] | Ref,Call,RelRec,RelCall,RelCont | rel: 2 |
| 70 | + // CHECK: RelRec | struct/Swift | SwiftStruct | [[Struct_USR]] |
| 71 | +} |
| 72 | + |
| 73 | +func typeofEnum(e: SwiftEnum) { |
| 74 | + type(of: e).staticMethod() |
| 75 | + // CHECK: [[@LINE-1]]:15 | static-method/Swift | staticMethod() | [[EnumStaticMethod_USR]] | Ref,Call,RelRec,RelCall,RelCont | rel: 2 |
| 76 | + // CHECK: RelRec | enum/Swift | SwiftEnum | [[Enum_USR]] |
| 77 | +} |
| 78 | + |
| 79 | +func typeofProtocol(proto: SwiftProto) { |
| 80 | + type(of: proto).staticMethod() |
| 81 | + // CHECK: [[@LINE-1]]:19 | static-method/Swift | staticMethod() | [[ProtoStaticMethod_USR]] | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 2 |
| 82 | + // CHECK: RelRec | protocol/Swift | SwiftProto | [[Proto_USR]] |
| 83 | +} |
| 84 | + |
| 85 | +// FIXME: Add the ReceivedBy relation for generics |
| 86 | +func genericSingle<T>(proto: T) where T: SwiftProto { |
| 87 | + type(of: proto).staticMethod() |
| 88 | + // CHECK: [[@LINE-1]]:19 | static-method/Swift | staticMethod() | [[ProtoStaticMethod_USR]] | Ref,Call,Dyn,RelCall,RelCont | rel: 1 |
| 89 | +} |
| 90 | + |
| 91 | +// FIXME: The composed cases currently picks one of the USRs, should we output |
| 92 | +// multiple occurrences? |
| 93 | +func genericComposedType<T>(proto: T) where T: SwiftProtoComposed { |
| 94 | + type(of: proto).staticMethod() |
| 95 | + // CHECK: [[@LINE-1]]:19 | static-method/Swift | staticMethod() | [[ProtoStaticMethod_USR]] | Ref,Call,Dyn,RelCall,RelCont | rel: 1 |
| 96 | +} |
| 97 | + |
| 98 | +func genericComposedWhere<T>(proto: T) where T: SwiftProto & SwiftProtoSame & SwiftProtoOther { |
| 99 | + type(of: proto).staticMethod() |
| 100 | + // CHECK: [[@LINE-1]]:19 | static-method/Swift | staticMethod() | [[ProtoSameStaticMethod_USR]] | Ref,Call,Dyn,RelCall,RelCont | rel: 1 |
| 101 | +} |
0 commit comments