ExpressibleByArrayLiteral
shouldn’t be called directly SW-W1027Compiler protocols like ExpressibleByArrayLiteral
define a contract that types adopting the protocol must adhere to. By calling the initializer directly, you bypass this contract and can potentially create instances that do not conform to the expected behavior defined by the protocol. This can lead to runtime errors and unpredictable results.
Compiler protocols often provide a convenient way to initialize instances of a type using literals. By calling the initializer directly, you lose the type safety that the protocol provides. This can lead to code that is harder to understand, maintain, and debug.
let set = Set(arrayLiteral: 1, 2)
let set: Set<Int> = [1, 2]