Skip to content

Commit 7bdd496

Browse files
author
Gabor Horvath
committed
Address review comments.
1 parent e5c5ec5 commit 7bdd496

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

lib/ClangImporter/ImportDecl.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -3017,6 +3017,10 @@ namespace {
30173017
/*Obsoleted=*/{});
30183018
classDecl->getAttrs().add(AvAttr);
30193019
}
3020+
3021+
if (decl->isEffectivelyFinal())
3022+
classDecl->getAttrs().add(new (Impl.SwiftContext)
3023+
FinalAttr(/*IsImplicit=*/true));
30203024
}
30213025

30223026
// If this module is declared as a C++ module, try to synthesize

test/Interop/Cxx/foreign-reference/Inputs/inheritance.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ DerivedFromValueTypeAndAnnotated *returnDerivedFromValueTypeAndAnnotated() { //
109109
return new DerivedFromValueTypeAndAnnotated();
110110
}
111111

112-
struct DerivedFromRefType : RefType {};
112+
struct DerivedFromRefType final : RefType {};
113113
DerivedFromRefType *returnDerivedFromRefType() {
114114
return new DerivedFromRefType();
115115
}
@@ -180,7 +180,7 @@ __attribute__((swift_attr("release:RCRelease"))) RefType {};
180180

181181
RefType *returnRefType() { return new RefType(); }; // expected-warning {{'returnRefType' should be annotated with either SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED as it is returning a SWIFT_SHARED_REFERENC}}
182182

183-
struct DerivedFromRefType : RefType {};
183+
struct DerivedFromRefType final : RefType {};
184184
DerivedFromRefType *returnDerivedFromRefType() { // TODO: rdar://145098078 Missing SWIFT_RETURNS_(UN)RETAINED annotation warning should trigger for inferred foreeign reference types as well
185185
return new DerivedFromRefType();
186186
};

test/Interop/Cxx/foreign-reference/Inputs/reference-counted.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace NS {
1414

1515
struct __attribute__((swift_attr("import_as_ref")))
1616
__attribute__((swift_attr("retain:LCRetain")))
17-
__attribute__((swift_attr("release:LCRelease"))) LocalCount {
17+
__attribute__((swift_attr("release:LCRelease"))) LocalCount final {
1818
int value = 0;
1919

2020
static LocalCount *create() {

test/Interop/Cxx/foreign-reference/extensions.swift

+14
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,24 @@
33

44
import ReferenceCounted
55

6+
protocol MyProto {
7+
func foo() -> Self
8+
}
9+
610
extension NS.LocalCount {
711
static func g() {}
812

913
public func f() {
1014
Self.g()
1115
}
1216
}
17+
18+
extension NS.LocalCount: MyProto {
19+
public func foo() -> Self {
20+
return self
21+
}
22+
}
23+
24+
let x = NS.LocalCount.create()
25+
x.f()
26+
let _ = x.foo()

0 commit comments

Comments
 (0)