Skip to content

Commit

Permalink
Version 3.0.0-173.0.dev
Browse files Browse the repository at this point in the history
Merge 812d26f into dev
  • Loading branch information
Dart CI committed Jan 27, 2023
2 parents d9ab9b3 + 812d26f commit 2cd9b7a
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 95 deletions.
5 changes: 2 additions & 3 deletions pkg/dev_compiler/test/modular_suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class SourceToSummaryDillStep implements IOModularStep {
'--multi-root-scheme',
rootScheme,
...extraArgs,
'--no-sound-null-safety',
'--sound-null-safety',
'--output',
'${toUri(module, dillId)}',
if (!module.isSdk) ...[
Expand Down Expand Up @@ -199,12 +199,11 @@ class DDCStep implements IOModularStep {
'--modules=es6',
'--no-summarize',
'--no-source-map',
'--experimental-output-compiled-kernel',
'--multi-root-scheme',
rootScheme,
...sources,
...extraArgs,
'--no-sound-null-safety',
'--sound-null-safety',
for (String flag in flags) '--enable-experiment=$flag',
...transitiveDependencies
.where((m) => !m.isSdk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class SourceToSummaryDillStep implements IOModularStep {
'--multi-root-scheme',
rootScheme,
...extraArgs,
'--no-sound-null-safety',
'--output',
'${toUri(module, dillId)}',
if (!module.isSdk) ...[
Expand All @@ -121,7 +122,6 @@ class SourceToSummaryDillStep implements IOModularStep {
.where((m) => !m.isSdk)
.expand((m) => ['--input-summary', '${toUri(m, dillId)}']),
...sources.expand((String uri) => ['--source', uri]),
'--sound-null-safety',
...flags.expand((String flag) => ['--enable-experiment', flag]),
];

Expand Down Expand Up @@ -203,7 +203,7 @@ class DDCStep implements IOModularStep {
rootScheme,
...sources,
...extraArgs,
'--sound-null-safety',
'--no-sound-null-safety',
for (String flag in flags) '--enable-experiment=$flag',
...transitiveDependencies
.where((m) => !m.isSdk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ library external_static_member_lowerings_test;
import 'dart:_js_interop';

import 'package:expect/minitest.dart';
import 'package:js/js.dart' show trustTypes, staticInterop;
import 'package:js/js.dart' show staticInterop;

@JS()
external dynamic eval(String code);
Expand Down Expand Up @@ -44,31 +44,28 @@ extension on ExternalStatic {
external String get initialValue;
}

@JS('ExternalStatic')
@staticInterop
@trustTypes
class ExternalStaticTrustType {
external static double field;
external static double get getSet;
external static double method();
}

// Top-level fields.
@JS()
external String field;
@JS('field')
external String renamedField;
@JS()
external final String finalField;

// Top-level getters and setters.
@JS()
external String get getSet;
@JS()
external set getSet(String val);
@JS('getSet')
external String get renamedGetSet;
@JS('getSet')
external set renamedGetSet(String val);

// Top-level methods.
@JS()
external String method();
@JS()
external String differentArgsMethod(String a, [String b = '']);
@JS('method')
external String renamedMethod();
Expand Down Expand Up @@ -129,14 +126,6 @@ void testClassStaticMembers() {
'optionalmethod');
expect(ExternalStatic.renamedMethod(), 'method');
expect((ExternalStatic.renamedMethod)(), 'method');

// Use wrong return type in conjunction with `@trustTypes`.
expect(ExternalStaticTrustType.field, 'renamedField');

expect(ExternalStaticTrustType.getSet, 'renamedGetSet');

expect(ExternalStaticTrustType.method(), 'method');
expect((ExternalStaticTrustType.method)(), 'method');
}

void testTopLevelMembers() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) 2023, 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.

@JS()
library external_static_member_lowerings_trusttypes_test;

// ignore: IMPORT_INTERNAL_LIBRARY
import 'dart:_js_interop';

import 'package:expect/minitest.dart';
import 'package:js/js.dart' show trustTypes, staticInterop;

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

@JS('ExternalStatic')
@staticInterop
@trustTypes
class ExternalStaticTrustType {
external static double field;
external static double get getSet;
external static double method();
}

// dart2js is smart enough to see that the expectations below will never be true
// as the types are incompatible. Therefore, it optimizes the expectation code
// to *always fail*, even if the values are the same! Since we're breaking
// soundness with @trustTypes, we need to confuse dart2js enough that it doesn't
// do those optimizations, hence this.
@pragma('dart2js:noInline')
@pragma('dart2js:assumeDynamic')
confuse(x) => x;

void main() {
eval('''
globalThis.ExternalStatic = function ExternalStatic() {}
globalThis.ExternalStatic.method = function() {
return 'method';
}
globalThis.ExternalStatic.field = 'field';
globalThis.ExternalStatic.getSet = 'getSet';
''');

// Use wrong return type in conjunction with `@trustTypes`.
expect(confuse(ExternalStaticTrustType.field), 'field');

expect(confuse(ExternalStaticTrustType.getSet), 'getSet');

expect(confuse(ExternalStaticTrustType.method()), 'method');
expect(confuse((ExternalStaticTrustType.method)()), 'method');
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'dart:_js_interop';
import 'dart:js_util' as js_util;

import 'package:expect/minitest.dart';
import 'package:js/js.dart' show trustTypes, staticInterop;
import 'package:js/js.dart' show staticInterop;

@JS('library3.ExternalStatic')
@staticInterop
Expand Down Expand Up @@ -45,15 +45,6 @@ extension on ExternalStatic {
external String get initialValue;
}

@JS('library3.ExternalStatic')
@staticInterop
@trustTypes
class ExternalStaticTrustType {
external static double field;
external static double get getSet;
external static double method();
}

void main() {
// Use `callMethod` instead of top-level external to `eval` since the library
// is namespaced.
Expand Down Expand Up @@ -107,15 +98,19 @@ external String namespacedField;
external final String finalField;

// Top-level getters and setters.
@JS()
external String get getSet;
@JS()
external set getSet(String val);
@JS('library3.namespacedGetSet')
external String get namespacedGetSet;
@JS('library3.namespacedGetSet')
external set namespacedGetSet(String val);

// Top-level methods.
@JS()
external String method();
@JS()
external String differentArgsMethod(String a, [String b = '']);
@JS('library3.namespacedMethod')
external String namespacedMethod();
Expand Down Expand Up @@ -146,14 +141,6 @@ void testClassStaticMembers() {
'optionalmethod');
expect(ExternalStatic.renamedMethod(), 'method');
expect((ExternalStatic.renamedMethod)(), 'method');

// Use wrong return type in conjunction with `@trustTypes`.
expect(ExternalStaticTrustType.field, 'renamedField');

expect(ExternalStaticTrustType.getSet, 'renamedGetSet');

expect(ExternalStaticTrustType.method(), 'method');
expect((ExternalStaticTrustType.method)(), 'method');
}

void testTopLevelMembers() {
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/lib.status
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ wasm/*: Skip # dart:wasm is currently behind a Dart SDK build flag.
convert/utf85_test: Skip # Pass, Slow Issue 12644.

[ $compiler == dart2wasm ]
js/static_interop_test/external_static_member_lowerings_test: SkipByDesign # Tests @trustTypes, which is unsupported on dart2wasm. TODO(srujzs): Refactor that code out.
js/static_interop_test/external_static_member_lowerings_with_namespaces_test: SkipByDesign # Tests @trustTypes, which is unsupported on dart2wasm. TODO(srujzs): Refactor that code out.
js/static_interop_test/external_static_member_lowerings_trusttypes_test: SkipByDesign # Tests @trustTypes, which is unsupported on dart2wasm.

[ $mode == product ]
developer/timeline_test: Skip # Not supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ library external_static_member_lowerings_test;
import 'dart:_js_interop';

import 'package:expect/minitest.dart';
import 'package:js/js.dart' show trustTypes, staticInterop;
import 'package:js/js.dart' show staticInterop;

@JS()
external dynamic eval(String code);
Expand Down Expand Up @@ -44,31 +44,28 @@ extension on ExternalStatic {
external String get initialValue;
}

@JS('ExternalStatic')
@staticInterop
@trustTypes
class ExternalStaticTrustType {
external static double field;
external static double get getSet;
external static double method();
}

// Top-level fields.
@JS()
external String field;
@JS('field')
external String renamedField;
@JS()
external final String finalField;

// Top-level getters and setters.
@JS()
external String get getSet;
@JS()
external set getSet(String val);
@JS('getSet')
external String get renamedGetSet;
@JS('getSet')
external set renamedGetSet(String val);

// Top-level methods.
@JS()
external String method();
@JS()
external String differentArgsMethod(String a, [String b = '']);
@JS('method')
external String renamedMethod();
Expand Down Expand Up @@ -129,14 +126,6 @@ void testClassStaticMembers() {
'optionalmethod');
expect(ExternalStatic.renamedMethod(), 'method');
expect((ExternalStatic.renamedMethod)(), 'method');

// Use wrong return type in conjunction with `@trustTypes`.
expect(ExternalStaticTrustType.field, 'renamedField');

expect(ExternalStaticTrustType.getSet, 'renamedGetSet');

expect(ExternalStaticTrustType.method(), 'method');
expect((ExternalStaticTrustType.method)(), 'method');
}

void testTopLevelMembers() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) 2023, 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.

@JS()
library external_static_member_lowerings_trusttypes_test;

// ignore: IMPORT_INTERNAL_LIBRARY
import 'dart:_js_interop';

import 'package:expect/minitest.dart';
import 'package:js/js.dart' show trustTypes, staticInterop;

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

@JS('ExternalStatic')
@staticInterop
@trustTypes
class ExternalStaticTrustType {
external static double field;
external static double get getSet;
external static double method();
}

// dart2js is smart enough to see that the expectations below will never be true
// as the types are incompatible. Therefore, it optimizes the expectation code
// to *always fail*, even if the values are the same! Since we're breaking
// soundness with @trustTypes, we need to confuse dart2js enough that it doesn't
// do those optimizations, hence this.
@pragma('dart2js:noInline')
@pragma('dart2js:assumeDynamic')
confuse(x) => x;

void main() {
eval('''
globalThis.ExternalStatic = function ExternalStatic() {}
globalThis.ExternalStatic.method = function() {
return 'method';
}
globalThis.ExternalStatic.field = 'field';
globalThis.ExternalStatic.getSet = 'getSet';
''');

// Use wrong return type in conjunction with `@trustTypes`.
expect(confuse(ExternalStaticTrustType.field), 'field');

expect(confuse(ExternalStaticTrustType.getSet), 'getSet');

expect(confuse(ExternalStaticTrustType.method()), 'method');
expect(confuse((ExternalStaticTrustType.method)()), 'method');
}
Loading

0 comments on commit 2cd9b7a

Please sign in to comment.