Skip to content

Commit ac9ee94

Browse files
authored
Merge pull request #34940 from DougGregor/async-nonasync-redecl-checking
[Concurrency] Disallow 'async' and non-async overloading.
2 parents b57751d + 1798e66 commit ac9ee94

File tree

4 files changed

+5
-12
lines changed

4 files changed

+5
-12
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,10 @@ struct OverloadSignature {
242242
/// Whether this declaration has an opaque return type.
243243
unsigned HasOpaqueReturnType : 1;
244244

245-
/// Whether this declaration is 'async'
246-
unsigned HasAsync : 1;
247-
248245
OverloadSignature()
249246
: UnaryOperator(UnaryOperatorKind::None), IsInstanceMember(false),
250247
IsVariable(false), IsFunction(false), InProtocolExtension(false),
251-
InExtensionOfGenericType(false), HasOpaqueReturnType(false),
252-
HasAsync(false) {}
248+
InExtensionOfGenericType(false), HasOpaqueReturnType(false) { }
253249
};
254250

255251
/// Determine whether two overload signatures conflict.

lib/AST/Decl.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,10 +2403,6 @@ bool swift::conflicting(const OverloadSignature& sig1,
24032403
(sig2.IsVariable && !sig1.Name.getArgumentNames().empty()));
24042404
}
24052405

2406-
// If one is asynchronous and the other is not, they can't conflict.
2407-
if (sig1.HasAsync != sig2.HasAsync)
2408-
return false;
2409-
24102406
// Note that we intentionally ignore the HasOpaqueReturnType bit here.
24112407
// For declarations that can't be overloaded by type, we want them to be
24122408
// considered conflicting independent of their type.
@@ -2630,8 +2626,6 @@ OverloadSignature ValueDecl::getOverloadSignature() const {
26302626
signature.IsTypeAlias = isa<TypeAliasDecl>(this);
26312627
signature.HasOpaqueReturnType =
26322628
!signature.IsVariable && (bool)getOpaqueResultTypeDecl();
2633-
signature.HasAsync = isa<AbstractFunctionDecl>(this) &&
2634-
cast<AbstractFunctionDecl>(this)->hasAsync();
26352629

26362630
// Unary operators also include prefix/postfix.
26372631
if (auto func = dyn_cast<FuncDecl>(this)) {

test/Constraints/async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func testNonConversions() async {
1212

1313
// Overloading
1414
@available(swift, deprecated: 4.0, message: "synchronous is no fun")
15-
func overloadedSame() -> String { "synchronous" }
15+
func overloadedSame(_: Int = 0) -> String { "synchronous" }
1616

1717
func overloadedSame() async -> String { "asynchronous" }
1818

test/decl/func/async.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
func redecl1() async { } // expected-note{{previously declared here}}
77
func redecl1() async throws { } // expected-error{{invalid redeclaration of 'redecl1()'}}
88

9+
func redecl2() -> String { "" } // expected-note{{previously declared here}}
10+
func redecl2() async -> String { "" } // expected-error{{invalid redeclaration of 'redecl2()'}}
11+
912
// Override checking
1013

1114
class Super {

0 commit comments

Comments
 (0)