Hello Juraj,

RoelTyper guesses types from message sends mainly.
In your example, there is no message sent to the iv 'color' so it has not 
enough information to guess it's type.
The rule of thumb is the more code you have the more precise the type inference 
is.
RoelTyper can also guess types from assignments but it's limited. 
It can guess the type of the right-hand expression of an assignment:
- if it's a global or a literal the type is known statically.
- if it's a message send to a class and if the corresponding method is 
classified under 'instance-creation' it assumes that the type is the class. In 
your example it doesn't do that assumption since #black is categorized under 
'defaults'.
There is maybe some other cases that I don't remember.

Cheers,
Camille
 
On 19 août 2014, at 21:42, Juraj Kubelka <juraj.kube...@gmail.com> wrote:

> Hi,
> 
> I play with RoelTyper, but it does not work as I expect. I have a simple 
> class:
> 
> -=-=-=-
> Object subclass: #AMock
>       instanceVariableNames: 'color'
>       classVariableNames: ''
>       poolDictionaries: ''
>       category: 'JK-Mocks’
> -=-=-=-
> 
> with method:
> 
> -=-=-=-
> initialize 
>       super initialize.
>       color := Color black.
> -=-=-=-
> 
> When the following command is evaluated:  (TypeCollector typeInstvar: #color 
> ofClass: AMock) types 
> RoelTyper returns "an OrderedCollection(Object)”
> 
> I expected Color. 
> 
> Do I miss something? 
> Thanks,
> Juraj


Reply via email to