[generator] Fix NRE when interfaces appear to implement classes. #798
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #797.
In #780 we made a change to only apply the ConstSugar logic to
Mono.Android.dll. However there are of course other libraries written by Google that use the same pattern, namely AndroidX. I still think removing ConstSugar is the correct move for libraries other thanMono.Androidbecause it causes more problems than it solves. (Also ConstSugar is irrelevant in the DIM world we want to move the ecosystem to.)However, there is an issue when other libraries try to create interfaces that inherit
Mono.Android'sAndroid.Provider.BaseColumns.Mono.Android contains:
When we build our Java -> C# typemap, we only support a single map per key, and it just happens that
abstract class BaseColumnswins. Thus when we look for the Symbol that matchesimplements android.provider.BaseColumnswe end up with aclassinstead of atype. We then cast that as anInterfaceGenwhich isnulland hit an NRE.There are probably some deep, risky changes that should happen that would fix this, like supporting multiple entries in our typemap, or not emitting
[Register]on our synthetic classes we create to allow access to Java interface constants.But for today the easiest fix is to bail if we hit this case. The bindings will still be fine since these interfaces are not meant to be implemented, just used to provide access to constants.