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