Skip to content

Commit b4ef9b3

Browse files
committed
SIL: Compute canonical type earlier
1 parent 92a7471 commit b4ef9b3

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,22 +2012,22 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
20122012

20132013
auto options = SILParameterInfo::Options();
20142014

2015-
Type type;
2015+
CanType type;
20162016
VarDecl *varDecl = nullptr;
20172017
if (auto *expr = capture.getPackElement()) {
2018-
type = expr->getType();
2018+
type = expr->getType()->getCanonicalType();
20192019
} else {
20202020
varDecl = cast<VarDecl>(capture.getDecl());
2021-
type = varDecl->getTypeInContext();
2021+
type = varDecl->getTypeInContext()->getCanonicalType();
20222022

20232023
// If we're capturing a parameter pack, wrap it in a tuple.
2024-
if (type->is<PackExpansionType>()) {
2024+
if (isa<PackExpansionType>(type)) {
20252025
assert(!cast<ParamDecl>(varDecl)->supportsMutation() &&
20262026
"Cannot capture a pack as an lvalue");
20272027

20282028
SmallVector<TupleTypeElt, 1> elts;
20292029
elts.push_back(type);
2030-
type = TupleType::get(elts, TC.Context);
2030+
type = CanType(TupleType::get(elts, TC.Context));
20312031
}
20322032

20332033
if (isolatedParam == varDecl) {

test/SILGen/phantom_existential_typealias.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ protocol P {
1818
func test1(p: any P) -> [Int] {
1919
return p.x.f { $0.y }
2020
}
21+
22+
func callee(_: () -> ()) {}
23+
24+
func test2(p: any P) {
25+
let a = p.x
26+
callee { _ = a }
27+
}

0 commit comments

Comments
 (0)