Skip to content

Commit

Permalink
[ddc] Compare types with new DartTypeEquivalence
Browse files Browse the repository at this point in the history
Avoids an assertion failure in the front end.

Change-Id: I7994fa611f82011857750cc60af64a2c89c96bf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152923
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
  • Loading branch information
nshahan authored and commit-bot@chromium.org committed Jul 6, 2020
1 parent f42889f commit 9547628
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/dev_compiler/lib/src/kernel/compiler.dart
Expand Up @@ -12,6 +12,7 @@ import 'package:kernel/kernel.dart' hide MapEntry;
import 'package:kernel/library_index.dart';
import 'package:kernel/type_algebra.dart';
import 'package:kernel/type_environment.dart';
import 'package:kernel/src/dart_type_equivalence.dart';
import 'package:source_span/source_span.dart' show SourceLocation;
import 'package:path/path.dart' as p;

Expand Down Expand Up @@ -5331,7 +5332,8 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
}

if (!isTypeError &&
from.withDeclaredNullability(Nullability.nonNullable) == to &&
DartTypeEquivalence(_coreTypes, ignoreTopLevelNullability: true)
.areEqual(from, to) &&
_mustBeNonNullable(to)) {
// If the underlying type is the same, we only need a null check.
return runtimeCall('nullCast(#, #)', [jsFrom, _emitType(to)]);
Expand Down

0 comments on commit 9547628

Please sign in to comment.