swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.6k stars 10.37k forks source link

Result builder inference from protocol requirement does not work when the attribute is attached to getter #76746

Closed AnthonyLatsis closed 1 month ago

AnthonyLatsis commented 1 month ago

Description

No response

Reproduction

@resultBuilder
enum Builder<T> {
  static func buildBlock(_ t: T...) -> Bool {true}
}
protocol P {
  var x: Bool { @Builder<Int> get }
}
struct Test: P {
  var x: Bool { 1 }
}
error: integer literal value '1' cannot be used as a boolean; did you mean 'true'? [integer_used_as_boolean_literal]
  var x: Bool { 1 }
                ^
                true

Expected behavior

Successful compilation.

Environment

Swift version 6.1-dev (614e8aa79a84486)

Additional information

No response