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

Commit ac38a9d

Browse files
committed
Version 2.16.0-134.5.beta
* Cherry-pick 3b440de to beta * Cherry-pick d9b69e9 to beta * Cherry-pick d172051 to beta * Cherry-pick 4bf6354 to beta
2 parents 455fe9d + 51a46f7 commit ac38a9d

File tree

13 files changed

+212
-12
lines changed

13 files changed

+212
-12
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ vars = {
108108
"dart_style_rev": "08b0294d0a500d5c02168ef57dcb8868d0c3cb48",
109109

110110
"dartdoc_rev" : "11c4b3c9723bfa7155efcf0fef02329233a6381d",
111-
"devtools_rev" : "85932bb66aa782c4b2c528be7718960bf256ffb7",
111+
"devtools_rev" : "013958fbd45351e5975068756b7b9114465a7f98",
112112
"jsshell_tag": "version:88.0",
113113
"ffi_rev": "4dd32429880a57b64edaf54c9d5af8a9fa9a4ffb",
114114
"fixnum_rev": "16d3890c6dc82ca629659da1934e412292508bba",

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class NativeEmitter {
9494

9595
Class objectClass = null;
9696
Class jsInterceptorClass = null;
97+
Class jsJavaScriptObjectClass = null;
9798

9899
void walk(Class cls) {
99100
if (cls.element == _commonElements.objectClass) {
@@ -104,6 +105,11 @@ class NativeEmitter {
104105
jsInterceptorClass = cls;
105106
return;
106107
}
108+
// Native classes may inherit either `Interceptor` e.g. `JSBool` or
109+
// `JavaScriptObject` e.g. `dart:html` classes.
110+
if (cls.element == _commonElements.jsJavaScriptObjectClass) {
111+
jsJavaScriptObjectClass = cls;
112+
}
107113
if (seen.contains(cls)) return;
108114
seen.add(cls);
109115
walk(cls.superclass);
@@ -215,6 +221,9 @@ class NativeEmitter {
215221
// by getNativeInterceptor and custom elements.
216222
if (_nativeCodegenEnqueuer.hasInstantiatedNativeClasses) {
217223
fillNativeInfo(jsInterceptorClass);
224+
if (jsJavaScriptObjectClass != null) {
225+
fillNativeInfo(jsJavaScriptObjectClass);
226+
}
218227
for (Class cls in classes) {
219228
if (!cls.isNative || neededClasses.contains(cls)) {
220229
fillNativeInfo(cls);

pkg/compiler/test/jsinterop/internal_annotations_test.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,15 @@ $mainSource
184184
"Expected $name to be indirectly instantiated in `${mainSource}`:"
185185
"\n${world.classHierarchy.dump(cls)}");
186186
}
187-
if (!isInstantiated && (name != 'Object' && name != 'Interceptor')) {
187+
// Classes that are expected to be instantiated by default. `Object` and
188+
// `Interceptor` are base types for non-native and native types, and
189+
// `JavaScriptObject` is the base type for `dart:html` types.
190+
var insantiatedBaseClasses = [
191+
'Object',
192+
'Interceptor',
193+
'JavaScriptObject'
194+
];
195+
if (!isInstantiated && !insantiatedBaseClasses.contains(name)) {
188196
Expect.isFalse(
189197
world.classHierarchy.isInstantiated(cls),
190198
"Expected $name to be uninstantiated in `${mainSource}`:"

pkg/compiler/test/jsinterop/world_test.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,15 @@ $mainSource
178178
"Expected $name to be indirectly instantiated in `${mainSource}`:"
179179
"\n${world.classHierarchy.dump(cls)}");
180180
}
181-
if (!isInstantiated && (name != 'Object' && name != 'Interceptor')) {
181+
// Classes that are expected to be instantiated by default. `Object` and
182+
// `Interceptor` are base types for non-native and native types, and
183+
// `JavaScriptObject` is the base type for `dart:html` types.
184+
var insantiatedBaseClasses = [
185+
'Object',
186+
'Interceptor',
187+
'JavaScriptObject'
188+
];
189+
if (!isInstantiated && !insantiatedBaseClasses.contains(name)) {
182190
Expect.isFalse(
183191
world.classHierarchy.isInstantiated(cls),
184192
"Expected $name to be uninstantiated in `${mainSource}`:"

sdk/bin/dartanalyzer_sdk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# Run dartanalyzer.dart on the Dart VM. This script assumes the Dart SDK's
77
# directory structure.
88

9+
echo "Warning: 'dartanalyzer' is deprecated. Please use 'dart analyze'." 1>&2
10+
911
function follow_links() {
1012
file="$1"
1113
while [ -h "$file" ]; do

sdk/bin/dartanalyzer_sdk.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ REM Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
33
REM for details. All rights reserved. Use of this source code is governed by a
44
REM BSD-style license that can be found in the LICENSE file.
55

6+
echo Warning: 'dartanalyzer' is deprecated. Please use 'dart analyze'. 1>&2
7+
68
setlocal
79
rem Handle the case where dart-sdk/bin has been symlinked to.
810
set DIR_NAME_WITH_SLASH=%~dp0

sdk/lib/_internal/js_runtime/lib/js_helper.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,19 +415,21 @@ class Primitives {
415415

416416
var interceptor = getInterceptor(object);
417417
if (identical(interceptor, JS_INTERCEPTOR_CONSTANT(Interceptor)) ||
418+
identical(interceptor, JS_INTERCEPTOR_CONSTANT(JavaScriptObject)) ||
418419
object is UnknownJavaScriptObject) {
419420
// Try to do better. If we do not find something better, fallthrough to
420-
// Dart-type based name that leave the name as 'UnknownJavaScriptObject'
421-
// or 'Interceptor' (or the minified versions thereof).
421+
// Dart-type based name that leave the name as 'UnknownJavaScriptObject',
422+
// 'Interceptor', or 'JavaScriptObject' (or their minified versions).
422423
//
423424
// When we get here via the UnknownJavaScriptObject test (for JavaScript
424425
// objects from outside the program), the object's constructor has a
425426
// better name that 'UnknownJavaScriptObject'.
426427
//
427-
// When we get here the Interceptor test (for Native classes that are
428-
// declared in the Dart program but have been 'folded' into Interceptor),
429-
// the native class's constructor name is better than the generic
430-
// 'Interceptor' (an abstract class).
428+
// When we get here via either the Interceptor or JavaScriptObject test
429+
// (for Native classes that are declared in the Dart program but have been
430+
// 'folded' into one of those interceptors), the native class's
431+
// constructor name is better than the generic 'Interceptor' or
432+
// 'JavaScriptObject'.
431433

432434
// Try the [constructorNameFallback]. This gets the constructor name for
433435
// any browser (used by [getNativeInterceptor]).

tests/web/dart2js.status

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ deferred_split_test: Slow, Pass # Issue 25940
2424
[ $compiler == dart2js && $runtime == chrome && $csp ]
2525
deferred/load_in_correct_order_test: SkipByDesign # Purposely uses `eval`
2626

27+
[ $compiler == dart2js && $runtime == d8 ]
28+
internal/object_members_test: SkipByDesign # Browser test
29+
2730
[ $compiler == dart2js && $runtime == ff && $system == windows ]
2831
consistent_index_error_string_test: Slow, Pass # Issue 25940
2932

3033
[ $compiler == dart2js && $csp ]
3134
deferred_custom_loader_test: SkipByDesign # Issue 25683
3235
deferred_fail_and_retry_test: SkipByDesign # Uses eval to simulate failed loading.
36+
internal/object_members_test: SkipByDesign # Uses eval for interop
3337

3438
[ $compiler == dart2js && !$host_checked ]
3539
dummy_compiler_test: Slow, Pass # Issue 32439. self-hosting doesn't work with CFE yet.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Make sure `Object` methods work as expected with `dart:html` and interop
6+
// types. The expectations here aren't guarantees that they should work a
7+
// particular way, but rather a way to monitor regressions/changes.
8+
9+
@JS()
10+
library object_members_test;
11+
12+
import 'package:js/js.dart';
13+
import 'package:expect/minitest.dart';
14+
15+
import 'dart:html';
16+
import 'dart:_interceptors' show JSObject;
17+
18+
@JS()
19+
external void eval(String code);
20+
21+
@JS()
22+
class JSClass {
23+
external JSClass();
24+
}
25+
26+
void main() {
27+
eval(r'''
28+
function JSClass() {}
29+
''');
30+
31+
// `dart:html` type.
32+
var div = document.createElement('div');
33+
expect(div == div, true);
34+
expect(div == DomPointReadOnly(), false);
35+
// Ensure that we get a random hash for each new instance. It should be
36+
// improbable for this to fail across many runs if the hash is
37+
// non-deterministic.
38+
var hashCode = div.hashCode;
39+
var attempts = 0;
40+
var maxAttempts = 1000;
41+
while (div.hashCode == hashCode && attempts < maxAttempts) {
42+
div = document.createElement('div');
43+
attempts++;
44+
}
45+
expect(attempts > 0 && attempts != maxAttempts, isTrue);
46+
expect(div.toString, isNotNull);
47+
expect(div.toString(), 'div');
48+
expect(div.noSuchMethod, isNotNull);
49+
var noSuchMethodErrorThrown = true;
50+
try {
51+
(div as dynamic).triggerNoSuchMethod();
52+
noSuchMethodErrorThrown = false;
53+
} catch (_) {}
54+
expect(noSuchMethodErrorThrown, isTrue);
55+
expect(div.runtimeType, DivElement);
56+
57+
// `toString` for `dart:html` types that do not have an overridden `toString`
58+
// should look up the type through the proto.
59+
expect(window.navigator.toString(), "Instance of 'Navigator'");
60+
61+
// Interop type.
62+
var js = JSClass();
63+
expect(js == js, true);
64+
expect(js == JSClass(), false);
65+
// TODO(srujzs): Modify this once interop has random hash codes.
66+
hashCode = js.hashCode;
67+
expect(hashCode, 0);
68+
expect(hashCode, js.hashCode);
69+
expect(js.toString, isNotNull);
70+
// Should forward to underlying `toString` call.
71+
expect(js.toString(), '[object Object]');
72+
expect(js.noSuchMethod, isNotNull);
73+
noSuchMethodErrorThrown = true;
74+
try {
75+
(js as dynamic).triggerNoSuchMethod();
76+
noSuchMethodErrorThrown = false;
77+
} catch (_) {}
78+
expect(noSuchMethodErrorThrown, isTrue);
79+
expect(js.runtimeType, JSObject);
80+
}

tests/web_2/dart2js_2.status

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ deferred_split_test: Slow, Pass # Issue 25940
2424
[ $compiler == dart2js && $runtime == chrome && $csp ]
2525
deferred/load_in_correct_order_test: SkipByDesign # Purposely uses `eval`
2626

27+
[ $compiler == dart2js && $runtime == d8 ]
28+
internal/object_members_test: SkipByDesign # Browser test
29+
2730
[ $compiler == dart2js && $runtime == ff && $system == windows ]
2831
consistent_index_error_string_test: Slow, Pass # Issue 25940
2932

3033
[ $compiler == dart2js && $csp ]
3134
deferred_custom_loader_test: SkipByDesign # Issue 25683
3235
deferred_fail_and_retry_test: SkipByDesign # Uses eval to simulate failed loading.
36+
internal/object_members_test: SkipByDesign # Uses eval for interop
3337

3438
[ $compiler == dart2js && !$host_checked ]
3539
dummy_compiler_test: Slow, Pass # Issue 32439. self-hosting doesn't work with CFE yet.

0 commit comments

Comments
 (0)