Skip to content
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
2 changes: 2 additions & 0 deletions docs/website/mtouch-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2642,6 +2642,8 @@ If this is an API exposed by Xamarin, please file a new issue on
[GitHub](https://github.com/xamarin/xamarin-macios/issues/new), if it's a
third-party binding, please contact the vendor.

### MT4180: Cannot construct an instance of the type '*' from Objective-C because the type is abstract. [Runtime exception]

## MT5xxx: GCC and toolchain error messages

### MT51xx: Compilation
Expand Down
8 changes: 8 additions & 0 deletions tools/dotnet-linker/Steps/ManagedRegistrarStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,14 @@ public void EmitCallToExportedMethod (MethodDefinition method, MethodDefinition
il.Emit (OpCodes.Throw);
// We're throwing an exception, so there's no need for any more code.
skipEverythingAfter = il.Body.Instructions.Last ();
} else if (method.DeclaringType.IsAbstract) {
il.Emit (OpCodes.Ldc_I4, 4180);
postLeaveBranch.Operand = il.Body.Instructions.Last ();
il.Emit (OpCodes.Ldstr, $"Cannot construct an instance of the type '{method.DeclaringType.FullName}' from Objective-C because the type is abstract.");
il.Emit (OpCodes.Call, abr.Runtime_CreateRuntimeException);
il.Emit (OpCodes.Throw);
// We're throwing an exception, so there's no need for any more code.
skipEverythingAfter = il.Body.Instructions.Last ();
} else {
// Whenever there's an NSObject constructor that we call from a registrar callback, we need to create
// a separate constructor that will first set the `handle` and `flags` values of the NSObject before
Expand Down