@@ -2007,33 +2007,39 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
2007
2007
continue ;
2008
2008
}
2009
2009
2010
- auto *varDecl = cast<VarDecl>(capture.getDecl ());
2010
+ auto options = SILParameterInfo::Options ();
2011
+
2012
+ Type type;
2013
+ VarDecl *varDecl = nullptr ;
2014
+ if (auto *expr = capture.getPackElement ()) {
2015
+ type = expr->getType ();
2016
+ } else {
2017
+ varDecl = cast<VarDecl>(capture.getDecl ());
2018
+ type = varDecl->getTypeInContext ();
2019
+
2020
+ // If we're capturing a parameter pack, wrap it in a tuple.
2021
+ if (type->is <PackExpansionType>()) {
2022
+ assert (!cast<ParamDecl>(varDecl)->supportsMutation () &&
2023
+ " Cannot capture a pack as an lvalue" );
2024
+
2025
+ SmallVector<TupleTypeElt, 1 > elts;
2026
+ elts.push_back (type);
2027
+ type = TupleType::get (elts, TC.Context );
2028
+ }
2029
+
2030
+ if (isolatedParam == varDecl) {
2031
+ options |= SILParameterInfo::Isolated;
2032
+ isolatedParam = nullptr ;
2033
+ }
2034
+ }
2011
2035
2012
- auto type = varDecl->getTypeInContext ();
2013
2036
assert (!type->hasLocalArchetype () ||
2014
2037
(genericSig && origGenericSig &&
2015
2038
!genericSig->isEqual (origGenericSig)));
2016
2039
type = mapTypeOutOfContext (type);
2017
2040
2018
2041
auto canType = type->getReducedType (
2019
2042
genericSig ? genericSig : origGenericSig);
2020
-
2021
- auto options = SILParameterInfo::Options ();
2022
- if (isolatedParam == varDecl) {
2023
- options |= SILParameterInfo::Isolated;
2024
- isolatedParam = nullptr ;
2025
- }
2026
-
2027
- // If we're capturing a parameter pack, wrap it in a tuple.
2028
- if (isa<PackExpansionType>(canType)) {
2029
- assert (!cast<ParamDecl>(varDecl)->supportsMutation () &&
2030
- " Cannot capture a pack as an lvalue" );
2031
-
2032
- SmallVector<TupleTypeElt, 1 > elts;
2033
- elts.push_back (canType);
2034
- canType = CanTupleType (TupleType::get (elts, TC.Context ));
2035
- }
2036
-
2037
2043
auto &loweredTL =
2038
2044
TC.getTypeLowering (AbstractionPattern (genericSig, canType), canType,
2039
2045
expansion);
@@ -2055,6 +2061,8 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
2055
2061
break ;
2056
2062
}
2057
2063
case CaptureKind::Box: {
2064
+ assert (varDecl);
2065
+
2058
2066
// The type in the box is lowered in the minimal context.
2059
2067
auto minimalLoweredTy =
2060
2068
TC.getTypeLowering (AbstractionPattern (genericSig, canType), canType,
@@ -2072,6 +2080,8 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
2072
2080
break ;
2073
2081
}
2074
2082
case CaptureKind::ImmutableBox: {
2083
+ assert (varDecl);
2084
+
2075
2085
// The type in the box is lowered in the minimal context.
2076
2086
auto minimalLoweredTy =
2077
2087
TC.getTypeLowering (AbstractionPattern (genericSig, canType), canType,
0 commit comments