Skip to content

Commit 4022e3d

Browse files
authored
Merge pull request swiftlang#34539 from zoecarver/cxx/fix/no-dependent-type-crash
[cxx-interop] Bail on dependent types (instead of crashing).
2 parents f95702c + 949d657 commit 4022e3d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,9 @@ namespace {
211211

212212
ImportResult VisitType(const Type*) = delete;
213213

214+
// TODO: Add support for dependent types (SR-13809).
214215
#define DEPENDENT_TYPE(Class, Base) \
215-
ImportResult Visit##Class##Type(const clang::Class##Type *) { \
216-
llvm_unreachable("Dependent types cannot be converted"); \
217-
}
216+
ImportResult Visit##Class##Type(const clang::Class##Type *) { return Type(); }
218217
#define TYPE(Class, Base)
219218
#include "clang/AST/TypeNodes.inc"
220219

test/Interop/Cxx/templates/Inputs/function-templates.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ decltype(auto) testAuto(T arg) {
3636
return arg;
3737
}
3838

39-
// TODO: Add tests for Decltype, UnaryTransform, and TemplateSpecialization with a dependent type once those are supported.
39+
// TODO: Add tests for Decltype, UnaryTransform, and TemplateSpecialization with
40+
// a dependent type once those are supported.
4041

4142
// TODO: Add test for DeducedTemplateSpecializationType once we support class templates.
43+
44+
// TODO(SR-13809): We don't yet support dependent types but we still shouldn't
45+
// crash when importing one.
46+
template <class T> struct Dep { using TT = T; };
47+
48+
template <class T> void useDependentType(typename Dep<T>::TT) {}

0 commit comments

Comments
 (0)