Optionals issue in Fire .2331

I have the following class in Android project in Fire:

class ValueChangeParams<T> {
    
    init(from anOldValue: T, to aNewValue: T) {
        self.newValue = aNewValue
        self.oldValue = anOldValue
    }
    
    public var newValue: T
    public var oldValue: T
}

If I use it like this:

protocol SomeControl {
    func doSomething(_ aParams: Any)
}

extension SomeControl {

    func valueWillChange(from anOldValue: Any?, to aNewValue: Any?) {
        let params = ValueChangeParams<Any?>(from: anOldValue, to: aNewValue)
        doSomething(params)
    }
}

I get the following compilation errors:

Value passed for parameter 1 is nullable but must be not null in call to init(from aNewValue: Any?, to anOldValue: Any?) [CommonLib.Controls.Protocols.swift (62)]
Value passed for parameter 2 is nullable but must be not null in call to init(from aNewValue: Any?, to anOldValue: Any?) [CommonLib.Controls.Protocols.swift (62)]

It compiles fine in Xcode 10.

FTR, it compiled in both, Xcode and Fire when I changed:

func valueWillChange(from anOldValue: Any?, to aNewValue: Any?)

to

func valueWillChange<T>(from anOldValue: T, to aNewValue: T)

So maybe it’s not a bug?

Thanks, logged as bugs://81140

apple swift does seem to have some curious edge cases. I’ll take a look.

For now:

et params = ValueChangeParams<Any?>(from: anOldValue?, to: aNewValue?)

Should fix it, as a temporary solution.

bugs://81140 got closed with status fixed.