I managed to find some time to progress with my Smalltalk / Pharo learning and am going through the Spec booklet. I noticed that autocompletion most of the times works excellent, sometimes it struggles.
For instance, if you prepare
CustomerSatisfaction >> initializeWidgets
buttonBad := self instantiate: ButtonPresenter.
and then start to write
buttonBad label: ...
in the same method, the #label: selector is found immediately.
> On 16 Jun 2019, at 08:41, eftomi <[hidden email]> wrote:
> I found the cause - I created the #buttonBad accessing methods with code
> (re)factoring (generate accessors), and in this case the accessors are made
> in this fashion:
> CustomerSatisfaction >> buttonBad: *anObject
> *buttonBad := *anObject
> *It's better to use
> CustomerSatisfaction >> buttonBad: *aComposablePresenterClass
> *buttonBad := *aComposablePresenterClass
> *as this method is doing:
> ComposablePresenter >> instantiate: aComposablePresenterClass
> "Instantiate a ComposablePresenter subclass and set its instance owner"
> ^ aComposablePresenterClass owner: self
Yes, the problem is that the Type guesser guesses types, but then they are used as
if they would be the truth…
this is done in two cases:
1) names of arguments, as you have seen: if you call it “anArray”, the code completion will only show you method for Array.
2) sends to Globals that are classes: every send of the kind “Class something” will be types as “instance of Class”. Which is not
even true for #new in all cases (see String).
What would be better: distinguish between “types” and “type guess”. The later we should use to sort the results, not to restrict it.
> To find the cause, I used the debugger extensively and found the core logic
> in ECInstVarTypeGuesser >> perform method - it was quite an exercise!