Skip to content

Commit 413fb37

Browse files
committed
[Print as C++] Don't crash on sugared types
1 parent 2c40a85 commit 413fb37

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/PrintAsClang/PrintClangFunction.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@ class CFunctionSignatureTypePrinter
152152
if (printIfKnownSimpleType(alias, optionalKind, isInOutParam))
153153
return ClangRepresentation::representable;
154154

155-
return visitPart(aliasTy->getSinglyDesugaredType(), optionalKind,
155+
return visitSugarType(aliasTy, optionalKind, isInOutParam);
156+
}
157+
158+
ClangRepresentation visitSugarType(SugarType *sugarTy,
159+
Optional<OptionalTypeKind> optionalKind,
160+
bool isInOutParam) {
161+
return visitPart(sugarTy->getSinglyDesugaredType(), optionalKind,
156162
isInOutParam);
157163
}
158164

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend %s -typecheck -clang-header-expose-public-decls -emit-clang-header-path %t/function_with_array.h
3+
// RUN: %FileCheck %s < %t/function_with_array.h
4+
5+
// CHECK: namespace function_with_array
6+
// FIXME: we don't actually emit a declaration for this, but for now at least
7+
// check that we don't crash.
8+
// CHECK-NOT: void f
9+
public func f(_: [Int]) { }

0 commit comments

Comments
 (0)