This type is private, and can only be used within its module

Hi

I am a bit confused and I wonder if someone can give me some guidance.

I have a simple app with one window and one module.
The module contains 5 classes; some methods in one class use the other classes within the module.
All classes within the module and all methods/properties within the classes are set to Public scope and none are subclasses.

Xojo complains when compiling that “This type is private, and can only be used within its module.” when I Dim either of just two of the classes within the methods of another. But is happily allowing me to Dim another of the classes just one line above the ‘offending’ code. If I set those two classes to Global scope then compilation error goes away. If I remove the module name from the dimension line then the error goes away.

In the code below ‘Foo’ is my Module name and Rest, Request, Response are classes with Public scope inside the Foo Module, the code snippets are from a method in another class in the Foo Module that also has Public scope and the method itself has Public scope.

Example that has compilation error:


Dim rst as new Foo.Rest  // ok
Dim req as new Foo.Request  // This type is private and can only be used within its module
Dim res as new Foo.Response  // This type is private and can only be used within its module

Example that compiles (and works) Ok:


Dim rst as new Foo.Rest  // ok
Dim req as new Request  // ok
Dim res as new Response  // ok

This issue only surfaced when I decided to refactor and put the classes inside a module. Is it a bug or something that I do not understand properly?

Any ideas appreciated…

Any chance you could upload an example project somewhere? It’s easier to reply correctly if there’s the actual code in front of me.

Hi Joe

I just found my bug, my fault - my problem is that I use other languages. I simplified the code in my first post and it obscured the variable naming error. I am not used to the case insensitivity and Xojo’s inability to differentiate between a namespace name and a variable name. It should have looked more like:

Dim foo as new Foo.Rest  // ok
Dim req as new Foo.Request  // This type is private and can only be used within its module
Dim res as new Foo.Response  // This type is private and can only be used within its module

And I should have been more suspicious of the first line working ok and the subsequent lines failing!

Sorry for the disturbance