Analyzer fails to use proper context type for conditions of conditional expressions #48199
Labels
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Consider the following code:
The CFE analyzes the subexpression
castObject(true)..whatever()
using a context type ofbool
, so it interprets it ascastObject<bool>(true)..whatever()
. SincecastObject<bool>(true)
has typebool
, the method lookup ofwhatever
fails, and the CFE issues the compile-time error:The analyzer, on the other hand, analyzes the subexpression
castObject(true)..whatever()
with a null context type, so it interprets it ascastObject<dynamic>(true)..whatever()
. SincecastObject<dynamic>(true)
has typedynamic
, the method lookup ofwhatever
is not type checked, so the analyzer issues no error.I believe the CFE's behavior is correct, and this is an oversight in the analyzer implementation.
The text was updated successfully, but these errors were encountered: