Property wrappers without parenthesis

Hi!

I've just discovered that if property wrapper has generic parameters other than wrappedValue's type and it has initialiser without arguments under some constraint, you can't use this property wrapper without parenthesis:

enum First {}

@propertyWrapper
struct MagicBox<T, Mode> {
  var wrappedValue: T

  init() where Mode == First {
    fatalError()
  }
}

// Error: Generic parameter 'Mode' could not be inferred
@MagicBox
var foo: Int 

// Works fine
@MagicBox()
var foo: Int

So, as I understand, compiler has enough information to infer Mode parameter, but it can't for some reason. Is that expected behaviour or bug? May be I'm missing something?

1 Like