Files
sdk/pkg/kernel/lib/transformations
Alexander Markov cbb5305f78 [vm/nnbd] Optimize type casts
Add a kernel transformation which removes redundant casts and reduces
some casts to null checks. This transformation assumes that type
system is sound and subtyping relation is transitive. So in NNBD weak
mode this transformation is always correct. In NNBD strong mode
this transformation is correct only if opted-out libraries are not
allowed.

The following patterns are handled:
If S <: T (this includes S <: T? in weak mode)
  S x; x as T => x
If S <: T? in strong mode
  S x; x as T => (x == null) ? x as T : x

This kernel transformation is not specific to the VM and can be reused
by other back-ends such as dart2js and DDC.

Fixes https://github.com/dart-lang/sdk/issues/40892
Issue https://github.com/dart-lang/sdk/issues/40893

Change-Id: I466ba96d763d5358011c768400c5225fa7bf5e67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139314
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-05-19 02:35:12 +00:00
..
2018-03-15 12:22:23 +00:00