Analyzer 6.5 doesn't canonicalize element instances, breaking type checks #55739
Labels
analyzer-api
Issues that impact the public API of the analyzer package
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
I have tests that got broken by upgrading from analyzer version 6.4 to version 6.5. From a short investigation, the problem appears to be that I somehow ended up with two
InterfaceType
s having equal, but not identical, elements. AsInterfaceType
s are only equal if their elements are identical, this completely breaks type checks.I unfortunately couldn't find a simple way to reproduce this yet (if having a simpler repro would help I'll investigate more time to reduce this), but this can be reproduced by running these tests:
The tests are all failing due to this condition being hit. Here, I'm calling
typeSystem.isAssignableTo(a, b)
with typesa
andb
that are both anint
type. What's interesting is thatexpectedDartType.element == typeToCheck.element
istrue
, butidentical(expectedDartType.element, typeToCheck.element)
isfalse
! This causes the types to not be equal (despite describing the same thing) and the type system reporting that the types are incompatible.One of the
int
types has been extracted from the type argument of a larger interface type, and the otherint
type is fromTypeProvider
.I was under the impression that that's impossible to reach without seeing an
InconsistentAnalysisException
first (and it's a recent regression), so I figured I'd open an issue. I was unable to reproduce this with a simpler setup doing similar type checks unfortunately, but I can try looking some more if necessary.The text was updated successfully, but these errors were encountered: