[cxx-interop] Implement foreign reference types.#39605
[cxx-interop] Implement foreign reference types.#39605zoecarver merged 1 commit intoswiftlang:mainfrom
Conversation
| if (auto *classDecl = dyn_cast<ClassDecl>(storage->getDeclContext())) { | ||
| if (storage->isFinal() || classDecl->isFinal()) | ||
| if (storage->isFinal() || classDecl->isFinal() || | ||
| classDecl->isForeignReferenceType()) |
There was a problem hiding this comment.
Why is this here? Imported classes can have polymorphic operations. At the very least, this needs a comment.
6cf5f8e to
dd2f450
Compare
dd2f450 to
b693fc7
Compare
|
@rjmccall this should be ready for re-review now. I think I addressed all your comments. Let me know what you think. Note: I still need to fix the issue with optionals (unless some macro tells us otherwise, we should be importing foreign reference types as optionals). I'll do that shortly, but I think the rest of the PR can still be reviewed without that change. |
5a89572 to
65b4f3c
Compare
|
@swift-ci please smoke test. |
|
@rjmccall friendly ping :) |
|
@swift-ci please smoke test. |
|
@rjmccall friendly ping :) |
65b4f3c to
89fc96a
Compare
include/swift/AST/Decl.h
Outdated
There was a problem hiding this comment.
This is not ideal, but I think it's OK because we never construct a const decl, right?
89fc96a to
191800f
Compare
|
@swift-ci please smoke test. |
6e17e51 to
ed9dad3
Compare
|
@swift-ci please smoke test. |
|
@rjmccall friendly ping :) |
6feca79 to
298cb75
Compare
c6f92e4 to
815b95a
Compare
|
@swift-ci please smoke test. |
815b95a to
649b072
Compare
|
@swift-ci please smoke test. |
1 similar comment
|
@swift-ci please smoke test. |
649b072 to
f01913e
Compare
|
@swift-ci please smoke test. |
f01913e to
58d5f52
Compare
|
@swift-ci please smoke test Linux. |
58d5f52 to
817a695
Compare
|
@swift-ci please smoke test Linux. |
817a695 to
9f0119b
Compare
|
@swift-ci please smoke test Linux. |
9f0119b to
c38d1ed
Compare
|
@swift-ci please smoke test Linux. |
c38d1ed to
ae9b541
Compare
|
@swift-ci please smoke test. |
This is an expiremental feature to allow an attribute, `import_as_ref`, to import a C++ record as a non-reference-counted reference type in Swift.
ae9b541 to
fc3b3a1
Compare
|
@swift-ci please smoke test. |
| } | ||
|
|
||
| bool CanType::isForeignReferenceType() { | ||
| if (auto *classDecl = getPointer()->lookThroughAllOptionalTypes()->getClassOrBoundGenericClass()) |
There was a problem hiding this comment.
Looks like you duplicate the logic here. Can you call getPointer()->isForeignReferenceType() instead?
| public func test(_ _: AnyObject) {} | ||
|
|
||
| // TODO: make this a better error. | ||
| test(Empty.create()) // expected-error {{type of expression is ambiguous without more context}} |
There was a problem hiding this comment.
Add a test for casting explicitly to any object.
| IntPair passThroughByValue(IntPair x) { return x; } | ||
|
|
||
| struct __attribute__((swift_attr("import_as_ref"))) RefHoldingPair { | ||
| // REVIEW-NOTE: I added support for this but then removed it, as this sort of |
- swiftlang#58975 switched many tests from XFAIL on linux to linux-gnu, so seven fail on the Android CI and two natively. They are now explicitly excluded. - swiftlang#39605 added several C++ Interop tests, 11 of which fail on the Android CI, so disable them for now. - swiftlang#42478 removed the @NoEscape attribute for the non-Android SIL/clang-function-types tests, so I remove it for Android too. - My pull swiftlang#40779 moved the Swift pointer tags to the second byte, so SILOptimizer/concat_string_literals.64 will need to be updated for that, disabled it for now. - Compiler-rt moved the directory in which it places those libraries for Android, llvm/llvm-project@a68ccba, so lit.cfg is updated for that.
This is an experimental feature to allow an attribute,
import_as_ref, to import a C++ record as a non-reference-counted reference type in Swift.