Hi all, 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
sizeof(UInt) which should be sizeof(UInt.self) 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? https://github.com/apple/swift-evolution/blob/master/proposals/0090-remove-dot-self.md 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). Thoughts? - Doug
enforce-metatype-self.patch
Description: Binary data
_______________________________________________ swift-dev mailing list swift-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-dev