@@ -1917,6 +1917,7 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
1917
1917
// signature from the AST for that.
1918
1918
auto origGenericSig = function.getAnyFunctionRef ()->getGenericSignature ();
1919
1919
auto loweredCaptures = TC.getLoweredLocalCaptures (function);
1920
+ auto *isolatedParam = loweredCaptures.getIsolatedParamCapture ();
1920
1921
1921
1922
for (auto capture : loweredCaptures.getCaptures ()) {
1922
1923
if (capture.isDynamicSelfMetadata ()) {
@@ -1955,13 +1956,17 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
1955
1956
continue ;
1956
1957
}
1957
1958
1958
- auto *VD = capture.getDecl ();
1959
- auto type = VD ->getInterfaceType ();
1959
+ auto *varDecl = capture.getDecl ();
1960
+ auto type = varDecl ->getInterfaceType ();
1960
1961
auto canType = type->getReducedType (origGenericSig);
1961
1962
1963
+ auto options = SILParameterInfo::Options ();
1964
+ if (isolatedParam == varDecl)
1965
+ options |= SILParameterInfo::Isolated;
1966
+
1962
1967
// If we're capturing a parameter pack, wrap it in a tuple.
1963
1968
if (isa<PackExpansionType>(canType)) {
1964
- assert (!cast<ParamDecl>(VD )->supportsMutation () &&
1969
+ assert (!cast<ParamDecl>(varDecl )->supportsMutation () &&
1965
1970
" Cannot capture a pack as an lvalue" );
1966
1971
1967
1972
SmallVector<TupleTypeElt, 1 > elts;
@@ -1983,7 +1988,7 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
1983
1988
} else {
1984
1989
convention = ParameterConvention::Direct_Guaranteed;
1985
1990
}
1986
- SILParameterInfo param (loweredTy.getASTType (), convention);
1991
+ SILParameterInfo param (loweredTy.getASTType (), convention, options );
1987
1992
inputs.push_back (param);
1988
1993
break ;
1989
1994
}
@@ -1995,10 +2000,10 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
1995
2000
.getLoweredType ();
1996
2001
// Lvalues are captured as a box that owns the captured value.
1997
2002
auto boxTy = TC.getInterfaceBoxTypeForCapture (
1998
- VD , minimalLoweredTy.getASTType (),
2003
+ varDecl , minimalLoweredTy.getASTType (),
1999
2004
/* mutable*/ true );
2000
2005
auto convention = ParameterConvention::Direct_Guaranteed;
2001
- auto param = SILParameterInfo (boxTy, convention);
2006
+ auto param = SILParameterInfo (boxTy, convention, options );
2002
2007
inputs.push_back (param);
2003
2008
break ;
2004
2009
}
@@ -2009,30 +2014,30 @@ lowerCaptureContextParameters(TypeConverter &TC, SILDeclRef function,
2009
2014
TypeExpansionContext::minimal ())
2010
2015
.getLoweredType ();
2011
2016
// Lvalues are captured as a box that owns the captured value.
2012
- auto boxTy =
2013
- TC. getInterfaceBoxTypeForCapture (VD , minimalLoweredTy.getASTType (),
2014
- /* mutable*/ false );
2017
+ auto boxTy = TC. getInterfaceBoxTypeForCapture (
2018
+ varDecl , minimalLoweredTy.getASTType (),
2019
+ /* mutable*/ false );
2015
2020
auto convention = ParameterConvention::Direct_Guaranteed;
2016
- auto param = SILParameterInfo (boxTy, convention);
2021
+ auto param = SILParameterInfo (boxTy, convention, options );
2017
2022
inputs.push_back (param);
2018
2023
break ;
2019
2024
}
2020
2025
case CaptureKind::StorageAddress: {
2021
2026
// Non-escaping lvalues are captured as the address of the value.
2022
2027
SILType ty = loweredTy.getAddressType ();
2023
- auto param =
2024
- SILParameterInfo ( ty.getASTType (),
2025
- ParameterConvention::Indirect_InoutAliasable );
2028
+ auto param = SILParameterInfo (
2029
+ ty.getASTType (), ParameterConvention::Indirect_InoutAliasable ,
2030
+ options );
2026
2031
inputs.push_back (param);
2027
2032
break ;
2028
2033
}
2029
2034
case CaptureKind::Immutable: {
2030
2035
// 'let' constants that are address-only are captured as the address of
2031
2036
// the value and will be consumed by the closure.
2032
2037
SILType ty = loweredTy.getAddressType ();
2033
- auto param =
2034
- SILParameterInfo (ty. getASTType () ,
2035
- ParameterConvention::Indirect_In_Guaranteed );
2038
+ auto param = SILParameterInfo (ty. getASTType (),
2039
+ ParameterConvention::Indirect_In_Guaranteed ,
2040
+ options );
2036
2041
inputs.push_back (param);
2037
2042
break ;
2038
2043
}
0 commit comments