Acknowledged
CIQQA-3136

Type checker should prevent devs from passing in class name / classdef where class instance is required

Consider the following incorrect code:

if (Graphics.Dc has :drawAngledText) {
dc.drawAngledText (
dc.getWidth() / 2,
dc.getHeight() / 2,
  Graphics.VectorFont, // Compile-time: White check mark Run-time: "Symbol Not Found Error"
// "hello",
5,
Graphics.TEXT_JUSTIFY_CENTER,
90
);

This compiles without warning or error at all type check levels, but it crashes at runtime with a "Symbol Not Found" error, because "Graphics.VectorFont" [class name / classdef] actually can't be passed into drawAngledText, which requires an *instance* of the class.

This goes back to earlier discourse / bug reports about issues with devs passing in a class name to their own functions or assigning a class name to a variable (then attempting to use that variable in the same way that the class name would normally be used).

I've argued this kind of thing isn't really intended in Monkey C, although clearly Lang.Method.initialize() requires it.

So even if this is a supported coding pattern, it isn't fully supported in the type checker:

- there's seemingly no way to signify in the Monkey Types system that a function takes a class name (as opposed to a class instance)

- the type checker incorrectly accepts a class name where a class instance is required

- if you assign a class or module name to a variable x, type checking is not applied on usages of "dereferencing" x the same way it would be if the class/module name was used directly. In this case, the compiler is unable to determine what symbols are allowed to be used when x is "dereferenced".

e.g.

Toybox.System.getWidth(); // "Cannot find symbol ':getWidth' on type '$.Toybox.System'"" (as expected)

// somewhat non-standard monkey c (imo):
var x = Toybox.System;
x.getWidth(); // "Cannot determine type for method invocation." [*] (only a warning at some levels, so a runtime crash is possible)

[*] others have posted bug reports about this type of warning/error. 

I'd be very curious to hear the intentions/recommendations of the CIQ team, regarding this kind of coding pattern (assigning a class/module name to a function, passing it to a function other than Lang.Method.initialize()). Specifically, should devs be doing this kind of thing, outside of using Lang.Method.initialize()?

References:

https://forums.garmin.com/developer/connect-iq/f/discussion/408902/forerunner-955-drawangledtext-and-drawradialtext-return-symbol-not-found-error/

https://forums.garmin.com/developer/connect-iq/i/bug-reports/type-checker-does-not-detect-access-of-non-existent-symbol-on-class-definition-when-class-is-assigned-to-a-variable

https://forums.garmin.com/developer/connect-iq/f/discussion/407372/class-name-as-function-parameter-how-does-it-work