Skip to content

Commit 6ccb390

Browse files
authored
Merge pull request #62688 from adrian-prantl/102367872-1
Ensure unique names in ParameterList::clone()
2 parents e2f051b + 9e22b70 commit 6ccb390

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/AST/Parameter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ParameterList *ParameterList::clone(const ASTContext &C,
6060
SmallVector<ParamDecl*, 8> params(begin(), end());
6161

6262
// Remap the ParamDecls inside of the ParameterList.
63+
unsigned i = 0;
6364
for (auto &decl : params) {
6465
auto defaultArgKind = decl->getDefaultArgumentKind();
6566

@@ -69,8 +70,11 @@ ParameterList *ParameterList::clone(const ASTContext &C,
6970

7071
// If the argument isn't named, give the parameter a name so that
7172
// silgen will produce a value for it.
72-
if (decl->getName().empty() && (options & NamedArguments))
73-
decl->setName(C.getIdentifier("argument"));
73+
if (decl->getName().empty() && (options & NamedArguments)) {
74+
llvm::SmallString<16> s;
75+
{ llvm::raw_svector_ostream(s) << "__argument" << ++i; }
76+
decl->setName(C.getIdentifier(s));
77+
}
7478

7579
// If we're inheriting a default argument, mark it as such.
7680
// FIXME: Figure out how to clone default arguments as well.

test/ModuleInterface/inherited-generic-parameters.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class Base<In, Out> {
3030
public class Derived<T> : Base<T, T> {
3131
// CHECK-NEXT: override public init(x: @escaping (T) -> T)
3232
// CHECK-NEXT: override public init<A>(_ a1: A, _ a2: A)
33-
// CHECK-NEXT: override public init<C>(_ argument: C) where C : main.Base<T, T>
33+
// CHECK-NEXT: override public init<C>(_ __argument1: C) where C : main.Base<T, T>
3434
// CHECK-NEXT: {{(@objc )?}}deinit
3535
// CHECK-NEXT: }
3636
}

0 commit comments

Comments
 (0)