@@ -6426,8 +6426,9 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6426
6426
}
6427
6427
}
6428
6428
6429
- void visitAnyFunctionTypeParams (ArrayRef<AnyFunctionType::Param> Params,
6430
- bool printLabels) {
6429
+ void visitAnyFunctionTypeParams (
6430
+ ArrayRef<AnyFunctionType::Param> Params, bool printLabels,
6431
+ ArrayRef<LifetimeDependenceInfo> lifetimeDependencies) {
6431
6432
Printer << " (" ;
6432
6433
6433
6434
for (unsigned i = 0 , e = Params.size (); i != e; ++i) {
@@ -6461,6 +6462,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6461
6462
Printer << " : " ;
6462
6463
}
6463
6464
6465
+ Printer.printLifetimeDependenceAt (lifetimeDependencies, i);
6466
+
6464
6467
auto type = Param.getPlainType ();
6465
6468
if (Param.isVariadic ()) {
6466
6469
visit (type);
@@ -6484,7 +6487,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6484
6487
printFunctionExtInfo (T);
6485
6488
6486
6489
// If we're stripping argument labels from types, do it when printing.
6487
- visitAnyFunctionTypeParams (T->getParams (), /* printLabels*/ false );
6490
+ visitAnyFunctionTypeParams (T->getParams (), /* printLabels*/ false ,
6491
+ T->getLifetimeDependencies ());
6488
6492
6489
6493
if (T->hasExtInfo ()) {
6490
6494
if (T->isAsync ()) {
@@ -6510,11 +6514,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6510
6514
Printer.printKeyword (" sending " , Options);
6511
6515
}
6512
6516
6513
- if (T->hasLifetimeDependenceInfo ()) {
6514
- auto lifetimeDependenceInfo = T->getExtInfo ().getLifetimeDependenceInfo ();
6515
- assert (!lifetimeDependenceInfo.empty ());
6516
- Printer << lifetimeDependenceInfo.getString () << " " ;
6517
- }
6517
+ Printer.printLifetimeDependence (T->getLifetimeDependenceForResult ());
6518
6518
6519
6519
Printer.callPrintStructurePre (PrintStructureKind::FunctionReturnType);
6520
6520
T->getResult ().print (Printer, Options);
@@ -6548,16 +6548,17 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6548
6548
PrintAST::defaultGenericRequirementFlags (Options));
6549
6549
Printer << " " ;
6550
6550
6551
- visitAnyFunctionTypeParams (T->getParams (), /* printLabels*/ true );
6551
+ visitAnyFunctionTypeParams (T->getParams (), /* printLabels*/ true ,
6552
+ T->getLifetimeDependencies ());
6552
6553
6553
- if (T->hasExtInfo ()) {
6554
- if (T->isAsync ()) {
6555
- Printer << " " ;
6556
- Printer.printKeyword (" async" , Options);
6557
- }
6554
+ if (T->hasExtInfo ()) {
6555
+ if (T->isAsync ()) {
6556
+ Printer << " " ;
6557
+ Printer.printKeyword (" async" , Options);
6558
+ }
6558
6559
6559
- if (T->isThrowing ()) {
6560
- Printer << " " << tok::kw_throws;
6560
+ if (T->isThrowing ()) {
6561
+ Printer << " " << tok::kw_throws;
6561
6562
6562
6563
if (auto thrownError = T->getThrownError ()) {
6563
6564
Printer << " (" ;
@@ -6569,11 +6570,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6569
6570
6570
6571
Printer << " -> " ;
6571
6572
6572
- if (T->hasLifetimeDependenceInfo ()) {
6573
- auto lifetimeDependenceInfo = T->getExtInfo ().getLifetimeDependenceInfo ();
6574
- assert (!lifetimeDependenceInfo.empty ());
6575
- Printer << lifetimeDependenceInfo.getString () << " " ;
6576
- }
6573
+ Printer.printLifetimeDependenceAt (T->getLifetimeDependencies (),
6574
+ T->getParams ().size ());
6577
6575
6578
6576
Printer.callPrintStructurePre (PrintStructureKind::FunctionReturnType);
6579
6577
T->getResult ().print (Printer, Options);
@@ -6669,16 +6667,16 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6669
6667
[T, sub, &subOptions] {
6670
6668
sub->Printer << " (" ;
6671
6669
bool first = true ;
6670
+ unsigned paramIndex = 0 ;
6672
6671
for (auto param : T->getParameters ()) {
6673
6672
sub->Printer .printSeparator (first, " , " );
6674
- param.print (sub->Printer , subOptions);
6673
+ param.print (sub->Printer , subOptions,
6674
+ T->getLifetimeDependenceFor (paramIndex));
6675
+ paramIndex++;
6675
6676
}
6676
6677
sub->Printer << " ) -> " ;
6677
6678
6678
- auto lifetimeDependenceInfo = T->getLifetimeDependenceInfo ();
6679
- if (!lifetimeDependenceInfo.empty ()) {
6680
- sub->Printer << lifetimeDependenceInfo.getString () << " " ;
6681
- }
6679
+ sub->Printer .printLifetimeDependence (T->getLifetimeDependenceForResult ());
6682
6680
6683
6681
bool parenthesizeResults = mustParenthesizeResults (T);
6684
6682
if (parenthesizeResults)
@@ -6689,6 +6687,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6689
6687
for (auto yield : T->getYields ()) {
6690
6688
sub->Printer .printSeparator (first, " , " );
6691
6689
sub->Printer << " @yields " ;
6690
+ // TODO: Fix lifetime dependence printing here
6692
6691
yield.print (sub->Printer , subOptions);
6693
6692
}
6694
6693
@@ -6708,8 +6707,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
6708
6707
else {
6709
6708
assert (false && " Should have error, error_indirect, or error_unowned" );
6710
6709
}
6711
-
6712
-
6713
6710
T->getErrorResult ().getInterfaceType ().print (sub->Printer , subOptions);
6714
6711
}
6715
6712
@@ -7259,8 +7256,10 @@ void AnyFunctionType::printParams(ArrayRef<AnyFunctionType::Param> Params,
7259
7256
void AnyFunctionType::printParams (ArrayRef<AnyFunctionType::Param> Params,
7260
7257
ASTPrinter &Printer,
7261
7258
const PrintOptions &PO) {
7262
- TypePrinter (Printer, PO).visitAnyFunctionTypeParams (Params,
7263
- /* printLabels*/ true );
7259
+ // TODO: Handle lifetime dependence printing here
7260
+ TypePrinter (Printer, PO)
7261
+ .visitAnyFunctionTypeParams (Params,
7262
+ /* printLabels*/ true , {});
7264
7263
}
7265
7264
7266
7265
std::string
@@ -7414,12 +7413,16 @@ StringRef swift::getCheckedCastKindName(CheckedCastKind kind) {
7414
7413
llvm_unreachable (" bad checked cast name" );
7415
7414
}
7416
7415
7417
- void SILParameterInfo::print (raw_ostream &OS, const PrintOptions &Opts) const {
7416
+ void SILParameterInfo::print (
7417
+ raw_ostream &OS, const PrintOptions &Opts,
7418
+ std::optional<LifetimeDependenceInfo> lifetimeDependence) const {
7418
7419
StreamPrinter Printer (OS);
7419
- print (Printer, Opts);
7420
+ print (Printer, Opts, lifetimeDependence );
7420
7421
}
7421
- void SILParameterInfo::print (ASTPrinter &Printer,
7422
- const PrintOptions &Opts) const {
7422
+
7423
+ void SILParameterInfo::print (
7424
+ ASTPrinter &Printer, const PrintOptions &Opts,
7425
+ std::optional<LifetimeDependenceInfo> lifetimeDependence) const {
7423
7426
auto options = getOptions ();
7424
7427
7425
7428
if (options.contains (SILParameterInfo::NotDifferentiable)) {
@@ -7437,6 +7440,10 @@ void SILParameterInfo::print(ASTPrinter &Printer,
7437
7440
Printer << " @sil_isolated " ;
7438
7441
}
7439
7442
7443
+ if (lifetimeDependence) {
7444
+ Printer.printLifetimeDependence (*lifetimeDependence);
7445
+ }
7446
+
7440
7447
// If we did not handle a case in Options, this code was not updated
7441
7448
// appropriately.
7442
7449
assert (!bool (options) && " Code not updated for introduced option" );
0 commit comments