Skip to content

Commit b6574b5

Browse files
authored
Merge pull request #60215 from zoecarver/diags-record-in-namesapce
[cxx-interop][diags] Fix diagnostics for records inside namespaces.
2 parents 4eb1dbd + d59d32f commit b6574b5

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,12 @@ static Type diagnoseUnknownType(TypeResolution resolution,
12531253
.diagnose(comp->getNameLoc(), diag::invalid_member_type,
12541254
comp->getNameRef(), kind, parentType)
12551255
.highlight(parentRange);
1256+
1257+
if (!ctx.LangOpts.DisableExperimentalClangImporterDiagnostics) {
1258+
ctx.getClangModuleLoader()->diagnoseMemberValue(
1259+
comp->getNameRef().getFullName(), parentType);
1260+
}
1261+
12561262
return ErrorType::get(ctx);
12571263
}
12581264

@@ -1308,6 +1314,12 @@ static Type diagnoseUnknownType(TypeResolution resolution,
13081314
.diagnose(comp->getNameLoc(), diag::invalid_member_type,
13091315
comp->getNameRef(), kind, parentType)
13101316
.highlight(parentRange);
1317+
1318+
if (!ctx.LangOpts.DisableExperimentalClangImporterDiagnostics) {
1319+
ctx.getClangModuleLoader()->diagnoseMemberValue(
1320+
comp->getNameRef().getFullName(), parentType);
1321+
}
1322+
13111323
// Note where the type was defined, this can help diagnose if the user
13121324
// expected name lookup to find a module when there's a conflicting type.
13131325
if (auto typeDecl = parentType->getNominalOrBoundGenericNominal()) {

test/Interop/Cxx/class/invalid-class-errors.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,19 @@ struct __attribute__((swift_attr("import_unsafe"))) B {
1717
B(const B&) = delete;
1818
};
1919

20+
namespace Namespace {
21+
struct Nested {
22+
Nested(const Nested&) = delete;
23+
};
24+
}
25+
2026
//--- test.swift
2127

2228
import Test
2329

2430
// CHECK: note: record 'A' is not automatically importable: does not have a copy constructor or destructor. Refer to the C++ Interop User Manual to classify this type.
2531
public func test(x: A) { }
2632
// CHECK: note: record 'B' is not automatically importable: does not have a copy constructor or destructor. Refer to the C++ Interop User Manual to classify this type.
27-
public func test(x: B) { }
33+
public func test(x: B) { }
34+
// CHECK: note: record 'Nested' is not automatically importable: does not have a copy constructor or destructor. Refer to the C++ Interop User Manual to classify this type.
35+
public func test(x: Namespace.Nested) { }

0 commit comments

Comments
 (0)