Skip to content

Commit 0de5aeb

Browse files
committed
Ignore whether a parameter is "isolated" for the purposes of redeclarations.
Overload resolution won't be able to tell them apart, and they're mangled identically. Fixes rdar://80918858.
1 parent 66f9db8 commit 0de5aeb

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/AST/Decl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,8 +2688,10 @@ static Type mapSignatureFunctionType(ASTContext &ctx, Type type,
26882688
for (const auto &param : funcTy->getParams()) {
26892689
auto newParamType = mapSignatureParamType(ctx, param.getPlainType());
26902690

2691-
// Don't allow overloading by @_nonEphemeral.
2692-
auto newFlags = param.getParameterFlags().withNonEphemeral(false);
2691+
// Don't allow overloading by @_nonEphemeral or isolated.
2692+
auto newFlags = param.getParameterFlags()
2693+
.withNonEphemeral(false)
2694+
.withIsolated(false);
26932695

26942696
// For the 'self' of a method, strip off 'inout'.
26952697
if (isMethod) {

test/Concurrency/isolated_parameters.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,15 @@ struct S: P {
9090
func k(isolated y: Int) -> Int { return j(isolated: y) }
9191
func l(isolated _: Int) -> Int { return k(isolated: 0) }
9292
}
93+
94+
95+
// Redeclaration checking
96+
actor TestActor {
97+
func test() { // expected-note{{'test()' previously declared here}}
98+
}
99+
nonisolated func test() { // expected-error{{invalid redeclaration of 'test()'}}
100+
}
101+
}
102+
103+
func redecl(_: TestActor) { } // expected-note{{'redecl' previously declared here}}
104+
func redecl(_: isolated TestActor) { } // expected-error{{invalid redeclaration of 'redecl'}}

0 commit comments

Comments
 (0)