Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[registrar] Fix generic argument check to allow INativeObject. Fixes #52868. #1803

Merged
merged 1 commit into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/mtouch/RegistrarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,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 @@ -1959,9 +1959,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 @@ -289,7 +289,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