Commit Graph

1 Commits

Author SHA1 Message Date
Doug Gregor
31e7be143a Introduce support for the type coercion syntax
T(x)

where T is the name of a type. This syntax either coerces 'x' to the
type T or, failing that, enumerates the constructors of T and invokes
one of them.

Note that, syntactically, this coercion is syntactically identical to
a function application

  f(x)

We distinguish these cases with a simple, syntax-based scheme: if the
'function' subexpression of the application can be trivially
determined to have metatype type, then we consider this a
construction. Otherwise, we assume that it's a function
application. This disallows some crazy coercions---e.g., those that
involve overloaded variables of metatype type---but should feel fairly
intuitive, and it keeps the constraint systems simpler.



Swift SVN r2802
2012-08-28 23:38:23 +00:00