Skip to content

Commit bbd54ae

Browse files
committed
Ban annotating function type with lifetime dependence
1 parent a91cb28 commit bbd54ae

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7994,6 +7994,9 @@ ERROR(lifetime_dependence_cannot_infer_ambiguous_candidate, none,
79947994
())
79957995
ERROR(lifetime_dependence_immortal_conflict_name, none,
79967996
"conflict between the parameter name and immortal keyword", ())
7997+
ERROR(lifetime_dependence_function_type, none,
7998+
"lifetime dependencies on function types are not supported",
7999+
())
79978000

79988001
//===----------------------------------------------------------------------===//
79998002
// MARK: Sending

lib/Sema/TypeCheckType.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3961,6 +3961,12 @@ NeverNullType TypeResolver::resolveASTFunctionType(
39613961
}
39623962
}
39633963

3964+
if (auto *lifetimeRepr = dyn_cast_or_null<LifetimeDependentReturnTypeRepr>(
3965+
repr->getResultTypeRepr())) {
3966+
diagnoseInvalid(lifetimeRepr, lifetimeRepr->getLoc(),
3967+
diag::lifetime_dependence_function_type);
3968+
}
3969+
39643970
auto resultOptions = options.withoutContext();
39653971
resultOptions.setContext(TypeResolverContext::FunctionResult);
39663972
auto outputTy = resolveType(repr->getResultTypeRepr(), resultOptions);

0 commit comments

Comments
 (0)