File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -255,6 +255,9 @@ struct OverloadSignature {
255
255
// / Whether this is a type alias.
256
256
unsigned IsTypeAlias : 1 ;
257
257
258
+ // / Whether this is a macro.
259
+ unsigned IsMacro : 1 ;
260
+
258
261
// / Whether this signature is part of a protocol extension.
259
262
unsigned InProtocolExtension : 1 ;
260
263
Original file line number Diff line number Diff line change @@ -2785,6 +2785,10 @@ bool swift::conflicting(const OverloadSignature& sig1,
2785
2785
if (sig1.IsAsyncFunction != sig2.IsAsyncFunction )
2786
2786
return false ;
2787
2787
2788
+ // If one is a macro and the other is not, they can't conflict.
2789
+ if (sig1.IsMacro != sig2.IsMacro )
2790
+ return false ;
2791
+
2788
2792
// If one is a compound name and the other is not, they do not conflict
2789
2793
// if one is a property and the other is a non-nullary function.
2790
2794
if (sig1.Name .isCompoundName () != sig2.Name .isCompoundName ()) {
@@ -3016,6 +3020,7 @@ OverloadSignature ValueDecl::getOverloadSignature() const {
3016
3020
signature.IsEnumElement = isa<EnumElementDecl>(this );
3017
3021
signature.IsNominal = isa<NominalTypeDecl>(this );
3018
3022
signature.IsTypeAlias = isa<TypeAliasDecl>(this );
3023
+ signature.IsMacro = isa<MacroDecl>(this );
3019
3024
signature.HasOpaqueReturnType =
3020
3025
!signature.IsVariable && (bool )getOpaqueResultTypeDecl ();
3021
3026
Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ struct ZZZ {
41
41
@expression macro multiArgMacro( _: Any, second : Any) = MissingModule. MissingType
42
42
// expected-note@-1{{'multiArgMacro(_:second:)' declared here}}
43
43
44
+ @expression macro overloaded1( _ p: P ) = MissingModule. MissingType
45
+ func overloaded1 ( _ p: Any ) { }
46
+
47
+ @expression macro notOverloaded1( _ p: P ) = MissingModule . MissingType // expected-note{{'notOverloaded1' previously declared here}}
48
+ @expression macro notOverloaded1( _ p: P ) = MissingModule . MissingOtherType // expected-error{{invalid redeclaration of 'notOverloaded1'}}
49
+
44
50
func testDiags( a: Int , b: Int ) {
45
51
// FIXME: Bad diagnostic.
46
52
let s = #stringify < Int , Int > ( a + b) // expected-error{{type of expression is ambiguous without more context}}
@@ -59,6 +65,9 @@ func testDiags(a: Int, b: Int) {
59
65
60
66
_ = stringify ( a + b)
61
67
// expected-error@-1{{expansion of macro 'stringify' requires leading '#'}}{{7-7=#}}
68
+
69
+ overloaded1 ( a) // okay, calls the function
70
+ #overloaded1 ( a) // expected-error{{argument type 'Int' does not conform to expected type 'P'}}
62
71
}
63
72
64
73
func shadow( a: Int , b: Int , stringify: Int ) {
You can’t perform that action at this time.
0 commit comments