Ambiguous type incorrect?

Is it a bug or not implemented yet? I don't think it's really the ambiguous type.

class Sample {
    static func one() -> Sample {
        return .init()
    }
    func two() -> Sample {
        return self
    }
}

var listOK: [Sample] = [.one(), Sample.one().two()]
var listNotOK: [Sample] = [.one().two()] // Error: Type of expression is ambiguous without more context

var itemOK: Sample = .one()
var itemOK2: Sample = Sample.one().two()
var itemNotOK: Sample = .one().two() // Error: Type of expression is ambiguous without more context

It seems that “implicit member expressions” work only with a single level of automatic type inference, not with nested levels. Another example:

let x: Int = .min // OK
let y: UInt = Int.min.magnitude // OK
let z: UInt = .min.magnitude // Error: Type of expression is ambiguous without more context
1 Like

Yes. It's the current state. But I thank it should't limit to one level.
But I think your example change to these would be more clear:

let x: UInt = .min // OK
let y: UInt = UInt.min.magnitude // OK
let z: UInt = .min.magnitude // Error: Type of expression is ambiguous without more context

Not need to bring in different type Int because if z declare as UInt, the .min.magnitude should be work as UInt.min.magnitude if possible in the future.