guillermomuntaner / Burritos

A collection of Swift Property Wrappers (formerly "Property Delegates")
MIT License
1.33k stars 43 forks source link

Getting compile error when using @LazyConstant #13

Closed RomanPodymov closed 3 years ago

RomanPodymov commented 4 years ago

I used Swift 5.1/Xcode 11.1 to reproduce this issue. Consider the following code:

protocol P {
    func f()
}

struct S: P {
    func f() { }
}

func f(p: P) {
    p.f()
}

class C {
    @LazyConstant
    var s: S = {
        return S()
    }()

    func g() {
        f(p: s)
    }
}

Getting the following error: Expression type '()' is ambiguous without more context. To fix it replace f(p: s) with f(p: s as P). But as for me this is a bug. I also created an issue at https://bugs.swift.org.