Files
sdk/pkg/compiler/test/codegen/data/array_add.dart
T
Nate Biggs ef75007c2f [dart2js] Fix as-check type registration.
We would expect failing as checks to throw in all modes (unless --omit-as-casts is provided). However, the new test program fails in production mode. This is because we are not registering the type usage of the function's type parameter. This leads us to drop the as check completely later on.

We should be doing subtype checks with nullability if we want to consider an as test omitted.

Golem patch results: https://golem.corp.goog/Comparison?repository=dart#targetA%3Ddart2js%3BmachineTypeA%3Dlinux-x64%3BrevisionA%3D107840%3BpatchA%3Dnatebiggs--dart2js--Fix-as-check-type-registration.-7%3BtargetB%3Ddart2js%3BmachineTypeB%3Dlinux-x64%3BrevisionB%3D107839%3BpatchB%3DNone

Fixed: https://github.com/dart-lang/sdk/issues/54419
Change-Id: If93f78a939a690f05f5398c1a5ca971df1fc9243
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343821
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-01-09 00:04:50 +00:00

29 lines
745 B
Dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// In prod mode, List.add is lowered to Array.push.
//
// TODO(sra): Lower when type of input does not need a generic covariant check.
@pragma('dart2js:noInline')
/*spec|canary.member: test1:function() {
var t1 = A._setArrayType([], type$.JSArray_int);
B.JSArray_methods.add$1(t1, 1);
return t1;
}*/
/*prod.member: test1:function() {
var t1 = A._setArrayType([], type$.JSArray_int);
t1.push(1);
return t1;
}*/
test1() {
return <int>[]..add(1);
}
/*member: main:function() {
A.test1();
}*/
main() {
test1();
}