Skip to content

Commit

Permalink
[registrar] Fix generic argument check to allow INativeObject. Fixes …
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne authored Feb 28, 2017
1 parent 0889b0d commit d196a78
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions tests/mtouch/RegistrarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,21 @@ class FutureType : NSObject
".*/Test.cs(.*): error MT4164: Cannot export the property 'Complex' because its selector '_Complex' is an Objective-C keyword. Please use a different name.");
}

[Test]
public void MT4167 ()
{
var code = @"
class X : ReplayKit.RPBroadcastControllerDelegate
{
public override void DidUpdateServiceInfo (ReplayKit.RPBroadcastController broadcastController, NSDictionary<NSString, INSCoding> serviceInfo)
{
throw new NotImplementedException ();
}
}
";
Verify (R.Static, code, true);
}

[Test]
public void MultiplePropertiesInHierarchy ()
{
Expand Down
4 changes: 2 additions & 2 deletions tools/common/StaticRegistrar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1968,9 +1968,9 @@ string ToObjCParameterType (TypeReference type, string descriptiveMethodName, Li
if (i > 0)
sb.Append (", ");
var argumentType = git.GenericArguments [i];
if (!IsNSObject (argumentType)) {
if (!IsINativeObject (argumentType)) {
// I believe the generic constraints we have should make this error impossible to hit, but better safe than sorry.
AddException (ref exceptions, CreateException (4167, inMethod.Resolve () as MethodDefinition, "Cannot register the method '{0}' because the signature contains a generic type ({1}) with a generic argument type that isn't an NSObject subclass ({2}).", descriptiveMethodName, GetTypeFullName (type), GetTypeFullName (argumentType)));
AddException (ref exceptions, CreateException (4167, inMethod.Resolve () as MethodDefinition, "Cannot register the method '{0}' because the signature contains a generic type ({1}) with a generic argument type that doesn't implement INativeObject ({2}).", descriptiveMethodName, GetTypeFullName (type), GetTypeFullName (argumentType)));
return "id";
}
sb.Append (ToObjCParameterType (argumentType, descriptiveMethodName, exceptions, inMethod));
Expand Down
2 changes: 1 addition & 1 deletion tools/mtouch/error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ namespace Xamarin.Bundler {
// MT4164 Cannot export the property '{0}' because its selector '{1}' is an Objective-C keyword. Please use a different name.
// MT4165 The registrar couldn't find the type 'System.Void' in any of the referenced assemblies.
// MT4166 Cannot register the method '{0}' because the signature contains a type ({1}) that isn't a reference type.
// MT4167 Cannot register the method '{0}' because the signature contains a generic type ({1}) with a generic argument type that isn't an NSObject subclass ({2}).
// MT4167 Cannot register the method '{0}' because the signature contains a generic type ({1}) with a generic argument type that doesn't implement INativeObject ({2}).
// MT5xxx GCC and toolchain
// MT51xx compilation
// MT5101 Missing '{0}' compiler. Please install Xcode 'Command-Line Tools' component
Expand Down

0 comments on commit d196a78

Please sign in to comment.