mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 18:01:07 +01:00
Explorer: Print self pattern for callable declarations (#3216)
When printing callable declarations, it does not print the self pattern
in the deduced bindings.
Example:
User code:
```
class A {
fn Fun[self: Self]() {}
}
```
Print output is missing the self pattern
```
class A {
fn Fun ()
{
}
}
```
This PR fixes it and includes the self pattern in the print output.
```
class A {
fn Fun [self: Self]()
{
}
}
```
---------
Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
co-authored by
Geoff Romer
parent
3eb8c9a5f2
commit
7dc1d627d7
@@ -415,12 +415,15 @@ void CallableDeclaration::PrintIndent(int indent_num_spaces,
|
||||
auto name = GetName(*this);
|
||||
CARBON_CHECK(name) << "Unexpected missing name for `" << *this << "`.";
|
||||
out.indent(indent_num_spaces) << "fn " << *name << " ";
|
||||
if (!deduced_parameters_.empty()) {
|
||||
if (!deduced_parameters_.empty() || self_pattern_) {
|
||||
out << "[";
|
||||
llvm::ListSeparator sep;
|
||||
for (Nonnull<const GenericBinding*> deduced : deduced_parameters_) {
|
||||
out << sep << *deduced;
|
||||
}
|
||||
if (self_pattern_) {
|
||||
out << sep << **self_pattern_;
|
||||
}
|
||||
out << "]";
|
||||
}
|
||||
out << *param_pattern_;
|
||||
|
||||
Reference in New Issue
Block a user