Skip to content

Commit a39d2fd

Browse files
committed
C++Interop: Don't create default argument expressions that are templated
SwiftDeclSynthesizer::makeDefaultArgument does not create substituion map while creating the implicit FuncDecl which leads to TypeChecker complaining about the absence when there are type parameters. Avoid importing such C++ functions for now.
1 parent 8a2984e commit a39d2fd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/AST/LifetimeDependence.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,8 @@ LifetimeDependenceInfo::infer(AbstractFunctionDecl *afd) {
547547
}
548548
}
549549

550+
ASSERT(ctx.LangOpts.hasFeature(Feature::NonescapableTypes));
551+
550552
if (!cd && afd->hasImplicitSelfDecl()) {
551553
Type selfTypeInContext = dc->getSelfTypeInContext();
552554
if (selfTypeInContext->isEscapable()) {

lib/ClangImporter/ImportType.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2656,9 +2656,11 @@ static ParamDecl *getParameterInfo(ClangImporter::Implementation *impl,
26562656
// Swift doesn't support default values of inout parameters.
26572657
// TODO: support default arguments of constructors
26582658
// (https://github.com/apple/swift/issues/70124)
2659+
// TODO: support params with template parameters
26592660
if (param->hasDefaultArg() && !isInOut &&
26602661
!isa<clang::CXXConstructorDecl>(param->getDeclContext()) &&
2661-
impl->isDefaultArgSafeToImport(param)) {
2662+
impl->isDefaultArgSafeToImport(param) &&
2663+
!isa<clang::FunctionTemplateDecl>(param->getDeclContext())) {
26622664
SwiftDeclSynthesizer synthesizer(*impl);
26632665
if (CallExpr *defaultArgExpr = synthesizer.makeDefaultArgument(
26642666
param, swiftParamTy, paramInfo->getParameterNameLoc())) {

0 commit comments

Comments
 (0)