Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit bcd18e6

Browse files
fishythefishcommit-bot@chromium.org
authored andcommitted
[dart2js] Mark native classes as needed if they have new-rti is-tests or
named type variables. Change-Id: I12af7f8595d6580cac4bc98cad5cd7795f6a71ab Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127964 Commit-Queue: Mayank Patke <fishythefish@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
1 parent ac3b457 commit bcd18e6

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

pkg/compiler/lib/src/js_backend/runtime_types_codegen.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class ClassChecks {
6161

6262
Iterable<TypeCheck> get checks => _map.values;
6363

64+
bool get isEmpty => _map.isEmpty;
65+
6466
@override
6567
String toString() {
6668
return 'ClassChecks($checks)';

pkg/compiler/lib/src/js_emitter/native_emitter.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,13 @@ class NativeEmitter {
251251
field.needsCheckedSetter;
252252
}
253253

254+
// TODO(fishythefish): Have trivial classes redirect to their supertypes in
255+
// the ruleset.
254256
return cls.methods.isEmpty &&
255257
cls.isChecks.isEmpty &&
258+
(cls.classChecksNewRti == null || cls.classChecksNewRti.isEmpty) &&
256259
cls.callStubs.isEmpty &&
260+
cls.namedTypeVariablesNewRti.isEmpty &&
257261
!cls.superclass.isSimpleMixinApplication &&
258262
!cls.fields.any(needsAccessor);
259263
}

tests/compiler/dart2js/rti/emission/event_callback.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import 'dart:html';
77
/*strong.class: global#Event:checkedInstance,checkedTypeArgument,checks=[$isEvent],instance,typeArgument*/
88

99
/*strong.class: global#MouseEvent:checks=[$isMouseEvent],instance,typeArgument*/
10-
/*omit.class: global#MouseEvent:instance*/
10+
/*omit.class: global#MouseEvent:checks=[],instance*/
1111

1212
/*strong.class: global#KeyboardEvent:checks=[$isKeyboardEvent],instance,typeArgument*/
13-
/*omit.class: global#KeyboardEvent:instance*/
13+
/*omit.class: global#KeyboardEvent:checks=[],instance*/
1414

1515
void main() {
1616
print('InputElement');

tests/compiler/dart2js/rti/emission/native.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import 'dart:_foreign_helper' show JS;
1212
@Native('PPPP')
1313
class Purple {}
1414

15-
/*class: Q:instance*/
15+
/*strong.class: Q:checks=[],instance*/
16+
/*omit.class: Q:instance*/
1617
@Native('QQQQ')
1718
class Q {}
1819

tests/compiler/dart2js_native/error_safeToString_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
4+
//
5+
// dart2jsOptions=--no-minify
46

57
import "native_testing.dart";
68
import 'dart:_foreign_helper' show JS_INTERCEPTOR_CONSTANT;
@@ -147,7 +149,7 @@ testNative() {
147149
print('Q: $x ${Error.safeToString(x)}');
148150
// We are going to get either the general interceptor or the JavaScript
149151
// constructor.
150-
Expect.isTrue("Instance of 'QQQQ'" == Error.safeToString(x) ||
152+
Expect.isTrue("Instance of 'Q'" == Error.safeToString(x) ||
151153
interceptorString == Error.safeToString(x));
152154

153155
x = makeR();

0 commit comments

Comments
 (0)