Compiler Protocol Init

The initializers declared in compiler protocols such as ExpressibleByArrayLiteral shouldn’t be called directly.

  • Identifier: compiler_protocol_init
  • Enabled by default: Yes
  • Supports autocorrection: No
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning

Non Triggering Examples

let set: Set<Int> = [1, 2]
let set = Set(array)

Triggering Examples

let set = Set(arrayLiteral: 1, 2)
let set = Set (arrayLiteral: 1, 2)
let set = Set.init(arrayLiteral: 1, 2)
let set = Set.init(arrayLiteral : 1, 2)