-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[generator] Fix NRE from return type not consistently set (#834)
Fixes: dotnet/android#5921 Context: #834 (comment) Context: https://github.com/xamarin/java.interop/blob/100fffc1dc416f543293d0509870138d9d4f1669/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/CodeGenerator.cs#L1175-L1181 Consider the following Java type declaration: package com.example; public interface FlowIterator<R> { R next(); public static class RangeIterator<T extends Comparable<T>> implements FlowIterator<T> { public T next() {return null;} } } This used to work in d16-7 -- not sure when exactly we broke it -- but it now throws a `NullReferenceException` when using `generator --codegen-target=XAJavaInterop1`, when emitting the nested `FlowIteratorRangerIterator` type: $ mono bin/Debug/generator.exe -o yyy ji-834-fixed.xml --codegen-target=XAJavaInterop1 … Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at Xamarin.SourceWriter.MethodWriter.WriteReturnType (Xamarin.SourceWriter.CodeWriter writer) at Xamarin.SourceWriter.MethodWriter.WriteSignature (Xamarin.SourceWriter.CodeWriter writer) at Xamarin.SourceWriter.MethodWriter.Write (Xamarin.SourceWriter.CodeWriter writer) Fix the `NullReferenceException` by ensuring that the `ReturnType` property and `Parameters` collection are set before the `BoundMethodAbstractDeclaration` constructor completes.
- Loading branch information
Showing
2 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters