[swift-evolution] Making `.self` After `Type` Optional

Tanner Nelson tannernelson at gmail.com
Wed Mar 9 15:24:28 CST 2016


That makes sense in the context of saying something like 

	let foo = Foo.self

But I don't see any utility for method arguments since those will almost always be typed.

	func needsAnObject(object: Foo) {}

	needsAnObject(Foo)
                                  ^~~ cannot convert Foo.Type to Foo


> On Mar 9, 2016, at 4:14 PM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> I would like to propose making `.self` After a Type optional when referencing Types in expressions.
> 
>> This has been confirmed as a bug, and the report can be seen here <https://bugs.swift.org/browse/SR-899>.
>> 
>> After a Twitter conversation with Joe Groff on the Swift team (https://twitter.com/jckarter/status/707287663586324481) it is determined that this requirement is due to difficulty disambiguating generics `Foo<T>` vs infix less-than operations `Foo < T`.
> 
> My understanding from previous Twitter discussions is that the primary reason for this feature is to keep you from writing `Foo` where you meant `Foo()`. That is, it's a deliberate design, meant to keep you from making mistakes. I suspect that you will have to overcome *that* impulse, not just any narrow parsing issue.
> 
> -- 
> Brent Royal-Gordon
> Architechies
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list