Skip to content

Commit

Permalink
Version 2.16.0-134.5.beta
Browse files Browse the repository at this point in the history
* Cherry-pick 3b440de to beta
* Cherry-pick d9b69e9 to beta
* Cherry-pick d172051 to beta
* Cherry-pick 4bf6354 to beta
  • Loading branch information
whesse committed Jan 24, 2022
2 parents 455fe9d + 51a46f7 commit ac38a9d
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ vars = {
"dart_style_rev": "08b0294d0a500d5c02168ef57dcb8868d0c3cb48",

"dartdoc_rev" : "11c4b3c9723bfa7155efcf0fef02329233a6381d",
"devtools_rev" : "85932bb66aa782c4b2c528be7718960bf256ffb7",
"devtools_rev" : "013958fbd45351e5975068756b7b9114465a7f98",
"jsshell_tag": "version:88.0",
"ffi_rev": "4dd32429880a57b64edaf54c9d5af8a9fa9a4ffb",
"fixnum_rev": "16d3890c6dc82ca629659da1934e412292508bba",
Expand Down
9 changes: 9 additions & 0 deletions pkg/compiler/lib/src/js_emitter/native_emitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class NativeEmitter {

Class objectClass = null;
Class jsInterceptorClass = null;
Class jsJavaScriptObjectClass = null;

void walk(Class cls) {
if (cls.element == _commonElements.objectClass) {
Expand All @@ -104,6 +105,11 @@ class NativeEmitter {
jsInterceptorClass = cls;
return;
}
// Native classes may inherit either `Interceptor` e.g. `JSBool` or
// `JavaScriptObject` e.g. `dart:html` classes.
if (cls.element == _commonElements.jsJavaScriptObjectClass) {
jsJavaScriptObjectClass = cls;
}
if (seen.contains(cls)) return;
seen.add(cls);
walk(cls.superclass);
Expand Down Expand Up @@ -215,6 +221,9 @@ class NativeEmitter {
// by getNativeInterceptor and custom elements.
if (_nativeCodegenEnqueuer.hasInstantiatedNativeClasses) {
fillNativeInfo(jsInterceptorClass);
if (jsJavaScriptObjectClass != null) {
fillNativeInfo(jsJavaScriptObjectClass);
}
for (Class cls in classes) {
if (!cls.isNative || neededClasses.contains(cls)) {
fillNativeInfo(cls);
Expand Down
10 changes: 9 additions & 1 deletion pkg/compiler/test/jsinterop/internal_annotations_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,15 @@ $mainSource
"Expected $name to be indirectly instantiated in `${mainSource}`:"
"\n${world.classHierarchy.dump(cls)}");
}
if (!isInstantiated && (name != 'Object' && name != 'Interceptor')) {
// Classes that are expected to be instantiated by default. `Object` and
// `Interceptor` are base types for non-native and native types, and
// `JavaScriptObject` is the base type for `dart:html` types.
var insantiatedBaseClasses = [
'Object',
'Interceptor',
'JavaScriptObject'
];
if (!isInstantiated && !insantiatedBaseClasses.contains(name)) {
Expect.isFalse(
world.classHierarchy.isInstantiated(cls),
"Expected $name to be uninstantiated in `${mainSource}`:"
Expand Down
10 changes: 9 additions & 1 deletion pkg/compiler/test/jsinterop/world_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,15 @@ $mainSource
"Expected $name to be indirectly instantiated in `${mainSource}`:"
"\n${world.classHierarchy.dump(cls)}");
}
if (!isInstantiated && (name != 'Object' && name != 'Interceptor')) {
// Classes that are expected to be instantiated by default. `Object` and
// `Interceptor` are base types for non-native and native types, and
// `JavaScriptObject` is the base type for `dart:html` types.
var insantiatedBaseClasses = [
'Object',
'Interceptor',
'JavaScriptObject'
];
if (!isInstantiated && !insantiatedBaseClasses.contains(name)) {
Expect.isFalse(
world.classHierarchy.isInstantiated(cls),
"Expected $name to be uninstantiated in `${mainSource}`:"
Expand Down
2 changes: 2 additions & 0 deletions sdk/bin/dartanalyzer_sdk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Run dartanalyzer.dart on the Dart VM. This script assumes the Dart SDK's
# directory structure.

echo "Warning: 'dartanalyzer' is deprecated. Please use 'dart analyze'." 1>&2

function follow_links() {
file="$1"
while [ -h "$file" ]; do
Expand Down
2 changes: 2 additions & 0 deletions sdk/bin/dartanalyzer_sdk.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ REM Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
REM for details. All rights reserved. Use of this source code is governed by a
REM BSD-style license that can be found in the LICENSE file.

echo Warning: 'dartanalyzer' is deprecated. Please use 'dart analyze'. 1>&2

setlocal
rem Handle the case where dart-sdk/bin has been symlinked to.
set DIR_NAME_WITH_SLASH=%~dp0
Expand Down
14 changes: 8 additions & 6 deletions sdk/lib/_internal/js_runtime/lib/js_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -415,19 +415,21 @@ class Primitives {

var interceptor = getInterceptor(object);
if (identical(interceptor, JS_INTERCEPTOR_CONSTANT(Interceptor)) ||
identical(interceptor, JS_INTERCEPTOR_CONSTANT(JavaScriptObject)) ||
object is UnknownJavaScriptObject) {
// Try to do better. If we do not find something better, fallthrough to
// Dart-type based name that leave the name as 'UnknownJavaScriptObject'
// or 'Interceptor' (or the minified versions thereof).
// Dart-type based name that leave the name as 'UnknownJavaScriptObject',
// 'Interceptor', or 'JavaScriptObject' (or their minified versions).
//
// When we get here via the UnknownJavaScriptObject test (for JavaScript
// objects from outside the program), the object's constructor has a
// better name that 'UnknownJavaScriptObject'.
//
// When we get here the Interceptor test (for Native classes that are
// declared in the Dart program but have been 'folded' into Interceptor),
// the native class's constructor name is better than the generic
// 'Interceptor' (an abstract class).
// When we get here via either the Interceptor or JavaScriptObject test
// (for Native classes that are declared in the Dart program but have been
// 'folded' into one of those interceptors), the native class's
// constructor name is better than the generic 'Interceptor' or
// 'JavaScriptObject'.

// Try the [constructorNameFallback]. This gets the constructor name for
// any browser (used by [getNativeInterceptor]).
Expand Down
4 changes: 4 additions & 0 deletions tests/web/dart2js.status
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ deferred_split_test: Slow, Pass # Issue 25940
[ $compiler == dart2js && $runtime == chrome && $csp ]
deferred/load_in_correct_order_test: SkipByDesign # Purposely uses `eval`

[ $compiler == dart2js && $runtime == d8 ]
internal/object_members_test: SkipByDesign # Browser test

[ $compiler == dart2js && $runtime == ff && $system == windows ]
consistent_index_error_string_test: Slow, Pass # Issue 25940

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

[ $compiler == dart2js && !$host_checked ]
dummy_compiler_test: Slow, Pass # Issue 32439. self-hosting doesn't work with CFE yet.
Expand Down
80 changes: 80 additions & 0 deletions tests/web/internal/object_members_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright (c) 2022, 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.

// Make sure `Object` methods work as expected with `dart:html` and interop
// types. The expectations here aren't guarantees that they should work a
// particular way, but rather a way to monitor regressions/changes.

@JS()
library object_members_test;

import 'package:js/js.dart';
import 'package:expect/minitest.dart';

import 'dart:html';
import 'dart:_interceptors' show JSObject;

@JS()
external void eval(String code);

@JS()
class JSClass {
external JSClass();
}

void main() {
eval(r'''
function JSClass() {}
''');

// `dart:html` type.
var div = document.createElement('div');
expect(div == div, true);
expect(div == DomPointReadOnly(), false);
// Ensure that we get a random hash for each new instance. It should be
// improbable for this to fail across many runs if the hash is
// non-deterministic.
var hashCode = div.hashCode;
var attempts = 0;
var maxAttempts = 1000;
while (div.hashCode == hashCode && attempts < maxAttempts) {
div = document.createElement('div');
attempts++;
}
expect(attempts > 0 && attempts != maxAttempts, isTrue);
expect(div.toString, isNotNull);
expect(div.toString(), 'div');
expect(div.noSuchMethod, isNotNull);
var noSuchMethodErrorThrown = true;
try {
(div as dynamic).triggerNoSuchMethod();
noSuchMethodErrorThrown = false;
} catch (_) {}
expect(noSuchMethodErrorThrown, isTrue);
expect(div.runtimeType, DivElement);

// `toString` for `dart:html` types that do not have an overridden `toString`
// should look up the type through the proto.
expect(window.navigator.toString(), "Instance of 'Navigator'");

// Interop type.
var js = JSClass();
expect(js == js, true);
expect(js == JSClass(), false);
// TODO(srujzs): Modify this once interop has random hash codes.
hashCode = js.hashCode;
expect(hashCode, 0);
expect(hashCode, js.hashCode);
expect(js.toString, isNotNull);
// Should forward to underlying `toString` call.
expect(js.toString(), '[object Object]');
expect(js.noSuchMethod, isNotNull);
noSuchMethodErrorThrown = true;
try {
(js as dynamic).triggerNoSuchMethod();
noSuchMethodErrorThrown = false;
} catch (_) {}
expect(noSuchMethodErrorThrown, isTrue);
expect(js.runtimeType, JSObject);
}
4 changes: 4 additions & 0 deletions tests/web_2/dart2js_2.status
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ deferred_split_test: Slow, Pass # Issue 25940
[ $compiler == dart2js && $runtime == chrome && $csp ]
deferred/load_in_correct_order_test: SkipByDesign # Purposely uses `eval`

[ $compiler == dart2js && $runtime == d8 ]
internal/object_members_test: SkipByDesign # Browser test

[ $compiler == dart2js && $runtime == ff && $system == windows ]
consistent_index_error_string_test: Slow, Pass # Issue 25940

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

[ $compiler == dart2js && !$host_checked ]
dummy_compiler_test: Slow, Pass # Issue 32439. self-hosting doesn't work with CFE yet.
Expand Down
80 changes: 80 additions & 0 deletions tests/web_2/internal/object_members_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright (c) 2022, 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.

// Make sure `Object` methods work as expected with `dart:html` and interop
// types. The expectations here aren't guarantees that they should work a
// particular way, but rather a way to monitor regressions/changes.

@JS()
library object_members_test;

import 'package:js/js.dart';
import 'package:expect/minitest.dart';

import 'dart:html';
import 'dart:_interceptors' show JSObject;

@JS()
external void eval(String code);

@JS()
class JSClass {
external JSClass();
}

void main() {
eval(r'''
function JSClass() {}
''');

// `dart:html` type.
var div = document.createElement('div');
expect(div == div, true);
expect(div == DomPointReadOnly(), false);
// Ensure that we get a random hash for each new instance. It should be
// improbable for this to fail across many runs if the hash is
// non-deterministic.
var hashCode = div.hashCode;
var attempts = 0;
var maxAttempts = 1000;
while (div.hashCode == hashCode && attempts < maxAttempts) {
div = document.createElement('div');
attempts++;
}
expect(attempts > 0 && attempts != maxAttempts, isTrue);
expect(div.toString, isNotNull);
expect(div.toString(), 'div');
expect(div.noSuchMethod, isNotNull);
var noSuchMethodErrorThrown = true;
try {
(div as dynamic).triggerNoSuchMethod();
noSuchMethodErrorThrown = false;
} catch (_) {}
expect(noSuchMethodErrorThrown, isTrue);
expect(div.runtimeType, DivElement);

// `toString` for `dart:html` types that do not have an overridden `toString`
// should look up the type through the proto.
expect(window.navigator.toString(), "Instance of 'Navigator'");

// Interop type.
var js = JSClass();
expect(js == js, true);
expect(js == JSClass(), false);
// TODO(srujzs): Modify this once interop has random hash codes.
hashCode = js.hashCode;
expect(hashCode, 0);
expect(hashCode, js.hashCode);
expect(js.toString, isNotNull);
// Should forward to underlying `toString` call.
expect(js.toString(), '[object Object]');
expect(js.noSuchMethod, isNotNull);
noSuchMethodErrorThrown = true;
try {
(js as dynamic).triggerNoSuchMethod();
noSuchMethodErrorThrown = false;
} catch (_) {}
expect(noSuchMethodErrorThrown, isTrue);
expect(js.runtimeType, JSObject);
}
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ MAJOR 2
MINOR 16
PATCH 0
PRERELEASE 134
PRERELEASE_PATCH 1
PRERELEASE_PATCH 5
5 changes: 3 additions & 2 deletions tools/bots/dart_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def DartArchiveUnstrippedBinaries(arch):
def CreateUploadAPIDocs():
dartdoc_dir = BuildRootPath('gen-dartdocs')
dartdoc_zip = BuildRootPath('dartdocs-api.zip')
if CHANNEL == bot_utils.Channel.TRY:
if CHANNEL == bot_utils.Channel.TRY or DART_EXPERIMENTAL_BUILD == '1':
BuildDartdocAPIDocs(dartdoc_dir)
else:
UploadApiLatestFile()
Expand Down Expand Up @@ -222,12 +222,13 @@ def Run(command, env=None):

BUILD_OS = utils.GuessOS()
BUILDER_NAME = os.environ.get('BUILDBOT_BUILDERNAME')
DART_EXPERIMENTAL_BUILD = os.environ.get('DART_EXPERIMENTAL_BUILD')
CHANNEL = bot_utils.GetChannelFromName(BUILDER_NAME)

if command == 'api_docs':
if BUILD_OS == 'linux':
CreateUploadAPIDocs()
elif CHANNEL != bot_utils.Channel.TRY:
elif CHANNEL != bot_utils.Channel.TRY and DART_EXPERIMENTAL_BUILD != '1':
for arch in archs:
print('Create and upload sdk zip for ' + arch)
sdk_path = BuildRootPath('dart-sdk', arch=arch)
Expand Down

0 comments on commit ac38a9d

Please sign in to comment.