Tensegritics / ClojureDart

Clojure dialect for Flutter and Dart
1.41k stars 90 forks source link

Error: Can't use an expression of type 'void Function()?' as a function because it's potentially null. #300

Open dupuchba opened 9 months ago

dupuchba commented 9 months ago

When binding a nullable Function property inference should remove the?

(when-some [cb (-> (m/ContextMenuButtonItem .onPressed nil) .-onPressed)]
    (cb))

will generate

final void Function()? some$6054_$AUTO_$1=const f_material.ContextMenuButtonItem(onPressed: null, ).onPressed;
if((null == some$6054_$AUTO_$1)){
return null;
}
final void Function()? cb$1=some$6054_$AUTO_$1;
return cb$1();

Which throws at compile time

Try calling using ?.call instead.
Performing hot reload...                                        
return cb$1();
           ^
Try again after fixing the above error(s).