Here we could use the test (source is EfficientLengthIterable) except for the lack of type promotion.
Testing an interface type with type variables instantiated to bounds is more efficient since the type arguments do not need to be tested.
dart2js should compile a test like this as a test against the generic type instantiated to bounds rather than the type dependent on a type variable.
@johnniwinther Is there enough information about the related types to do this reliably in the front-end? It would also be beneficial to DDC.
@alexmarkov Does VM-JIT or AOT do this optimization or something similar?
Some type tests have a type argument that is needed for type promotion but unnecessary for operational correctness.
https://github.com/dart-lang/sdk/blob/252bfcb27aa14042ee07e081f25abf60cf6222b3/sdk/lib/internal/cast.dart#L70-L73
Here we could use the test
(source is EfficientLengthIterable)
except for the lack of type promotion. Testing an interface type with type variables instantiated to bounds is more efficient since the type arguments do not need to be tested.dart2js should compile a test like this as a test against the generic type instantiated to bounds rather than the type dependent on a type variable.
@johnniwinther Is there enough information about the related types to do this reliably in the front-end? It would also be beneficial to DDC.
@alexmarkov Does VM-JIT or AOT do this optimization or something similar?