-
Notifications
You must be signed in to change notification settings - Fork 10.5k
C++ Interop: improve skipping already imported struct members #38439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef TEST_INTEROP_CXX_NAMESPACE_INPUTS_TEMPLATES_WITH_FORWARD_DECL_H | ||
#define TEST_INTEROP_CXX_NAMESPACE_INPUTS_TEMPLATES_WITH_FORWARD_DECL_H | ||
|
||
namespace NS1 { | ||
|
||
template <typename T> | ||
struct Decl; | ||
|
||
typedef Decl<int> di; | ||
|
||
} // namespace NS1 | ||
|
||
namespace NS1 { | ||
|
||
template <typename T> | ||
struct ForwardDeclared; | ||
|
||
template <typename T> | ||
struct Decl { | ||
typedef T MyInt; | ||
ForwardDeclared<T> fwd; | ||
const static MyInt intValue = -1; | ||
}; | ||
|
||
template <typename T> | ||
const typename Decl<T>::MyInt Decl<T>::intValue; | ||
|
||
} // namespace NS1 | ||
|
||
namespace NS1 { | ||
|
||
template <typename T> | ||
struct ForwardDeclared {}; | ||
|
||
} // namespace NS1 | ||
|
||
#endif // TEST_INTEROP_CXX_NAMESPACE_INPUTS_TEMPLATES_WITH_FORWARD_DECL_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// RUN: %target-swift-ide-test -print-module -module-to-print=TemplatesWithForwardDecl -I %S/Inputs -source-filename=x -enable-cxx-interop | %FileCheck %s | ||
|
||
// CHECK: extension NS1 { | ||
// CHECK: struct __CxxTemplateInstN3NS14DeclIiEE { | ||
// CHECK: typealias MyInt = Int32 | ||
// CHECK: var fwd: NS1.__CxxTemplateInstN3NS115ForwardDeclaredIiEE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we check these class template specializations too? Might as well, these module interface tests are pretty easy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Amusingly, we would need #37695 for that :) Currently the lookup logic gets confused & only the contents of the first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Maybe if you think of it, you could fix this as a follow up. But it's not super important. The test is good as is. |
||
// CHECK: static let intValue: NS1.__CxxTemplateInstN3NS14DeclIiEE.MyInt | ||
// CHECK: } | ||
// CHECK: } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Come to think of it, I bet you could get this behavior without using a template. Can you please try that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm that's weird, but it doesn't seem reproducible without a template. I'll need a bit more time to figure out why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is interesting. It would be good to understand why we need this to be a template. But in the mean time, I don't think this patch should be blocked on that.