Skip to content

Commit 1f49050

Browse files
authored
Merge pull request #27193 from DougGregor/sr-11062-5.1
[5.1] [AST] Look through ConstructorRefCallExpr to find direct callee.
2 parents 17b87a1 + f330ef8 commit 1f49050

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/AST/Expr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,6 +1814,11 @@ Expr *CallExpr::getDirectCallee() const {
18141814
continue;
18151815
}
18161816

1817+
if (auto ctorCall = dyn_cast<ConstructorRefCallExpr>(fn)) {
1818+
fn = ctorCall->getFn();
1819+
continue;
1820+
}
1821+
18171822
return fn;
18181823
}
18191824
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %target-swift-frontend -emit-ir %s
2+
3+
struct MyText<V> {
4+
let label: String
5+
let value: V
6+
}
7+
8+
extension MyText where V == Void {
9+
init(_ label: String, defaulted: Int = 17) {
10+
self.label = label
11+
self.value = ()
12+
}
13+
}
14+
15+
struct ImagePulse {
16+
@Inspectable(control: { MyText("duration") })
17+
var test: Double = 0
18+
}
19+
20+
@propertyWrapper
21+
final class Inspectable<Value> {
22+
var wrappedValue: Value
23+
24+
init<V>(wrappedValue initialValue: Value, control: @escaping () -> V) {
25+
self.wrappedValue = initialValue
26+
}
27+
}

0 commit comments

Comments
 (0)