mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Deduplicate class export and fix identifier error in ExportNameScopeToCpp (#7550)
Added method_alias.carbon test so that the class export code in `ExportNameScopeToCpp` is tested. Refactored `ExportClassToCpp` so that `ExportNameScopeToCpp` can reuse that code. Moved the `identifier_info` code in `ExportNameScopeToCpp` into the namespace block, because the name scope's name ID is not valid for classes. Added a call to `CompleteType` for classes exported via `ExportNameScopeToCpp`, otherwise a "queried property of class with no definition" assert is later reached (when adding methods) in the call chain `BuildCppToCarbonThunkDecl` -> `DeclContext::addHiddenDecl` -> `CXXRecordDecl::addedMember` -> `CXXRecordDecl::data`.
This commit is contained in:
@@ -88,3 +88,17 @@ void F() {
|
||||
Carbon::C().M();
|
||||
}
|
||||
''';
|
||||
|
||||
// --- method_alias.carbon
|
||||
library "[[@TEST_NAME]]";
|
||||
import Cpp;
|
||||
|
||||
class A {
|
||||
fn F();
|
||||
}
|
||||
|
||||
alias G = A.F;
|
||||
|
||||
inline Cpp '''
|
||||
void call() { Carbon::G(); }
|
||||
''';
|
||||
|
||||
Reference in New Issue
Block a user