Skip to content

Sema: Check the availability of result builder attributes on function parameters #60734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/Sema/TypeCheckAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,9 @@ class DeclAvailabilityChecker : public DeclVisitor<DeclAvailabilityChecker> {
checkType(wrapperType, wrapperAttrs[index]->getTypeRepr(), fn);
}

if (auto attr = P->getAttachedResultBuilder())
checkType(P->getResultBuilderType(), attr->getTypeRepr(), fn);

checkType(P->getInterfaceType(), P->getTypeRepr(), fn);
}
}
Expand Down
5 changes: 4 additions & 1 deletion test/Constraints/result_builder_availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
@available(*, unavailable)
@resultBuilder
struct UnavailableBuilder {
// expected-note@-1 {{'UnavailableBuilder' has been explicitly marked unavailable here}}
// expected-note@-1 2 {{'UnavailableBuilder' has been explicitly marked unavailable here}}
static func buildBlock() {}
}

@UnavailableBuilder public func usesUnavailableBuilder() {}
// expected-error@-1 {{'UnavailableBuilder' is unavailable}}

public func takesUnavailableBuilder(@UnavailableBuilder _ fn: () -> ()) {}
// expected-error@-1 {{'UnavailableBuilder' is unavailable}}

enum Either<T,U> {
case first(T)
case second(U)
Expand Down