Because the name of a direct method must be agreed upon by the caller and the implementation, certain bad practices that one can get away with when using dynamism are fatal with direct methods.
To avoid really weird and unscruttable linker error, tighten the front-end error reporting.
Rule 1:
Direct methods can only have at most one declaration in an @interface container. Any redeclaration is strictly forbidden. Today some amount of redeclaration is tolerated between the main interface and categories for dynamic methods, but we can't have that.
Rule 2:
Direct method implementations can only be declared in a matching @interface container: when implemented in the primary @implementation then the declaration must be in the primary @interface or an extension, and when implemented in a category, the declaration must be in the @interface for the same category.
Also fix another issue with ObjCMethod::getCanonicalDecl(): when an implementation lives in the primary @interface, then its canonical declaration can be in any extension, even when it's not an accessor.
Add Sema tests to cover the new errors, and CG tests to beef up testing around function names for categories and extensions.
Radar-Id: rdar://problem/58054563
Does principal mean the ObjCInterfaceDecl of ImplD? Should we say that instead?