Skip to content

Commit 8863d99

Browse files
committed
Add regression test, and actually fix
1 parent fbdc88e commit 8863d99

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7915,8 +7915,7 @@ void SwiftASTContext::DumpTypeDescription(opaque_compiler_type_t type,
79157915
bool print_help_if_available,
79167916
bool print_extensions_if_available,
79177917
lldb::DescriptionLevel level) {
7918-
llvm::SmallVector<char, 1024> buf;
7919-
llvm::raw_svector_ostream llvm_ostrm(buf);
7918+
const auto initial_written_bytes = s->GetWrittenBytes();
79207919

79217920
if (type) {
79227921
swift::CanType swift_can_type(GetCanonicalSwiftType(type));
@@ -8082,11 +8081,8 @@ void SwiftASTContext::DumpTypeDescription(opaque_compiler_type_t type,
80828081
}
80838082
}
80848083

8085-
if (buf.size() > 0) {
8086-
s->Write(buf.data(), buf.size());
8087-
} else {
8084+
if (s->GetWrittenBytes() == initial_written_bytes)
80888085
s->Printf("<could not resolve type>");
8089-
}
80908086
}
80918087

80928088
TypeSP SwiftASTContext::GetCachedType(ConstString mangled) {

lldb/test/API/lang/swift/printdecl/TestSwiftTypeLookup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ def test_swift_type_lookup(self):
5656
'func bar()',
5757
'var b'])
5858

59+
# Regression test. Ensure "<could not resolve type>" is not output.
60+
self.expect(
61+
"type lookup String",
62+
matching=False,
63+
substrs=["<could not resolve type>"])
64+
5965
# check that specifiers are honored
6066
# self.expect('type lookup class Cla1', substrs=['class Cla1 {'])
6167
# self.expect('type lookup struct Cla1', substrs=['class Cla1 {'], matching=False, error=True)

0 commit comments

Comments
 (0)