Oxygene array decl form breaks mapped method parameters on Android

I’m working on a SQLite encapsulation which levels the playing field across the different platforms (e.g. named parameters supported on all) and ran into a very strange problem when building a test project for my first cut of the Android implementation. I’ve not (yet) been able to reproduce the issue in a dedicated repro case so it may be something peculiar to other aspects of my project.

I’ll provide my solution if it will help, but first up I thought I’d share the initial problem and see if it rang any bells.

The problem arose when I reached the point of connecting up a Cursor exposed on the Android implementation of my SQLiteQuery to a SimpleCursorAdapter. As part of that I needed an array of column names and view id’s. In my initial attempt I had something like this:

qryTables.Open;

var cursor  := qryTables.Dataset;
var columns : array[1] of String := ['name'];
var views   : array[1] of Integer := [R.id.itemtext];

var adapter := new SimpleCursorAdapter(self, R.layout.listview_item, cursor, columns, views, 0);

This failed to compile but the errors were not in my MainActivity (where this code was written) but in ALL my mapped types in a shared code project referenced by the Android project. In every single case, any method which had a mapping which involved parameters the compiler was complaining that the mapped parameter name reference was an unknown identifier. Mapped methods with no parameters were unaffected.

This only affected the Android project build. All other projects continued to build just fine, using the same shared project.

In the Android project for the errors in the first mapped class declaration each error offered two fix-its for every named parameter. The first to replace the unknown identifier with itself (!) and the other to replace it with a parameter name that appeared to be simply the declared name without the a prefix (it was the wrong case to be the name of the parameter in the underlying mapped type):

In every subsequent mapped class, the same compilation error was reported but where there were multiple parameters in a mapped method, only the first was reported as an error, with no error highlight in the source and no fix-its offered at all.

The mapped types are used exclusively within the SQLite classes in my Android project. They are not referenced directly in the project code itself.

I spent a while trying to figure out what I had done to break my mapped types and after ruling out any changes to he mapped types themselves, issues in the installation, corrupt project, project settings etc, reverted to reversing all my changes in the Android test project to see what happened (it was previously compiling and running just fine, running a query etc, before I added this code to hook the results up to a listview). The reverted code simply stepped thru the result set without referencing the cursor directly:

qryTables.Open;
while not qryTables.EOF do
  qryTables.Next;

The problem disappeared ! This code compiled and ran just fine. There appeared to be nothing intrinsically wrong with the mapped types themselves. I then started re-introducing my MainActivity cursor code to see at what point it would break again (if it did).

What I found was that it was my array declarations that were responsible ! So I then experimented with different array declarations and found that if I changed this:

var columns : array[1] of String = ('name');
var views   := array[1] of Integer = R.id.itemtext;

To this:

var columns := new String[1];
var views   := new Integer[1];

columns[0] := 'name';
views[0]   := R.id.itemtext;

Then I could hook the cursor up to my listview via the adapter and the project would compile, deploy and run perfectly! (yay!) :slight_smile:

As soon as I introduced an array declaration using the previous form the build failed with the same errors in those mapped types. Initialisation of the array doesn’t appear to be a factor, only the form of the declaration:

var foo: array[1] of String;       // Not used but enough to 'break' the mapped types
var columns := new String[1];
var views   := new Integer[1];

columns[0] := 'name';
views[0]   := R.id.itemtext;

This is particularly odd because these array variables are referenced only in the MainActivity code and are passed to the exposed platform Cursor type method. All of the mapped type references and usage are internal to the SQLite classes, so I cannot fathom how these declarations can be having this effect.

Also, I tried adding the same declaration to the program code in .NET, OS X and Java console application projects and it caused no such problem in those cases. Those projects would still build and run successfully, all using the same shared SQLite and mapped type code.

It’s a curious pickle and no mistake. :thinking:

Obviously I now have my solution/work-around: Use the different array declaration form. But I am curious to know what is going wrong or (more importantly) if there is some mistake I am making that I need to be aware of ?

Can you give me some code that shows this behavior? It sounds rather odd but nothing in what you said explains what happens.

I tried re-creating a MCVE without success, so I’ll send you my solution by pm.

Thanks, logged as bugs://75357

bugs://75357 got closed with status fixed.

Logged as bugs://i63341.

bugs://i63341 was closed as fixed.