// RUN: %target-typecheck-verify-swift // RUN: %target-typecheck-verify-swift -I %t // This test verifies that `buildBlock` is type-checked together with enclosing context, // which means that it's not captured into separate variable but rather used directly and // contextual information can impact overload resolution. protocol ActionIdentifier: Hashable { } struct ActionLookup { init(_: Identifier...) {} } @resultBuilder enum ActionLookupBuilder { // expected-note 3{{'Identifier' previously declared here}} static func buildBlock(_ components: [ActionLookup]...) -> ActionLookup { // expected-warning {{generic parameter 'Identifier' shadows generic parameter from outer scope with the same name; this is an error in Swift 6}} fatalError() } static func buildBlock(_ components: [ActionLookup]...) -> [ActionLookup] { // expected-warning {{generic parameter 'Identifier' shadows generic parameter from outer scope with the same name; this is an error in Swift 6}} [] } static func buildExpression(_ expression: ActionLookup) -> [ActionLookup] { [] } static func buildOptional(_ component: [ActionLookup]?) -> [ActionLookup] { // expected-warning {{generic parameter 'Identifier' shadows generic parameter from outer scope with the same name; this is an error in Swift 6}} [] } } enum ActionType: String, ActionIdentifier, CaseIterable { case download case upload public typealias ActionTypeLookup = ActionLookup public typealias ActionTypeLookupBuilder = ActionLookupBuilder @ActionTypeLookupBuilder static var test: ActionTypeLookup { ActionTypeLookup( .download ) if true { // If condition is needed to make sure that `buildOptional` affects `buildBlock` resolution. ActionTypeLookup( .upload ) } } }