Start importing factory methods as initializers.

When an Objective-C class method follows the naming convention of a
factory method, i.e., its starting words match the ending words of the
class name, import it as a convenience initializer when it also:
  - Returns instancetype (i.e., dynamic Self in Swift parlance)
  - Has no NSError** parameters, which indicate the potential for failures

This is under a new flag (-enable-objc-factory-method-constructors)
because it is not generally functional. However, this is a step toward
<rdar://problem/16509024>.

Swift SVN r16479
This commit is contained in:
Doug Gregor
2014-04-17 23:34:00 +00:00
parent 318aba81ef
commit f56c68386e
9 changed files with 252 additions and 31 deletions

View File

@@ -566,6 +566,8 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args,
Opts.InferImplicitProperties =
Args.hasArg(OPT_enable_objc_implicit_properties);
Opts.ImportFactoryMethodsAsConstructors =
Args.hasArg(OPT_enable_objc_factory_method_constructors);
return false;
}