Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6101,7 +6101,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
// it is in the same module, update the vtable.
if (auto *baseDecl = dyn_cast<ClassDecl>(base->getDeclContext())) {
if (baseDecl->hasKnownSwiftImplementation() &&
!base->isDynamic() &&
!base->isDynamic() && !isKnownObjC &&
override->getDeclContext()->isExtensionContext()) {
// For compatibility, only generate a warning in Swift 3
TC.diagnose(override, (TC.Context.isSwiftVersion3()
Expand Down
12 changes: 12 additions & 0 deletions test/decl/inherit/override.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class A {

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

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

override func f3() { } // expected-error{{cannot override a non-dynamic class declaration from an extension}}
override func f4() -> ObjCClassB { } // expected-error{{cannot override a non-dynamic class declaration from an extension}}
override var v1: Int { return 1 } // expected-error{{cannot override a non-dynamic class declaration from an extension}}
override var v2: Int { // expected-error{{cannot override a non-dynamic class declaration from an extension}}
get { return 1 }
set { }
}
override var v3: Int { // expected-error{{cannot override a non-dynamic class declaration from an extension}}
willSet { }
didSet { }
}

override func f3D() { }
override func f4D() -> ObjCClassB { }
Expand Down