mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Resolve result builder type in innermost decl context
This commit is contained in:
@@ -379,7 +379,7 @@ Type ResultBuilderTypeRequest::evaluate(Evaluator &evaluator,
|
||||
|
||||
// Resolve a type for the attribute.
|
||||
auto mutableAttr = const_cast<CustomAttr*>(attr);
|
||||
auto dc = decl->getDeclContext();
|
||||
auto *dc = decl->getInnermostDeclContext();
|
||||
auto &ctx = dc->getASTContext();
|
||||
Type type = evaluateOrDefault(
|
||||
evaluator,
|
||||
|
||||
40
test/Constraints/result_builder_generic_exec.swift
Normal file
40
test/Constraints/result_builder_generic_exec.swift
Normal file
@@ -0,0 +1,40 @@
|
||||
// No warnings.
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
//
|
||||
// RUN: %target-run-simple-swift | %FileCheck %s
|
||||
//
|
||||
// REQUIRES: executable_test
|
||||
|
||||
@resultBuilder
|
||||
struct Builder<T> {
|
||||
static func buildBlock(_ args: T...) -> [T] { args }
|
||||
}
|
||||
|
||||
// https://github.com/swiftlang/swift/issues/72739
|
||||
do {
|
||||
@Builder<T>
|
||||
func buildArray<T>(_ t1: T, _ t2: T, _ t3: T) -> [T] {
|
||||
t1
|
||||
t2
|
||||
t3
|
||||
}
|
||||
|
||||
enum TypeContext {
|
||||
@Builder<T>
|
||||
static func buildArray<T>(_ t1: T, _ t2: T, _ t3: T) -> [T] {
|
||||
t1
|
||||
t2
|
||||
t3
|
||||
}
|
||||
}
|
||||
|
||||
// CHECK: begin
|
||||
print("begin")
|
||||
// CHECK-NEXT: [1, 2, 3]
|
||||
print(buildArray(1, 2, 3))
|
||||
// CHECK-NEXT: [1, 2, 3]
|
||||
print(TypeContext.buildArray(1, 2, 3))
|
||||
// CHECK-NEXT: end
|
||||
print("end")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user