diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-10-27 10:31:08 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-10-30 13:23:20 +0000 |
commit | ee807026bb2afb984c2ce50a22f586c12b65e45d (patch) | |
tree | f052db7da25f924f8316aec53293ee73f753e2c8 | |
parent | bf7534e2fab3f35be38dff3153f58adeb7874b9f (diff) |
Fix losing the default value when the type altered
The changes influence, for instance, the following line:
```python
@staticmethod
def translate(
context: str,
key: str,
disambiguation: Optional[str] = ...,
n: int = ...
) -> str: ...
```
Namely, the `disambiguation` argument now indicates
that it has a default value.
It seems that the `pyi-type` attribute of the modify-argument tag
eats the argument default value.
The commit should add the omitted values if they're provided.
Initial-patch-by: Anton Yablokov (stsav012@gmail.com)
Change-Id: Ie3914c3ef13578ef8cfff9ecb8c6c64f167b5360
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
(cherry picked from commit e82812a17888e8bbf30908f790b16433b086a4ef)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index e56982b6c..74a9d8e91 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -5003,12 +5003,6 @@ QString CppGenerator::signatureParameter(const AbstractMetaArgument &arg) const if (size > 1) s << ']'; - if (!arg.defaultValueExpression().isEmpty()) { - s << '='; - QString e = arg.defaultValueExpression(); - e.replace(u"::"_s, u"."_s); - s << e; - } return result; } @@ -5029,14 +5023,18 @@ void CppGenerator::writeSignatureInfo(TextStream &s, const OverloadData &overloa const auto &arguments = f->arguments(); for (qsizetype i = 0, size = arguments.size(); i < size; ++i) { const auto n = i + 1; + const auto &arg = arguments.at(i); if (!f->argumentRemoved(n)) { QString t = f->pyiTypeReplaced(n); if (t.isEmpty()) { - t = signatureParameter(arguments.at(i)); + t = signatureParameter(arg); } else { t.prepend(u':'); - t.prepend(arguments.at(i).name()); + t.prepend(arg.name()); } + QString defaultValue = arg.defaultValueExpression(); + if (!defaultValue.isEmpty()) + t += u'=' + defaultValue.replace(u"::"_s, u"."_s); args.append(t); } } |