File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,9 @@ struct OverloadSignature {
310
310
// / Whether this is a macro.
311
311
unsigned IsMacro : 1 ;
312
312
313
+ // / Whether this is a generic argument.
314
+ unsigned IsGenericArg : 1 ;
315
+
313
316
// / Whether this signature is part of a protocol extension.
314
317
unsigned InProtocolExtension : 1 ;
315
318
@@ -323,8 +326,10 @@ struct OverloadSignature {
323
326
OverloadSignature ()
324
327
: UnaryOperator(UnaryOperatorKind::None), IsInstanceMember(false ),
325
328
IsVariable (false ), IsFunction(false ), IsAsyncFunction(false ),
326
- IsDistributed(false ), InProtocolExtension(false ),
327
- InExtensionOfGenericType(false ), HasOpaqueReturnType(false ) { }
329
+ IsDistributed(false ), IsEnumElement(false ), IsNominal(false ),
330
+ IsTypeAlias(false ), IsMacro(false ), IsGenericArg(false ),
331
+ InProtocolExtension(false ), InExtensionOfGenericType(false ),
332
+ HasOpaqueReturnType(false ) { }
328
333
};
329
334
330
335
// / Determine whether two overload signatures conflict.
Original file line number Diff line number Diff line change @@ -3856,6 +3856,13 @@ bool swift::conflicting(ASTContext &ctx,
3856
3856
if (sig1.IsFunction != sig2.IsFunction )
3857
3857
return true ;
3858
3858
3859
+ // Gracefully handle the case where value generic arguments were introduced
3860
+ // as a conflicting value with static variables of the same name.
3861
+ if (sig1.IsGenericArg != sig2.IsGenericArg ) {
3862
+ *wouldConflictInSwift5 = true ;
3863
+ return true ;
3864
+ }
3865
+
3859
3866
// Variables always conflict with non-variables with the same signature.
3860
3867
// (e.g variables with zero argument functions, variables with type
3861
3868
// declarations)
@@ -4034,6 +4041,7 @@ OverloadSignature ValueDecl::getOverloadSignature() const {
4034
4041
signature.IsNominal = isa<NominalTypeDecl>(this );
4035
4042
signature.IsTypeAlias = isa<TypeAliasDecl>(this );
4036
4043
signature.IsMacro = isa<MacroDecl>(this );
4044
+ signature.IsGenericArg = isa<GenericTypeParamDecl>(this );
4037
4045
signature.HasOpaqueReturnType =
4038
4046
!signature.IsVariable && (bool )getOpaqueResultTypeDecl ();
4039
4047
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ func testC4<let T: Int>(with c: C<T, T>) {
123
123
struct D < let N: Int & P > { } // expected-error {{non-protocol, non-class type 'Int' cannot be used within a protocol-constrained type}}
124
124
125
125
struct E < A, let b: Int > { // expected-note {{'b' previously declared here}}
126
- static var b : Int { // expected-error {{invalid redeclaration of 'b'}}
126
+ static var b : Int { // expected-warning {{redeclaration of 'b' is deprecated and will be an error in Swift 5 }}
127
127
// expected-note@-1 {{'b' declared here}}
128
128
123
129
129
}
@@ -185,7 +185,7 @@ func testTypeOf2<let c: Int>(_: E<Int, c>.Type) -> Int {
185
185
}
186
186
187
187
struct H < let I: Int > { // expected-note {{'I' previously declared here}}
188
- struct I { } // expected-error {{invalid redeclaration of 'I'}}
188
+ struct I { } // expected-warning {{redeclaration of 'I' is deprecated and will be an error in Swift 5 }}
189
189
}
190
190
191
191
typealias J = E < Int , 123 > . b // expected-error {{static property 'b' is not a member type of 'E<Int, 123>'}}
You can’t perform that action at this time.
0 commit comments