Yeah, my understanding is that .foo syntax only works if ‘foo’ is an immediate 
static member of the contextual type where the expression appears. So nested 
member access like .foo.b <http://foo.br/>ar does not make sense.

Slava

> On Sep 1, 2017, at 6:04 AM, Adrian Zubarev via swift-users 
> <swift-users@swift.org> wrote:
> 
> Yet this is correct behavior because the compiler cannot traverse the 
> expression tree without knowing the root type of that expression tree. The 
> type information flow in such case should be from root to the leaves where 
> the root is NOT the root of the expression, but the type from the function 
> parameter, which then should be passed to the expression tree. However the 
> expression tree is not complete, because there MIGHT be another 
> `phythagoreanTruple` somewhere else. Even if there is no other 
> `phythagoreanTruple`, here the general rules are applied which results into 
> the mentioned error message.
> 
> Please correct me if I’m wrong here.
> 
> 
> Am 1. September 2017 um 14:53:35, David Hart (da...@hartbit.com 
> <mailto:da...@hartbit.com>) schrieb:
> 
>> Its slightly different though. In the case of:
>> 
>> let cgColor: CGColor = .clear.cgColor
>> 
>> clear is a static property on UIColor, not CGColor. In his example, 
>> pythagoreanTriple is a property on Double so it does feel like a bug.
>> 
>>> On 1 Sep 2017, at 13:31, Adrian Zubarev via swift-users 
>>> <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
>>> 
>>> It’s because the compiler does not support this yet. It’s the same with 
>>> `let cgColor: CGColor = .clear.cgColor // will not work`.
>>> 
>>> Instead you need to write `UIColor.clear.cgColor` or in your case 
>>> `Double.phythagoreanTruple.0`
>>> 
>>> 
>>> Am 1. September 2017 um 12:17:57, Rudolf Adamkovič via swift-users 
>>> (swift-users@swift.org <mailto:swift-users@swift.org>) schrieb:
>>> 
>>>> Given the following extension ...
>>>> 
>>>> extension Double {
>>>>     typealias Triple = (Double, Double, Double)
>>>>     static let pythagoreanTriple: Triple = (3, 4, 5)
>>>> }
>>>> ... why does Swift compiler emits the following errors?
>>>> 
>>>> // Type of expression is ambiguous without more context
>>>> let a: Double = .pythagoreanTriple.0
>>>> 
>>>> // Type of expression is ambiguous without more context
>>>> func f(_ x: Double) {}
>>>> f(.pythagoreanTriple.0)
>>>> The errors disappear with explicit Double.pythagoreanTriple.0.
>>>> 
>>>> Why doesn't the compiler infer Double in this case?
>>>> 
>>>> FYI: Posted also to Stack Overflow here:
>>>> 
>>>> https://stackoverflow.com/questions/45998034/type-of-expression-is-ambiguous-for-static-tuples
>>>>  
>>>> <https://stackoverflow.com/questions/45998034/type-of-expression-is-ambiguous-for-static-tuples>
>>>> R+
>>>> 
>>>> _______________________________________________
>>>> swift-users mailing list
>>>> swift-users@swift.org <mailto:swift-users@swift.org>
>>>> https://lists.swift.org/mailman/listinfo/swift-users
>>> _______________________________________________
>>> swift-users mailing list
>>> swift-users@swift.org <mailto:swift-users@swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-users 
>>> <https://lists.swift.org/mailman/listinfo/swift-users>
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to