@@ -1970,33 +1970,39 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
1970
1970
continue ;
1971
1971
}
1972
1972
1973
- auto *varDecl = cast<VarDecl>(capture.getDecl ());
1973
+ auto options = SILParameterInfo::Options ();
1974
+
1975
+ Type type;
1976
+ VarDecl *varDecl = nullptr ;
1977
+ if (auto *expr = capture.getPackElement ()) {
1978
+ type = expr->getType ();
1979
+ } else {
1980
+ varDecl = cast<VarDecl>(capture.getDecl ());
1981
+ type = varDecl->getTypeInContext ();
1982
+
1983
+ // If we're capturing a parameter pack, wrap it in a tuple.
1984
+ if (type->is <PackExpansionType>()) {
1985
+ assert (!cast<ParamDecl>(varDecl)->supportsMutation () &&
1986
+ " Cannot capture a pack as an lvalue" );
1987
+
1988
+ SmallVector<TupleTypeElt, 1 > elts;
1989
+ elts.push_back (type);
1990
+ type = TupleType::get (elts, TC.Context );
1991
+ }
1992
+
1993
+ if (isolatedParam == varDecl) {
1994
+ options |= SILParameterInfo::Isolated;
1995
+ isolatedParam = nullptr ;
1996
+ }
1997
+ }
1974
1998
1975
- auto type = varDecl->getTypeInContext ();
1976
1999
assert (!type->hasLocalArchetype () ||
1977
2000
(genericSig && origGenericSig &&
1978
2001
!genericSig->isEqual (origGenericSig)));
1979
2002
type = mapTypeOutOfContext (type);
1980
2003
1981
2004
auto canType = type->getReducedType (
1982
2005
genericSig ? genericSig : origGenericSig);
1983
-
1984
- auto options = SILParameterInfo::Options ();
1985
- if (isolatedParam == varDecl) {
1986
- options |= SILParameterInfo::Isolated;
1987
- isolatedParam = nullptr ;
1988
- }
1989
-
1990
- // If we're capturing a parameter pack, wrap it in a tuple.
1991
- if (isa<PackExpansionType>(canType)) {
1992
- assert (!cast<ParamDecl>(varDecl)->supportsMutation () &&
1993
- " Cannot capture a pack as an lvalue" );
1994
-
1995
- SmallVector<TupleTypeElt, 1 > elts;
1996
- elts.push_back (canType);
1997
- canType = CanTupleType (TupleType::get (elts, TC.Context ));
1998
- }
1999
-
2000
2006
auto &loweredTL =
2001
2007
TC.getTypeLowering (AbstractionPattern (genericSig, canType), canType,
2002
2008
expansion);
@@ -2018,6 +2024,8 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
2018
2024
break ;
2019
2025
}
2020
2026
case CaptureKind::Box: {
2027
+ assert (varDecl);
2028
+
2021
2029
// The type in the box is lowered in the minimal context.
2022
2030
auto minimalLoweredTy =
2023
2031
TC.getTypeLowering (AbstractionPattern (genericSig, canType), canType,
@@ -2035,6 +2043,8 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
2035
2043
break ;
2036
2044
}
2037
2045
case CaptureKind::ImmutableBox: {
2046
+ assert (varDecl);
2047
+
2038
2048
// The type in the box is lowered in the minimal context.
2039
2049
auto minimalLoweredTy =
2040
2050
TC.getTypeLowering (AbstractionPattern (genericSig, canType), canType,
0 commit comments