Skip to content

Commit 7b06b3d

Browse files
authored
Merge pull request #7704 from KingOfBrian/bugfix/SR-4024
[Diagnostics] Do not report an override warning multiple times
2 parents fa50dc5 + 43a168a commit 7b06b3d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6135,7 +6135,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
61356135
// it is in the same module, update the vtable.
61366136
if (auto *baseDecl = dyn_cast<ClassDecl>(base->getDeclContext())) {
61376137
if (baseDecl->hasKnownSwiftImplementation() &&
6138-
!base->isDynamic() &&
6138+
!base->isDynamic() && !isKnownObjC &&
61396139
override->getDeclContext()->isExtensionContext()) {
61406140
// For compatibility, only generate a warning in Swift 3
61416141
TC.diagnose(override, (TC.Context.isSwiftVersion3()

test/decl/inherit/override.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ class A {
99

1010
@objc func f3() { } // expected-note{{overridden declaration is here}}
1111
@objc func f4() -> ObjCClassA { } // expected-note{{overridden declaration is here}}
12+
@objc var v1: Int { return 0 } // expected-note{{overridden declaration is here}}
13+
@objc var v2: Int { return 0 } // expected-note{{overridden declaration is here}}
14+
@objc var v3: Int = 0 // expected-note{{overridden declaration is here}}
1215

1316
dynamic func f3D() { }
1417
dynamic func f4D() -> ObjCClassA { }
@@ -30,6 +33,15 @@ extension B {
3033

3134
override func f3() { } // expected-error{{cannot override a non-dynamic class declaration from an extension}}
3235
override func f4() -> ObjCClassB { } // expected-error{{cannot override a non-dynamic class declaration from an extension}}
36+
override var v1: Int { return 1 } // expected-error{{cannot override a non-dynamic class declaration from an extension}}
37+
override var v2: Int { // expected-error{{cannot override a non-dynamic class declaration from an extension}}
38+
get { return 1 }
39+
set { }
40+
}
41+
override var v3: Int { // expected-error{{cannot override a non-dynamic class declaration from an extension}}
42+
willSet { }
43+
didSet { }
44+
}
3345

3446
override func f3D() { }
3547
override func f4D() -> ObjCClassB { }

0 commit comments

Comments
 (0)