File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,8 @@ extractFunctionArguments(const ArgumentList *args) {
138
138
if (decl->hasDefaultExpr ()) {
139
139
argExpr = decl->getTypeCheckedDefaultExpr ();
140
140
}
141
+ } else if (auto optionalInject = dyn_cast<InjectIntoOptionalExpr>(argExpr)) {
142
+ argExpr = optionalInject->getSubExpr ();
141
143
}
142
144
parameters.push_back ({label, type, extractCompileTimeValue (argExpr)});
143
145
}
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: echo "[MyProto]" > %t/protocols.json
3
+
4
+ // RUN: %target-swift-frontend -typecheck -emit-const-values-path %t/ExtractLiterals.swiftconstvalues -const-gather-protocols-file %t/protocols.json -primary-file %s
5
+ // RUN: cat %t/ExtractLiterals.swiftconstvalues 2>&1 | %FileCheck %s
6
+
7
+ protocol MyProto { }
8
+ struct InjectablePropertyStruct : MyProto {
9
+ let init1 = Bat ( buz: " hello " , fuz: 4 )
10
+ }
11
+
12
+ public struct Bat {
13
+ let buz : String ?
14
+ let fuz : Int
15
+
16
+ init ( buz: String ? = " " , fuz: Int = 0 ) {
17
+ self . buz = buz
18
+ self . fuz = fuz
19
+ }
20
+ }
21
+
22
+ // CHECK: "arguments": [
23
+ // CHECK-NEXT: {
24
+ // CHECK-NEXT: "label": "buz",
25
+ // CHECK-NEXT: "type": "Swift.Optional<Swift.String>",
26
+ // CHECK-NEXT: "valueKind": "RawLiteral",
27
+ // CHECK-NEXT: "value": "hello"
28
+ // CHECK-NEXT: },
29
+ // CHECK-NEXT: {
30
+ // CHECK-NEXT: "label": "fuz",
31
+ // CHECK-NEXT: "type": "Swift.Int",
32
+ // CHECK-NEXT: "valueKind": "RawLiteral",
33
+ // CHECK-NEXT: "value": "4"
34
+ // CHECK-NEXT: }
35
+ // CHECK-NEXT: ]
You can’t perform that action at this time.
0 commit comments