Implement SE-0001: Allow (most) keywords as argument labels.

Allow all keywords except for parameter introducers (var/let/inout) to
be argument labels when declaring or calling a
function/initializer/subscript, e.g., this

  func touchesMatching(phase: NSTouchPhase, `in` view: NSView?) -> Set<NSTouch>

can now be expressed as

  func touchesMatching(phase: NSTouchPhase, in view: NSView?) -> Set<NSTouch>

and the call goes from

  event.touchesMatching(phase, `in`: view)

to

  event.touchesMatching(phase, in: view)

Fixes [SR-344](https://bugs.swift.org/browse/SR-344) /
rdar://problem/22415674.
This commit is contained in:
Doug Gregor
2015-12-22 16:15:37 -08:00
parent 5b35c786b8
commit c8dd8d0661
16 changed files with 160 additions and 42 deletions

View File

@@ -27,6 +27,13 @@
using namespace swift;
using namespace camel_case;
bool swift::canBeArgumentLabel(StringRef identifier) {
if (identifier == "var" || identifier == "let" || identifier == "inout")
return false;
return true;
}
PrepositionKind swift::getPrepositionKind(StringRef word) {
#define DIRECTIONAL_PREPOSITION(Word) \
if (word.equals_lower(#Word)) \