While working on some unrelated refactoring, I stumbled across a minor fix that would make use properly enforce “.self” when we want to get the metatype of a named type. For example, the Swift compiler currently (incorrectly) allows
which should be
The fix for this is actually pretty simple (patch attached), but the question is… do we want to fix the problem, if we think that we’ll get SE-0090 that makes “.self” go away?
On the one hand, I want to fix the problem:
* This came out of a desire to make the AST more sane. Essentially, the folding of expressions into TypeExprs—which will go away entirely if/when SE-0090 is implemented—is pulling in the parentheses describing call arguments. Without the fix, we still have weird AST.
* SE-0090 is labeled as “deferred out of Swift 3”, so having the compiler not implement the stated language for an entire release cycle seems really unfortunate.
OTOH, I don’t want to jerk people’s code around, forcing them to add “.self” now only to remove it a year from now (or whenever).
enforce-metatype-self.patch (5.89 KB)