Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [vjet-dev] Strict Type Conversion from Object to T

Created bug for this discussion/decision.



On Mar 7, 2013, at 6:38 PM, Justin Early <earlyster@xxxxxxxxx> wrote:

Our current type checking in 0.10 is very strict about converting from Object to T (or some of the derivatives - see below) is not allowed. This is very good to run our coding audit but in practice applications don't worry about this conversion rule. 

I propose we should allow this conversion and provide opt in configuration to allow users to see where there may be issues in their code. 

This also includes 

Object[] -> T
ObjLiteral -> T
ObjLiteral[] -> T[]
ObjLiteral[] -> T

Some of the trouble cases are:

1. function callbacks where  it is difficult to add the cast required but this has highlighted areas of factory functions in library analysis.

//>void doIt(String)
function doIt(a){

}

//>void fn((void fn(Object)) fn)
function funWithCallBack(fn){

}

funWithCallBack(function(p0){
doIt(p0); // get error here - "Invalid argument at 1: cannot convert from Object to String"
})

2.  There are some specific cases that I am finding in ExtJS such as:

Object Literal []  -> MixedCollection
Object -> Mixed

With ExtJs 
MixedCollection can convert from most []
Mixed can convert from Object 


1. I will disable this conversion error (in 0.10) for revisit in 0.11
2. In 0.11 we can make this configurable so users can turn on tighter validation as opt in case
3. Also in 0.11 we should look at vjet doc case for function callbacks 
4. In 0.11 we can also look at adding type converter extensions for exceptional cases such as the ones mentioned ObjectLiteral[] to MixedCollection so adopters/type library / anvil developers can have graduation level of forging their types.




Back to the top