@@ -104,6 +104,7 @@ PrintOptions PrintOptions::printParseableInterfaceFile() {
104
104
result.OmitNameOfInaccessibleProperties = true ;
105
105
result.FunctionDefinitions = true ;
106
106
result.CollapseSingleGetterProperty = false ;
107
+ result.VarInitializers = true ;
107
108
108
109
result.FunctionBody = [](const ValueDecl *decl, ASTPrinter &printer) {
109
110
auto AFD = dyn_cast<AbstractFunctionDecl>(decl);
@@ -2099,20 +2100,19 @@ void PrintAST::visitPatternBindingDecl(PatternBindingDecl *decl) {
2099
2100
}
2100
2101
2101
2102
if (Options.VarInitializers ) {
2102
- // FIXME: Implement once we can pretty-print expressions.
2103
- }
2104
-
2105
- auto vd = entry.getAnchoringVarDecl ();
2106
- if (entry.hasInitStringRepresentation () &&
2107
- vd->isInitExposedToClients ()) {
2108
- SmallString<128 > scratch;
2109
- Printer << " = " << entry.getInitStringRepresentation (scratch);
2103
+ auto vd = entry.getAnchoringVarDecl ();
2104
+ if (entry.hasInitStringRepresentation () &&
2105
+ vd->isInitExposedToClients ()) {
2106
+ SmallString<128 > scratch;
2107
+ Printer << " = " << entry.getInitStringRepresentation (scratch);
2108
+ }
2110
2109
}
2111
2110
2112
- // HACK: If we're just printing a single pattern and it has accessors,
2113
- // print the accessors here.
2114
- if (decl->getNumPatternEntries () == 1 ) {
2115
- printAccessors (vd);
2111
+ // If we're just printing a single pattern and it has accessors,
2112
+ // print the accessors here. It is an error to add accessors to a
2113
+ // pattern binding with multiple entries.
2114
+ if (auto var = decl->getSingleVar ()) {
2115
+ printAccessors (var);
2116
2116
}
2117
2117
}
2118
2118
}
@@ -3230,7 +3230,7 @@ bool Decl::shouldPrintInContext(const PrintOptions &PO) const {
3230
3230
// Stored variables in Swift source will be picked up by the
3231
3231
// PatternBindingDecl.
3232
3232
if (auto *VD = dyn_cast<VarDecl>(this )) {
3233
- if (!VD->hasClangNode () && VD->getImplInfo (). isSimpleStored ())
3233
+ if (!VD->hasClangNode () && VD->hasStorage ())
3234
3234
return false ;
3235
3235
}
3236
3236
@@ -3241,7 +3241,7 @@ bool Decl::shouldPrintInContext(const PrintOptions &PO) const {
3241
3241
auto pattern =
3242
3242
pbd->getPatternList ()[0 ].getPattern ()->getSemanticsProvidingPattern ();
3243
3243
if (auto named = dyn_cast<NamedPattern>(pattern)) {
3244
- if (!named->getDecl ()->getImplInfo (). isSimpleStored ())
3244
+ if (!named->getDecl ()->hasStorage ())
3245
3245
return false ;
3246
3246
}
3247
3247
}
0 commit comments