|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: echo "[MyProto]" > %t/protocols.json |
| 3 | + |
| 4 | +// RUN: %target-swift-frontend -typecheck -emit-const-values-path %t/ExtractInterpolatedStringLiterals.swiftconstvalues -const-gather-protocols-file %t/protocols.json -primary-file %s |
| 5 | +// RUN: cat %t/ExtractInterpolatedStringLiterals.swiftconstvalues 2>&1 | %FileCheck %s |
| 6 | + |
| 7 | +protocol MyProto {} |
| 8 | + |
| 9 | +func generateString(input: String) -> String { |
| 10 | + return "function" + input |
| 11 | +} |
| 12 | + |
| 13 | +public struct Internal: MyProto { |
| 14 | + static var internalTitle: String = "Inner title" |
| 15 | +} |
| 16 | + |
| 17 | +public struct MyType { |
| 18 | + var nested: NestedOne |
| 19 | + |
| 20 | + struct NestedOne { |
| 21 | + var foo: String |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +public struct External: MyProto { |
| 26 | + var interpolatedTitle = "Start Interpolation with Member Reference: \(Internal.internalTitle). Followed By Function Call: \(generateString(input: "test")). End with KeyPath: \(\MyType.nested.foo)." |
| 27 | +} |
| 28 | + |
| 29 | +// CHECK: [ |
| 30 | +// CHECK-NEXT: { |
| 31 | +// CHECK-NEXT: "typeName": "ExtractInterpolatedStringLiterals.Internal", |
| 32 | +// CHECK-NEXT: "mangledTypeName": "33ExtractInterpolatedStringLiterals8InternalV", |
| 33 | +// CHECK-NEXT: "kind": "struct", |
| 34 | +// CHECK-NEXT: "file": "{{.*}}test{{/|\\\\}}ConstExtraction{{/|\\\\}}ExtractInterpolatedStringLiterals.swift", |
| 35 | +// CHECK-NEXT: "line": 13, |
| 36 | +// CHECK-NEXT: "conformances": [ |
| 37 | +// CHECK-NEXT: "ExtractInterpolatedStringLiterals.MyProto" |
| 38 | +// CHECK-NEXT: ], |
| 39 | +// CHECK-NEXT: "associatedTypeAliases": [], |
| 40 | +// CHECK-NEXT: "properties": [ |
| 41 | +// CHECK-NEXT: { |
| 42 | +// CHECK-NEXT: "label": "internalTitle", |
| 43 | +// CHECK-NEXT: "type": "Swift.String", |
| 44 | +// CHECK-NEXT: "mangledTypeName": "n/a - deprecated", |
| 45 | +// CHECK-NEXT: "isStatic": "true", |
| 46 | +// CHECK-NEXT: "isComputed": "false", |
| 47 | +// CHECK-NEXT: "file": "{{.*}}test{{/|\\\\}}ConstExtraction{{/|\\\\}}ExtractInterpolatedStringLiterals.swift", |
| 48 | +// CHECK-NEXT: "line": 14, |
| 49 | +// CHECK-NEXT: "valueKind": "RawLiteral", |
| 50 | +// CHECK-NEXT: "value": "Inner title" |
| 51 | +// CHECK-NEXT: } |
| 52 | +// CHECK-NEXT: ] |
| 53 | +// CHECK-NEXT: }, |
| 54 | +// CHECK-NEXT: { |
| 55 | +// CHECK-NEXT: "typeName": "ExtractInterpolatedStringLiterals.External", |
| 56 | +// CHECK-NEXT: "mangledTypeName": "33ExtractInterpolatedStringLiterals8ExternalV", |
| 57 | +// CHECK-NEXT: "kind": "struct", |
| 58 | +// CHECK-NEXT: "file": "{{.*}}test{{/|\\\\}}ConstExtraction{{/|\\\\}}ExtractInterpolatedStringLiterals.swift", |
| 59 | +// CHECK-NEXT: "line": 25, |
| 60 | +// CHECK-NEXT: "conformances": [ |
| 61 | +// CHECK-NEXT: "ExtractInterpolatedStringLiterals.MyProto" |
| 62 | +// CHECK-NEXT: ], |
| 63 | +// CHECK-NEXT: "associatedTypeAliases": [], |
| 64 | +// CHECK-NEXT: "properties": [ |
| 65 | +// CHECK-NEXT: { |
| 66 | +// CHECK-NEXT: "label": "interpolatedTitle", |
| 67 | +// CHECK-NEXT: "type": "Swift.String", |
| 68 | +// CHECK-NEXT: "mangledTypeName": "n/a - deprecated", |
| 69 | +// CHECK-NEXT: "isStatic": "false", |
| 70 | +// CHECK-NEXT: "isComputed": "false", |
| 71 | +// CHECK-NEXT: "file": "{{.*}}test{{/|\\\\}}ConstExtraction{{/|\\\\}}ExtractInterpolatedStringLiterals.swift", |
| 72 | +// CHECK-NEXT: "line": 26, |
| 73 | +// CHECK-NEXT: "valueKind": "InterpolatedStringLiteral", |
| 74 | +// CHECK-NEXT: "value": { |
| 75 | +// CHECK-NEXT: "segments": [ |
| 76 | +// CHECK-NEXT: "Start Interpolation with Member Reference: ", |
| 77 | +// CHECK-NEXT: "${Interpolation__1}", |
| 78 | +// CHECK-NEXT: ". Followed By Function Call: ", |
| 79 | +// CHECK-NEXT: "${FunctionCall__generateString(input:)}", |
| 80 | +// CHECK-NEXT: ". End with KeyPath: ", |
| 81 | +// CHECK-NEXT: "${KeyPath__5}", |
| 82 | +// CHECK-NEXT: "." |
| 83 | +// CHECK-NEXT: ], |
| 84 | +// CHECK-NEXT: "interpolations": [ |
| 85 | +// CHECK-NEXT: { |
| 86 | +// CHECK-NEXT: "segmentKey": "${Interpolation__1}", |
| 87 | +// CHECK-NEXT: "baseTypeName": "ExtractInterpolatedStringLiterals.Internal", |
| 88 | +// CHECK-NEXT: "mangledBaseTypeName": "33ExtractInterpolatedStringLiterals8InternalV", |
| 89 | +// CHECK-NEXT: "label": "internalTitle" |
| 90 | +// CHECK-NEXT: }, |
| 91 | +// CHECK-NEXT: { |
| 92 | +// CHECK-NEXT: "segmentKey": "${KeyPath__5}", |
| 93 | +// CHECK-NEXT: "baseTypeName": "ExtractInterpolatedStringLiterals.MyType", |
| 94 | +// CHECK-NEXT: "mangledBaseTypeName": "33ExtractInterpolatedStringLiterals6MyTypeV", |
| 95 | +// CHECK-NEXT: "label": "nested.foo" |
| 96 | +// CHECK-NEXT: } |
| 97 | +// CHECK-NEXT: ] |
| 98 | +// CHECK-NEXT: } |
| 99 | +// CHECK-NEXT: } |
| 100 | +// CHECK-NEXT: ] |
| 101 | +// CHECK-NEXT: } |
| 102 | +// CHECK-NEXT: ] |
0 commit comments