mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
SIL: Compute canonical type earlier
This commit is contained in:
@@ -2012,22 +2012,22 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
|
||||
|
||||
auto options = SILParameterInfo::Options();
|
||||
|
||||
Type type;
|
||||
CanType type;
|
||||
VarDecl *varDecl = nullptr;
|
||||
if (auto *expr = capture.getPackElement()) {
|
||||
type = expr->getType();
|
||||
type = expr->getType()->getCanonicalType();
|
||||
} else {
|
||||
varDecl = cast<VarDecl>(capture.getDecl());
|
||||
type = varDecl->getTypeInContext();
|
||||
type = varDecl->getTypeInContext()->getCanonicalType();
|
||||
|
||||
// If we're capturing a parameter pack, wrap it in a tuple.
|
||||
if (type->is<PackExpansionType>()) {
|
||||
if (isa<PackExpansionType>(type)) {
|
||||
assert(!cast<ParamDecl>(varDecl)->supportsMutation() &&
|
||||
"Cannot capture a pack as an lvalue");
|
||||
|
||||
SmallVector<TupleTypeElt, 1> elts;
|
||||
elts.push_back(type);
|
||||
type = TupleType::get(elts, TC.Context);
|
||||
type = CanType(TupleType::get(elts, TC.Context));
|
||||
}
|
||||
|
||||
if (isolatedParam == varDecl) {
|
||||
|
||||
@@ -18,3 +18,10 @@ protocol P {
|
||||
func test1(p: any P) -> [Int] {
|
||||
return p.x.f { $0.y }
|
||||
}
|
||||
|
||||
func callee(_: () -> ()) {}
|
||||
|
||||
func test2(p: any P) {
|
||||
let a = p.x
|
||||
callee { _ = a }
|
||||
}
|
||||
Reference in New Issue
Block a user