Version 2.12.0-227.0.dev
Merge commit '8d971e1beffa4165e1bb32413ea67d2a1e041c9c' into 'dev'
diff --git a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
index d5be3ee..ee22cc5 100644
--- a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
@@ -831,6 +831,10 @@
/// necessary; in this case, [viaInitializer] should be `true`.
void write(
Variable variable, Type writtenType, Expression? writtenExpression);
+
+ /// Prints out a summary of the current state of flow analysis, intended for
+ /// debugging use only.
+ void _dumpState();
}
/// Alternate implementation of [FlowAnalysis] that prints out inputs and output
@@ -838,7 +842,7 @@
class FlowAnalysisDebug<Node extends Object, Statement extends Node,
Expression extends Object, Variable extends Object, Type extends Object>
implements FlowAnalysis<Node, Statement, Expression, Variable, Type> {
- _FlowAnalysisImpl<Node, Statement, Expression, Variable, Type> _wrapped;
+ FlowAnalysis<Node, Statement, Expression, Variable, Type> _wrapped;
bool _exceptionOccurred = false;
@@ -1305,6 +1309,9 @@
() => _wrapped.write(variable, writtenType, writtenExpression));
}
+ @override
+ void _dumpState() => _wrapped._dumpState();
+
T _wrap<T>(String description, T callback(),
{bool isQuery: false, bool? isPure}) {
isPure ??= isQuery;
@@ -3806,6 +3813,7 @@
_current.write(variable, writtenType, newSsaNode, typeOperations);
}
+ @override
void _dumpState() {
print(' current: $_current');
print(' expressionWithInfo: $_expressionWithInfo');
diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
index 1ea05e1..d2ba523 100644
--- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
@@ -5937,6 +5937,39 @@
tip: r"""Try replacing them with normal or optional parameters.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Template<
+ Message Function(
+ String name,
+ String name2,
+ String
+ string3)> templateJsInteropNativeClassInAnnotation = const Template<
+ Message Function(String name, String name2, String string3)>(
+ messageTemplate:
+ r"""JS interop class '#name' conflicts with natively supported class '#name2' in '#string3'.""",
+ withArguments: _withArgumentsJsInteropNativeClassInAnnotation);
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Code<Message Function(String name, String name2, String string3)>
+ codeJsInteropNativeClassInAnnotation =
+ const Code<Message Function(String name, String name2, String string3)>(
+ "JsInteropNativeClassInAnnotation",
+);
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+Message _withArgumentsJsInteropNativeClassInAnnotation(
+ String name, String name2, String string3) {
+ if (name.isEmpty) throw 'No name provided';
+ name = demangleMixinApplicationName(name);
+ if (name2.isEmpty) throw 'No name provided';
+ name2 = demangleMixinApplicationName(name2);
+ if (string3.isEmpty) throw 'No string provided';
+ return new Message(codeJsInteropNativeClassInAnnotation,
+ message:
+ """JS interop class '${name}' conflicts with natively supported class '${name2}' in '${string3}'.""",
+ arguments: {'name': name, 'name2': name2, 'string3': string3});
+}
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeJsInteropNonExternalConstructor =
messageJsInteropNonExternalConstructor;
diff --git a/pkg/_js_interop_checks/lib/js_interop_checks.dart b/pkg/_js_interop_checks/lib/js_interop_checks.dart
index 8bb8c6d..e3f0978 100644
--- a/pkg/_js_interop_checks/lib/js_interop_checks.dart
+++ b/pkg/_js_interop_checks/lib/js_interop_checks.dart
@@ -17,17 +17,40 @@
messageJsInteropNonExternalConstructor,
messageJsInteropNonExternalMember,
templateJsInteropDartClassExtendsJSClass,
- templateJsInteropJSClassExtendsDartClass;
+ templateJsInteropJSClassExtendsDartClass,
+ templateJsInteropNativeClassInAnnotation;
import 'src/js_interop.dart';
class JsInteropChecks extends RecursiveVisitor<void> {
final CoreTypes _coreTypes;
final DiagnosticReporter<Message, LocatedMessage> _diagnosticsReporter;
+ final Map<String, Class> _nativeClasses;
bool _classHasJSAnnotation = false;
+ bool _classHasAnonymousAnnotation = false;
bool _libraryHasJSAnnotation = false;
+ bool _libraryIsGlobalNamespace = false;
- JsInteropChecks(this._coreTypes, this._diagnosticsReporter);
+ JsInteropChecks(
+ this._coreTypes, this._diagnosticsReporter, this._nativeClasses);
+
+ /// Extract all native class names from the [component].
+ ///
+ /// Returns a map from the name to the underlying Class node. This is a
+ /// static method so that the result can be cached in the corresponding
+ /// compiler target.
+ static Map<String, Class> getNativeClasses(Component component) {
+ Map<String, Class> nativeClasses = {};
+ for (var library in component.libraries) {
+ for (var cls in library.classes) {
+ var nativeNames = getNativeNames(cls);
+ for (var nativeName in nativeNames) {
+ nativeClasses[nativeName] = cls;
+ }
+ }
+ }
+ return nativeClasses;
+ }
@override
void defaultMember(Member member) {
@@ -40,6 +63,7 @@
@override
void visitClass(Class cls) {
_classHasJSAnnotation = hasJSInteropAnnotation(cls);
+ _classHasAnonymousAnnotation = hasAnonymousAnnotation(cls);
var superclass = cls.superclass;
if (superclass != null && superclass != _coreTypes.objectClass) {
var superHasJSAnnotation = hasJSInteropAnnotation(superclass);
@@ -59,14 +83,53 @@
cls.location.file);
}
}
+ if (_classHasJSAnnotation &&
+ !_classHasAnonymousAnnotation &&
+ _libraryIsGlobalNamespace) {
+ var jsClass = getJSName(cls);
+ if (jsClass.isEmpty) {
+ // No rename, take the name of the class directly.
+ jsClass = cls.name;
+ } else {
+ // Remove any global prefixes. Regex here is greedy and will only return
+ // a value for `className` that doesn't start with 'self.' or 'window.'.
+ var classRegexp = new RegExp(r'^((self|window)\.)*(?<className>.*)$');
+ var matches = classRegexp.allMatches(jsClass);
+ jsClass = matches.first.namedGroup('className');
+ }
+ if (_nativeClasses.containsKey(jsClass)) {
+ var nativeClass = _nativeClasses[jsClass];
+ _diagnosticsReporter.report(
+ templateJsInteropNativeClassInAnnotation.withArguments(
+ cls.name,
+ nativeClass.name,
+ nativeClass.enclosingLibrary.importUri.toString()),
+ cls.fileOffset,
+ cls.name.length,
+ cls.location.file);
+ }
+ }
super.visitClass(cls);
+ _classHasAnonymousAnnotation = false;
_classHasJSAnnotation = false;
}
@override
void visitLibrary(Library lib) {
_libraryHasJSAnnotation = hasJSInteropAnnotation(lib);
+ _libraryIsGlobalNamespace = false;
+ if (_libraryHasJSAnnotation) {
+ var libraryAnnotation = getJSName(lib);
+ var globalRegexp = new RegExp(r'^(self|window)(\.(self|window))*$');
+ if (libraryAnnotation.isEmpty ||
+ globalRegexp.hasMatch(libraryAnnotation)) {
+ _libraryIsGlobalNamespace = true;
+ }
+ } else {
+ _libraryIsGlobalNamespace = true;
+ }
super.visitLibrary(lib);
+ _libraryIsGlobalNamespace = false;
_libraryHasJSAnnotation = false;
}
@@ -98,7 +161,7 @@
}
var isAnonymousFactory =
- isAnonymousClassMember(procedure) && procedure.isFactory;
+ _classHasAnonymousAnnotation && procedure.isFactory;
if (isAnonymousFactory) {
if (procedure.function != null &&
diff --git a/pkg/_js_interop_checks/lib/src/js_interop.dart b/pkg/_js_interop_checks/lib/src/js_interop.dart
index 33ab00b..7831f2d 100644
--- a/pkg/_js_interop_checks/lib/src/js_interop.dart
+++ b/pkg/_js_interop_checks/lib/src/js_interop.dart
@@ -9,15 +9,48 @@
bool hasJSInteropAnnotation(Annotatable a) =>
a.annotations.any(_isPublicJSAnnotation);
-/// Returns true if [m] belongs to an anonymous class.
-bool isAnonymousClassMember(Member m) {
- var enclosingClass = m.enclosingClass;
- if (enclosingClass == null) return false;
- return enclosingClass.annotations.any(_isAnonymousAnnotation);
+/// Returns true iff the node has an `@anonymous(...)` annotation from
+/// `package:js` or from the internal `dart:_js_annotations`.
+bool hasAnonymousAnnotation(Annotatable a) =>
+ a.annotations.any(_isAnonymousAnnotation);
+
+/// If [a] has a `@JS('...')` annotation, returns the value inside the
+/// parentheses.
+///
+/// If there is none or the class does not have a `@JS()` annotation, returns
+/// an empty String.
+String getJSName(Annotatable a) {
+ String jsClass = '';
+ for (var annotation in a.annotations) {
+ if (_isPublicJSAnnotation(annotation)) {
+ var jsClasses = _stringAnnotationValues(annotation);
+ if (jsClasses.length > 0) {
+ jsClass = jsClasses[0];
+ }
+ }
+ }
+ return jsClass;
+}
+
+/// If [a] has a `@Native('...')` annotation, returns the values inside the
+/// parentheses.
+///
+/// If there are none or the class does not have a `@Native()` annotation,
+/// returns an empty list. Unlike `@JS()`, the string within `@Native()` is
+/// allowed to contain several classes separated by a `,`.
+List<String> getNativeNames(Annotatable a) {
+ List<String> nativeClasses = [];
+ for (var annotation in a.annotations) {
+ if (_isNativeAnnotation(annotation)) {
+ nativeClasses.addAll(_stringAnnotationValues(annotation));
+ }
+ }
+ return nativeClasses;
}
final _packageJs = Uri.parse('package:js/js.dart');
final _internalJs = Uri.parse('dart:_js_annotations');
+final _jsHelper = Uri.parse('dart:_js_helper');
/// Returns true if [value] is the `JS` annotation from `package:js` or from
/// `dart:_js_annotations`.
@@ -39,12 +72,20 @@
c.enclosingLibrary.importUri == _internalJs);
}
+bool _isNativeAnnotation(Expression value) {
+ var c = _annotationClass(value);
+ return c != null &&
+ c.name == 'Native' &&
+ c.enclosingLibrary.importUri == _jsHelper;
+}
+
/// Returns the class of the instance referred to by metadata annotation [node].
///
/// For example:
///
/// - `@JS()` would return the "JS" class in "package:js".
/// - `@anonymous` would return the "_Anonymous" class in "package:js".
+/// - `@Native` would return the "Native" class in "dart:_js_helper".
///
/// This function works regardless of whether the CFE is evaluating constants,
/// or whether the constant is a field reference (such as "anonymous" above).
@@ -60,3 +101,40 @@
}
return null;
}
+
+/// Returns the string values inside of a metadata annotation [node].
+///
+/// For example:
+/// - `@JS('Foo')` would return ['Foo'].
+/// - `@Native('Foo,Bar')` would return ['Foo', 'Bar'].
+///
+/// [node] is expected to be an annotation with either StringConstants or
+/// StringLiterals that can be made up of multiple values. If there are none,
+/// this method returns an empty list. This method throws an assertion if there
+/// are multiple arguments or a named arg in the annotation.
+List<String> _stringAnnotationValues(Expression node) {
+ List<String> values = [];
+ if (node is ConstantExpression) {
+ var constant = node.constant;
+ if (constant is InstanceConstant) {
+ var argLength = constant.fieldValues.values.length;
+ if (argLength == 1) {
+ var value = constant.fieldValues.values.elementAt(0);
+ if (value is StringConstant) values.addAll(value.value.split(','));
+ } else if (argLength > 1) {
+ throw new ArgumentError('Method expects annotation with at most one '
+ 'positional argument: $node.');
+ }
+ }
+ } else if (node is ConstructorInvocation) {
+ var argLength = node.arguments.positional.length;
+ if (argLength > 1 || node.arguments.named.length > 0) {
+ throw new ArgumentError('Method expects annotation with at most one '
+ 'positional argument: $node.');
+ } else if (argLength == 1) {
+ var value = node.arguments.positional[0];
+ if (value is StringLiteral) values.addAll(value.value.split(','));
+ }
+ }
+ return values;
+}
diff --git a/pkg/analysis_server/test/plugin/protocol_dart_test.dart b/pkg/analysis_server/test/plugin/protocol_dart_test.dart
index d693387..aabef45 100644
--- a/pkg/analysis_server/test/plugin/protocol_dart_test.dart
+++ b/pkg/analysis_server/test/plugin/protocol_dart_test.dart
@@ -3,10 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/plugin/protocol/protocol_dart.dart';
-import 'package:analyzer/dart/ast/ast.dart' as engine;
import 'package:analyzer/dart/element/element.dart' as engine;
import 'package:analyzer/src/dart/element/element.dart' as engine;
-import 'package:analyzer/src/generated/testing/element_search.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -91,20 +89,13 @@
@reflectiveTest
class ElementTest extends AbstractSingleUnitTest {
- engine.Element findElementInUnit(engine.CompilationUnit unit, String name,
- [engine.ElementKind kind]) {
- return findElementsByName(unit, name)
- .where((e) => kind == null || e.kind == kind)
- .single;
- }
-
Future<void> test_fromElement_CLASS() async {
await resolveTestCode('''
@deprecated
abstract class _A {}
class B<K, V> {}''');
{
- engine.ClassElement engineElement = findElementInUnit(testUnit, '_A');
+ var engineElement = findElement.class_('_A');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.CLASS);
@@ -126,7 +117,7 @@
Element.FLAG_PRIVATE);
}
{
- engine.ClassElement engineElement = findElementInUnit(testUnit, 'B');
+ var engineElement = findElement.class_('B');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.CLASS);
@@ -141,8 +132,7 @@
class A {
const A.myConstructor(int a, [String b]);
}''');
- engine.ConstructorElement engineElement =
- findElementInUnit(testUnit, 'myConstructor');
+ var engineElement = findElement.constructor('myConstructor');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.CONSTRUCTOR);
@@ -169,8 +159,7 @@
const A.myConstructor(int a, {int b, @required int c});
}''');
- engine.ConstructorElement engineElement =
- findElementInUnit(testUnit, 'myConstructor');
+ var engineElement = findElement.constructor('myConstructor');
// create notification Element
var element = convertElement(engineElement);
expect(element.parameters, '(int a, {@required int c, int b})');
@@ -185,8 +174,7 @@
const A.myConstructor(int a, {int b, @required int d, @required int c});
}''');
- engine.ConstructorElement engineElement =
- findElementInUnit(testUnit, 'myConstructor');
+ var engineElement = findElement.constructor('myConstructor');
// create notification Element
var element = convertElement(engineElement);
expect(element.parameters,
@@ -203,8 +191,7 @@
const A.myConstructor(int a, {int b, @required int d, @required int c, int a});
}''');
- engine.ConstructorElement engineElement =
- findElementInUnit(testUnit, 'myConstructor');
+ var engineElement = findElement.constructor('myConstructor');
// create notification Element
var element = convertElement(engineElement);
expect(element.parameters,
@@ -229,7 +216,7 @@
enum _E1 { one, two }
enum E2 { three, four }''');
{
- engine.ClassElement engineElement = findElementInUnit(testUnit, '_E1');
+ var engineElement = findElement.enum_('_E1');
expect(engineElement.hasDeprecated, isTrue);
// create notification Element
var element = convertElement(engineElement);
@@ -251,7 +238,7 @@
Element.FLAG_PRIVATE);
}
{
- engine.ClassElement engineElement = findElementInUnit(testUnit, 'E2');
+ var engineElement = findElement.enum_('E2');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.ENUM);
@@ -267,7 +254,7 @@
enum _E1 { one, two }
enum E2 { three, four }''');
{
- engine.FieldElement engineElement = findElementInUnit(testUnit, 'one');
+ var engineElement = findElement.field('one');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.ENUM_CONSTANT);
@@ -291,7 +278,7 @@
Element.FLAG_CONST | Element.FLAG_STATIC);
}
{
- engine.FieldElement engineElement = findElementInUnit(testUnit, 'three');
+ var engineElement = findElement.field('three');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.ENUM_CONSTANT);
@@ -309,7 +296,7 @@
expect(element.flags, Element.FLAG_CONST | Element.FLAG_STATIC);
}
{
- var engineElement = testUnit.declaredElement.enums[1].getField('index');
+ var engineElement = findElement.field('index', of: 'E2');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.FIELD);
@@ -327,7 +314,7 @@
expect(element.flags, Element.FLAG_FINAL);
}
{
- var engineElement = testUnit.declaredElement.enums[1].getField('values');
+ var engineElement = findElement.field('values', of: 'E2');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.FIELD);
@@ -351,7 +338,7 @@
class A {
static const myField = 42;
}''');
- engine.FieldElement engineElement = findElementInUnit(testUnit, 'myField');
+ var engineElement = findElement.field('myField');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.FIELD);
@@ -373,8 +360,7 @@
await resolveTestCode('''
typedef int F<T>(String x);
''');
- engine.FunctionTypeAliasElement engineElement =
- findElementInUnit(testUnit, 'F');
+ var engineElement = findElement.typeAlias('F');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS);
@@ -397,8 +383,7 @@
await resolveTestCode('''
typedef F<T> = int Function(String x);
''');
- engine.FunctionTypeAliasElement engineElement =
- findElementInUnit(testUnit, 'F');
+ var engineElement = findElement.typeAlias('F');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS);
@@ -423,8 +408,7 @@
class A {
String get myGetter => 42;
}''');
- engine.PropertyAccessorElement engineElement =
- findElementInUnit(testUnit, 'myGetter', engine.ElementKind.GETTER);
+ var engineElement = findElement.getter('myGetter');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.GETTER);
@@ -450,7 +434,7 @@
break myLabel;
}
}''');
- engine.LabelElement engineElement = findElementInUnit(testUnit, 'myLabel');
+ var engineElement = findElement.label('myLabel');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.LABEL);
@@ -475,8 +459,7 @@
return null;
}
}''');
- engine.MethodElement engineElement =
- findElementInUnit(testUnit, 'myMethod');
+ var engineElement = findElement.method('myMethod');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.METHOD);
@@ -499,7 +482,7 @@
mixin A {}
''');
{
- engine.ClassElement engineElement = findElementInUnit(testUnit, 'A');
+ var engineElement = findElement.mixin('A');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.MIXIN);
@@ -523,8 +506,7 @@
class A {
set mySetter(String x) {}
}''');
- engine.PropertyAccessorElement engineElement =
- findElementInUnit(testUnit, 'mySetter', engine.ElementKind.SETTER);
+ var engineElement = findElement.setter('mySetter');
// create notification Element
var element = convertElement(engineElement);
expect(element.kind, ElementKind.SETTER);
diff --git a/pkg/analysis_server/test/services/refactoring/convert_method_to_getter_test.dart b/pkg/analysis_server/test/services/refactoring/convert_method_to_getter_test.dart
index 4683949..95e8ed2 100644
--- a/pkg/analysis_server/test/services/refactoring/convert_method_to_getter_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/convert_method_to_getter_test.dart
@@ -4,7 +4,6 @@
import 'package:analysis_server/src/services/refactoring/refactoring.dart';
import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/src/generated/testing/element_search.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart'
show RefactoringProblemSeverity;
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -155,7 +154,7 @@
var v = test();
}
''');
- ExecutableElement element = findElementsByName(testUnit, 'test').single;
+ var element = findElement.localFunction('test');
_createRefactoringForElement(element);
// check conditions
await _assertInitialConditions_fatal(
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index cf138c1..fe2afbf 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -2,6 +2,8 @@
* Deprecated `FunctionTypeAliasElement.function`.
Use `TypeAliasElement.aliasedElement` instead.
* Widened the dependency on package:crypto to include version 3.0.0.
+* Deprecated `CompilationUnitElement.functionTypeAliases`.
+ Use `CompilationUnitElement.typeAliases` instead.
## 0.41.1
* Updated `PackageBuildWorkspace` that supports `package:build` to stop
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index be78683..5f38ebb 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -391,6 +391,7 @@
/// Return a list containing all of the function type aliases contained in
/// this compilation unit.
+ @Deprecated('Use typeAliases instead')
List<FunctionTypeAliasElement> get functionTypeAliases;
/// Return `true` if this compilation unit defines a top-level function named
diff --git a/pkg/analyzer/lib/src/dart/analysis/search.dart b/pkg/analyzer/lib/src/dart/analysis/search.dart
index 4207727..3074d5b 100644
--- a/pkg/analyzer/lib/src/dart/analysis/search.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/search.dart
@@ -179,9 +179,9 @@
unitElement.enums.forEach(addElement);
unitElement.extensions.forEach(addElement);
unitElement.functions.forEach(addElement);
- unitElement.functionTypeAliases.forEach(addElement);
unitElement.mixins.forEach(addElement);
unitElement.topLevelVariables.forEach(addElement);
+ unitElement.typeAliases.forEach(addElement);
unitElement.types.forEach(addElement);
}
}
diff --git a/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart b/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart
index 7b620f3..8149a3b 100644
--- a/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart
+++ b/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart
@@ -39,7 +39,7 @@
bool _isConstantTypeName(Identifier name) {
var element = name.staticElement;
- if (element is ClassElement || element is FunctionTypeAliasElement) {
+ if (element is ClassElement || element is TypeAliasElement) {
if (name is PrefixedIdentifier) {
if (name.isDeferred) {
return false;
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index a76e610..9ac4dc9 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -1318,6 +1318,7 @@
_functions = functions;
}
+ @Deprecated('Use typeAliases instead')
@override
List<FunctionTypeAliasElement> get functionTypeAliases {
return _functionTypeAliases ??=
@@ -1430,10 +1431,9 @@
return _typeAliases ?? const <TypeAliasElement>[];
}
- /// Set the function type aliases contained in this compilation unit to the
- /// given [typeAliases].
- set typeAliases(List<FunctionTypeAliasElement> typeAliases) {
- for (FunctionTypeAliasElement typeAlias in typeAliases) {
+ /// Set the type aliases contained in this compilation unit to [typeAliases].
+ set typeAliases(List<TypeAliasElement> typeAliases) {
+ for (TypeAliasElement typeAlias in typeAliases) {
(typeAlias as ElementImpl).enclosingElement = this;
}
_typeAliases = typeAliases;
@@ -1524,8 +1524,8 @@
safelyVisitChildren(enums, visitor);
safelyVisitChildren(extensions, visitor);
safelyVisitChildren(functions, visitor);
- safelyVisitChildren(functionTypeAliases, visitor);
safelyVisitChildren(mixins, visitor);
+ safelyVisitChildren(typeAliases, visitor);
safelyVisitChildren(types, visitor);
safelyVisitChildren(topLevelVariables, visitor);
}
@@ -5244,10 +5244,10 @@
yield* unit.accessors;
yield* unit.enums;
yield* unit.extensions;
- yield* unit.functionTypeAliases;
yield* unit.functions;
yield* unit.mixins;
yield* unit.topLevelVariables;
+ yield* unit.typeAliases;
yield* unit.types;
}
}
diff --git a/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart b/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart
index 7c19f05..c2380d8 100644
--- a/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart
+++ b/pkg/analyzer/lib/src/dart/element/replacement_visitor.dart
@@ -376,7 +376,7 @@
var element = type.element;
if (element is ClassElement) {
parameters = element.typeParameters;
- } else if (element is FunctionTypeAliasElement) {
+ } else if (element is TypeAliasElement) {
parameters = element.typeParameters;
}
diff --git a/pkg/analyzer/lib/src/dart/resolver/scope.dart b/pkg/analyzer/lib/src/dart/resolver/scope.dart
index 0eebe01..b9c2384 100644
--- a/pkg/analyzer/lib/src/dart/resolver/scope.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/scope.dart
@@ -248,11 +248,10 @@
for (FunctionElement element in compilationUnit.functions) {
_addIfPublic(definedNames, element);
}
- for (FunctionTypeAliasElement element
- in compilationUnit.functionTypeAliases) {
+ for (ClassElement element in compilationUnit.mixins) {
_addIfPublic(definedNames, element);
}
- for (ClassElement element in compilationUnit.mixins) {
+ for (TypeAliasElement element in compilationUnit.typeAliases) {
_addIfPublic(definedNames, element);
}
for (ClassElement element in compilationUnit.types) {
diff --git a/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart b/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
index 0b5e1f1..073ca29 100644
--- a/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
+++ b/pkg/analyzer/lib/src/error/duplicate_definition_verifier.dart
@@ -202,15 +202,15 @@
for (FunctionElement function in element.functions) {
definedGetters[function.name] = function;
}
- for (FunctionTypeAliasElement alias in element.functionTypeAliases) {
- definedGetters[alias.name] = alias;
- }
for (TopLevelVariableElement variable in element.topLevelVariables) {
definedGetters[variable.name] = variable;
if (!variable.isFinal && !variable.isConst) {
definedGetters[variable.name + '='] = variable;
}
}
+ for (TypeAliasElement alias in element.typeAliases) {
+ definedGetters[alias.name] = alias;
+ }
for (ClassElement type in element.types) {
definedGetters[type.name] = type;
}
diff --git a/pkg/analyzer/lib/src/generated/testing/element_search.dart b/pkg/analyzer/lib/src/generated/testing/element_search.dart
deleted file mode 100644
index e0bfdbb1..0000000
--- a/pkg/analyzer/lib/src/generated/testing/element_search.dart
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2017, 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.
-
-import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
-
-/// Search the [unit] for the [Element]s with the given [name].
-List<Element> findElementsByName(CompilationUnit unit, String name) {
- var finder = _ElementsByNameFinder(name);
- unit.accept(finder);
- return finder.elements;
-}
-
-class _ElementsByNameFinder extends RecursiveAstVisitor<void> {
- final String name;
- final List<Element> elements = [];
-
- _ElementsByNameFinder(this.name);
-
- @override
- void visitSimpleIdentifier(SimpleIdentifier node) {
- if (node.name == name && node.inDeclarationContext()) {
- elements.add(node.staticElement);
- }
- }
-}
diff --git a/pkg/analyzer/lib/src/generated/testing/node_search.dart b/pkg/analyzer/lib/src/generated/testing/node_search.dart
deleted file mode 100644
index 9a2b15d..0000000
--- a/pkg/analyzer/lib/src/generated/testing/node_search.dart
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2017, 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.
-
-import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/ast/visitor.dart';
-
-/// Search the [unit] for declared [SimpleIdentifier]s with the given [name].
-List<SimpleIdentifier> findDeclaredIdentifiersByName(
- CompilationUnit unit, String name) {
- var finder = _DeclaredIdentifiersByNameFinder(name);
- unit.accept(finder);
- return finder.identifiers;
-}
-
-class _DeclaredIdentifiersByNameFinder extends RecursiveAstVisitor<void> {
- final String name;
- final List<SimpleIdentifier> identifiers = [];
-
- _DeclaredIdentifiersByNameFinder(this.name);
-
- @override
- void visitSimpleIdentifier(SimpleIdentifier node) {
- if (node.name == name && node.inDeclarationContext()) {
- identifiers.add(node);
- }
- }
-}
diff --git a/pkg/analyzer/lib/src/summary2/simply_bounded.dart b/pkg/analyzer/lib/src/summary2/simply_bounded.dart
index 03be657..fb5d0ed 100644
--- a/pkg/analyzer/lib/src/summary2/simply_bounded.dart
+++ b/pkg/analyzer/lib/src/summary2/simply_bounded.dart
@@ -19,7 +19,7 @@
var nodes = <SimplyBoundedNode>[];
for (var libraryBuilder in libraryBuilders) {
for (var unit in libraryBuilder.element.units) {
- for (var element in unit.functionTypeAliases) {
+ for (var element in unit.typeAliases) {
var node = walker.getNode(element);
nodes.add(node);
}
diff --git a/pkg/analyzer/lib/src/summary2/variance_builder.dart b/pkg/analyzer/lib/src/summary2/variance_builder.dart
index 1dc486d..5eb87ce 100644
--- a/pkg/analyzer/lib/src/summary2/variance_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/variance_builder.dart
@@ -197,7 +197,7 @@
return;
}
- var type = node.functionType?.type;
+ var type = node.type?.type;
// Not a function type, recover.
if (type == null) {
diff --git a/pkg/analyzer/test/generated/strong_mode_test.dart b/pkg/analyzer/test/generated/strong_mode_test.dart
index ca63fe8..11c4578 100644
--- a/pkg/analyzer/test/generated/strong_mode_test.dart
+++ b/pkg/analyzer/test/generated/strong_mode_test.dart
@@ -1141,7 +1141,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 225, 1),
]);
- DartType cType = findLocalVariable(unit, 'c').type;
+ DartType cType = findElement.localVar('c').type;
Element elementC = AstFinder.getClass(unit, "C").declaredElement;
_isInstantiationOf(_hasElement(elementC))([_isDynamic])(cType);
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
index b10a2b7..0dd6b71 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
@@ -6253,7 +6253,7 @@
var myLibrary = myImport.importedLibrary;
var myUnit = myLibrary.definingCompilationUnit;
var myClass = myUnit.types.single;
- var myFunctionTypeAlias = myUnit.functionTypeAliases.single;
+ var myTypeAlias = myUnit.typeAliases.single;
var myTopVariable = myUnit.topLevelVariables[0];
var myTopFunction = myUnit.functions.single;
var myGetter = myUnit.topLevelVariables[1].getter;
@@ -6280,7 +6280,7 @@
}
assertPrefixedIdentifier(0, myClass, typeProvider.typeType);
- assertPrefixedIdentifier(1, myFunctionTypeAlias, typeProvider.typeType);
+ assertPrefixedIdentifier(1, myTypeAlias, typeProvider.typeType);
assertPrefixedIdentifier(2, myTopVariable.getter, typeProvider.intType);
{
@@ -7597,12 +7597,11 @@
await resolveTestFile();
CompilationUnit unit = result.unit;
- CompilationUnitElement unitElement = unit.declaredElement;
FunctionTypeAlias alias = unit.declarations[0];
TypeAliasElement aliasElement = alias.declaredElement;
var function = aliasElement.aliasedElement as GenericFunctionTypeElement;
- expect(aliasElement, same(unitElement.functionTypeAliases[0]));
+ expect(aliasElement, same(findElement.typeAlias('F')));
expect(function.returnType, typeProvider.intType);
_assertTypeNameSimple(alias.returnType, typeProvider.intType);
diff --git a/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart b/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart
index 4ba18ab..97a88b3 100644
--- a/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart
+++ b/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart
@@ -14,7 +14,7 @@
defineReflectiveTests(IsConstantTypeExpressionTest);
defineReflectiveTests(IsPotentiallyConstantTypeExpressionTest);
defineReflectiveTests(PotentiallyConstantTest);
- defineReflectiveTests(PotentiallyConstantWithNullSafetyTest);
+ defineReflectiveTests(PotentiallyConstantWithNonFunctionTypeAliasesTest);
});
}
@@ -749,6 +749,12 @@
''', () => _xInitializer(), () => [findNode.typeName('T>{0')]);
}
+ test_simpleIdentifier_class() async {
+ await _assertConst(r'''
+var x = int;
+''', () => _xInitializer());
+ }
+
test_simpleIdentifier_function() async {
await _assertConst(r'''
var x = f;
@@ -845,9 +851,10 @@
);
}
- test_simpleIdentifier_type_class() async {
+ test_simpleIdentifier_typedef_functionType() async {
await _assertConst(r'''
-var x = int;
+typedef A = void Function();
+var x = A;
''', () => _xInitializer());
}
@@ -918,8 +925,8 @@
}
@reflectiveTest
-class PotentiallyConstantWithNullSafetyTest extends PotentiallyConstantTest
- with WithNullSafetyMixin {
+class PotentiallyConstantWithNonFunctionTypeAliasesTest
+ extends PotentiallyConstantTest with WithNonFunctionTypeAliasesMixin {
@override
test_asExpression_typeParameter() async {
await _assertConst(r'''
@@ -965,4 +972,21 @@
}
''', () => _xInitializer());
}
+
+ test_prefixedIdentifier_typedef_interfaceType() async {
+ newFile('$testPackageLibPath/a.dart', content: r'''
+typedef A = List<int>;
+''');
+ await _assertConst(r'''
+import 'a.dart' as p;
+var x = p.A;
+''', () => _xInitializer());
+ }
+
+ test_simpleIdentifier_typedef_interfaceType() async {
+ await _assertConst(r'''
+typedef A = List<int>;
+var x = A;
+''', () => _xInitializer());
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
index 1891285..a69ca06 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
@@ -936,7 +936,8 @@
}
@reflectiveTest
-class DuplicateDefinitionTest extends PubPackageResolutionTest {
+class DuplicateDefinitionTest extends PubPackageResolutionTest
+ with WithNonFunctionTypeAliasesMixin {
test_catch() async {
await assertErrorsInCode(r'''
main() {
@@ -979,16 +980,16 @@
test_locals_block_if() async {
await assertErrorsInCode(r'''
-main(int p) {
+void f(int p) {
if (p != 0) {
var a;
var a;
}
}
''', [
- error(HintCode.UNUSED_LOCAL_VARIABLE, 38, 1),
- error(HintCode.UNUSED_LOCAL_VARIABLE, 49, 1),
- error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 49, 1),
+ error(HintCode.UNUSED_LOCAL_VARIABLE, 40, 1),
+ error(HintCode.UNUSED_LOCAL_VARIABLE, 51, 1),
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 51, 1),
]);
}
@@ -1214,4 +1215,13 @@
error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 27, 1),
]);
}
+
+ test_unitMembers_typedef_interfaceType() async {
+ await assertErrorsInCode('''
+typedef A = List<int>;
+typedef A = List<int>;
+''', [
+ error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 31, 1),
+ ]);
+ }
}
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 5bca31e..b439e4f 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -1730,50 +1730,6 @@
''');
}
- test_class_type_parameters_variance_contravariant() async {
- var library = await checkLibrary('class C<in T> {}');
- checkElementText(
- library,
- r'''
-class C<contravariant T> {
-}
-''',
- withTypeParameterVariance: true);
- }
-
- test_class_type_parameters_variance_covariant() async {
- var library = await checkLibrary('class C<out T> {}');
- checkElementText(
- library,
- r'''
-class C<covariant T> {
-}
-''',
- withTypeParameterVariance: true);
- }
-
- test_class_type_parameters_variance_invariant() async {
- var library = await checkLibrary('class C<inout T> {}');
- checkElementText(
- library,
- r'''
-class C<invariant T> {
-}
-''',
- withTypeParameterVariance: true);
- }
-
- test_class_type_parameters_variance_multiple() async {
- var library = await checkLibrary('class C<inout T, in U, out V> {}');
- checkElementText(
- library,
- r'''
-class C<invariant T, contravariant U, covariant V> {
-}
-''',
- withTypeParameterVariance: true);
- }
-
test_class_typeParameters_defaultType_functionTypeAlias_contravariant_legacy() async {
featureSet = FeatureSets.beforeNullSafe;
var library = await checkLibrary(r'''
@@ -1807,6 +1763,22 @@
withTypeParameterVariance: true);
}
+ test_class_typeParameters_defaultType_functionTypeAlias_covariant_nullSafe() async {
+ var library = await checkLibrary(r'''
+typedef F<X> = X Function();
+
+class A<X extends F<X>> {}
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F<covariant X> = X Function();
+notSimplyBounded class A<covariant X extends X Function() = dynamic Function()> {
+}
+''',
+ withTypeParameterVariance: true);
+ }
+
test_class_typeParameters_defaultType_functionTypeAlias_invariant_legacy() async {
var library = await checkLibrary(r'''
typedef F<X> = X Function(X);
@@ -1901,6 +1873,84 @@
''');
}
+ test_class_typeParameters_defaultType_typeAlias_interface_contravariant() async {
+ featureSet = FeatureSets.nonFunctionTypeAliases;
+ var library = await checkLibrary(r'''
+typedef A<X> = List<void Function(X)>;
+
+class B<X extends A<X>> {}
+''');
+ checkElementText(
+ library,
+ r'''
+typedef A<contravariant X> = List<void Function(X)>;
+notSimplyBounded class B<covariant X extends List<void Function(X)> = List<void Function(Never)>> {
+}
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_class_typeParameters_defaultType_typeAlias_interface_covariant() async {
+ featureSet = FeatureSets.nonFunctionTypeAliases;
+ var library = await checkLibrary(r'''
+typedef A<X> = Map<X, int>;
+
+class B<X extends A<X>> {}
+''');
+ checkElementText(
+ library,
+ r'''
+typedef A<covariant X> = Map<X, int>;
+notSimplyBounded class B<covariant X extends Map<X, int> = Map<dynamic, int>> {
+}
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_class_typeParameters_variance_contravariant() async {
+ var library = await checkLibrary('class C<in T> {}');
+ checkElementText(
+ library,
+ r'''
+class C<contravariant T> {
+}
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_class_typeParameters_variance_covariant() async {
+ var library = await checkLibrary('class C<out T> {}');
+ checkElementText(
+ library,
+ r'''
+class C<covariant T> {
+}
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_class_typeParameters_variance_invariant() async {
+ var library = await checkLibrary('class C<inout T> {}');
+ checkElementText(
+ library,
+ r'''
+class C<invariant T> {
+}
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_class_typeParameters_variance_multiple() async {
+ var library = await checkLibrary('class C<inout T, in U, out V> {}');
+ checkElementText(
+ library,
+ r'''
+class C<invariant T, contravariant U, covariant V> {
+}
+''',
+ withTypeParameterVariance: true);
+ }
+
test_classes() async {
var library = await checkLibrary('class C {} class D {}');
checkElementText(library, r'''
@@ -7314,7 +7364,7 @@
''');
var unit = library.definingCompilationUnit;
- var F = unit.functionTypeAliases[0];
+ var F = unit.typeAliases[0];
expect(F.name, 'F');
var T = F.typeParameters[0];
@@ -7337,11 +7387,11 @@
var unit = library.definingCompilationUnit;
var type = unit.topLevelVariables[0].type as FunctionType;
- expect(type.aliasElement, same(unit.functionTypeAliases[0]));
+ expect(type.aliasElement, same(unit.typeAliases[0]));
_assertTypeStrings(type.aliasArguments, ['int']);
// TODO(scheglov) https://github.com/dart-lang/sdk/issues/44629
- expect(type.element.enclosingElement, same(unit.functionTypeAliases[0]));
+ expect(type.element.enclosingElement, same(unit.typeAliases[0]));
_assertTypeStrings(type.typeArguments, ['int']);
}
@@ -7643,7 +7693,7 @@
''');
var unit = library.definingCompilationUnit;
- var F = unit.functionTypeAliases[0];
+ var F = unit.typeAliases[0];
expect(F.name, 'F');
var T = F.typeParameters[0];
@@ -7671,151 +7721,6 @@
''');
}
- test_genericTypeAlias_typeParameters_variance_contravariant() async {
- var library = await checkLibrary(r'''
-typedef F<T> = void Function(T);
-''');
- checkElementText(
- library,
- r'''
-typedef F<contravariant T> = void Function(T );
-''',
- withTypeParameterVariance: true);
- }
-
- test_genericTypeAlias_typeParameters_variance_contravariant2() async {
- var library = await checkLibrary(r'''
-typedef F1<T> = void Function(T);
-typedef F2<T> = F1<T> Function();
-''');
- checkElementText(
- library,
- r'''
-typedef F1<contravariant T> = void Function(T );
-typedef F2<contravariant T> = void Function(T) Function();
-''',
- withTypeParameterVariance: true);
- }
-
- test_genericTypeAlias_typeParameters_variance_covariant() async {
- var library = await checkLibrary(r'''
-typedef F<T> = T Function();
-''');
- checkElementText(
- library,
- r'''
-typedef F<covariant T> = T Function();
-''',
- withTypeParameterVariance: true);
- }
-
- test_genericTypeAlias_typeParameters_variance_covariant2() async {
- var library = await checkLibrary(r'''
-typedef F<T> = List<T> Function();
-''');
- checkElementText(
- library,
- r'''
-typedef F<covariant T> = List<T> Function();
-''',
- withTypeParameterVariance: true);
- }
-
- test_genericTypeAlias_typeParameters_variance_covariant3() async {
- var library = await checkLibrary(r'''
-typedef F1<T> = T Function();
-typedef F2<T> = F1<T> Function();
-''');
- checkElementText(
- library,
- r'''
-typedef F1<covariant T> = T Function();
-typedef F2<covariant T> = T Function() Function();
-''',
- withTypeParameterVariance: true);
- }
-
- test_genericTypeAlias_typeParameters_variance_covariant4() async {
- var library = await checkLibrary(r'''
-typedef F1<T> = void Function(T);
-typedef F2<T> = void Function(F1<T>);
-''');
- checkElementText(
- library,
- r'''
-typedef F1<contravariant T> = void Function(T );
-typedef F2<covariant T> = void Function(void Function(T) );
-''',
- withTypeParameterVariance: true);
- }
-
- test_genericTypeAlias_typeParameters_variance_invalid() async {
- var library = await checkLibrary(r'''
-class A {}
-typedef F<T> = void Function(A<int>);
-''');
- checkElementText(
- library,
- r'''
-typedef F<unrelated T> = void Function(A );
-class A {
-}
-''',
- withTypeParameterVariance: true);
- }
-
- test_genericTypeAlias_typeParameters_variance_invalid2() async {
- var library = await checkLibrary(r'''
-typedef F = void Function();
-typedef G<T> = void Function(F<int>);
-''');
- checkElementText(
- library,
- r'''
-typedef F = void Function();
-typedef G<unrelated T> = void Function(void Function() );
-''',
- withTypeParameterVariance: true);
- }
-
- test_genericTypeAlias_typeParameters_variance_invariant() async {
- var library = await checkLibrary(r'''
-typedef F<T> = T Function(T);
-''');
- checkElementText(
- library,
- r'''
-typedef F<invariant T> = T Function(T );
-''',
- withTypeParameterVariance: true);
- }
-
- test_genericTypeAlias_typeParameters_variance_invariant2() async {
- var library = await checkLibrary(r'''
-typedef F1<T> = T Function();
-typedef F2<T> = F1<T> Function(T);
-''');
- checkElementText(
- library,
- r'''
-typedef F1<covariant T> = T Function();
-typedef F2<invariant T> = T Function() Function(T );
-''',
- withTypeParameterVariance: true);
- }
-
- test_genericTypeAlias_typeParameters_variance_unrelated() async {
- var library = await checkLibrary(r'''
-typedef F<T> = void Function(int);
-''');
- checkElementText(
- library,
- r'''
-typedef F<unrelated T> = void Function(int );
-''',
- withTypeParameterVariance: true);
- }
-
test_getter_documented() async {
var library = await checkLibrary('''
// Extra comment so doc comment offset != 0
@@ -10765,7 +10670,7 @@
''');
}
- test_mixin_type_parameters_variance_contravariant() async {
+ test_mixin_typeParameters_variance_contravariant() async {
var library = await checkLibrary('mixin M<in T> {}');
checkElementText(
library,
@@ -10776,7 +10681,7 @@
withTypeParameterVariance: true);
}
- test_mixin_type_parameters_variance_covariant() async {
+ test_mixin_typeParameters_variance_covariant() async {
var library = await checkLibrary('mixin M<out T> {}');
checkElementText(
library,
@@ -10787,7 +10692,7 @@
withTypeParameterVariance: true);
}
- test_mixin_type_parameters_variance_invariant() async {
+ test_mixin_typeParameters_variance_invariant() async {
var library = await checkLibrary('mixin M<inout T> {}');
checkElementText(
library,
@@ -10798,7 +10703,7 @@
withTypeParameterVariance: true);
}
- test_mixin_type_parameters_variance_multiple() async {
+ test_mixin_typeParameters_variance_multiple() async {
var library = await checkLibrary('mixin M<inout T, in U, out V> {}');
checkElementText(
library,
@@ -10954,7 +10859,7 @@
''');
}
- test_new_typedef_notSimplyBounded_functionType_returnType() async {
+ test_new_typedef_function_notSimplyBounded_functionType_returnType() async {
var library = await checkLibrary('''
typedef F = G Function();
typedef G = F Function();
@@ -10965,7 +10870,7 @@
''');
}
- test_new_typedef_notSimplyBounded_functionType_returnType_viaInterfaceType() async {
+ test_new_typedef_function_notSimplyBounded_functionType_returnType_viaInterfaceType() async {
var library = await checkLibrary('''
typedef F = List<F> Function();
''');
@@ -10974,7 +10879,7 @@
''');
}
- test_new_typedef_notSimplyBounded_self() async {
+ test_new_typedef_function_notSimplyBounded_self() async {
var library = await checkLibrary('''
typedef F<T extends F> = void Function();
''');
@@ -10983,7 +10888,7 @@
''');
}
- test_new_typedef_notSimplyBounded_simple_no_bounds() async {
+ test_new_typedef_function_notSimplyBounded_simple_no_bounds() async {
var library = await checkLibrary('''
typedef F<T> = void Function();
''');
@@ -10992,7 +10897,7 @@
''');
}
- test_new_typedef_notSimplyBounded_simple_non_generic() async {
+ test_new_typedef_function_notSimplyBounded_simple_non_generic() async {
var library = await checkLibrary('''
typedef F = void Function();
''');
@@ -11001,6 +10906,26 @@
''');
}
+ test_new_typedef_nonFunction_notSimplyBounded_self() async {
+ featureSet = FeatureSets.nonFunctionTypeAliases;
+ var library = await checkLibrary('''
+typedef F<T extends F> = List<int>;
+''');
+ checkElementText(library, r'''
+notSimplyBounded typedef F<T extends dynamic> = List<int>;
+''');
+ }
+
+ test_new_typedef_nonFunction_notSimplyBounded_viaInterfaceType() async {
+ featureSet = FeatureSets.nonFunctionTypeAliases;
+ var library = await checkLibrary('''
+typedef F = List<F>;
+''');
+ checkElementText(library, r'''
+notSimplyBounded typedef F = List<dynamic>;
+''');
+ }
+
test_old_typedef_notSimplyBounded_self() async {
var library = await checkLibrary('''
typedef void F<T extends F>();
@@ -12209,6 +12134,207 @@
''');
}
+ test_typeAlias_typeParameters_variance_function_contravariant() async {
+ var library = await checkLibrary(r'''
+typedef F<T> = void Function(T);
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F<contravariant T> = void Function(T );
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_function_contravariant2() async {
+ var library = await checkLibrary(r'''
+typedef F1<T> = void Function(T);
+typedef F2<T> = F1<T> Function();
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F1<contravariant T> = void Function(T );
+typedef F2<contravariant T> = void Function(T) Function();
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_function_covariant() async {
+ var library = await checkLibrary(r'''
+typedef F<T> = T Function();
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F<covariant T> = T Function();
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_function_covariant2() async {
+ var library = await checkLibrary(r'''
+typedef F<T> = List<T> Function();
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F<covariant T> = List<T> Function();
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_function_covariant3() async {
+ var library = await checkLibrary(r'''
+typedef F1<T> = T Function();
+typedef F2<T> = F1<T> Function();
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F1<covariant T> = T Function();
+typedef F2<covariant T> = T Function() Function();
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_function_covariant4() async {
+ var library = await checkLibrary(r'''
+typedef F1<T> = void Function(T);
+typedef F2<T> = void Function(F1<T>);
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F1<contravariant T> = void Function(T );
+typedef F2<covariant T> = void Function(void Function(T) );
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_function_invalid() async {
+ var library = await checkLibrary(r'''
+class A {}
+typedef F<T> = void Function(A<int>);
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F<unrelated T> = void Function(A );
+class A {
+}
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_function_invalid2() async {
+ var library = await checkLibrary(r'''
+typedef F = void Function();
+typedef G<T> = void Function(F<int>);
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F = void Function();
+typedef G<unrelated T> = void Function(void Function() );
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_function_invariant() async {
+ var library = await checkLibrary(r'''
+typedef F<T> = T Function(T);
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F<invariant T> = T Function(T );
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_function_invariant2() async {
+ var library = await checkLibrary(r'''
+typedef F1<T> = T Function();
+typedef F2<T> = F1<T> Function(T);
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F1<covariant T> = T Function();
+typedef F2<invariant T> = T Function() Function(T );
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_function_unrelated() async {
+ var library = await checkLibrary(r'''
+typedef F<T> = void Function(int);
+''');
+ checkElementText(
+ library,
+ r'''
+typedef F<unrelated T> = void Function(int );
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_interface_contravariant() async {
+ featureSet = FeatureSets.nonFunctionTypeAliases;
+ var library = await checkLibrary(r'''
+typedef A<T> = List<void Function(T)>;
+''');
+ checkElementText(
+ library,
+ r'''
+typedef A<contravariant T> = List<void Function(T)>;
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_interface_contravariant2() async {
+ featureSet = FeatureSets.nonFunctionTypeAliases;
+ var library = await checkLibrary(r'''
+typedef A<T> = void Function(T);
+typedef B<T> = List<A<T>>;
+''');
+ checkElementText(
+ library,
+ r'''
+typedef A<contravariant T> = void Function(T );
+typedef B<contravariant T> = List<void Function(T)>;
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_interface_covariant() async {
+ featureSet = FeatureSets.nonFunctionTypeAliases;
+ var library = await checkLibrary(r'''
+typedef A<T> = List<T>;
+''');
+ checkElementText(
+ library,
+ r'''
+typedef A<covariant T> = List<T>;
+''',
+ withTypeParameterVariance: true);
+ }
+
+ test_typeAlias_typeParameters_variance_interface_covariant2() async {
+ featureSet = FeatureSets.nonFunctionTypeAliases;
+ var library = await checkLibrary(r'''
+typedef A<T> = Map<int, T>;
+typedef B<T> = List<A<T>>;
+''');
+ checkElementText(
+ library,
+ r'''
+typedef A<covariant T> = Map<int, T>;
+typedef B<covariant T> = List<Map<int, T>>;
+''',
+ withTypeParameterVariance: true);
+ }
+
test_typedef_documented() async {
var library = await checkLibrary('''
// Extra comment so doc comment offset != 0
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index b182fa7..7e41586 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -2,14 +2,12 @@
// 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.
-import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../utils.dart';
import '../../dart/resolution/context_collection_resolution.dart';
void main() {
@@ -20,8 +18,6 @@
@reflectiveTest
class InferredTypeTest extends PubPackageResolutionTest {
- CompilationUnit get _resultUnit => result.unit;
-
CompilationUnitElement get _resultUnitElement {
return result.unit.declaredElement;
}
@@ -89,7 +85,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 241, 1),
]);
- var f = findLocalVariable(_resultUnit, 'f');
+ var f = findElement.localVar('f');
_assertTypeStr(f.type, 'Future<num> Function()');
}
@@ -112,7 +108,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 192, 1),
]);
- var f = findLocalVariable(_resultUnit, 'f');
+ var f = findElement.localVar('f');
_assertTypeStr(f.type, 'Future<num> Function()');
}
@@ -135,7 +131,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 215, 1),
]);
- var f = findLocalVariable(_resultUnit, 'f');
+ var f = findElement.localVar('f');
_assertTypeStr(f.type, 'Future<num> Function()');
}
@@ -155,7 +151,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 122, 1),
]);
- var f = findLocalVariable(_resultUnit, 'f');
+ var f = findElement.localVar('f');
_assertTypeStr(f.type, 'Stream<num> Function()');
}
@@ -183,7 +179,7 @@
error(CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_CLOSURE, 62, 1),
]);
- var g = findLocalVariable(_resultUnit, 'g');
+ var g = findElement.localVar('g');
_assertTypeStr(g.type, 'String Function()');
}
@@ -210,7 +206,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 105, 1),
]);
- var f = findLocalVariable(_resultUnit, 'f');
+ var f = findElement.localVar('f');
_assertTypeStr(f.type, 'Future<Null> Function()');
}
@@ -228,7 +224,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 105, 1),
]);
- var f = findLocalVariable(_resultUnit, 'f');
+ var f = findElement.localVar('f');
_assertTypeStr(f.type, 'Stream<Null> Function()');
}
@@ -251,7 +247,7 @@
error(CompileTimeErrorCode.INVALID_CAST_LITERAL, 126, 7),
]);
- var f = findLocalVariable(_resultUnit, 'f');
+ var f = findElement.localVar('f');
_assertTypeStr(f.type, 'Null Function(Object)');
}
@@ -269,7 +265,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 102, 1),
]);
- var f = findLocalVariable(_resultUnit, 'f');
+ var f = findElement.localVar('f');
_assertTypeStr(f.type, 'Iterable<Null> Function()');
}
@@ -306,7 +302,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
]);
- var f = findLocalVariable(_resultUnit, 'f');
+ var f = findElement.localVar('f');
_assertTypeStr(f.type, 'double Function(int) Function()');
}
@@ -321,7 +317,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 67, 1),
]);
- var y = findLocalVariable(_resultUnit, 'y');
+ var y = findElement.localVar('y');
_assertTypeStr(y.type, 'Iterable<Null>');
}
@@ -340,7 +336,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 110, 1),
]);
- var f = findLocalVariable(_resultUnit, 'f');
+ var f = findElement.localVar('f');
_assertTypeStr(f.type, 'Iterable<num> Function()');
}
@@ -473,11 +469,10 @@
error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 349, 7),
]);
- _assertTypeStr(findLocalVariable(_resultUnit, 'x').type, 'C<int>');
- _assertTypeStr(findLocalVariable(_resultUnit, 'c_int').type, 'C<int>');
- _assertTypeStr(findLocalVariable(_resultUnit, 'c_num').type, 'C<num>');
- _assertTypeStr(
- findLocalVariable(_resultUnit, 'c_dynamic').type, 'C<dynamic>');
+ _assertTypeStr(findElement.localVar('x').type, 'C<int>');
+ _assertTypeStr(findElement.localVar('c_int').type, 'C<int>');
+ _assertTypeStr(findElement.localVar('c_num').type, 'C<num>');
+ _assertTypeStr(findElement.localVar('c_dynamic').type, 'C<dynamic>');
}
test_constructors_inferFromArguments_const() async {
@@ -494,7 +489,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 63, 1),
]);
- var x = findLocalVariable(_resultUnit, 'x');
+ var x = findElement.localVar('x');
_assertTypeStr(x.type, 'C<int>');
}
@@ -561,7 +556,7 @@
error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 149, 7),
]);
- var x = findLocalVariable(_resultUnit, 'x');
+ var x = findElement.localVar('x');
_assertTypeStr(x.type, 'C<int>');
}
@@ -592,7 +587,7 @@
error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 95, 7),
]);
- var x = findLocalVariable(_resultUnit, 'x');
+ var x = findElement.localVar('x');
_assertTypeStr(x.type, 'C<int>');
}
@@ -618,7 +613,7 @@
error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 156, 7),
]);
- var x = findLocalVariable(_resultUnit, 'x');
+ var x = findElement.localVar('x');
_assertTypeStr(x.type, 'C<int>');
}
@@ -639,7 +634,7 @@
error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 123, 7),
]);
- var x = findLocalVariable(_resultUnit, 'x');
+ var x = findElement.localVar('x');
_assertTypeStr(x.type, 'C<int>');
}
@@ -665,7 +660,7 @@
error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 183, 7),
]);
- var x = findLocalVariable(_resultUnit, 'x');
+ var x = findElement.localVar('x');
_assertTypeStr(x.type, 'C<int>');
}
@@ -692,7 +687,7 @@
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, 39, 2),
]);
- var a = findLocalVariable(_resultUnit, 'a');
+ var a = findElement.localVar('a');
_assertTypeStr(a.type, 'A<dynamic>');
}
@@ -2326,7 +2321,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 118, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'List<int> Function(num)');
}
@@ -2813,7 +2808,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 68, 1),
]);
- var y = findLocalVariable(_resultUnit, 'y');
+ var y = findElement.localVar('y');
_assertTypeStr(y.type, 'double');
}
@@ -2829,7 +2824,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 59, 1),
]);
- var y = findLocalVariable(_resultUnit, 'y');
+ var y = findElement.localVar('y');
_assertTypeStr(y.type, 'double');
}
@@ -2845,7 +2840,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 69, 1),
]);
- var y = findLocalVariable(_resultUnit, 'y');
+ var y = findElement.localVar('y');
_assertTypeStr(y.type, 'double');
}
@@ -2861,7 +2856,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 47, 1),
]);
- var y = findLocalVariable(_resultUnit, 'y');
+ var y = findElement.localVar('y');
_assertTypeStr(y.type, 'int');
}
@@ -2930,27 +2925,25 @@
contextMessages: [message(testFilePath, 211, 2)]),
]);
- _assertTypeStr(findLocalFunction(_resultUnit, 'f0').type, 'int Function()');
- _assertTypeStr(
- findLocalFunction(_resultUnit, 'f1').type, 'Future<int> Function()');
+ void assertLocalFunctionType(String name, String expected) {
+ var type = findElement.localFunction(name).type;
+ _assertTypeStr(type, expected);
+ }
- _assertTypeStr(findLocalFunction(_resultUnit, 'f2').type, 'int Function()');
- _assertTypeStr(
- findLocalFunction(_resultUnit, 'f3').type, 'Future<int> Function()');
- _assertTypeStr(
- findLocalFunction(_resultUnit, 'f4').type, 'Iterable<int> Function()');
- _assertTypeStr(
- findLocalFunction(_resultUnit, 'f5').type, 'Stream<int> Function()');
+ assertLocalFunctionType('f0', 'int Function()');
+ assertLocalFunctionType('f1', 'Future<int> Function()');
- _assertTypeStr(findLocalFunction(_resultUnit, 'f6').type, 'num Function()');
+ assertLocalFunctionType('f2', 'int Function()');
+ assertLocalFunctionType('f3', 'Future<int> Function()');
+ assertLocalFunctionType('f4', 'Iterable<int> Function()');
+ assertLocalFunctionType('f5', 'Stream<int> Function()');
+
+ assertLocalFunctionType('f6', 'num Function()');
// Recursive cases: these infer in declaration order.
- _assertTypeStr(
- findLocalFunction(_resultUnit, 'f7').type, 'dynamic Function()');
- _assertTypeStr(
- findLocalFunction(_resultUnit, 'f8').type, 'dynamic Function()');
- _assertTypeStr(
- findLocalFunction(_resultUnit, 'f9').type, 'Stream<int> Function()');
+ assertLocalFunctionType('f7', 'dynamic Function()');
+ assertLocalFunctionType('f8', 'dynamic Function()');
+ assertLocalFunctionType('f9', 'Stream<int> Function()');
}
test_inferParameterType_setter_fromField() async {
@@ -3032,7 +3025,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
]);
- var f = findLocalVariable(_resultUnit, 'f');
+ var f = findElement.localVar('f');
_assertTypeStr(f.type, 'Null Function()');
}
@@ -3089,7 +3082,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 72, 1),
]);
- var x = findLocalVariable(_resultUnit, 'x');
+ var x = findElement.localVar('x');
expect(x.name, 'x');
_assertTypeStr(x.type, 'bool');
}
@@ -3108,7 +3101,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 105, 1),
]);
- var x = findLocalVariable(_resultUnit, 'x');
+ var x = findElement.localVar('x');
expect(x.name, 'x');
_assertTypeStr(x.type, 'bool');
}
@@ -3912,7 +3905,7 @@
error(CompileTimeErrorCode.INVALID_CAST_LITERAL, 36, 2),
]);
- var x = findLocalVariable(_resultUnit, 'x');
+ var x = findElement.localVar('x');
_assertTypeStr(x.type, 'List<Null>');
}
@@ -3991,7 +3984,7 @@
error(CompileTimeErrorCode.INVALID_CAST_LITERAL, 45, 3),
]);
- var x = findLocalVariable(_resultUnit, 'x');
+ var x = findElement.localVar('x');
_assertTypeStr(x.type, 'Map<Null, Null>');
}
@@ -4086,7 +4079,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 36, 1),
]);
- var y = findLocalVariable(_resultUnit, 'y');
+ var y = findElement.localVar('y');
_assertTypeStr(y.type, 'List<num>');
}
@@ -4297,7 +4290,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
expect(v.name, 'v');
_assertTypeStr(v.type, 'double');
}
@@ -4341,7 +4334,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 42, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
expect(v.name, 'v');
_assertTypeStr(v.type, 'C<int>');
}
@@ -4435,7 +4428,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'List<int>');
}
@@ -4452,7 +4445,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'List<int>');
}
@@ -4466,7 +4459,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'double');
}
@@ -4480,7 +4473,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'double');
}
@@ -4493,7 +4486,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'List<dynamic>');
}
@@ -4507,7 +4500,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 32, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'List<int Function()>');
}
@@ -4523,7 +4516,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'List<int Function()>');
}
@@ -4536,7 +4529,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'Map<int, dynamic>');
}
@@ -4550,7 +4543,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 32, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'Map<int, int Function()>');
}
@@ -4566,7 +4559,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 15, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'Map<int, int Function()>');
}
@@ -4582,7 +4575,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 62, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'List<dynamic>');
}
@@ -4598,7 +4591,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 62, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'List<int>');
}
@@ -4617,7 +4610,7 @@
error(HintCode.UNUSED_LOCAL_VARIABLE, 62, 1),
]);
- var v = findLocalVariable(_resultUnit, 'v');
+ var v = findElement.localVar('v');
_assertTypeStr(v.type, 'List<int>');
}
diff --git a/pkg/analyzer/test/utils.dart b/pkg/analyzer/test/utils.dart
index 2e00258..64b63f6 100644
--- a/pkg/analyzer/test/utils.dart
+++ b/pkg/analyzer/test/utils.dart
@@ -7,28 +7,8 @@
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/generated/testing/element_search.dart';
import 'package:test/test.dart';
-/// Search the [unit] for the [LocalVariableElement] with the given [name].
-/// Fail if there is not exactly one such variable.
-FunctionElement findLocalFunction(CompilationUnit unit, String name) {
- List<Element> elements = findElementsByName(unit, name);
- List<Element> functions = elements.whereType<FunctionElement>().toList();
- expect(functions, hasLength(1));
- return functions[0];
-}
-
-/// Search the [unit] for the [LocalVariableElement] with the given [name].
-/// Fail if there is not exactly one such variable.
-LocalVariableElement findLocalVariable(CompilationUnit unit, String name) {
- List<Element> elements = findElementsByName(unit, name);
- List<Element> localVariables =
- elements.whereType<LocalVariableElement>().toList();
- expect(localVariables, hasLength(1));
- return localVariables[0];
-}
-
/// The type of an assertion which asserts properties of [T]s.
typedef Asserter<T> = void Function(T type);
diff --git a/pkg/analyzer_plugin/test/support/abstract_context.dart b/pkg/analyzer_plugin/test/support/abstract_context.dart
index a634551..b7c0d5a 100644
--- a/pkg/analyzer_plugin/test/support/abstract_context.dart
+++ b/pkg/analyzer_plugin/test/support/abstract_context.dart
@@ -6,7 +6,6 @@
import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/session.dart';
-import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/visitor.dart';
import 'package:analyzer/file_system/file_system.dart';
@@ -15,7 +14,6 @@
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine;
-import 'package:analyzer/src/generated/testing/element_search.dart';
import 'package:analyzer/src/test_utilities/mock_packages.dart';
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
@@ -95,13 +93,6 @@
return context.driver;
}
- Element findElementInUnit(CompilationUnit unit, String name,
- [ElementKind kind]) {
- return findElementsByName(unit, name)
- .where((e) => kind == null || e.kind == kind)
- .single;
- }
-
@override
File newFile(String path, {String content = ''}) {
if (_analysisContextCollection != null && !path.endsWith('.dart')) {
diff --git a/pkg/analyzer_plugin/test/support/abstract_single_unit.dart b/pkg/analyzer_plugin/test/support/abstract_single_unit.dart
index 03082d7..96d22e0 100644
--- a/pkg/analyzer_plugin/test/support/abstract_single_unit.dart
+++ b/pkg/analyzer_plugin/test/support/abstract_single_unit.dart
@@ -9,6 +9,8 @@
import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/dart/error/hint_codes.dart';
import 'package:analyzer/src/generated/java_engine.dart';
+import 'package:analyzer/src/test_utilities/find_element.dart';
+import 'package:analyzer/src/test_utilities/find_node.dart';
import 'package:test/test.dart';
import 'abstract_context.dart';
@@ -21,16 +23,14 @@
CompilationUnit testUnit;
CompilationUnitElement testUnitElement;
LibraryElement testLibraryElement;
+ FindNode findNode;
+ FindElement findElement;
void addTestSource(String code) {
testCode = code;
addSource(testFile, code);
}
- Element findElement(String name, [ElementKind kind]) {
- return findChildElement(testUnitElement, name, kind);
- }
-
int findEnd(String search) {
return findOffset(search) + search.length;
}
@@ -93,7 +93,8 @@
Future<void> resolveTestUnit(String code) async {
addTestSource(code);
var result = await resolveFile(testFile);
- testUnit = (result).unit;
+ testCode = result.content;
+ testUnit = result.unit;
if (verifyNoTestUnitErrors) {
expect(result.errors.where((AnalysisError error) {
return error.errorCode != HintCode.DEAD_CODE &&
@@ -107,6 +108,8 @@
}
testUnitElement = testUnit.declaredElement;
testLibraryElement = testUnitElement.library;
+ findNode = FindNode(testCode, testUnit);
+ findElement = FindElement(testUnit);
}
@override
diff --git a/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart b/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
index 5d75ed1..49b70c5 100644
--- a/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
+++ b/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
@@ -15,17 +15,16 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../support/abstract_context.dart';
+import '../support/abstract_single_unit.dart';
void main() {
defineReflectiveTests(AnalyzerConverterTest);
}
@reflectiveTest
-class AnalyzerConverterTest extends AbstractContextTest {
+class AnalyzerConverterTest extends AbstractSingleUnitTest {
AnalyzerConverter converter = AnalyzerConverter();
analyzer.Source source;
- String testFile;
/// Assert that the given [pluginError] matches the given [analyzerError].
void assertError(
@@ -200,14 +199,12 @@
}
Future<void> test_convertElement_class() async {
- addSource(testFile, '''
+ await resolveTestUnit('''
@deprecated
abstract class _A {}
class B<K, V> {}''');
- var unit = (await resolveFile(testFile))?.unit;
{
- var engineElement =
- findElementInUnit(unit, '_A') as analyzer.ClassElement;
+ var engineElement = findElement.class_('_A');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.CLASS);
@@ -229,7 +226,7 @@
plugin.Element.FLAG_PRIVATE);
}
{
- var engineElement = findElementInUnit(unit, 'B') as analyzer.ClassElement;
+ var engineElement = findElement.class_('B');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.CLASS);
@@ -240,13 +237,11 @@
}
Future<void> test_convertElement_constructor() async {
- addSource(testFile, '''
+ await resolveTestUnit('''
class A {
const A.myConstructor(int a, [String b]);
}''');
- var unit = (await resolveFile(testFile))?.unit;
- var engineElement =
- findElementInUnit(unit, 'myConstructor') as analyzer.ConstructorElement;
+ var engineElement = findElement.constructor('myConstructor');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.CONSTRUCTOR);
@@ -278,14 +273,12 @@
}
Future<void> test_convertElement_enum() async {
- addSource(testFile, '''
+ await resolveTestUnit('''
@deprecated
enum _E1 { one, two }
enum E2 { three, four }''');
- var unit = (await resolveFile(testFile))?.unit;
{
- var engineElement =
- findElementInUnit(unit, '_E1') as analyzer.ClassElement;
+ var engineElement = findElement.enum_('_E1');
expect(engineElement.hasDeprecated, isTrue);
// create notification Element
var element = converter.convertElement(engineElement);
@@ -307,8 +300,7 @@
plugin.Element.FLAG_PRIVATE);
}
{
- var engineElement =
- findElementInUnit(unit, 'E2') as analyzer.ClassElement;
+ var engineElement = findElement.enum_('E2');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.ENUM);
@@ -319,14 +311,12 @@
}
Future<void> test_convertElement_enumConstant() async {
- addSource(testFile, '''
+ await resolveTestUnit('''
@deprecated
enum _E1 { one, two }
enum E2 { three, four }''');
- var unit = (await resolveFile(testFile))?.unit;
{
- var engineElement =
- findElementInUnit(unit, 'one') as analyzer.FieldElement;
+ var engineElement = findElement.field('one');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.ENUM_CONSTANT);
@@ -350,8 +340,7 @@
plugin.Element.FLAG_CONST | plugin.Element.FLAG_STATIC);
}
{
- var engineElement =
- findElementInUnit(unit, 'three') as analyzer.FieldElement;
+ var engineElement = findElement.field('three');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.ENUM_CONSTANT);
@@ -370,7 +359,7 @@
plugin.Element.FLAG_CONST | plugin.Element.FLAG_STATIC);
}
{
- var engineElement = unit.declaredElement.enums[1].getField('index');
+ var engineElement = findElement.field('index', of: 'E2');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.FIELD);
@@ -388,7 +377,7 @@
expect(element.flags, plugin.Element.FLAG_FINAL);
}
{
- var engineElement = unit.declaredElement.enums[1].getField('values');
+ var engineElement = findElement.field('values', of: 'E2');
// create notification Element
var element = converter.convertElement(engineElement);
@@ -410,13 +399,11 @@
}
Future<void> test_convertElement_field() async {
- addSource(testFile, '''
+ await resolveTestUnit('''
class A {
static const myField = 42;
}''');
- var unit = (await resolveFile(testFile))?.unit;
- var engineElement =
- findElementInUnit(unit, 'myField') as analyzer.FieldElement;
+ var engineElement = findElement.field('myField');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.FIELD);
@@ -436,12 +423,10 @@
}
Future<void> test_convertElement_functionTypeAlias() async {
- addSource(testFile, '''
+ await resolveTestUnit('''
typedef int F<T>(String x);
''');
- var unit = (await resolveFile(testFile))?.unit;
- var engineElement =
- findElementInUnit(unit, 'F') as analyzer.FunctionTypeAliasElement;
+ var engineElement = findElement.typeAlias('F');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.FUNCTION_TYPE_ALIAS);
@@ -461,12 +446,10 @@
}
Future<void> test_convertElement_genericTypeAlias_function() async {
- addSource(testFile, '''
+ await resolveTestUnit('''
typedef F<T> = int Function(String x);
''');
- var unit = (await resolveFile(testFile))?.unit;
- var engineElement =
- findElementInUnit(unit, 'F') as analyzer.FunctionTypeAliasElement;
+ var engineElement = findElement.typeAlias('F');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.FUNCTION_TYPE_ALIAS);
@@ -486,14 +469,11 @@
}
Future<void> test_convertElement_getter() async {
- addSource(testFile, '''
+ await resolveTestUnit('''
class A {
- String get myGetter => 42;
+ int get myGetter => 42;
}''');
- var unit = (await resolveFile(testFile))?.unit;
- var engineElement =
- findElementInUnit(unit, 'myGetter', analyzer.ElementKind.GETTER)
- as analyzer.PropertyAccessorElement;
+ var engineElement = findElement.getter('myGetter');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.GETTER);
@@ -501,26 +481,24 @@
{
var location = element.location;
expect(location.file, testFile);
- expect(location.offset, 23);
+ expect(location.offset, 20);
expect(location.length, 'myGetter'.length);
expect(location.startLine, 2);
- expect(location.startColumn, 14);
+ expect(location.startColumn, 11);
}
expect(element.parameters, isNull);
- expect(element.returnType, 'String');
+ expect(element.returnType, 'int');
expect(element.flags, 0);
}
Future<void> test_convertElement_method() async {
- addSource(testFile, '''
+ await resolveTestUnit('''
class A {
static List<String> myMethod(int a, {String b, int c}) {
return null;
}
}''');
- var unit = (await resolveFile(testFile))?.unit;
- var engineElement =
- findElementInUnit(unit, 'myMethod') as analyzer.MethodElement;
+ var engineElement = findElement.method('myMethod');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.METHOD);
@@ -539,14 +517,11 @@
}
Future<void> test_convertElement_setter() async {
- addSource(testFile, '''
+ await resolveTestUnit('''
class A {
set mySetter(String x) {}
}''');
- var unit = (await resolveFile(testFile))?.unit;
- var engineElement =
- findElementInUnit(unit, 'mySetter', analyzer.ElementKind.SETTER)
- as analyzer.PropertyAccessorElement;
+ var engineElement = findElement.setter('mySetter');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.SETTER);
@@ -615,16 +590,14 @@
}
Future<void> test_fromElement_LABEL() async {
- addSource(testFile, '''
+ await resolveTestUnit('''
main() {
myLabel:
while (true) {
break myLabel;
}
}''');
- var unit = (await resolveFile(testFile))?.unit;
- var engineElement =
- findElementInUnit(unit, 'myLabel') as analyzer.LabelElement;
+ var engineElement = findElement.label('myLabel');
// create notification Element
var element = converter.convertElement(engineElement);
expect(element.kind, plugin.ElementKind.LABEL);
diff --git a/pkg/analyzer_plugin/test/utilities/range_factory_test.dart b/pkg/analyzer_plugin/test/utilities/range_factory_test.dart
index a2ac201..e157ab5 100644
--- a/pkg/analyzer_plugin/test/utilities/range_factory_test.dart
+++ b/pkg/analyzer_plugin/test/utilities/range_factory_test.dart
@@ -173,7 +173,7 @@
Future<void> test_elementName() async {
await resolveTestUnit('class ABC {}');
- var element = findElement('ABC');
+ var element = findElement.class_('ABC');
expect(range.elementName(element), SourceRange(6, 3));
}
diff --git a/pkg/compiler/lib/src/kernel/dart2js_target.dart b/pkg/compiler/lib/src/kernel/dart2js_target.dart
index 49923c1..547be62 100644
--- a/pkg/compiler/lib/src/kernel/dart2js_target.dart
+++ b/pkg/compiler/lib/src/kernel/dart2js_target.dart
@@ -63,6 +63,8 @@
@override
final String name;
+ Map<String, ir.Class> _nativeClasses;
+
Dart2jsTarget(this.name, this.flags);
@override
@@ -124,9 +126,12 @@
ReferenceFromIndex referenceFromIndex,
{void logger(String msg),
ChangedStructureNotifier changedStructureNotifier}) {
+ _nativeClasses ??= JsInteropChecks.getNativeClasses(component);
for (var library in libraries) {
- JsInteropChecks(coreTypes,
- diagnosticReporter as DiagnosticReporter<Message, LocatedMessage>)
+ JsInteropChecks(
+ coreTypes,
+ diagnosticReporter as DiagnosticReporter<Message, LocatedMessage>,
+ _nativeClasses)
.visitLibrary(library);
}
lowering.transformLibraries(
diff --git a/pkg/dds/CHANGELOG.md b/pkg/dds/CHANGELOG.md
index c657089..80420e2 100644
--- a/pkg/dds/CHANGELOG.md
+++ b/pkg/dds/CHANGELOG.md
@@ -1,3 +1,6 @@
+# 1.7.1
+- Fixed issue where DartDevelopmentServiceException could have a null message.
+
# 1.7.0
- Added `package:dds/vm_service_extensions.dart`, which adds DDS functionality to
`package:vm_service` when imported.
diff --git a/pkg/dds/lib/src/dds_impl.dart b/pkg/dds/lib/src/dds_impl.dart
index 8fdc7a8..137cd20 100644
--- a/pkg/dds/lib/src/dds_impl.dart
+++ b/pkg/dds/lib/src/dds_impl.dart
@@ -136,10 +136,12 @@
});
} on json_rpc.RpcException catch (e) {
await _server.close(force: true);
+ String message = e.toString();
+ if (e.data != null) {
+ message += ' data: ${e.data}';
+ }
// _yieldControlToDDS fails if DDS is not the only VM service client.
- throw DartDevelopmentServiceException.existingDdsInstance(
- e.data != null ? e.data['details'] : e.toString(),
- );
+ throw DartDevelopmentServiceException.existingDdsInstance(message);
}
_uri = tmpUri;
diff --git a/pkg/dds/pubspec.yaml b/pkg/dds/pubspec.yaml
index 27bf432..a7fff90 100644
--- a/pkg/dds/pubspec.yaml
+++ b/pkg/dds/pubspec.yaml
@@ -3,7 +3,7 @@
A library used to spawn the Dart Developer Service, used to communicate with
a Dart VM Service instance.
-version: 1.7.0
+version: 1.7.1
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/dds
diff --git a/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart b/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart
index 87ddd49..363ff0b 100644
--- a/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart
+++ b/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart
@@ -481,7 +481,8 @@
/// Emits imports and extension methods into [items].
@protected
- void emitImportsAndExtensionSymbols(List<js_ast.ModuleItem> items) {
+ void emitImportsAndExtensionSymbols(List<js_ast.ModuleItem> items,
+ {bool forceExtensionSymbols = false}) {
var modules = <String, List<Library>>{};
for (var import in _imports.keys) {
@@ -525,6 +526,9 @@
js_ast.PropertyAccess(extensionSymbolsModule, propertyName(name));
if (isBuildingSdk) {
value = js.call('# = Symbol(#)', [value, js.string('dartx.$name')]);
+ } else if (forceExtensionSymbols) {
+ value = js.call(
+ '# || (# = Symbol(#))', [value, value, js.string('dartx.$name')]);
}
if (!_symbolContainer.canEmit(id)) {
// Extension symbols marked with noEmit are managed manually.
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index 0098e51..9a1b17c 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -35,6 +35,7 @@
import 'native_types.dart';
import 'nullable_inference.dart';
import 'property_model.dart';
+import 'target.dart' show allowedNativeTest;
import 'type_table.dart';
class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
@@ -251,7 +252,7 @@
coreTypes ??= CoreTypes(component);
var types = TypeEnvironment(coreTypes, hierarchy);
var constants = DevCompilerConstants();
- var nativeTypes = NativeTypeSet(coreTypes, constants);
+ var nativeTypes = NativeTypeSet(coreTypes, constants, component);
var jsTypeRep = JSTypeRep(types, hierarchy);
var staticTypeContext = StatefulStaticTypeContext.stacked(types);
return ProgramCompiler._(
@@ -411,7 +412,9 @@
libraries.forEach(_emitExports);
// Declare imports and extension symbols
- emitImportsAndExtensionSymbols(items);
+ emitImportsAndExtensionSymbols(items,
+ forceExtensionSymbols:
+ libraries.any((l) => allowedNativeTest(l.importUri)));
// Insert a check that runs when loading this module to verify that the null
// safety mode it was compiled in matches the mode used when compiling the
@@ -2456,7 +2459,12 @@
js_ast.PropertyAccess _emitTopLevelNameNoInterop(NamedNode n,
{String suffix = ''}) {
- return js_ast.PropertyAccess(emitLibraryName(getLibrary(n)),
+ // Some native tests use top-level native methods.
+ var isTopLevelNative = n is Member && isNative(n);
+ return js_ast.PropertyAccess(
+ isTopLevelNative
+ ? runtimeCall('global.self')
+ : emitLibraryName(getLibrary(n)),
_emitTopLevelMemberName(n, suffix: suffix));
}
diff --git a/pkg/dev_compiler/lib/src/kernel/js_interop.dart b/pkg/dev_compiler/lib/src/kernel/js_interop.dart
index ae20b09..13b1f25 100644
--- a/pkg/dev_compiler/lib/src/kernel/js_interop.dart
+++ b/pkg/dev_compiler/lib/src/kernel/js_interop.dart
@@ -45,7 +45,9 @@
bool isJsMember(Member member) {
// TODO(vsm): If we ever use external outside the SDK for non-JS interop,
// we're need to fix this.
- return !_isLibrary(member.enclosingLibrary, ['dart:*']) && member.isExternal;
+ return !_isLibrary(member.enclosingLibrary, ['dart:*']) &&
+ member.isExternal &&
+ !isNative(member);
}
bool _annotationIsFromJSLibrary(String expectedName, Expression value) {
diff --git a/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart b/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
index fbc740a..64eb246 100644
--- a/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
+++ b/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
@@ -353,3 +353,28 @@
t is TypedefType ||
t is VoidType;
}
+
+/// Whether [member] is declared native, as in:
+///
+/// void foo() native;
+///
+/// This syntax is only allowed in sdk libraries and native tests.
+bool isNative(Member member) =>
+ // The CFE represents `native` members with the `external` bit and with an
+ // internal @ExternalName annotation as a marker.
+ member.isExternal && member.annotations.any(_isNativeMarkerAnnotation);
+
+bool _isNativeMarkerAnnotation(Expression annotation) {
+ if (annotation is ConstantExpression) {
+ var constant = annotation.constant;
+ if (constant is InstanceConstant &&
+ constant.classNode.name == 'ExternalName' &&
+ _isDartInternal(constant.classNode.enclosingLibrary.importUri)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool _isDartInternal(Uri uri) =>
+ uri.scheme == 'dart' && uri.path == '_internal';
diff --git a/pkg/dev_compiler/lib/src/kernel/native_types.dart b/pkg/dev_compiler/lib/src/kernel/native_types.dart
index 2aa3164..dd7bdc8 100644
--- a/pkg/dev_compiler/lib/src/kernel/native_types.dart
+++ b/pkg/dev_compiler/lib/src/kernel/native_types.dart
@@ -9,6 +9,7 @@
import 'package:kernel/kernel.dart';
import 'constants.dart';
import 'kernel_helpers.dart';
+import 'target.dart' show allowedNativeTest;
/// Contains information about native JS types (those types provided by the
/// implementation) that are also provided by the Dart SDK.
@@ -39,7 +40,7 @@
final _nativeTypes = HashSet<Class>.identity();
final _pendingLibraries = HashSet<Library>.identity();
- NativeTypeSet(this.coreTypes, this.constants) {
+ NativeTypeSet(this.coreTypes, this.constants, Component component) {
// First, core types:
// TODO(vsm): If we're analyzing against the main SDK, those
// types are not explicitly annotated.
@@ -69,6 +70,14 @@
_addPendingExtensionTypes(sdk.getLibrary('dart:web_audio'));
_addPendingExtensionTypes(sdk.getLibrary('dart:web_gl'));
_addPendingExtensionTypes(sdk.getLibrary('dart:web_sql'));
+
+ // For testing purposes only, we add extension types outside the Dart SDK.
+ // These are only allowed for native tests (see allowedNativeTest).
+ for (var library in component.libraries) {
+ if (allowedNativeTest(library.importUri)) {
+ _addExtensionTypes(library);
+ }
+ }
}
void _addExtensionType(Class c, [bool mustBeNative = false]) {
diff --git a/pkg/dev_compiler/lib/src/kernel/target.dart b/pkg/dev_compiler/lib/src/kernel/target.dart
index ca82d2e..ecec776 100644
--- a/pkg/dev_compiler/lib/src/kernel/target.dart
+++ b/pkg/dev_compiler/lib/src/kernel/target.dart
@@ -30,6 +30,8 @@
WidgetCreatorTracker _widgetTracker;
+ Map<String, Class> _nativeClasses;
+
@override
bool get enableSuperMixins => true;
@@ -116,9 +118,7 @@
bool _allowedTestLibrary(Uri uri) {
// Multi-root scheme used by modular test framework.
if (uri.scheme == 'dev-dart-app') return true;
-
- var scriptName = uri.path;
- return scriptName.contains('tests/dartdevc');
+ return allowedNativeTest(uri);
}
bool _allowedDartLibrary(Uri uri) => uri.scheme == 'dart';
@@ -152,10 +152,13 @@
ReferenceFromIndex referenceFromIndex,
{void Function(String msg) logger,
ChangedStructureNotifier changedStructureNotifier}) {
+ _nativeClasses ??= JsInteropChecks.getNativeClasses(component);
for (var library in libraries) {
_CovarianceTransformer(library).transform();
- JsInteropChecks(coreTypes,
- diagnosticReporter as DiagnosticReporter<Message, LocatedMessage>)
+ JsInteropChecks(
+ coreTypes,
+ diagnosticReporter as DiagnosticReporter<Message, LocatedMessage>,
+ _nativeClasses)
.visitLibrary(library);
}
}
@@ -444,3 +447,16 @@
super.visitEqualsCall(node);
}
}
+
+List<Pattern> _allowedNativeTestPatterns = [
+ 'tests/dartdevc',
+ 'tests/dart2js/native',
+ 'tests/dart2js_2/native',
+ 'tests/dart2js/internal',
+ 'tests/dart2js_2/internal',
+];
+
+bool allowedNativeTest(Uri uri) {
+ var path = uri.path;
+ return _allowedNativeTestPatterns.any((pattern) => path.contains(pattern));
+}
diff --git a/pkg/front_end/messages.status b/pkg/front_end/messages.status
index c275e1e..afaa87e 100644
--- a/pkg/front_end/messages.status
+++ b/pkg/front_end/messages.status
@@ -488,6 +488,8 @@
JsInteropJSClassExtendsDartClass/example: Fail # Web compiler specific
JsInteropNamedParameters/analyzerCode: Fail # Web compiler specific
JsInteropNamedParameters/example: Fail # Web compiler specific
+JsInteropNativeClassInAnnotation/analyzerCode: Fail # Web compiler specific
+JsInteropNativeClassInAnnotation/example: Fail # Web compiler specific
JsInteropNonExternalConstructor/analyzerCode: Fail # Web compiler specific
JsInteropNonExternalConstructor/example: Fail # Web compiler specific
JsInteropNonExternalMember/analyzerCode: Fail # Web compiler specific
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index 1f25446..390424e 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -4671,6 +4671,9 @@
template: "Named parameters for JS interop functions are only allowed in a factory constructor of an @anonymous JS class."
tip: "Try replacing them with normal or optional parameters."
+JsInteropNativeClassInAnnotation:
+ template: "JS interop class '#name' conflicts with natively supported class '#name2' in '#string3'."
+
JsInteropNonExternalConstructor:
template: "JS interop classes do not support non-external constructors."
tip: "Try annotating with `external`."
@@ -4932,4 +4935,4 @@
exampleAllowMoreCodes: true
analyzerCode: UNEXPECTED_TOKEN
script:
- - "late int x;"
\ No newline at end of file
+ - "late int x;"
diff --git a/pkg/front_end/test/spell_checking_list_messages.txt b/pkg/front_end/test/spell_checking_list_messages.txt
index b0f4e5e..d754653 100644
--- a/pkg/front_end/test/spell_checking_list_messages.txt
+++ b/pkg/front_end/test/spell_checking_list_messages.txt
@@ -41,6 +41,7 @@
name.stack
nameokempty
native('native
+natively
nativetype
nnbd
nosuchmethod
diff --git a/pkg/frontend_server/lib/frontend_server.dart b/pkg/frontend_server/lib/frontend_server.dart
index 763bfee..5b8a4eb 100644
--- a/pkg/frontend_server/lib/frontend_server.dart
+++ b/pkg/frontend_server/lib/frontend_server.dart
@@ -56,9 +56,6 @@
..addFlag('tree-shake-write-only-fields',
help: 'Enable tree shaking of fields which are only written in AOT mode.',
defaultsTo: true)
- ..addFlag('protobuf-tree-shaker',
- help: 'Enable protobuf tree shaker transformation in AOT mode.',
- defaultsTo: false)
..addFlag('protobuf-tree-shaker-v2',
help: 'Enable protobuf tree shaker v2 in AOT mode.', defaultsTo: false)
..addFlag('minimal-kernel',
@@ -529,7 +526,6 @@
useGlobalTypeFlowAnalysis: options['tfa'],
environmentDefines: environmentDefines,
enableAsserts: options['enable-asserts'],
- useProtobufTreeShaker: options['protobuf-tree-shaker'],
useProtobufTreeShakerV2: options['protobuf-tree-shaker-v2'],
minimalKernel: options['minimal-kernel'],
treeShakeWriteOnlyFields: options['tree-shake-write-only-fields'],
diff --git a/pkg/vm/bin/protobuf_aware_treeshaker.dart b/pkg/vm/bin/protobuf_aware_treeshaker.dart
index d1fa2d1..69aa466 100644
--- a/pkg/vm/bin/protobuf_aware_treeshaker.dart
+++ b/pkg/vm/bin/protobuf_aware_treeshaker.dart
@@ -30,13 +30,14 @@
import 'package:args/args.dart';
import 'package:kernel/kernel.dart';
import 'package:kernel/binary/ast_to_binary.dart';
+import 'package:kernel/core_types.dart' show CoreTypes;
import 'package:vm/kernel_front_end.dart'
show runGlobalTransformations, ErrorDetector;
import 'package:kernel/target/targets.dart' show TargetFlags, getTarget;
import 'package:meta/meta.dart';
import 'package:vm/target/install.dart' show installAdditionalTargets;
-import 'package:vm/transformations/protobuf_aware_treeshaker/transformer.dart'
- as treeshaker;
+import 'package:vm/transformations/type_flow/transformer.dart' as globalTypeFlow
+ show transformComponent;
ArgResults parseArgs(List<String> args) {
ArgParser argParser = ArgParser()
@@ -99,11 +100,6 @@
final input = argResults.rest[0];
final output = argResults.rest[1];
- final Map<String, String> environment = Map.fromIterable(
- argResults['define'].map((x) => x.split('=')),
- key: (x) => x[0],
- value: (x) => x[1]);
-
var bytes = File(input).readAsBytesSync();
final platformFile = argResults['platform'];
if (platformFile != null) {
@@ -119,31 +115,19 @@
if (argResults['aot']) {
const bool useGlobalTypeFlowAnalysis = true;
const bool enableAsserts = false;
- const bool useProtobufAwareTreeShaker = true;
- const bool useProtobufAwareTreeShakerV2 = false;
+ const bool useProtobufAwareTreeShakerV2 = true;
final nopErrorDetector = ErrorDetector();
runGlobalTransformations(
target,
component,
useGlobalTypeFlowAnalysis,
enableAsserts,
- useProtobufAwareTreeShaker,
useProtobufAwareTreeShakerV2,
nopErrorDetector,
);
} else {
- treeshaker.TransformationInfo info = treeshaker.transformComponent(
- component, environment, target,
- collectInfo: argResults['verbose']);
-
- if (argResults['verbose']) {
- for (String fieldName in info.removedMessageFields) {
- print('Removed $fieldName');
- }
- for (Class removedClass in info.removedMessageClasses) {
- print('Removed $removedClass');
- }
- }
+ globalTypeFlow.transformComponent(target, CoreTypes(component), component,
+ treeShakeProtobufs: true, treeShakeSignatures: false);
}
if (argResults['aot']) {
diff --git a/pkg/vm/lib/kernel_front_end.dart b/pkg/vm/lib/kernel_front_end.dart
index eb8f045..bd60735 100644
--- a/pkg/vm/lib/kernel_front_end.dart
+++ b/pkg/vm/lib/kernel_front_end.dart
@@ -55,8 +55,6 @@
show transformComponent;
import 'transformations/no_dynamic_invocations_annotator.dart'
as no_dynamic_invocations_annotator show transformComponent;
-import 'transformations/protobuf_aware_treeshaker/transformer.dart'
- as protobuf_tree_shaker;
import 'transformations/type_flow/transformer.dart' as globalTypeFlow
show transformComponent;
import 'transformations/obfuscation_prohibitions_annotator.dart'
@@ -104,9 +102,6 @@
args.addFlag('tree-shake-write-only-fields',
help: 'Enable tree shaking of fields which are only written in AOT mode.',
defaultsTo: true);
- args.addFlag('protobuf-tree-shaker',
- help: 'Enable protobuf tree shaker transformation in AOT mode.',
- defaultsTo: false);
args.addFlag('protobuf-tree-shaker-v2',
help: 'Enable protobuf tree shaker v2 in AOT mode.', defaultsTo: false);
args.addMultiOption('define',
@@ -174,7 +169,6 @@
final bool embedSources = options['embed-sources'];
final bool enableAsserts = options['enable-asserts'];
final bool nullSafety = options['sound-null-safety'];
- final bool useProtobufTreeShaker = options['protobuf-tree-shaker'];
final bool useProtobufTreeShakerV2 = options['protobuf-tree-shaker-v2'];
final bool splitOutputByPackages = options['split-output-by-packages'];
final String manifestFilename = options['manifest'];
@@ -255,7 +249,6 @@
useGlobalTypeFlowAnalysis: tfa,
environmentDefines: environmentDefines,
enableAsserts: enableAsserts,
- useProtobufTreeShaker: useProtobufTreeShaker,
useProtobufTreeShakerV2: useProtobufTreeShakerV2,
minimalKernel: minimalKernel,
treeShakeWriteOnlyFields: treeShakeWriteOnlyFields,
@@ -322,7 +315,6 @@
bool useGlobalTypeFlowAnalysis: false,
Map<String, String> environmentDefines,
bool enableAsserts: true,
- bool useProtobufTreeShaker: false,
bool useProtobufTreeShakerV2: false,
bool minimalKernel: false,
bool treeShakeWriteOnlyFields: false,
@@ -356,7 +348,6 @@
component,
useGlobalTypeFlowAnalysis,
enableAsserts,
- useProtobufTreeShaker,
useProtobufTreeShakerV2,
errorDetector,
minimalKernel: minimalKernel,
@@ -414,7 +405,6 @@
Component component,
bool useGlobalTypeFlowAnalysis,
bool enableAsserts,
- bool useProtobufTreeShaker,
bool useProtobufTreeShakerV2,
ErrorDetector errorDetector,
{bool minimalKernel: false,
@@ -435,10 +425,6 @@
// before type flow analysis so TFA won't take unreachable code into account.
unreachable_code_elimination.transformComponent(component, enableAsserts);
- if (useProtobufTreeShaker && useProtobufTreeShakerV2) {
- throw 'Cannot use both versions of protobuf tree shaker';
- }
-
if (useGlobalTypeFlowAnalysis) {
globalTypeFlow.transformComponent(target, coreTypes, component,
treeShakeSignatures: !minimalKernel,
@@ -449,19 +435,6 @@
no_dynamic_invocations_annotator.transformComponent(component);
}
- if (useProtobufTreeShaker) {
- if (!useGlobalTypeFlowAnalysis) {
- throw 'Protobuf tree shaker requires type flow analysis (--tfa)';
- }
-
- protobuf_tree_shaker.removeUnusedProtoReferences(
- component, coreTypes, null);
-
- globalTypeFlow.transformComponent(target, coreTypes, component,
- treeShakeSignatures: !minimalKernel,
- treeShakeWriteOnlyFields: treeShakeWriteOnlyFields);
- }
-
// TODO(35069): avoid recomputing CSA by reading it from the platform files.
void ignoreAmbiguousSupertypes(cls, a, b) {}
final hierarchy = new ClassHierarchy(component, coreTypes,
diff --git a/pkg/vm/lib/transformations/protobuf_aware_treeshaker/transformer.dart b/pkg/vm/lib/transformations/protobuf_aware_treeshaker/transformer.dart
deleted file mode 100644
index e216685..0000000
--- a/pkg/vm/lib/transformations/protobuf_aware_treeshaker/transformer.dart
+++ /dev/null
@@ -1,341 +0,0 @@
-// Copyright (c) 2019, 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.
-
-import 'package:kernel/kernel.dart';
-import 'package:kernel/target/targets.dart';
-import 'package:kernel/core_types.dart';
-import 'package:meta/meta.dart';
-import 'package:vm/transformations/type_flow/transformer.dart' as globalTypeFlow
- show transformComponent;
-import 'package:vm/transformations/no_dynamic_invocations_annotator.dart'
- show Selector;
-
-class TransformationInfo {
- final List<String> removedMessageFields = <String>[];
- final List<Class> removedMessageClasses = <Class>[];
-}
-
-TransformationInfo transformComponent(
- Component component, Map<String, String> environment, Target target,
- {@required bool collectInfo}) {
- final coreTypes = new CoreTypes(component);
-
- TransformationInfo info = collectInfo ? TransformationInfo() : null;
-
- _treeshakeProtos(target, component, coreTypes, info);
- return info;
-}
-
-void _treeshakeProtos(Target target, Component component, CoreTypes coreTypes,
- TransformationInfo info) {
- globalTypeFlow.transformComponent(target, coreTypes, component,
- treeShakeSignatures: false);
-
- final collector = removeUnusedProtoReferences(component, coreTypes, info);
- if (collector != null) {
- globalTypeFlow.transformComponent(target, coreTypes, component,
- treeShakeSignatures: false);
- if (info != null) {
- for (Class gmSubclass in collector.gmSubclasses) {
- if (!gmSubclass.enclosingLibrary.classes.contains(gmSubclass)) {
- info.removedMessageClasses.add(gmSubclass);
- }
- }
- }
- }
-
- // Remove metadata added by the typeflow analysis (even if the code doesn't
- // use any protos).
- component.metadata.clear();
-}
-
-/// Called by the signature shaker to exclude the positional parameters of
-/// certain members whose first few parameters are depended upon by the
-/// protobuf-aware tree shaker.
-bool excludePositionalParametersFromSignatureShaking(Member member) {
- return member.enclosingClass?.name == 'BuilderInfo' &&
- member.enclosingLibrary.importUri ==
- Uri.parse('package:protobuf/protobuf.dart') &&
- _UnusedFieldMetadataPruner.fieldAddingMethods.contains(member.name.name);
-}
-
-InfoCollector removeUnusedProtoReferences(
- Component component, CoreTypes coreTypes, TransformationInfo info) {
- final protobufUri = Uri.parse('package:protobuf/protobuf.dart');
- final protobufLibs =
- component.libraries.where((lib) => lib.importUri == protobufUri);
- if (protobufLibs.isEmpty) {
- return null;
- }
- final protobufLib = protobufLibs.single;
-
- final gmClass = protobufLib.classes
- .where((klass) => klass.name == 'GeneratedMessage')
- .single;
- final tagNumberClass =
- protobufLib.classes.where((klass) => klass.name == 'TagNumber').single;
-
- final collector = InfoCollector(gmClass);
-
- final biClass =
- protobufLib.classes.where((klass) => klass.name == 'BuilderInfo').single;
- final addMethod =
- biClass.members.singleWhere((Member member) => member.name.text == 'add');
-
- component.accept(collector);
-
- _UnusedFieldMetadataPruner(tagNumberClass, biClass, addMethod,
- collector.dynamicSelectors, coreTypes, info)
- .removeMetadataForUnusedFields(
- collector.gmSubclasses,
- collector.gmSubclassesInvokedMethods,
- coreTypes,
- info,
- );
-
- return collector;
-}
-
-/// For protobuf fields which are not accessed, prune away its metadata.
-class _UnusedFieldMetadataPruner extends TreeVisitor<void> {
- final Class tagNumberClass;
- final Reference tagNumberField;
- // All of those methods have the dart field name as second positional
- // parameter.
- // Method names are defined in:
- // https://github.com/dart-lang/protobuf/blob/master/protobuf/lib/src/protobuf/builder_info.dart
- // The code is generated by:
- // https://github.com/dart-lang/protobuf/blob/master/protoc_plugin/lib/protobuf_field.dart.
- static final fieldAddingMethods = Set<String>.from(const <String>[
- 'a',
- 'aOM',
- 'aOS',
- 'aQM',
- 'pPS',
- 'aQS',
- 'aInt64',
- 'aOB',
- 'e',
- 'p',
- 'pc',
- 'm',
- ]);
-
- final Class builderInfoClass;
- Class visitedClass;
- final names = Set<String>();
- final usedTagNumbers = Set<int>();
-
- final dynamicNames = Set<String>();
- final CoreTypes coreTypes;
- final TransformationInfo info;
- final Member addMethod;
-
- _UnusedFieldMetadataPruner(this.tagNumberClass, this.builderInfoClass,
- this.addMethod, Set<Selector> dynamicSelectors, this.coreTypes, this.info)
- : tagNumberField = tagNumberClass.fields
- .firstWhere((f) => f.name.text == 'tagNumber')
- .getterReference {
- dynamicNames.addAll(dynamicSelectors.map((sel) => sel.target.text));
- }
-
- /// If a proto message field is never accessed (neither read nor written to),
- /// remove its corresponding metadata in the construction of the Message._i
- /// field (i.e. the BuilderInfo metadata).
- void removeMetadataForUnusedFields(
- Set<Class> gmSubclasses,
- Map<Class, Set<Selector>> invokedMethods,
- CoreTypes coreTypes,
- TransformationInfo info) {
- for (final klass in gmSubclasses) {
- final selectors = invokedMethods[klass] ?? Set<Selector>();
- final builderInfoFields = klass.fields.where((f) => f.name.text == '_i');
- if (builderInfoFields.isEmpty) {
- continue;
- }
- final builderInfoField = builderInfoFields.single;
- _pruneBuilderInfoField(builderInfoField, selectors, klass);
- }
- }
-
- void _pruneBuilderInfoField(
- Field field, Set<Selector> selectors, Class gmSubclass) {
- names.clear();
- names.addAll(selectors.map((sel) => sel.target.text));
- visitedClass = gmSubclass;
- _computeUsedTagNumbers(gmSubclass);
- field.initializer.accept(this);
- }
-
- void _computeUsedTagNumbers(Class gmSubclass) {
- usedTagNumbers.clear();
- for (final procedure in gmSubclass.procedures) {
- for (final annotation in procedure.annotations) {
- if (annotation is ConstantExpression) {
- final constant = annotation.constant;
- if (constant is InstanceConstant &&
- constant.classReference == tagNumberClass.reference) {
- final name = procedure.name.text;
- if (dynamicNames.contains(name) || names.contains(name)) {
- usedTagNumbers.add(
- (constant.fieldValues[tagNumberField] as IntConstant).value);
- }
- }
- }
- }
- }
- }
-
- @override
- visitBlockExpression(BlockExpression node) {
- // The BuilderInfo field `_i` is set up with a row of cascaded calls.
- // ```
- // static final BuilderInfo _i = BuilderInfo('MessageName')
- // ..a(1, 'foo', PbFieldType.OM)
- // ..a(2, 'bar', PbFieldType.OM)
- // ```
- // Each cascaded call will be represented in kernel as an entry in a
- // BlockExpression (but starts out in a Let), where each statement in block
- // is an ExpressionStatement, and where each statement will be a call to a
- // method of `builderInfo`.
- // For example:
- // ```
- // {protobuf::BuilderInfo::a}<dart.core::int*>(1, "foo", #C10)
- // ```
- // The methods enumerated in `fieldAddingMethods` are the ones that set up
- // fields (other methods do other things).
- //
- // First argument is the tag-number of the added field.
- // Second argument is the field-name.
- // Further arguments are specific to the method.
- for (Statement statement in node.body.statements) {
- if (statement is ExpressionStatement) {
- _changeCascadeEntry(statement.expression);
- }
- }
- node.body.accept(this);
- }
-
- @override
- visitLet(Let node) {
- // See comment in visitBlockExpression.
- node.body.accept(this);
- }
-
- String _extractFieldName(Expression expression) {
- if (expression is StringLiteral) {
- return expression.value;
- }
- if (expression is ConditionalExpression) {
- return _extractFieldName(expression.otherwise);
- }
- throw ArgumentError.value(
- expression, 'expression', 'Unsupported expression');
- }
-
- void _changeCascadeEntry(Expression initializer) {
- if (initializer is MethodInvocation &&
- initializer.interfaceTarget?.enclosingClass == builderInfoClass &&
- fieldAddingMethods.contains(initializer.name.text)) {
- final tagNumber =
- (initializer.arguments.positional[0] as IntLiteral).value;
- if (!usedTagNumbers.contains(tagNumber)) {
- if (info != null) {
- final fieldName =
- _extractFieldName(initializer.arguments.positional[1]);
- info.removedMessageFields.add("${visitedClass.name}.$fieldName");
- }
-
- // Replace the field metadata method with a dummy call to
- // `BuilderInfo.add`. This is to preserve the index calculations when
- // removing a field.
- // Change the tag-number to 0. Otherwise the decoder will get confused.
- initializer.interfaceTarget = addMethod;
- initializer.name = addMethod.name;
- initializer.arguments.replaceWith(
- Arguments(
- <Expression>[
- IntLiteral(0), // tagNumber
- NullLiteral(), // name
- NullLiteral(), // fieldType
- NullLiteral(), // defaultOrMaker
- NullLiteral(), // subBuilder
- NullLiteral(), // valueOf
- NullLiteral(), // enumValues
- ],
- types: <DartType>[const NullType()],
- ),
- );
- }
- }
- }
-}
-
-/// Finds all subclasses of [GeneratedMessage] and all methods invoked on them
-/// (potentially in a dynamic call).
-class InfoCollector extends RecursiveVisitor<void> {
- final dynamicSelectors = Set<Selector>();
- final Class generatedMessageClass;
- final gmSubclasses = Set<Class>();
- final gmSubclassesInvokedMethods = Map<Class, Set<Selector>>();
-
- InfoCollector(this.generatedMessageClass);
-
- @override
- visitClass(Class klass) {
- if (isGeneratedMethodSubclass(klass)) {
- gmSubclasses.add(klass);
- }
- return super.visitClass(klass);
- }
-
- @override
- visitMethodInvocation(MethodInvocation node) {
- if (node.interfaceTarget == null) {
- dynamicSelectors.add(Selector.doInvoke(node.name));
- }
-
- final targetClass = node.interfaceTarget?.enclosingClass;
- if (isGeneratedMethodSubclass(targetClass)) {
- addInvokedMethod(targetClass, Selector.doInvoke(node.name));
- }
- super.visitMethodInvocation(node);
- }
-
- @override
- visitPropertyGet(PropertyGet node) {
- if (node.interfaceTarget == null) {
- dynamicSelectors.add(Selector.doGet(node.name));
- }
-
- final targetClass = node.interfaceTarget?.enclosingClass;
- if (isGeneratedMethodSubclass(targetClass)) {
- addInvokedMethod(targetClass, Selector.doGet(node.name));
- }
- super.visitPropertyGet(node);
- }
-
- @override
- visitPropertySet(PropertySet node) {
- if (node.interfaceTarget == null) {
- dynamicSelectors.add(Selector.doSet(node.name));
- }
-
- final targetClass = node.interfaceTarget?.enclosingClass;
- if (isGeneratedMethodSubclass(targetClass)) {
- addInvokedMethod(targetClass, Selector.doSet(node.name));
- }
- super.visitPropertySet(node);
- }
-
- bool isGeneratedMethodSubclass(Class klass) {
- return klass?.superclass == generatedMessageClass;
- }
-
- void addInvokedMethod(Class klass, Selector selector) {
- final selectors =
- gmSubclassesInvokedMethods.putIfAbsent(klass, () => Set<Selector>());
- selectors.add(selector);
- }
-}
diff --git a/pkg/vm/lib/transformations/type_flow/signature_shaking.dart b/pkg/vm/lib/transformations/type_flow/signature_shaking.dart
index 8be7d86..4adf6c6 100644
--- a/pkg/vm/lib/transformations/type_flow/signature_shaking.dart
+++ b/pkg/vm/lib/transformations/type_flow/signature_shaking.dart
@@ -10,8 +10,6 @@
import 'table_selector_assigner.dart';
import 'types.dart';
import 'utils.dart';
-import '../protobuf_aware_treeshaker/transformer.dart'
- show excludePositionalParametersFromSignatureShaking;
import '../../metadata/procedure_attributes.dart';
/// Transform parameters from optional to required when they are always passed,
@@ -125,11 +123,6 @@
int callCount = 0;
bool eligible = true;
- /// Whether positional parameters can be eliminated from this member. Some
- /// protobuf methods require these parameters to be preserved for the
- /// protobuf-aware tree shaker to function.
- bool canEliminatePositional = true;
-
_ParameterInfo ensurePositional(int i) {
if (positional.length <= i) {
assert(positional.length == i);
@@ -178,8 +171,7 @@
bool get isNeverPassed => passCount == 0;
bool get canBeEliminated =>
- (!isUsed || (isNeverPassed || isConstant && !isChecked) && !isWritten) &&
- (isNamed || info.canEliminatePositional);
+ (!isUsed || (isNeverPassed || isConstant && !isChecked) && !isWritten);
void observeParameter(
Member member, VariableDeclaration param, SignatureShaker shaker) {
@@ -244,10 +236,6 @@
getExternalName(member) != null) {
info.eligible = false;
}
-
- if (excludePositionalParametersFromSignatureShaking(member)) {
- info.canEliminatePositional = false;
- }
}
@override
diff --git a/pkg/vm/test/modular_kernel_plus_aot_test.dart b/pkg/vm/test/modular_kernel_plus_aot_test.dart
index ee17639..ed8c0d2 100644
--- a/pkg/vm/test/modular_kernel_plus_aot_test.dart
+++ b/pkg/vm/test/modular_kernel_plus_aot_test.dart
@@ -56,14 +56,12 @@
const useGlobalTypeFlowAnalysis = true;
const enableAsserts = false;
- const useProtobufTreeShaker = false;
const useProtobufTreeShakerV2 = false;
await runGlobalTransformations(
vmTarget,
component,
useGlobalTypeFlowAnalysis,
enableAsserts,
- useProtobufTreeShaker,
useProtobufTreeShakerV2,
ErrorDetector());
diff --git a/pkg/vm/test/transformations/protobuf_aware_treeshaker/treeshaker_test.dart b/pkg/vm/test/transformations/protobuf_aware_treeshaker/treeshaker_test.dart
index 4a29089..023c93e 100644
--- a/pkg/vm/test/transformations/protobuf_aware_treeshaker/treeshaker_test.dart
+++ b/pkg/vm/test/transformations/protobuf_aware_treeshaker/treeshaker_test.dart
@@ -8,14 +8,15 @@
import 'package:kernel/ast.dart';
import 'package:kernel/kernel.dart';
import 'package:kernel/binary/ast_to_binary.dart';
+import 'package:kernel/core_types.dart' show CoreTypes;
import 'package:kernel/src/printer.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'package:vm/kernel_front_end.dart'
show runGlobalTransformations, ErrorDetector;
-import 'package:vm/transformations/protobuf_aware_treeshaker/transformer.dart'
- as treeshaker;
+import 'package:vm/transformations/type_flow/transformer.dart' as globalTypeFlow
+ show transformComponent;
import '../../common_test_utils.dart';
@@ -39,8 +40,9 @@
)
.toList();
- treeshaker.transformComponent(component, {}, TestingVmTarget(TargetFlags()),
- collectInfo: true);
+ globalTypeFlow.transformComponent(
+ TestingVmTarget(TargetFlags()), CoreTypes(component), component,
+ treeShakeProtobufs: true, treeShakeSignatures: false);
for (Class messageClass in messageClasses) {
expect(messageClass.enclosingLibrary.classes.contains(messageClass),
@@ -54,6 +56,7 @@
final sink = file.openWrite();
final printer = BinaryPrinter(sink, includeSources: false);
+ component.metadata.clear();
printer.writeComponentFile(component);
await sink.close();
@@ -77,15 +80,13 @@
// Copied verbatim from pkg/vm/bin/protobuf_aware_treeshaker.dart.
const bool useGlobalTypeFlowAnalysis = true;
const bool enableAsserts = false;
- const bool useProtobufAwareTreeShaker = true;
- const bool useProtobufAwareTreeShakerV2 = false;
+ const bool useProtobufAwareTreeShakerV2 = true;
final nopErrorDetector = ErrorDetector();
runGlobalTransformations(
target,
component,
useGlobalTypeFlowAnalysis,
enableAsserts,
- useProtobufAwareTreeShaker,
useProtobufAwareTreeShakerV2,
nopErrorDetector,
);
@@ -96,7 +97,9 @@
pkgVmDir,
'testcases',
'transformations',
- 'protobuf_aware_treeshaker',
+ 'type_flow',
+ 'transformer',
+ 'protobuf_handler',
'lib',
)).listSync().where((f) => f.path.endsWith('_test.dart'));
for (final entry in testCases) {
diff --git a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/compile_protos.sh b/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/compile_protos.sh
deleted file mode 100755
index 8031891..0000000
--- a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/compile_protos.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env bash
-# Copyright (c) 2019, 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.
-
-# Running this script requires having protoc_plugin installed in your path.
-
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-
-rm -rf $DIR/lib/generated
-mkdir $DIR/lib/generated
-
-# Directory of the script
-GENERATED_DIR=$DIR/lib/generated
-
-protoc --dart_out=$GENERATED_DIR -I$DIR/protos $DIR/protos/*.proto
-rm $GENERATED_DIR/*.pbenum.dart $GENERATED_DIR/*.pbjson.dart $GENERATED_DIR/*.pbserver.dart
-
-dartfmt -w $DIR/lib/generated
diff --git a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/create_test.dart b/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/create_test.dart
deleted file mode 100644
index 1912459..0000000
--- a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/create_test.dart
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2019, 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.
-
-import 'package:test/test.dart';
-
-import 'generated/foo.pb.dart';
-
-main() {
- FooKeep foo = FooKeep()
- ..barKeep = (BarKeep()..aKeep = 5)
- ..mapKeep['foo'] = (BarKeep()..aKeep = 2)
- ..aKeep = 43;
- test('retrieving values', () {
- expect(foo.barKeep.aKeep, 5);
- expect(foo.mapKeep['foo'].aKeep, 2);
- expect(foo.hasHasKeep(), false);
- expect(foo.aKeep, 43);
- foo.clearClearKeep();
- });
-}
diff --git a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/decode_test.dart b/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/decode_test.dart
deleted file mode 100644
index d33289f..0000000
--- a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/decode_test.dart
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2019, 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.
-
-import 'package:test/test.dart';
-
-import 'generated/foo.pb.dart';
-
-List<int> buffer = <int>[
- 10, 4, 8, 5, 16, //
- 4, 26, 9, 10, 3,
- 102, 111, 111, 18, 2,
- 8, 42, 34, 9, 10,
- 3, 122, 111, 112, 18,
- 2, 8, 3, 40, 43,
- 50, 0, 58, 0,
-];
-
-main() {
- FooKeep foo = FooKeep.fromBuffer(buffer);
- test('Kept values are restored correctly', () {
- expect(foo.mapKeep['foo'].aKeep, 42);
- expect(foo.barKeep.aKeep, 5);
- expect(foo.aKeep, 43);
- expect(foo.hasHasKeep(), true);
- foo.clearClearKeep();
- });
-}
diff --git a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/encode_all_fields.dart b/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/encode_all_fields.dart
deleted file mode 100644
index de756cc..0000000
--- a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/encode_all_fields.dart
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2019, 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.
-
-import 'dart:math';
-
-import 'generated/foo.pb.dart';
-
-main() {
- FooKeep foo = FooKeep()
- ..barKeep = (BarKeep()
- ..aKeep = 5
- ..bDrop = 4)
- ..mapKeep['foo'] = (BarKeep()..aKeep = 42)
- ..mapDrop['zop'] = (ZopDrop()..aDrop = 3)
- ..aKeep = 43
- ..hasKeep = HasKeep()
- ..clearKeep = ClearKeep();
- final buffer = foo.writeToBuffer();
- print('List<int> buffer = <int>[');
- for (int i = 0; i < buffer.length; i += 5) {
- final numbers = buffer.sublist(i, min(buffer.length, i + 5)).join(', ');
- print(' $numbers,${i == 0 ? ' //' : ''}');
- }
- print('];');
-}
diff --git a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/freeze_test.dart b/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/freeze_test.dart
deleted file mode 100644
index 0529e4a..0000000
--- a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/freeze_test.dart
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2019, 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.
-
-import 'package:test/test.dart';
-
-import 'generated/foo.pb.dart';
-
-main() {
- FooKeep foo = FooKeep()
- ..barKeep = (BarKeep()..aKeep = 5)
- ..mapKeep['foo'] = (BarKeep()..aKeep = 2)
- ..aKeep = 43;
- test('Freezing a message works', () {
- foo.freeze();
- expect(foo.barKeep.aKeep, 5);
- expect(foo.mapKeep['foo'].aKeep, 2);
- expect(foo.hasHasKeep(), false);
- expect(foo.aKeep, 43);
- expect(() => foo.clearClearKeep(),
- throwsA(const TypeMatcher<UnsupportedError>()));
- });
-}
diff --git a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/generated/foo.pb.dart b/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/generated/foo.pb.dart
deleted file mode 100644
index 19c9bac5..0000000
--- a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/generated/foo.pb.dart
+++ /dev/null
@@ -1,440 +0,0 @@
-///
-// Generated code. Do not modify.
-// source: foo.proto
-//
-// @dart = 2.12
-// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
-
-import 'dart:core' as $core;
-
-import 'package:protobuf/protobuf.dart' as $pb;
-
-class FooKeep extends $pb.GeneratedMessage {
- static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'FooKeep',
- createEmptyInstance: create)
- ..aOM<BarKeep>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'barKeep',
- protoName: 'barKeep', subBuilder: BarKeep.create)
- ..aOM<BarKeep>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'barDrop',
- protoName: 'barDrop', subBuilder: BarKeep.create)
- ..m<$core.String, BarKeep>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'mapKeep',
- protoName: 'mapKeep',
- entryClassName: 'FooKeep.MapKeepEntry',
- keyFieldType: $pb.PbFieldType.OS,
- valueFieldType: $pb.PbFieldType.OM,
- valueCreator: BarKeep.create)
- ..m<$core.String, ZopDrop>(
- 4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'mapDrop',
- protoName: 'mapDrop',
- entryClassName: 'FooKeep.MapDropEntry',
- keyFieldType: $pb.PbFieldType.OS,
- valueFieldType: $pb.PbFieldType.OM,
- valueCreator: ZopDrop.create)
- ..a<$core.int>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'aKeep', $pb.PbFieldType.O3,
- protoName: 'aKeep')
- ..aOM<HasKeep>(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hasKeep',
- protoName: 'hasKeep', subBuilder: HasKeep.create)
- ..aOM<ClearKeep>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'clearKeep',
- protoName: 'clearKeep', subBuilder: ClearKeep.create)
- ..hasRequiredFields = false;
-
- FooKeep._() : super();
- factory FooKeep() => create();
- factory FooKeep.fromBuffer($core.List<$core.int> i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromBuffer(i, r);
- factory FooKeep.fromJson($core.String i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromJson(i, r);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
- 'Will be removed in next major version')
- FooKeep clone() => FooKeep()..mergeFromMessage(this);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
- 'Will be removed in next major version')
- FooKeep copyWith(void Function(FooKeep) updates) =>
- super.copyWith((message) => updates(message as FooKeep))
- as FooKeep; // ignore: deprecated_member_use
- $pb.BuilderInfo get info_ => _i;
- @$core.pragma('dart2js:noInline')
- static FooKeep create() => FooKeep._();
- FooKeep createEmptyInstance() => create();
- static $pb.PbList<FooKeep> createRepeated() => $pb.PbList<FooKeep>();
- @$core.pragma('dart2js:noInline')
- static FooKeep getDefault() =>
- _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<FooKeep>(create);
- static FooKeep? _defaultInstance;
-
- @$pb.TagNumber(1)
- BarKeep get barKeep => $_getN(0);
- @$pb.TagNumber(1)
- set barKeep(BarKeep v) {
- setField(1, v);
- }
-
- @$pb.TagNumber(1)
- $core.bool hasBarKeep() => $_has(0);
- @$pb.TagNumber(1)
- void clearBarKeep() => clearField(1);
- @$pb.TagNumber(1)
- BarKeep ensureBarKeep() => $_ensure(0);
-
- @$pb.TagNumber(2)
- BarKeep get barDrop => $_getN(1);
- @$pb.TagNumber(2)
- set barDrop(BarKeep v) {
- setField(2, v);
- }
-
- @$pb.TagNumber(2)
- $core.bool hasBarDrop() => $_has(1);
- @$pb.TagNumber(2)
- void clearBarDrop() => clearField(2);
- @$pb.TagNumber(2)
- BarKeep ensureBarDrop() => $_ensure(1);
-
- @$pb.TagNumber(3)
- $core.Map<$core.String, BarKeep> get mapKeep => $_getMap(2);
-
- @$pb.TagNumber(4)
- $core.Map<$core.String, ZopDrop> get mapDrop => $_getMap(3);
-
- @$pb.TagNumber(5)
- $core.int get aKeep => $_getIZ(4);
- @$pb.TagNumber(5)
- set aKeep($core.int v) {
- $_setSignedInt32(4, v);
- }
-
- @$pb.TagNumber(5)
- $core.bool hasAKeep() => $_has(4);
- @$pb.TagNumber(5)
- void clearAKeep() => clearField(5);
-
- @$pb.TagNumber(6)
- HasKeep get hasKeep => $_getN(5);
- @$pb.TagNumber(6)
- set hasKeep(HasKeep v) {
- setField(6, v);
- }
-
- @$pb.TagNumber(6)
- $core.bool hasHasKeep() => $_has(5);
- @$pb.TagNumber(6)
- void clearHasKeep() => clearField(6);
- @$pb.TagNumber(6)
- HasKeep ensureHasKeep() => $_ensure(5);
-
- @$pb.TagNumber(7)
- ClearKeep get clearKeep => $_getN(6);
- @$pb.TagNumber(7)
- set clearKeep(ClearKeep v) {
- setField(7, v);
- }
-
- @$pb.TagNumber(7)
- $core.bool hasClearKeep() => $_has(6);
- @$pb.TagNumber(7)
- void clearClearKeep() => clearField(7);
- @$pb.TagNumber(7)
- ClearKeep ensureClearKeep() => $_ensure(6);
-}
-
-class BarKeep extends $pb.GeneratedMessage {
- static final $pb.BuilderInfo _i = $pb.BuilderInfo(
- const $core.bool.fromEnvironment('protobuf.omit_message_names')
- ? ''
- : 'BarKeep',
- createEmptyInstance: create)
- ..a<$core.int>(
- 1,
- const $core.bool.fromEnvironment('protobuf.omit_field_names')
- ? ''
- : 'aKeep',
- $pb.PbFieldType.O3,
- protoName: 'aKeep')
- ..a<$core.int>(
- 2,
- const $core.bool.fromEnvironment('protobuf.omit_field_names')
- ? ''
- : 'bDrop',
- $pb.PbFieldType.O3,
- protoName: 'bDrop')
- ..hasRequiredFields = false;
-
- BarKeep._() : super();
- factory BarKeep() => create();
- factory BarKeep.fromBuffer($core.List<$core.int> i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromBuffer(i, r);
- factory BarKeep.fromJson($core.String i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromJson(i, r);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
- 'Will be removed in next major version')
- BarKeep clone() => BarKeep()..mergeFromMessage(this);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
- 'Will be removed in next major version')
- BarKeep copyWith(void Function(BarKeep) updates) =>
- super.copyWith((message) => updates(message as BarKeep))
- as BarKeep; // ignore: deprecated_member_use
- $pb.BuilderInfo get info_ => _i;
- @$core.pragma('dart2js:noInline')
- static BarKeep create() => BarKeep._();
- BarKeep createEmptyInstance() => create();
- static $pb.PbList<BarKeep> createRepeated() => $pb.PbList<BarKeep>();
- @$core.pragma('dart2js:noInline')
- static BarKeep getDefault() =>
- _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<BarKeep>(create);
- static BarKeep? _defaultInstance;
-
- @$pb.TagNumber(1)
- $core.int get aKeep => $_getIZ(0);
- @$pb.TagNumber(1)
- set aKeep($core.int v) {
- $_setSignedInt32(0, v);
- }
-
- @$pb.TagNumber(1)
- $core.bool hasAKeep() => $_has(0);
- @$pb.TagNumber(1)
- void clearAKeep() => clearField(1);
-
- @$pb.TagNumber(2)
- $core.int get bDrop => $_getIZ(1);
- @$pb.TagNumber(2)
- set bDrop($core.int v) {
- $_setSignedInt32(1, v);
- }
-
- @$pb.TagNumber(2)
- $core.bool hasBDrop() => $_has(1);
- @$pb.TagNumber(2)
- void clearBDrop() => clearField(2);
-}
-
-class HasKeep extends $pb.GeneratedMessage {
- static final $pb.BuilderInfo _i = $pb.BuilderInfo(
- const $core.bool.fromEnvironment('protobuf.omit_message_names')
- ? ''
- : 'HasKeep',
- createEmptyInstance: create)
- ..a<$core.int>(
- 1,
- const $core.bool.fromEnvironment('protobuf.omit_field_names')
- ? ''
- : 'aDrop',
- $pb.PbFieldType.O3,
- protoName: 'aDrop')
- ..hasRequiredFields = false;
-
- HasKeep._() : super();
- factory HasKeep() => create();
- factory HasKeep.fromBuffer($core.List<$core.int> i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromBuffer(i, r);
- factory HasKeep.fromJson($core.String i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromJson(i, r);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
- 'Will be removed in next major version')
- HasKeep clone() => HasKeep()..mergeFromMessage(this);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
- 'Will be removed in next major version')
- HasKeep copyWith(void Function(HasKeep) updates) =>
- super.copyWith((message) => updates(message as HasKeep))
- as HasKeep; // ignore: deprecated_member_use
- $pb.BuilderInfo get info_ => _i;
- @$core.pragma('dart2js:noInline')
- static HasKeep create() => HasKeep._();
- HasKeep createEmptyInstance() => create();
- static $pb.PbList<HasKeep> createRepeated() => $pb.PbList<HasKeep>();
- @$core.pragma('dart2js:noInline')
- static HasKeep getDefault() =>
- _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<HasKeep>(create);
- static HasKeep? _defaultInstance;
-
- @$pb.TagNumber(1)
- $core.int get aDrop => $_getIZ(0);
- @$pb.TagNumber(1)
- set aDrop($core.int v) {
- $_setSignedInt32(0, v);
- }
-
- @$pb.TagNumber(1)
- $core.bool hasADrop() => $_has(0);
- @$pb.TagNumber(1)
- void clearADrop() => clearField(1);
-}
-
-class ClearKeep extends $pb.GeneratedMessage {
- static final $pb.BuilderInfo _i = $pb.BuilderInfo(
- const $core.bool.fromEnvironment('protobuf.omit_message_names')
- ? ''
- : 'ClearKeep',
- createEmptyInstance: create)
- ..a<$core.int>(
- 1,
- const $core.bool.fromEnvironment('protobuf.omit_field_names')
- ? ''
- : 'aDrop',
- $pb.PbFieldType.O3,
- protoName: 'aDrop')
- ..hasRequiredFields = false;
-
- ClearKeep._() : super();
- factory ClearKeep() => create();
- factory ClearKeep.fromBuffer($core.List<$core.int> i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromBuffer(i, r);
- factory ClearKeep.fromJson($core.String i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromJson(i, r);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
- 'Will be removed in next major version')
- ClearKeep clone() => ClearKeep()..mergeFromMessage(this);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
- 'Will be removed in next major version')
- ClearKeep copyWith(void Function(ClearKeep) updates) =>
- super.copyWith((message) => updates(message as ClearKeep))
- as ClearKeep; // ignore: deprecated_member_use
- $pb.BuilderInfo get info_ => _i;
- @$core.pragma('dart2js:noInline')
- static ClearKeep create() => ClearKeep._();
- ClearKeep createEmptyInstance() => create();
- static $pb.PbList<ClearKeep> createRepeated() => $pb.PbList<ClearKeep>();
- @$core.pragma('dart2js:noInline')
- static ClearKeep getDefault() =>
- _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ClearKeep>(create);
- static ClearKeep? _defaultInstance;
-
- @$pb.TagNumber(1)
- $core.int get aDrop => $_getIZ(0);
- @$pb.TagNumber(1)
- set aDrop($core.int v) {
- $_setSignedInt32(0, v);
- }
-
- @$pb.TagNumber(1)
- $core.bool hasADrop() => $_has(0);
- @$pb.TagNumber(1)
- void clearADrop() => clearField(1);
-}
-
-class ZopDrop extends $pb.GeneratedMessage {
- static final $pb.BuilderInfo _i = $pb.BuilderInfo(
- const $core.bool.fromEnvironment('protobuf.omit_message_names')
- ? ''
- : 'ZopDrop',
- createEmptyInstance: create)
- ..a<$core.int>(
- 1,
- const $core.bool.fromEnvironment('protobuf.omit_field_names')
- ? ''
- : 'aDrop',
- $pb.PbFieldType.O3,
- protoName: 'aDrop')
- ..hasRequiredFields = false;
-
- ZopDrop._() : super();
- factory ZopDrop() => create();
- factory ZopDrop.fromBuffer($core.List<$core.int> i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromBuffer(i, r);
- factory ZopDrop.fromJson($core.String i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromJson(i, r);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
- 'Will be removed in next major version')
- ZopDrop clone() => ZopDrop()..mergeFromMessage(this);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
- 'Will be removed in next major version')
- ZopDrop copyWith(void Function(ZopDrop) updates) =>
- super.copyWith((message) => updates(message as ZopDrop))
- as ZopDrop; // ignore: deprecated_member_use
- $pb.BuilderInfo get info_ => _i;
- @$core.pragma('dart2js:noInline')
- static ZopDrop create() => ZopDrop._();
- ZopDrop createEmptyInstance() => create();
- static $pb.PbList<ZopDrop> createRepeated() => $pb.PbList<ZopDrop>();
- @$core.pragma('dart2js:noInline')
- static ZopDrop getDefault() =>
- _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ZopDrop>(create);
- static ZopDrop? _defaultInstance;
-
- @$pb.TagNumber(1)
- $core.int get aDrop => $_getIZ(0);
- @$pb.TagNumber(1)
- set aDrop($core.int v) {
- $_setSignedInt32(0, v);
- }
-
- @$pb.TagNumber(1)
- $core.bool hasADrop() => $_has(0);
- @$pb.TagNumber(1)
- void clearADrop() => clearField(1);
-}
-
-class MobDrop extends $pb.GeneratedMessage {
- static final $pb.BuilderInfo _i = $pb.BuilderInfo(
- const $core.bool.fromEnvironment('protobuf.omit_message_names')
- ? ''
- : 'MobDrop',
- createEmptyInstance: create)
- ..a<$core.int>(
- 1,
- const $core.bool.fromEnvironment('protobuf.omit_field_names')
- ? ''
- : 'aDrop',
- $pb.PbFieldType.O3,
- protoName: 'aDrop')
- ..hasRequiredFields = false;
-
- MobDrop._() : super();
- factory MobDrop() => create();
- factory MobDrop.fromBuffer($core.List<$core.int> i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromBuffer(i, r);
- factory MobDrop.fromJson($core.String i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromJson(i, r);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
- 'Will be removed in next major version')
- MobDrop clone() => MobDrop()..mergeFromMessage(this);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
- 'Will be removed in next major version')
- MobDrop copyWith(void Function(MobDrop) updates) =>
- super.copyWith((message) => updates(message as MobDrop))
- as MobDrop; // ignore: deprecated_member_use
- $pb.BuilderInfo get info_ => _i;
- @$core.pragma('dart2js:noInline')
- static MobDrop create() => MobDrop._();
- MobDrop createEmptyInstance() => create();
- static $pb.PbList<MobDrop> createRepeated() => $pb.PbList<MobDrop>();
- @$core.pragma('dart2js:noInline')
- static MobDrop getDefault() =>
- _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<MobDrop>(create);
- static MobDrop? _defaultInstance;
-
- @$pb.TagNumber(1)
- $core.int get aDrop => $_getIZ(0);
- @$pb.TagNumber(1)
- set aDrop($core.int v) {
- $_setSignedInt32(0, v);
- }
-
- @$pb.TagNumber(1)
- $core.bool hasADrop() => $_has(0);
- @$pb.TagNumber(1)
- void clearADrop() => clearField(1);
-}
diff --git a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/generated/name_mangling.pb.dart b/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/generated/name_mangling.pb.dart
deleted file mode 100644
index c42141a..0000000
--- a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/generated/name_mangling.pb.dart
+++ /dev/null
@@ -1,105 +0,0 @@
-///
-// Generated code. Do not modify.
-// source: name_mangling.proto
-//
-// @dart = 2.12
-// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
-
-import 'dart:core' as $core;
-
-import 'package:protobuf/protobuf.dart' as $pb;
-
-class AKeep extends $pb.GeneratedMessage {
- static final $pb.BuilderInfo _i = $pb.BuilderInfo(
- const $core.bool.fromEnvironment('protobuf.omit_message_names')
- ? ''
- : 'AKeep',
- createEmptyInstance: create)
- ..hasRequiredFields = false;
-
- AKeep._() : super();
- factory AKeep() => create();
- factory AKeep.fromBuffer($core.List<$core.int> i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromBuffer(i, r);
- factory AKeep.fromJson($core.String i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromJson(i, r);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
- 'Will be removed in next major version')
- AKeep clone() => AKeep()..mergeFromMessage(this);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
- 'Will be removed in next major version')
- AKeep copyWith(void Function(AKeep) updates) =>
- super.copyWith((message) => updates(message as AKeep))
- as AKeep; // ignore: deprecated_member_use
- $pb.BuilderInfo get info_ => _i;
- @$core.pragma('dart2js:noInline')
- static AKeep create() => AKeep._();
- AKeep createEmptyInstance() => create();
- static $pb.PbList<AKeep> createRepeated() => $pb.PbList<AKeep>();
- @$core.pragma('dart2js:noInline')
- static AKeep getDefault() =>
- _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<AKeep>(create);
- static AKeep? _defaultInstance;
-}
-
-class NameManglingKeep extends $pb.GeneratedMessage {
- static final $pb.BuilderInfo _i = $pb.BuilderInfo(
- const $core.bool.fromEnvironment('protobuf.omit_message_names')
- ? ''
- : 'NameManglingKeep',
- createEmptyInstance: create)
- ..aOM<AKeep>(
- 10,
- const $core.bool.fromEnvironment('protobuf.omit_field_names')
- ? ''
- : 'clone',
- subBuilder: AKeep.create)
- ..hasRequiredFields = false;
-
- NameManglingKeep._() : super();
- factory NameManglingKeep() => create();
- factory NameManglingKeep.fromBuffer($core.List<$core.int> i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromBuffer(i, r);
- factory NameManglingKeep.fromJson($core.String i,
- [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) =>
- create()..mergeFromJson(i, r);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
- 'Will be removed in next major version')
- NameManglingKeep clone() => NameManglingKeep()..mergeFromMessage(this);
- @$core.Deprecated('Using this can add significant overhead to your binary. '
- 'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
- 'Will be removed in next major version')
- NameManglingKeep copyWith(void Function(NameManglingKeep) updates) =>
- super.copyWith((message) => updates(message as NameManglingKeep))
- as NameManglingKeep; // ignore: deprecated_member_use
- $pb.BuilderInfo get info_ => _i;
- @$core.pragma('dart2js:noInline')
- static NameManglingKeep create() => NameManglingKeep._();
- NameManglingKeep createEmptyInstance() => create();
- static $pb.PbList<NameManglingKeep> createRepeated() =>
- $pb.PbList<NameManglingKeep>();
- @$core.pragma('dart2js:noInline')
- static NameManglingKeep getDefault() => _defaultInstance ??=
- $pb.GeneratedMessage.$_defaultFor<NameManglingKeep>(create);
- static NameManglingKeep? _defaultInstance;
-
- @$pb.TagNumber(10)
- AKeep get clone_10 => $_getN(0);
- @$pb.TagNumber(10)
- set clone_10(AKeep v) {
- setField(10, v);
- }
-
- @$pb.TagNumber(10)
- $core.bool hasClone_10() => $_has(0);
- @$pb.TagNumber(10)
- void clearClone_10() => clearField(10);
- @$pb.TagNumber(10)
- AKeep ensureClone_10() => $_ensure(0);
-}
diff --git a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/name_mangling_test.dart b/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/name_mangling_test.dart
deleted file mode 100644
index b52c5dc..0000000
--- a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/name_mangling_test.dart
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (c) 2019, 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.
-
-import 'package:test/test.dart';
-
-import 'generated/name_mangling.pb.dart';
-
-main() {
- NameManglingKeep n = NameManglingKeep.fromBuffer([]);
- if (n.hasClone_10()) {
- print("Has clone field");
- }
-}
diff --git a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/nop_test.dart b/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/nop_test.dart
deleted file mode 100644
index 60997dc..0000000
--- a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/lib/nop_test.dart
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) 2019, 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.
-
-main() {
- // Ensures the protobuf-aware tree shaker can also transform non-protobuf
- // using code.
- print("hello world");
-}
diff --git a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/protos/foo.proto b/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/protos/foo.proto
deleted file mode 100644
index 1f10872..0000000
--- a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/protos/foo.proto
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2019, 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.
-
-syntax = "proto3";
-
-message FooKeep {
- BarKeep barKeep = 1;
- BarKeep barDrop = 2;
- map<string, BarKeep> mapKeep = 3;
- map<string, ZopDrop> mapDrop = 4;
- int32 aKeep = 5;
- HasKeep hasKeep = 6;
- ClearKeep clearKeep = 7;
-}
-
-message BarKeep {
- int32 aKeep = 1;
- int32 bDrop = 2;
-}
-
-message HasKeep {
- int32 aDrop = 1;
-}
-
-message ClearKeep {
- int32 aDrop = 1;
-}
-
-message ZopDrop {
- int32 aDrop = 1;
-}
-
-message MobDrop {
- int32 aDrop = 1;
-}
diff --git a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/protos/name_mangling.proto b/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/protos/name_mangling.proto
deleted file mode 100644
index f25b2f4..0000000
--- a/pkg/vm/testcases/transformations/protobuf_aware_treeshaker/protos/name_mangling.proto
+++ /dev/null
@@ -1,10 +0,0 @@
-syntax = "proto3";
-
-message AKeep {}
-
-message NameManglingKeep {
- // the name `clone` is mangled by the protoc_plugin to not conflict with
- // `GeneratedMessage.clone`.
- // Still we should be able to detect usages of this field.
- AKeep clone = 10;
-}
\ No newline at end of file
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/create_test.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/create_test.dart.expect
index a697cdd..ec70e94 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/create_test.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/create_test.dart.expect
@@ -38,11 +38,11 @@
[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t1 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "FooKeep") in block {
[@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::BarKeep>(1, (#C1) ?{core::String} "" : "barKeep", "barKeep", #C2);
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.m] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::m}<core::String, self::BarKeep>(3, (#C1) ?{core::String} "" : "mapKeep", #C2);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.m] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::m}<core::String, self::BarKeep>((#C1) ?{core::String} "" : "mapKeep", #C2);
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::a}<core::int>(5, (#C1) ?{core::String} "" : "aKeep", #C3);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::HasKeep>(6, (#C1) ?{core::String} "" : "hasKeep", "hasKeep", #C4);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::ClearKeep>(7, (#C1) ?{core::String} "" : "clearKeep", "clearKeep", #C5);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::a}<core::int>(5, (#C1) ?{core::String} "" : "aKeep");
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::HasKeep>(6, (#C1) ?{core::String} "" : "hasKeep", "hasKeep", #C3);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::ClearKeep>(7, (#C1) ?{core::String} "" : "clearKeep", "clearKeep", #C4);
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t1;
constructor _() → self::FooKeep
@@ -52,36 +52,36 @@
return [@vm.inferred-type.metadata=foo.pb.dart::FooKeep] self::FooKeep::create();
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::FooKeep::_i;
- @#C8
+ @#C7
static method create() → self::FooKeep
return new self::FooKeep::_();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:2,getterSelectorId:3] @#C10
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:2,getterSelectorId:3] @#C9
get barKeep() → self::BarKeep
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getN] [@vm.inferred-type.metadata=foo.pb.dart::BarKeep? (skip check)] this.{pro::GeneratedMessage::$_getN}<self::BarKeep>();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:2,getterSelectorId:3] @#C10
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:2,getterSelectorId:3] @#C9
set barKeep([@vm.inferred-type.metadata=foo.pb.dart::BarKeep] self::BarKeep v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.setField] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::setField}(v);
}
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] @#C12
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] @#C11
get mapKeep() → core::Map<core::String, self::BarKeep>
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getMap] [@vm.inferred-type.metadata=! (skip check)] this.{pro::GeneratedMessage::$_getMap}<core::String, self::BarKeep>();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5,getterSelectorId:6] [@vm.unboxing-info.metadata=()->i] @#C14
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5,getterSelectorId:6] [@vm.unboxing-info.metadata=()->i] @#C13
get aKeep() → core::int
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getIZ] [@vm.inferred-type.metadata=int (skip check)] this.{pro::GeneratedMessage::$_getIZ}(4);
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5,getterSelectorId:6] [@vm.unboxing-info.metadata=(i)->b] @#C14
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5,getterSelectorId:6] [@vm.unboxing-info.metadata=(i)->b] @#C13
set aKeep([@vm.inferred-type.metadata=dart.core::_Smi (value: 43)] core::int v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.$_setSignedInt32] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::$_setSignedInt32}(4, v);
}
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:7,getterSelectorId:8] @#C16
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:7,getterSelectorId:8] @#C15
method hasHasKeep() → core::bool
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_has] [@vm.inferred-type.metadata=dart.core::bool (skip check)] this.{pro::GeneratedMessage::$_has}();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:9,getterSelectorId:10] @#C18
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:9,getterSelectorId:10] @#C17
method clearClearKeep() → void
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.clearField] [@vm.inferred-type.metadata=dart.core::Null? (skip check) (value: null)] this.{pro::GeneratedMessage::clearField}();
}
class BarKeep extends pro::GeneratedMessage {
[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t2 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "BarKeep") in block {
- [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::a}<core::int>(1, (#C1) ?{core::String} "" : "aKeep", #C3);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::a}<core::int>(1, (#C1) ?{core::String} "" : "aKeep");
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t2;
@@ -92,13 +92,13 @@
return [@vm.inferred-type.metadata=foo.pb.dart::BarKeep] self::BarKeep::create();
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::BarKeep::_i;
- @#C8
+ @#C7
static method create() → self::BarKeep
return new self::BarKeep::_();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:11,getterSelectorId:12] [@vm.unboxing-info.metadata=()->i] @#C10
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:11,getterSelectorId:12] [@vm.unboxing-info.metadata=()->i] @#C9
get aKeep() → core::int
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getIZ] [@vm.inferred-type.metadata=int (skip check)] this.{pro::GeneratedMessage::$_getIZ}(0);
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:11,getterSelectorId:12] [@vm.unboxing-info.metadata=(i)->b] @#C10
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:11,getterSelectorId:12] [@vm.unboxing-info.metadata=(i)->b] @#C9
set aKeep([@vm.inferred-type.metadata=dart.core::_Smi] core::int v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.$_setSignedInt32] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::$_setSignedInt32}(0, v);
}
@@ -113,7 +113,7 @@
;
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::HasKeep::_i;
- @#C8
+ @#C7
static method create() → self::HasKeep
return new self::HasKeep::_();
}
@@ -127,7 +127,7 @@
;
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::ClearKeep::_i;
- @#C8
+ @#C7
static method create() → self::ClearKeep
return new self::ClearKeep::_();
}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/decode_test.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/decode_test.dart.expect
index 14a4689..71dc247 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/decode_test.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/decode_test.dart.expect
@@ -31,11 +31,11 @@
[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t1 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "FooKeep", createEmptyInstance: #C2) in block {
[@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::BarKeep>(1, (#C1) ?{core::String} "" : "barKeep", "barKeep", #C3);
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.m] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::m}<core::String, self::BarKeep>(3, (#C1) ?{core::String} "" : "mapKeep", #C3);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.m] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::m}<core::String, self::BarKeep>((#C1) ?{core::String} "" : "mapKeep", #C3);
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::a}<core::int>(5, (#C1) ?{core::String} "" : "aKeep", #C4);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::HasKeep>(6, (#C1) ?{core::String} "" : "hasKeep", "hasKeep", #C5);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::ClearKeep>(7, (#C1) ?{core::String} "" : "clearKeep", "clearKeep", #C6);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::a}<core::int>(5, (#C1) ?{core::String} "" : "aKeep");
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::HasKeep>(6, (#C1) ?{core::String} "" : "hasKeep", "hasKeep", #C4);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::ClearKeep>(7, (#C1) ?{core::String} "" : "clearKeep", "clearKeep", #C5);
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t1;
constructor _() → self::FooKeep
@@ -47,28 +47,28 @@
} =>#t2;
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::FooKeep::_i;
- @#C9
+ @#C8
static method create() → self::FooKeep
return new self::FooKeep::_();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:2] @#C11
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:2] @#C10
get barKeep() → self::BarKeep
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getN] [@vm.inferred-type.metadata=foo.pb.dart::BarKeep? (skip check)] this.{pro::GeneratedMessage::$_getN}<self::BarKeep>();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:3] @#C13
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:3] @#C12
get mapKeep() → core::Map<core::String, self::BarKeep>
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getMap] [@vm.inferred-type.metadata=! (skip check)] this.{pro::GeneratedMessage::$_getMap}<core::String, self::BarKeep>();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] [@vm.unboxing-info.metadata=()->i] @#C15
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] [@vm.unboxing-info.metadata=()->i] @#C14
get aKeep() → core::int
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getIZ] [@vm.inferred-type.metadata=int (skip check)] this.{pro::GeneratedMessage::$_getIZ}(4);
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5,getterSelectorId:6] @#C17
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5,getterSelectorId:6] @#C16
method hasHasKeep() → core::bool
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_has] [@vm.inferred-type.metadata=dart.core::bool (skip check)] this.{pro::GeneratedMessage::$_has}();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:7,getterSelectorId:8] @#C19
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:7,getterSelectorId:8] @#C18
method clearClearKeep() → void
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.clearField] [@vm.inferred-type.metadata=dart.core::Null? (skip check) (value: null)] this.{pro::GeneratedMessage::clearField}();
}
class BarKeep extends pro::GeneratedMessage {
[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t3 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "BarKeep", createEmptyInstance: #C3) in block {
- [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t3.{pro::BuilderInfo::a}<core::int>(1, (#C1) ?{core::String} "" : "aKeep", #C4);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t3.{pro::BuilderInfo::a}<core::int>(1, (#C1) ?{core::String} "" : "aKeep");
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t3.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t3.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t3;
@@ -77,15 +77,15 @@
;
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::BarKeep::_i;
- @#C9
+ @#C8
static method create() → self::BarKeep
return new self::BarKeep::_();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:9] [@vm.unboxing-info.metadata=()->i] @#C11
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:9] [@vm.unboxing-info.metadata=()->i] @#C10
get aKeep() → core::int
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getIZ] [@vm.inferred-type.metadata=int (skip check)] this.{pro::GeneratedMessage::$_getIZ}(0);
}
class HasKeep extends pro::GeneratedMessage {
-[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t4 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "HasKeep", createEmptyInstance: #C5) in block {
+[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t4 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "HasKeep", createEmptyInstance: #C4) in block {
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t4.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t4.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t4;
@@ -94,12 +94,12 @@
;
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::HasKeep::_i;
- @#C9
+ @#C8
static method create() → self::HasKeep
return new self::HasKeep::_();
}
class ClearKeep extends pro::GeneratedMessage {
-[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t5 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "ClearKeep", createEmptyInstance: #C6) in block {
+[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t5 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "ClearKeep", createEmptyInstance: #C5) in block {
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t5.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t5.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t5;
@@ -108,7 +108,7 @@
;
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::ClearKeep::_i;
- @#C9
+ @#C8
static method create() → self::ClearKeep
return new self::ClearKeep::_();
}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/encode_all_fields.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/encode_all_fields.dart.expect
index 4980123..e99a0c0 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/encode_all_fields.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/encode_all_fields.dart.expect
@@ -47,9 +47,9 @@
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
[@vm.direct-call.metadata=protobuf::BuilderInfo.m] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::m}<core::String, self::BarKeep>(3, (#C1) ?{core::String} "" : "mapKeep", "FooKeep.MapKeepEntry", "mapKeep", #C2);
[@vm.direct-call.metadata=protobuf::BuilderInfo.m] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::m}<core::String, self::ZopDrop>(4, (#C1) ?{core::String} "" : "mapDrop", "FooKeep.MapDropEntry", "mapDrop", #C3);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::a}<core::int>(5, (#C1) ?{core::String} "" : "aKeep", #C4, "aKeep");
- [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::HasKeep>(6, (#C1) ?{core::String} "" : "hasKeep", "hasKeep", #C5);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::ClearKeep>(7, (#C1) ?{core::String} "" : "clearKeep", "clearKeep", #C6);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::a}<core::int>(5, (#C1) ?{core::String} "" : "aKeep", "aKeep");
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::HasKeep>(6, (#C1) ?{core::String} "" : "hasKeep", "hasKeep", #C4);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::ClearKeep>(7, (#C1) ?{core::String} "" : "clearKeep", "clearKeep", #C5);
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t1;
constructor _() → self::FooKeep
@@ -59,36 +59,36 @@
return [@vm.inferred-type.metadata=foo.pb.dart::FooKeep] self::FooKeep::create();
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::FooKeep::_i;
- @#C9
+ @#C8
static method create() → self::FooKeep
return new self::FooKeep::_();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:2] @#C11
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:2] @#C10
set barKeep([@vm.inferred-type.metadata=foo.pb.dart::BarKeep] self::BarKeep v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.setField] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::setField}(1, v);
}
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:3] @#C13
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:3] @#C12
get mapKeep() → core::Map<core::String, self::BarKeep>
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getMap] [@vm.inferred-type.metadata=! (skip check)] this.{pro::GeneratedMessage::$_getMap}<core::String, self::BarKeep>(2);
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] @#C15
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] @#C14
get mapDrop() → core::Map<core::String, self::ZopDrop>
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getMap] [@vm.inferred-type.metadata=! (skip check)] this.{pro::GeneratedMessage::$_getMap}<core::String, self::ZopDrop>(3);
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5] [@vm.unboxing-info.metadata=(i)->b] @#C17
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5] [@vm.unboxing-info.metadata=(i)->b] @#C16
set aKeep([@vm.inferred-type.metadata=dart.core::_Smi (value: 43)] core::int v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.$_setSignedInt32] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::$_setSignedInt32}(4, v);
}
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:6] @#C19
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:6] @#C18
set hasKeep([@vm.inferred-type.metadata=foo.pb.dart::HasKeep] self::HasKeep v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.setField] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::setField}(6, v);
}
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:7] @#C21
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:7] @#C20
set clearKeep([@vm.inferred-type.metadata=foo.pb.dart::ClearKeep] self::ClearKeep v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.setField] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::setField}(7, v);
}
}
class BarKeep extends pro::GeneratedMessage {
[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t2 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "BarKeep") in block {
- [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::a}<core::int>(1, (#C1) ?{core::String} "" : "aKeep", #C4, "aKeep");
- [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::a}<core::int>(2, (#C1) ?{core::String} "" : "bDrop", #C4, "bDrop");
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::a}<core::int>(1, (#C1) ?{core::String} "" : "aKeep", "aKeep");
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::a}<core::int>(2, (#C1) ?{core::String} "" : "bDrop", "bDrop");
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t2;
constructor _() → self::BarKeep
@@ -98,14 +98,14 @@
return [@vm.inferred-type.metadata=foo.pb.dart::BarKeep] self::BarKeep::create();
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::BarKeep::_i;
- @#C9
+ @#C8
static method create() → self::BarKeep
return new self::BarKeep::_();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:8] [@vm.unboxing-info.metadata=(i)->b] @#C11
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:8] [@vm.unboxing-info.metadata=(i)->b] @#C10
set aKeep([@vm.inferred-type.metadata=dart.core::_Smi] core::int v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.$_setSignedInt32] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::$_setSignedInt32}(0, v);
}
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:9] [@vm.unboxing-info.metadata=(i)->b] @#C23
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:9] [@vm.unboxing-info.metadata=(i)->b] @#C22
set bDrop([@vm.inferred-type.metadata=dart.core::_Smi (value: 4)] core::int v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.$_setSignedInt32] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::$_setSignedInt32}(1, v);
}
@@ -122,7 +122,7 @@
return [@vm.inferred-type.metadata=foo.pb.dart::HasKeep] self::HasKeep::create();
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::HasKeep::_i;
- @#C9
+ @#C8
static method create() → self::HasKeep
return new self::HasKeep::_();
}
@@ -138,13 +138,13 @@
return [@vm.inferred-type.metadata=foo.pb.dart::ClearKeep] self::ClearKeep::create();
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::ClearKeep::_i;
- @#C9
+ @#C8
static method create() → self::ClearKeep
return new self::ClearKeep::_();
}
class ZopDrop extends pro::GeneratedMessage {
[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t5 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "ZopDrop") in block {
- [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t5.{pro::BuilderInfo::a}<core::int>(1, (#C1) ?{core::String} "" : "aDrop", #C4, "aDrop");
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t5.{pro::BuilderInfo::a}<core::int>(1, (#C1) ?{core::String} "" : "aDrop", "aDrop");
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t5.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t5;
constructor _() → self::ZopDrop
@@ -154,10 +154,10 @@
return [@vm.inferred-type.metadata=foo.pb.dart::ZopDrop] self::ZopDrop::create();
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::ZopDrop::_i;
- @#C9
+ @#C8
static method create() → self::ZopDrop
return new self::ZopDrop::_();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:10] [@vm.unboxing-info.metadata=(i)->b] @#C11
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:10] [@vm.unboxing-info.metadata=(i)->b] @#C10
set aDrop([@vm.inferred-type.metadata=dart.core::_Smi (value: 3)] core::int v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.$_setSignedInt32] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::$_setSignedInt32}(0, v);
}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/freeze_test.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/freeze_test.dart.expect
index 15a7ebf..b750159 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/freeze_test.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/freeze_test.dart.expect
@@ -41,11 +41,11 @@
[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t1 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "FooKeep") in block {
[@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::BarKeep>(1, (#C1) ?{core::String} "" : "barKeep", "barKeep", #C2);
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.m] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::m}<core::String, self::BarKeep>(3, (#C1) ?{core::String} "" : "mapKeep", #C2);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.m] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::m}<core::String, self::BarKeep>((#C1) ?{core::String} "" : "mapKeep", #C2);
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::a}<core::int>(5, (#C1) ?{core::String} "" : "aKeep", #C3);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::HasKeep>(6, (#C1) ?{core::String} "" : "hasKeep", "hasKeep", #C4);
- [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::ClearKeep>(7, (#C1) ?{core::String} "" : "clearKeep", "clearKeep", #C5);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::a}<core::int>(5, (#C1) ?{core::String} "" : "aKeep");
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::HasKeep>(6, (#C1) ?{core::String} "" : "hasKeep", "hasKeep", #C3);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::aOM}<self::ClearKeep>(7, (#C1) ?{core::String} "" : "clearKeep", "clearKeep", #C4);
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t1.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t1;
constructor _() → self::FooKeep
@@ -55,36 +55,36 @@
return [@vm.inferred-type.metadata=foo.pb.dart::FooKeep] self::FooKeep::create();
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::FooKeep::_i;
- @#C8
+ @#C7
static method create() → self::FooKeep
return new self::FooKeep::_();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:2,getterSelectorId:3] @#C10
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:2,getterSelectorId:3] @#C9
get barKeep() → self::BarKeep
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getN] [@vm.inferred-type.metadata=foo.pb.dart::BarKeep? (skip check)] this.{pro::GeneratedMessage::$_getN}<self::BarKeep>();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:2,getterSelectorId:3] @#C10
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:2,getterSelectorId:3] @#C9
set barKeep([@vm.inferred-type.metadata=foo.pb.dart::BarKeep] self::BarKeep v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.setField] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::setField}(v);
}
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] @#C12
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] @#C11
get mapKeep() → core::Map<core::String, self::BarKeep>
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getMap] [@vm.inferred-type.metadata=! (skip check)] this.{pro::GeneratedMessage::$_getMap}<core::String, self::BarKeep>();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5,getterSelectorId:6] [@vm.unboxing-info.metadata=()->i] @#C14
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5,getterSelectorId:6] [@vm.unboxing-info.metadata=()->i] @#C13
get aKeep() → core::int
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getIZ] [@vm.inferred-type.metadata=int (skip check)] this.{pro::GeneratedMessage::$_getIZ}(4);
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5,getterSelectorId:6] [@vm.unboxing-info.metadata=(i)->b] @#C14
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5,getterSelectorId:6] [@vm.unboxing-info.metadata=(i)->b] @#C13
set aKeep([@vm.inferred-type.metadata=dart.core::_Smi (value: 43)] core::int v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.$_setSignedInt32] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::$_setSignedInt32}(4, v);
}
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:7,getterSelectorId:8] @#C16
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:7,getterSelectorId:8] @#C15
method hasHasKeep() → core::bool
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_has] [@vm.inferred-type.metadata=dart.core::bool (skip check)] this.{pro::GeneratedMessage::$_has}();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:9,getterSelectorId:10] @#C18
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:9,getterSelectorId:10] @#C17
method clearClearKeep() → void
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.clearField] [@vm.inferred-type.metadata=dart.core::Null? (skip check) (value: null)] this.{pro::GeneratedMessage::clearField}();
}
class BarKeep extends pro::GeneratedMessage {
[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t2 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "BarKeep") in block {
- [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::a}<core::int>(1, (#C1) ?{core::String} "" : "aKeep", #C3);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.a] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::a}<core::int>(1, (#C1) ?{core::String} "" : "aKeep");
[@vm.direct-call.metadata=protobuf::BuilderInfo.add] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::add}<Null>(0, null, null, null, null, null, null);
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t2;
@@ -95,13 +95,13 @@
return [@vm.inferred-type.metadata=foo.pb.dart::BarKeep] self::BarKeep::create();
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::BarKeep::_i;
- @#C8
+ @#C7
static method create() → self::BarKeep
return new self::BarKeep::_();
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:11,getterSelectorId:12] [@vm.unboxing-info.metadata=()->i] @#C10
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:11,getterSelectorId:12] [@vm.unboxing-info.metadata=()->i] @#C9
get aKeep() → core::int
return [@vm.direct-call.metadata=protobuf::GeneratedMessage.$_getIZ] [@vm.inferred-type.metadata=int (skip check)] this.{pro::GeneratedMessage::$_getIZ}(0);
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:11,getterSelectorId:12] [@vm.unboxing-info.metadata=(i)->b] @#C10
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:11,getterSelectorId:12] [@vm.unboxing-info.metadata=(i)->b] @#C9
set aKeep([@vm.inferred-type.metadata=dart.core::_Smi] core::int v) → void {
[@vm.direct-call.metadata=protobuf::GeneratedMessage.$_setSignedInt32] [@vm.inferred-type.metadata=!? (skip check)] this.{pro::GeneratedMessage::$_setSignedInt32}(0, v);
}
@@ -116,7 +116,7 @@
;
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::HasKeep::_i;
- @#C8
+ @#C7
static method create() → self::HasKeep
return new self::HasKeep::_();
}
@@ -130,7 +130,7 @@
;
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] get info_() → pro::BuilderInfo
return [@vm.inferred-type.metadata=protobuf::BuilderInfo?] self::ClearKeep::_i;
- @#C8
+ @#C7
static method create() → self::ClearKeep
return new self::ClearKeep::_();
}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/name_mangling_test.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/name_mangling_test.dart.expect
index 2afead4..f3b8f42 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/name_mangling_test.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/protobuf_handler/lib/name_mangling_test.dart.expect
@@ -35,7 +35,7 @@
}
class NameManglingKeep extends pro::GeneratedMessage {
[@vm.inferred-type.metadata=protobuf::BuilderInfo?] static final field pro::BuilderInfo _i = let final pro::BuilderInfo #t2 = new pro::BuilderInfo::•((#C1) ?{core::String} "" : "NameManglingKeep", #C6) in block {
- [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::aOM}<self::AKeep>(10, (#C1) ?{core::String} "" : "clone", #C2);
+ [@vm.direct-call.metadata=protobuf::BuilderInfo.aOM] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::aOM}<self::AKeep>((#C1) ?{core::String} "" : "clone", #C2);
[@vm.direct-call.metadata=protobuf::BuilderInfo.hasRequiredFields] [@vm.inferred-type.metadata=!? (skip check)] #t2.{pro::BuilderInfo::hasRequiredFields} = false;
} =>#t2;
constructor _() → self::NameManglingKeep
diff --git a/pkg/vm/tool/precompiler2 b/pkg/vm/tool/precompiler2
index 6010ee8..192cac3 100755
--- a/pkg/vm/tool/precompiler2
+++ b/pkg/vm/tool/precompiler2
@@ -34,7 +34,6 @@
;;
--tfa | \
--no-tfa | \
- --protobuf-tree-shaker | \
--protobuf-tree-shaker-v2 | \
--minimal-kernel | \
--no-embed-sources | \
diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc
index 7aad2ee..6d0771d 100644
--- a/runtime/vm/compiler/aot/precompiler.cc
+++ b/runtime/vm/compiler/aot/precompiler.cc
@@ -1651,12 +1651,31 @@
: table_(Array::Handle(zone)),
kind_and_offset_(Smi::Handle(zone)),
target_function_(Function::Handle(zone)),
- target_code_(Code::Handle(zone)) {}
+ target_code_(Code::Handle(zone)),
+ pool_(ObjectPool::Handle(zone)) {}
void VisitCode(const Code& code) {
if (!code.IsFunctionCode()) return;
table_ = code.static_calls_target_table();
StaticCallsTable static_calls(table_);
+
+ // With bare instructions, there is a global pool and per-Code local
+ // pools. Instructions are generated to use offsets into the global pool,
+ // but we still use the local pool to track which Code are using which
+ // pool values for the purposes of analyzing snapshot size
+ // (--write_v8_snapshot_profile_to and --print_instructions_sizes_to) and
+ // deferred loading deciding which snapshots to place pool values in.
+ // We don't keep track of which offsets in the local pools correspond to
+ // which entries in the static call table, so we don't properly replace
+ // the old references to the CallStaticFunction stub, but it is sufficient
+ // for the local pool to include the actual call target.
+ compiler::ObjectPoolBuilder builder;
+ bool append_to_pool = FLAG_use_bare_instructions;
+ if (append_to_pool) {
+ pool_ = code.object_pool();
+ pool_.CopyInto(&builder);
+ }
+
for (auto& view : static_calls) {
kind_and_offset_ = view.Get<Code::kSCallTableKindAndOffset>();
auto const kind = Code::KindField::decode(kind_and_offset_.Value());
@@ -1678,6 +1697,9 @@
Code::OffsetField::decode(kind_and_offset_.Value());
const uword pc = pc_offset + code.PayloadStart();
CodePatcher::PatchStaticCallAt(pc, code, target_code_);
+ if (append_to_pool) {
+ builder.AddObject(Object::ZoneHandle(target_code_.raw()));
+ }
}
if (FLAG_trace_precompiler) {
THR_Print("Updated static call entry to %s in \"%s\"\n",
@@ -1685,6 +1707,10 @@
code.ToCString());
}
}
+
+ if (append_to_pool) {
+ code.set_object_pool(ObjectPool::NewFromBuilder(builder));
+ }
}
private:
@@ -1692,6 +1718,7 @@
Smi& kind_and_offset_;
Function& target_function_;
Code& target_code_;
+ ObjectPool& pool_;
};
HANDLESCOPE(T);
diff --git a/runtime/vm/compiler/assembler/assembler_base.cc b/runtime/vm/compiler/assembler/assembler_base.cc
index 96d98a1..7034652 100644
--- a/runtime/vm/compiler/assembler/assembler_base.cc
+++ b/runtime/vm/compiler/assembler/assembler_base.cc
@@ -327,6 +327,7 @@
if (parent_ != nullptr) {
const intptr_t idx = parent_->object_pool_index_table_.LookupValue(entry);
if (idx != ObjIndexPair::kNoIndex) {
+ used_from_parent_.Add(idx);
return idx;
}
}
diff --git a/runtime/vm/instructions_arm.cc b/runtime/vm/instructions_arm.cc
index d38a349..16bb992 100644
--- a/runtime/vm/instructions_arm.cc
+++ b/runtime/vm/instructions_arm.cc
@@ -11,6 +11,7 @@
#include "vm/constants.h"
#include "vm/cpu.h"
#include "vm/object.h"
+#include "vm/object_store.h"
#include "vm/reverse_pc_lookup_cache.h"
namespace dart {
@@ -220,12 +221,14 @@
Register dst;
if (IsLoadWithOffset(instr, PP, &offset, &dst)) {
intptr_t index = ObjectPool::IndexFromOffset(offset);
- const ObjectPool& pool = ObjectPool::Handle(code.object_pool());
- if (!pool.IsNull()) {
- if (pool.TypeAt(index) == ObjectPool::EntryType::kTaggedObject) {
- *obj = pool.ObjectAt(index);
- return true;
- }
+ const ObjectPool& pool = ObjectPool::Handle(
+ FLAG_use_bare_instructions
+ ? IsolateGroup::Current()->object_store()->global_object_pool()
+ : code.object_pool());
+ if (!pool.IsNull() && (index < pool.Length()) &&
+ (pool.TypeAt(index) == ObjectPool::EntryType::kTaggedObject)) {
+ *obj = pool.ObjectAt(index);
+ return true;
}
} else if (IsLoadWithOffset(instr, THR, &offset, &dst)) {
return Thread::ObjectAtOffset(offset, obj);
diff --git a/runtime/vm/instructions_arm64.cc b/runtime/vm/instructions_arm64.cc
index 1ebd214..210fca3 100644
--- a/runtime/vm/instructions_arm64.cc
+++ b/runtime/vm/instructions_arm64.cc
@@ -11,6 +11,7 @@
#include "vm/constants.h"
#include "vm/cpu.h"
#include "vm/object.h"
+#include "vm/object_store.h"
#include "vm/reverse_pc_lookup_cache.h"
namespace dart {
@@ -330,17 +331,15 @@
if (instr->RnField() == PP) {
// PP is untagged on ARM64.
ASSERT(Utils::IsAligned(offset, 8));
- // A code object may have an object pool attached in bare instructions
- // mode if the v8 snapshot profile writer is active, but this pool cannot
- // be used for object loading.
- if (FLAG_use_bare_instructions) return false;
intptr_t index = ObjectPool::IndexFromOffset(offset - kHeapObjectTag);
- const ObjectPool& pool = ObjectPool::Handle(code.object_pool());
- if (!pool.IsNull()) {
- if (pool.TypeAt(index) == ObjectPool::EntryType::kTaggedObject) {
- *obj = pool.ObjectAt(index);
- return true;
- }
+ const ObjectPool& pool = ObjectPool::Handle(
+ FLAG_use_bare_instructions
+ ? IsolateGroup::Current()->object_store()->global_object_pool()
+ : code.object_pool());
+ if (!pool.IsNull() && (index < pool.Length()) &&
+ (pool.TypeAt(index) == ObjectPool::EntryType::kTaggedObject)) {
+ *obj = pool.ObjectAt(index);
+ return true;
}
} else if (instr->RnField() == THR) {
return Thread::ObjectAtOffset(offset, obj);
diff --git a/runtime/vm/instructions_x64.cc b/runtime/vm/instructions_x64.cc
index 256faa9..7495066f 100644
--- a/runtime/vm/instructions_x64.cc
+++ b/runtime/vm/instructions_x64.cc
@@ -14,6 +14,7 @@
#include "vm/constants.h"
#include "vm/cpu.h"
#include "vm/object.h"
+#include "vm/object_store.h"
namespace dart {
@@ -63,22 +64,26 @@
if ((bytes[1] == 0x8b) || (bytes[1] == 0x3b)) { // movq, cmpq
if ((bytes[2] & 0xc7) == (0x80 | (PP & 7))) { // [r15+disp32]
intptr_t index = IndexFromPPLoadDisp32(pc + 3);
- const ObjectPool& pool = ObjectPool::Handle(code.object_pool());
- if (!pool.IsNull()) {
- if (pool.TypeAt(index) == ObjectPool::EntryType::kTaggedObject) {
- *obj = pool.ObjectAt(index);
- return true;
- }
+ const ObjectPool& pool = ObjectPool::Handle(
+ FLAG_use_bare_instructions
+ ? IsolateGroup::Current()->object_store()->global_object_pool()
+ : code.object_pool());
+ if (!pool.IsNull() && (index < pool.Length()) &&
+ (pool.TypeAt(index) == ObjectPool::EntryType::kTaggedObject)) {
+ *obj = pool.ObjectAt(index);
+ return true;
}
}
if ((bytes[2] & 0xc7) == (0x40 | (PP & 7))) { // [r15+disp8]
intptr_t index = IndexFromPPLoadDisp8(pc + 3);
- const ObjectPool& pool = ObjectPool::Handle(code.object_pool());
- if (!pool.IsNull()) {
- if (pool.TypeAt(index) == ObjectPool::EntryType::kTaggedObject) {
- *obj = pool.ObjectAt(index);
- return true;
- }
+ const ObjectPool& pool = ObjectPool::Handle(
+ FLAG_use_bare_instructions
+ ? IsolateGroup::Current()->object_store()->global_object_pool()
+ : code.object_pool());
+ if (!pool.IsNull() && (index < pool.Length()) &&
+ (pool.TypeAt(index) == ObjectPool::EntryType::kTaggedObject)) {
+ *obj = pool.ObjectAt(index);
+ return true;
}
}
}
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index cea08ae..ffad3f4 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -3798,7 +3798,7 @@
}
ArrayPtr Class::invocation_dispatcher_cache() const {
- return raw_ptr()->invocation_dispatcher_cache();
+ return raw_ptr()->invocation_dispatcher_cache<std::memory_order_acquire>();
}
void Class::Finalize() const {
@@ -5022,7 +5022,7 @@
// The exception is DeclarationType of Null which is kNullable.
ASSERT(value.type_class_id() != kNullCid || value.IsNullable());
ASSERT(value.type_class_id() == kNullCid || value.IsNonNullable());
- raw_ptr()->set_declaration_type(value.raw());
+ raw_ptr()->set_declaration_type<std::memory_order_release>(value.raw());
}
TypePtr Class::DeclarationType() const {
@@ -9957,7 +9957,7 @@
void ClosureData::set_implicit_static_closure(const Instance& closure) const {
ASSERT(!closure.IsNull());
ASSERT(raw_ptr()->closure() == Instance::null());
- raw_ptr()->set_closure(closure.raw());
+ raw_ptr()->set_closure<std::memory_order_release>(closure.raw());
}
void ClosureData::set_parent_function(const Function& value) const {
@@ -16466,9 +16466,7 @@
}
} else {
#if defined(DART_PRECOMPILER)
- const bool needs_pool = (FLAG_write_v8_snapshot_profile_to != nullptr) ||
- (FLAG_trace_precompiler_to != nullptr);
- if (needs_pool && assembler->HasObjectPoolBuilder() &&
+ if (assembler->HasObjectPoolBuilder() &&
assembler->object_pool_builder().HasParent()) {
// We are not going to write this pool into snapshot, but we will use
// it to emit references from this code object to other objects in the
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index ec29673..594bc24 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1588,7 +1588,9 @@
}
private:
- TypePtr declaration_type() const { return raw_ptr()->declaration_type(); }
+ TypePtr declaration_type() const {
+ return raw_ptr()->declaration_type<std::memory_order_acquire>();
+ }
// Caches the declaration type of this class.
void set_declaration_type(const Type& type) const;
@@ -3767,7 +3769,9 @@
FunctionPtr parent_function() const { return raw_ptr()->parent_function_; }
void set_parent_function(const Function& value) const;
- InstancePtr implicit_static_closure() const { return raw_ptr()->closure_; }
+ InstancePtr implicit_static_closure() const {
+ return raw_ptr()->closure<std::memory_order_acquire>();
+ }
void set_implicit_static_closure(const Instance& closure) const;
TypeArgumentsPtr default_type_arguments() const {
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/classes.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/classes.dart
index d862534..d9af93e 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/classes.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/classes.dart
@@ -504,6 +504,26 @@
_applyExtension(jsType, dartExtType);
}
+/// Apply a previously registered extension for testing purposes.
+///
+/// This method's only purpose is to aid in testing native classes. Most native
+/// tests define JavaScript classes in user code (e.g. in an eval string). The
+/// dartdevc compiler properly calls `registerExtension` when processing the
+/// native class declarations in Dart, but at that point in time the JavaScript
+/// counterpart is not defined.
+///
+/// This method is used to lookup those registrations and reapply the extension
+/// after the JavaScript declarations are added.
+///
+/// An alternative to this would be to invest in a better test infrastructure
+/// that would let us define the JavaScript code prior to loading the compiled
+/// module.
+applyExtensionForTesting(name) {
+ var dartExtType = JS('', '#.get(#)', _extensionMap, name);
+ var jsType = JS('', '#[#]', global_, name);
+ _applyExtension(jsType, dartExtType);
+}
+
///
/// Mark a concrete type as implementing extension methods.
/// For example: `class MyIter implements Iterable`.
diff --git a/sdk/lib/_internal/js_dev_runtime/private/interceptors.dart b/sdk/lib/_internal/js_dev_runtime/private/interceptors.dart
index 72fff96..71c559c 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/interceptors.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/interceptors.dart
@@ -239,3 +239,8 @@
findConstructorForNativeSubclassType(Type? type, String name) {}
getNativeInterceptor(object) {}
setDispatchProperty(object, value) {}
+
+// Added to allow dart2js and dartdevc to share tests
+// TODO(sigmund): revisit whether this method is still needed after reoganizing
+// all web tests.
+findInterceptorForType(Type? type) {}
diff --git a/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart b/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart
index 51eb666..08a1e1e 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/js_helper.dart
@@ -798,6 +798,11 @@
dart.applyExtension(name, nativeObject);
}
+/// Hook to apply extensions on native JS classes defined in a native unit test.
+void applyTestExtensions(List<String> names) {
+ names.forEach(dart.applyExtensionForTesting);
+}
+
/// Used internally by DDC to map ES6 symbols to Dart.
class PrivateSymbol implements Symbol {
// TODO(jmesserly): could also get this off the native symbol instead of
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index c30d332..1bef6a1 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -2999,10 +2999,14 @@
// This is currently a no-op in dart2js.
void registerGlobalObject(object) {}
-// Hook to register new browser classes.
+// Hook to register new browser classes in dartdevc.
// This is currently a no-op in dart2js.
void applyExtension(name, nativeObject) {}
+// Hook to upgrade user native-type classes in dartdevc.
+// This is currently a no-op in dart2js, but used for native tests.
+void applyTestExtensions(List<String> names) {}
+
// See tests/dart2js_2/platform_environment_variable1_test.dart
const String testPlatformEnvironmentVariableValue = String.fromEnvironment(
'dart2js.test.platform.environment.variable',
diff --git a/tests/dart2js/native/abstract_class_test.dart b/tests/dart2js/native/abstract_class_test.dart
index 6773385..7bcba7e 100644
--- a/tests/dart2js/native/abstract_class_test.dart
+++ b/tests/dart2js/native/abstract_class_test.dart
@@ -27,12 +27,12 @@
function A(){}
function B(){}
B.prototype.foo = function() { return 'B.foo'; };
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
-})()
-""");
+})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js/native/bound_closure_test.dart b/tests/dart2js/native/bound_closure_test.dart
index 3509722..1702a84 100644
--- a/tests/dart2js/native/bound_closure_test.dart
+++ b/tests/dart2js/native/bound_closure_test.dart
@@ -40,13 +40,14 @@
return 'CC.foo(' + u + ', ' + v + ')';
};
- makeBB = function(){return new BB()};
- makeCC = function(){return new CC()};
- inscrutable = function(a){return a;};
+ self.makeBB = function(){return new BB()};
+ self.makeCC = function(){return new CC()};
+ self.inscrutable = function(a){return a;};
self.nativeConstructor(BB);
self.nativeConstructor(CC);
})()""");
+ applyTestExtensions(['BB', 'CC']);
}
main() {
diff --git a/tests/dart2js/native/browser_compat_1_prepatched_test.dart b/tests/dart2js/native/browser_compat_1_prepatched_test.dart
index bfd62f5..e49b134 100644
--- a/tests/dart2js/native/browser_compat_1_prepatched_test.dart
+++ b/tests/dart2js/native/browser_compat_1_prepatched_test.dart
@@ -37,9 +37,9 @@
window.T1A = T1A;
window.T1CrazyB = T1CrazyB;
- makeT1A = function(){return new T1A()};
- makeT1B = function(){return new T1CrazyB()};
- makeT1C = function(){return new T1fakeA()};
+ self.makeT1A = function(){return new T1A()};
+ self.makeT1B = function(){return new T1CrazyB()};
+ self.makeT1C = function(){return new T1fakeA()};
self.nativeConstructor(T1A);
self.nativeConstructor(T1CrazyB);
@@ -71,6 +71,7 @@
dartNativeDispatchHooksTransformer = [transformer1];
})()''');
+ applyTestExtensions(['T1A', 'T1CrazyB', 'T1fakeA']);
}
main() {
diff --git a/tests/dart2js/native/browser_compat_1_unpatched_test.dart b/tests/dart2js/native/browser_compat_1_unpatched_test.dart
index 779b72a..82a1fba 100644
--- a/tests/dart2js/native/browser_compat_1_unpatched_test.dart
+++ b/tests/dart2js/native/browser_compat_1_unpatched_test.dart
@@ -38,9 +38,9 @@
window.T1A = T1A;
window.T1CrazyB = T1CrazyB;
- makeT1A = function(){return new T1A()};
- makeT1B = function(){return new T1CrazyB()};
- makeT1C = function(){return new T1fakeA()};
+ self.makeT1A = function(){return new T1A()};
+ self.makeT1B = function(){return new T1CrazyB()};
+ self.makeT1C = function(){return new T1fakeA()};
self.nativeConstructor(T1A);
self.nativeConstructor(T1CrazyB);
@@ -74,6 +74,7 @@
dartNativeDispatchHooksTransformer = [transformer1];
})()""");
+ applyTestExtensions(['T1A', 'T1CrazyB', 'T1fakeA']);
}
main() {
diff --git a/tests/dart2js/native/browser_compat_2_test.dart b/tests/dart2js/native/browser_compat_2_test.dart
index aa8f131..50a88b4 100644
--- a/tests/dart2js/native/browser_compat_2_test.dart
+++ b/tests/dart2js/native/browser_compat_2_test.dart
@@ -59,10 +59,10 @@
T1C.prototype.name = function() { return "C"; };
T1D.prototype.name = function() { return "D"; };
-makeT1A = function(){return new T1A()};
-makeT1B = function(){return new T1B()};
-makeT1C = function(){return new T1C()};
-makeT1D = function(){return new T1D()};
+self.makeT1A = function(){return new T1A()};
+self.makeT1B = function(){return new T1B()};
+self.makeT1C = function(){return new T1C()};
+self.makeT1D = function(){return new T1D()};
self.nativeConstructor(T1A);
self.nativeConstructor(T1B);
@@ -70,8 +70,8 @@
self.nativeConstructor(T1D);
var getTagCount = 0;
-getTagCallCount = function() { return getTagCount; };
-clearTagCallCount = function() { getTagCount = 0; };
+self.getTagCallCount = function() { return getTagCount; };
+self.clearTagCallCount = function() { getTagCount = 0; };
function transformer1(hooks) {
var getTag = hooks.getTag;
@@ -102,8 +102,9 @@
hooks.getTag = getTagNew;
}
-dartNativeDispatchHooksTransformer = [transformer1, transformer2];
+self.dartNativeDispatchHooksTransformer = [transformer1, transformer2];
})()''');
+ applyTestExtensions(['T1A', 'T1B', 'T1C', 'T1D']);
}
main() {
diff --git a/tests/dart2js/native/core_type_check_native_test.dart b/tests/dart2js/native/core_type_check_native_test.dart
index 6356192..572c136 100644
--- a/tests/dart2js/native/core_type_check_native_test.dart
+++ b/tests/dart2js/native/core_type_check_native_test.dart
@@ -31,20 +31,20 @@
JS('', r"""
(function(){
function A() {};
- makeA = function() { return new A(); };
+ self.makeA = function() { return new A(); };
function B() {};
- makeB = function() { return new B(); };
+ self.makeB = function() { return new B(); };
function C() {};
- makeC = function() { return new C(); };
+ self.makeC = function() { return new C(); };
function D() {};
- makeD = function() { return new D(); };
+ self.makeD = function() { return new D(); };
self.nativeConstructor(A);
self.nativeConstructor(B);
self.nativeConstructor(C);
self.nativeConstructor(D);
-})()
-""");
+})()""");
+ applyTestExtensions(['A', 'B', 'C', 'D']);
}
checkTest(value, expectComparable, expectPattern) {
diff --git a/tests/dart2js/native/dispatch_property_initialization_test.dart b/tests/dart2js/native/dispatch_property_initialization_test.dart
index 4e4ed95..21a6e9f 100644
--- a/tests/dart2js/native/dispatch_property_initialization_test.dart
+++ b/tests/dart2js/native/dispatch_property_initialization_test.dart
@@ -23,6 +23,7 @@
self.nativeConstructor(Foo);
})()""");
+ applyTestExtensions(['Foo']);
}
main() {
diff --git a/tests/dart2js/native/downcast_test.dart b/tests/dart2js/native/downcast_test.dart
index ab74f5f..9355948 100644
--- a/tests/dart2js/native/downcast_test.dart
+++ b/tests/dart2js/native/downcast_test.dart
@@ -46,12 +46,13 @@
inherits(B, A);
A.prototype.read = function() { return this._x; };
A.prototype.write = function(x) { this._x = x; };
-makeA = function(){return new A()};
-makeB = function(){return new B()};
+self.makeA = function(){return new A()};
+self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
class C {}
diff --git a/tests/dart2js/native/error_safeToString_test.dart b/tests/dart2js/native/error_safeToString_test.dart
index 022b53a..ecb3544 100644
--- a/tests/dart2js/native/error_safeToString_test.dart
+++ b/tests/dart2js/native/error_safeToString_test.dart
@@ -36,45 +36,46 @@
void setup() {
JS('', r"""
(function(){
- makeA = function(){return {hello: 123};};
+ self.makeA = function(){return {hello: 123};};
function BB(){}
- makeB = function(){return new BB();};
+ self.makeB = function(){return new BB();};
function CC(){}
- makeC = function(){
+ self.makeC = function(){
var x = new CC();
x.constructor = null; // Foils constructor lookup.
return x;
};
function DD(){}
- makeD = function(){
+ self.makeD = function(){
var x = new DD();
x.constructor = {name: 'DDxxx'}; // Foils constructor lookup.
return x;
};
function EE(){}
- makeE = function(){
+ self.makeE = function(){
var x = new EE();
x.constructor = function Liar(){}; // Looks like a legitimate constructor.
return x;
};
function PPPP(){}
- makeP = function(){return new PPPP();};
+ self.makeP = function(){return new PPPP();};
function QQQQ(){}
- makeQ = function(){return new QQQQ();};
+ self.makeQ = function(){return new QQQQ();};
function RRRR(){}
- makeR = function(){return new RRRR();};
+ self.makeR = function(){return new RRRR();};
self.nativeConstructor(PPPP);
self.nativeConstructor(QQQQ);
self.nativeConstructor(RRRR);
})()""");
+ applyTestExtensions(['PPPP', 'QQQQ', 'RRRR']);
}
expectTypeName(expectedName, s) {
diff --git a/tests/dart2js/native/event_loop_test.dart b/tests/dart2js/native/event_loop_test.dart
index e69d542..2706bb7 100644
--- a/tests/dart2js/native/event_loop_test.dart
+++ b/tests/dart2js/native/event_loop_test.dart
@@ -20,9 +20,10 @@
(function(){
function A() {}
A.prototype.foo = function(f) { return f(); };
-makeA = function() { return new A(); };
+self.makeA = function() { return new A(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/fake_thing_2_test.dart b/tests/dart2js/native/fake_thing_2_test.dart
index f630746..8ca0394 100644
--- a/tests/dart2js/native/fake_thing_2_test.dart
+++ b/tests/dart2js/native/fake_thing_2_test.dart
@@ -23,14 +23,15 @@
(function(){
function A() {}
A.prototype.$isThing = true;
- make1 = function(){return new A()};
- make2 = function(){return {$isThing: true}};
+ self.make1 = function(){return new A()};
+ self.make2 = function(){return {$isThing: true}};
function NT() {}
NT.prototype.$isThing = true;
- make3 = function(){return new NT()};
+ self.make3 = function(){return new NT()};
self.nativeConstructor(NT);
})()""");
+ applyTestExtensions(['NT']);
}
main() {
diff --git a/tests/dart2js/native/fake_thing_test.dart b/tests/dart2js/native/fake_thing_test.dart
index 542a5ca..4a699c4 100644
--- a/tests/dart2js/native/fake_thing_test.dart
+++ b/tests/dart2js/native/fake_thing_test.dart
@@ -21,8 +21,8 @@
(function(){
function A() {}
A.prototype.$isThing = true;
- make1 = function(){return new A();};
- make2 = function(){return {$isThing: true}};
+ self.make1 = function(){return new A();};
+ self.make2 = function(){return {$isThing: true}};
})()""");
}
diff --git a/tests/dart2js/native/field_type2_test.dart b/tests/dart2js/native/field_type2_test.dart
index fdf77bb..edece7a 100644
--- a/tests/dart2js/native/field_type2_test.dart
+++ b/tests/dart2js/native/field_type2_test.dart
@@ -19,10 +19,11 @@
(function(){
// This code is all inside 'setup' and so not accessible from the global scope.
function Node(parent){ this.parentNode = parent; }
-makeNode = function(p){return new Node(p);};
+self.makeNode = function(p){return new Node(p);};
self.nativeConstructor(Node);
})()""");
+ applyTestExtensions(['Node']);
}
main() {
diff --git a/tests/dart2js/native/field_type_test.dart b/tests/dart2js/native/field_type_test.dart
index 8135cd5..5cc73d0 100644
--- a/tests/dart2js/native/field_type_test.dart
+++ b/tests/dart2js/native/field_type_test.dart
@@ -48,9 +48,10 @@
(function(){
// This code is inside 'setup' and so not accessible from the global scope.
function Node(parent){ this.parentNode = parent; }
- makeNode = function(p){return new Node(p);};
+ self.makeNode = function(p){return new Node(p);};
self.nativeConstructor(Node);
})()""");
+ applyTestExtensions(['Node']);
}
main() {
diff --git a/tests/dart2js/native/fixup_get_tag_test.dart b/tests/dart2js/native/fixup_get_tag_test.dart
index e4e1ab8..a904982 100644
--- a/tests/dart2js/native/fixup_get_tag_test.dart
+++ b/tests/dart2js/native/fixup_get_tag_test.dart
@@ -33,11 +33,12 @@
function B(){ }
B.prototype.token = function () { return 'isB'; };
- makeA = function() { return new A(); };
- makeB = function() { return new B(); };
+ self.makeA = function() { return new A(); };
+ self.makeB = function() { return new B(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
makeA() native;
diff --git a/tests/dart2js/native/foreign_test.dart b/tests/dart2js/native/foreign_test.dart
index 31ab23b..d69efdd 100644
--- a/tests/dart2js/native/foreign_test.dart
+++ b/tests/dart2js/native/foreign_test.dart
@@ -33,7 +33,7 @@
// Ensure there will be isNaN and NaN variable names.
var isNaN = called ? 42 : 44;
var NaN = called ? 52 : 54;
- Expect.isFalse(JS('bool', 'isNaN(#)', isNaN));
- Expect.isFalse(JS('bool', 'isNaN(#)', NaN));
- Expect.isTrue(JS('bool', 'isNaN(#)', double.nan));
+ Expect.isFalse(JS('bool', 'self.isNaN(#)', isNaN));
+ Expect.isFalse(JS('bool', 'self.isNaN(#)', NaN));
+ Expect.isTrue(JS('bool', 'self.isNaN(#)', double.nan));
}
diff --git a/tests/dart2js/native/hash_code_test.dart b/tests/dart2js/native/hash_code_test.dart
index 137be8f..0b1f391 100644
--- a/tests/dart2js/native/hash_code_test.dart
+++ b/tests/dart2js/native/hash_code_test.dart
@@ -20,12 +20,13 @@
(function(){
function A() {}
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js/native/issue9182_test.dart b/tests/dart2js/native/issue9182_test.dart
index 62a0a60..0e22af0 100644
--- a/tests/dart2js/native/issue9182_test.dart
+++ b/tests/dart2js/native/issue9182_test.dart
@@ -28,9 +28,10 @@
JS('', r"""
(function(){
function A(){}
- makeA = function() { return new A() };
+ self.makeA = function() { return new A() };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
makeA() native;
diff --git a/tests/dart2js/native/jsobject_test.dart b/tests/dart2js/native/jsobject_test.dart
index dd0ec8e..0b769d0 100644
--- a/tests/dart2js/native/jsobject_test.dart
+++ b/tests/dart2js/native/jsobject_test.dart
@@ -27,16 +27,17 @@
void setup() {
JS('', r"""
(function(){
-makeA = function(){return {hello: 123};};
+self.makeA = function(){return {hello: 123};};
function BB(){}
-makeB = function(){return new BB();};
+self.makeB = function(){return new BB();};
function QQ(){}
-makeQ = function(){return new QQ();};
+self.makeQ = function(){return new QQ();};
self.nativeConstructor(QQ);
})()""");
+ applyTestExtensions(['QQ']);
}
class Is<T> {
diff --git a/tests/dart2js/native/name_conflict_test.dart b/tests/dart2js/native/name_conflict_test.dart
index 555c78e..3294895 100644
--- a/tests/dart2js/native/name_conflict_test.dart
+++ b/tests/dart2js/native/name_conflict_test.dart
@@ -35,9 +35,10 @@
function I(){}
I.prototype.read = function() { return this._x; };
I.prototype.write = function(x) { this._x = x; };
- makeI = function(){return new I()};
+ self.makeI = function(){return new I()};
self.nativeConstructor(I);
})()""");
+ applyTestExtensions(['I']);
}
// A pure Dart implementation of I.
diff --git a/tests/dart2js/native/native_call_arity1_frog_test.dart b/tests/dart2js/native/native_call_arity1_frog_test.dart
index f590001..e308b69 100644
--- a/tests/dart2js/native/native_call_arity1_frog_test.dart
+++ b/tests/dart2js/native/native_call_arity1_frog_test.dart
@@ -37,12 +37,13 @@
function B() {}
B.prototype.foo = function () { return arguments.length; };
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testDynamicContext() {
diff --git a/tests/dart2js/native/native_call_arity2_frog_test.dart b/tests/dart2js/native/native_call_arity2_frog_test.dart
index 1646809..32a1b63 100644
--- a/tests/dart2js/native/native_call_arity2_frog_test.dart
+++ b/tests/dart2js/native/native_call_arity2_frog_test.dart
@@ -40,12 +40,13 @@
B.prototype.foo = function () { return arguments.length; };
inherits(B, A);
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testDynamicContext() {
diff --git a/tests/dart2js/native/native_call_arity3_frog_test.dart b/tests/dart2js/native/native_call_arity3_frog_test.dart
index 3be4585..c33bc38 100644
--- a/tests/dart2js/native/native_call_arity3_frog_test.dart
+++ b/tests/dart2js/native/native_call_arity3_frog_test.dart
@@ -33,12 +33,13 @@
function B() {}
B.prototype.foo = function () { return arguments.length; };
- makeA = function(){return new A();};
- makeB = function(){return new B();};
+ self.makeA = function(){return new A();};
+ self.makeB = function(){return new B();};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testDynamicContext() {
diff --git a/tests/dart2js/native/native_checked_arguments1_frog_test.dart b/tests/dart2js/native/native_checked_arguments1_frog_test.dart
index ddce60e..0ae9012 100644
--- a/tests/dart2js/native/native_checked_arguments1_frog_test.dart
+++ b/tests/dart2js/native/native_checked_arguments1_frog_test.dart
@@ -24,6 +24,7 @@
void setup() {
JS('', r"""
(function(){
+ "use strict";
function A() {}
A.prototype.foo = function (x) { return x + 1; };
A.prototype.cmp = function (x) { return 0; };
@@ -32,12 +33,13 @@
B.prototype.foo = function (x) { return x + 'ha!'; };
B.prototype.cmp = function (x) { return 1; };
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
expectThrows(action()) {
diff --git a/tests/dart2js/native/native_checked_fields_frog_test.dart b/tests/dart2js/native/native_checked_fields_frog_test.dart
index 76d8902..e87c801 100644
--- a/tests/dart2js/native/native_checked_fields_frog_test.dart
+++ b/tests/dart2js/native/native_checked_fields_frog_test.dart
@@ -28,12 +28,13 @@
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
expectThrows(action()) {
diff --git a/tests/dart2js/native/native_class_avoids_hidden_name_frog_test.dart b/tests/dart2js/native/native_class_avoids_hidden_name_frog_test.dart
index 6e4a95c..dfe9dda 100644
--- a/tests/dart2js/native/native_class_avoids_hidden_name_frog_test.dart
+++ b/tests/dart2js/native/native_class_avoids_hidden_name_frog_test.dart
@@ -32,8 +32,8 @@
(function(){
// Poison hidden native names 'BB' and 'CC' to prove the compiler didn't place
// anything on the hidden native class.
- BB = null;
- CC = null;
+ self.BB = null;
+ self.CC = null;
})()""");
}
@@ -43,11 +43,12 @@
// This code is inside 'setup' and so not accessible from the global scope.
function BB(){}
function CC(){}
- makeA = function(){return new BB()}; // AA is native "BB"
- makeB = function(){return new CC()}; // BB is native "CC"
+ self.makeA = function(){return new BB()}; // AA is native "BB"
+ self.makeB = function(){return new CC()}; // BB is native "CC"
self.nativeConstructor(BB);
self.nativeConstructor(CC);
})()""");
+ applyTestExtensions(['BB', 'CC']);
}
main() {
diff --git a/tests/dart2js/native/native_class_fields_2_test.dart b/tests/dart2js/native/native_class_fields_2_test.dart
index 6529946..6575857 100644
--- a/tests/dart2js/native/native_class_fields_2_test.dart
+++ b/tests/dart2js/native/native_class_fields_2_test.dart
@@ -37,9 +37,10 @@
return a;
}
- makeA = function() { return new A(); };
+ self.makeA = function() { return new A(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
A makeA() native;
diff --git a/tests/dart2js/native/native_class_fields_3_test.dart b/tests/dart2js/native/native_class_fields_3_test.dart
index dd2824d..8a53e50 100644
--- a/tests/dart2js/native/native_class_fields_3_test.dart
+++ b/tests/dart2js/native/native_class_fields_3_test.dart
@@ -67,9 +67,10 @@
return a;
}
- makeA = function() { return new A(); };
+ self.makeA = function() { return new A(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
A makeA() native;
diff --git a/tests/dart2js/native/native_class_fields_test.dart b/tests/dart2js/native/native_class_fields_test.dart
index 64122ac..e0f5300 100644
--- a/tests/dart2js/native/native_class_fields_test.dart
+++ b/tests/dart2js/native/native_class_fields_test.dart
@@ -42,6 +42,7 @@
makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
A makeA() native;
diff --git a/tests/dart2js/native/native_class_inheritance1_frog_test.dart b/tests/dart2js/native/native_class_inheritance1_frog_test.dart
index 322dcba..44c5cb2 100644
--- a/tests/dart2js/native/native_class_inheritance1_frog_test.dart
+++ b/tests/dart2js/native/native_class_inheritance1_frog_test.dart
@@ -57,8 +57,8 @@
A1.prototype.foo = function(){return 100;};
B1.prototype.foo = function(){return 200;};
- makeA1 = function(){return new A1()};
- makeB1 = function(){return new B1()};
+ self.makeA1 = function(){return new A1()};
+ self.makeB1 = function(){return new B1()};
function A2(){}
function B2(){}
@@ -66,14 +66,15 @@
A2.prototype.foo = function(a){return a + 10000;};
B2.prototype.foo = function(z){return z + 20000;};
- makeA2 = function(){return new A2()};
- makeB2 = function(){return new B2()};
+ self.makeA2 = function(){return new A2()};
+ self.makeB2 = function(){return new B2()};
self.nativeConstructor(A1);
self.nativeConstructor(A2);
self.nativeConstructor(B1);
self.nativeConstructor(B2);
})()""");
+ applyTestExtensions(['A1', 'A2', 'B1', 'B2']);
}
main() {
diff --git a/tests/dart2js/native/native_class_inheritance2_frog_test.dart b/tests/dart2js/native/native_class_inheritance2_frog_test.dart
index 8fa4b67..66fb625 100644
--- a/tests/dart2js/native/native_class_inheritance2_frog_test.dart
+++ b/tests/dart2js/native/native_class_inheritance2_frog_test.dart
@@ -56,16 +56,17 @@
A.prototype.foo = function(a){return 'A.foo(' + a + ')'};
C.prototype.foo = function(z){return 'C.foo(' + z + ')'};
- makeA = function(){return new A()};
- makeB = function(){return new B()};
- makeC = function(){return new C()};
- makeD = function(){return new D()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
+ self.makeC = function(){return new C()};
+ self.makeD = function(){return new D()};
self.nativeConstructor(A);
self.nativeConstructor(B);
self.nativeConstructor(C);
self.nativeConstructor(D);
})()""");
+ applyTestExtensions(['A', 'B', 'C', 'D']);
}
main() {
diff --git a/tests/dart2js/native/native_class_inheritance3_frog_test.dart b/tests/dart2js/native/native_class_inheritance3_frog_test.dart
index af5a8e3..d123928 100644
--- a/tests/dart2js/native/native_class_inheritance3_frog_test.dart
+++ b/tests/dart2js/native/native_class_inheritance3_frog_test.dart
@@ -48,24 +48,25 @@
function B1(){}
inherits(B1, A1);
- makeA1 = function(){return new A1()};
- makeB1 = function(){return new B1()};
+ self.makeA1 = function(){return new A1()};
+ self.makeB1 = function(){return new B1()};
function A2(){}
function B2(){}
inherits(B2, A2);
A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';};
- makeA2 = function(){return new A2()};
- makeB2 = function(){return new B2()};
+ self.makeA2 = function(){return new A2()};
+ self.makeB2 = function(){return new B2()};
- makeObject = function(){return new Object()};
+ self.makeObject = function(){return new Object()};
self.nativeConstructor(A1);
self.nativeConstructor(A2);
self.nativeConstructor(B1);
self.nativeConstructor(B2);
})()""");
+ applyTestExtensions(['A1', 'A2', 'B1', 'B2']);
}
main() {
diff --git a/tests/dart2js/native/native_class_inheritance4_frog_test.dart b/tests/dart2js/native/native_class_inheritance4_frog_test.dart
index 25f8fcd..4d65752 100644
--- a/tests/dart2js/native/native_class_inheritance4_frog_test.dart
+++ b/tests/dart2js/native/native_class_inheritance4_frog_test.dart
@@ -52,12 +52,13 @@
function A(){}
function B(){}
inherits(B, A);
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testBasicA_dynamic() {
diff --git a/tests/dart2js/native/native_class_is_check1_frog_test.dart b/tests/dart2js/native/native_class_is_check1_frog_test.dart
index 6b8bb37..266db0e 100644
--- a/tests/dart2js/native/native_class_is_check1_frog_test.dart
+++ b/tests/dart2js/native/native_class_is_check1_frog_test.dart
@@ -29,9 +29,10 @@
function A(){}
A.prototype.read = function() { return this._x; };
A.prototype.write = function(x) { this._x = x; };
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
class B {}
diff --git a/tests/dart2js/native/native_class_is_check3_frog_test.dart b/tests/dart2js/native/native_class_is_check3_frog_test.dart
index 98cbf91..1e6f36e 100644
--- a/tests/dart2js/native/native_class_is_check3_frog_test.dart
+++ b/tests/dart2js/native/native_class_is_check3_frog_test.dart
@@ -47,11 +47,12 @@
inherits(B, A);
A.prototype.read = function() { return this._x; };
A.prototype.write = function(x) { this._x = x; };
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
class C {}
diff --git a/tests/dart2js/native/native_class_with_dart_methods_frog_test.dart b/tests/dart2js/native/native_class_with_dart_methods_frog_test.dart
index 574e684..d3cdb09 100644
--- a/tests/dart2js/native/native_class_with_dart_methods_frog_test.dart
+++ b/tests/dart2js/native/native_class_with_dart_methods_frog_test.dart
@@ -24,9 +24,10 @@
JS('', r"""
(function(){
function A() {}
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/native_closure_identity_frog_test.dart b/tests/dart2js/native/native_closure_identity_frog_test.dart
index c5f5084..9c23278 100644
--- a/tests/dart2js/native/native_closure_identity_frog_test.dart
+++ b/tests/dart2js/native/native_closure_identity_frog_test.dart
@@ -22,10 +22,11 @@
A.prototype.setClosure = function(f) { this.f = f; };
A.prototype.check = function(f) { return this.f === f; };
A.prototype.invoke = function() { return this.f(); };
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
var staticClosure;
diff --git a/tests/dart2js/native/native_constructor_name_test.dart b/tests/dart2js/native/native_constructor_name_test.dart
index 9d60a40..e1c7191 100644
--- a/tests/dart2js/native/native_constructor_name_test.dart
+++ b/tests/dart2js/native/native_constructor_name_test.dart
@@ -23,9 +23,10 @@
JS('', r"""
(function(){
function A(){}
- makeZ = function(){return new A()};
+ self.makeZ = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/native_equals_frog_test.dart b/tests/dart2js/native/native_equals_frog_test.dart
index 0b460b9..de5844c 100644
--- a/tests/dart2js/native/native_equals_frog_test.dart
+++ b/tests/dart2js/native/native_equals_frog_test.dart
@@ -27,11 +27,12 @@
(function(){
function A() {}
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['B']);
}
main() {
diff --git a/tests/dart2js/native/native_exception2_test.dart b/tests/dart2js/native/native_exception2_test.dart
index 59cf5b0..9ab9ffc 100644
--- a/tests/dart2js/native/native_exception2_test.dart
+++ b/tests/dart2js/native/native_exception2_test.dart
@@ -21,9 +21,10 @@
JS('', r"""
(function(){
function NativeClass() {}
- makeNativeClass = function() { return new NativeClass(); };
+ self.makeNativeClass = function() { return new NativeClass(); };
self.nativeConstructor(NativeClass);
})()""");
+ applyTestExtensions(['NativeClass']);
}
main() {
diff --git a/tests/dart2js/native/native_exceptions1_frog_test.dart b/tests/dart2js/native/native_exceptions1_frog_test.dart
index b9957e8..7585a39 100644
--- a/tests/dart2js/native/native_exceptions1_frog_test.dart
+++ b/tests/dart2js/native/native_exceptions1_frog_test.dart
@@ -47,6 +47,7 @@
A = null;
E = null;
})()""");
+ applyTestExtensions(['E', 'A']);
}
void setup2() {
@@ -60,7 +61,7 @@
if (x & 1) throw new E(100);
return x / 2;
};
-makeA = function(){return new A()};
+self.makeA = function(){return new A()};
self.nativeConstructor(E);
self.nativeConstructor(A);
diff --git a/tests/dart2js/native/native_field_invocation2_test.dart b/tests/dart2js/native/native_field_invocation2_test.dart
index 9c150687..c15ec25 100644
--- a/tests/dart2js/native/native_field_invocation2_test.dart
+++ b/tests/dart2js/native/native_field_invocation2_test.dart
@@ -36,7 +36,7 @@
void setup() {
JS('', r"""
(function(){
-nativeId = function(x) { return x; }
+self.nativeId = function(x) { return x; }
})()""");
}
diff --git a/tests/dart2js/native/native_field_invocation3_test.dart b/tests/dart2js/native/native_field_invocation3_test.dart
index 9ed3d9c..613f610 100644
--- a/tests/dart2js/native/native_field_invocation3_test.dart
+++ b/tests/dart2js/native/native_field_invocation3_test.dart
@@ -10,9 +10,10 @@
JS('', r"""
(function(){
function CC() {}
- makeCC = function() { return new CC() };
+ self.makeCC = function() { return new CC() };
self.nativeConstructor(CC);
})()""");
+ applyTestExtensions(['CC']);
}
@Native("CC")
diff --git a/tests/dart2js/native/native_field_invocation4_test.dart b/tests/dart2js/native/native_field_invocation4_test.dart
index afce3c09..0855c72 100644
--- a/tests/dart2js/native/native_field_invocation4_test.dart
+++ b/tests/dart2js/native/native_field_invocation4_test.dart
@@ -18,7 +18,7 @@
void setup() {
JS('', r"""
(function(){
-nativeId = function(x) { return x; }
+self.nativeId = function(x) { return x; }
})()""");
}
diff --git a/tests/dart2js/native/native_field_invocation5_test.dart b/tests/dart2js/native/native_field_invocation5_test.dart
index abd0169..f2ef30c 100644
--- a/tests/dart2js/native/native_field_invocation5_test.dart
+++ b/tests/dart2js/native/native_field_invocation5_test.dart
@@ -11,10 +11,11 @@
JS('', r"""
(function(){
function CC() {}
- makeCC = function() { return new CC() };
- nativeFirst = function(x, y) { return x; };
+ self.makeCC = function() { return new CC() };
+ self.nativeFirst = function(x, y) { return x; };
self.nativeConstructor(CC);
})()""");
+ applyTestExtensions(['CC']);
}
class C {
diff --git a/tests/dart2js/native/native_field_invocation6_test.dart b/tests/dart2js/native/native_field_invocation6_test.dart
index 17ed660..a226bbc 100644
--- a/tests/dart2js/native/native_field_invocation6_test.dart
+++ b/tests/dart2js/native/native_field_invocation6_test.dart
@@ -10,12 +10,13 @@
void setup() {
JS('', r"""
(function(){
- nativeFirst = function(x, y) { return x; };
+ self.nativeFirst = function(x, y) { return x; };
function A() {}
- makeA = function() { return new A() };
+ self.makeA = function() { return new A() };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
@Native("A")
diff --git a/tests/dart2js/native/native_field_invocation_test.dart b/tests/dart2js/native/native_field_invocation_test.dart
index e6f13b6..bdda86f 100644
--- a/tests/dart2js/native/native_field_invocation_test.dart
+++ b/tests/dart2js/native/native_field_invocation_test.dart
@@ -18,7 +18,7 @@
void setup() {
JS('', r"""
(function(){
- nativeId = function(x) { return x; }
+ self.nativeId = function(x) { return x; }
})()""");
}
diff --git a/tests/dart2js/native/native_field_name_test.dart b/tests/dart2js/native/native_field_name_test.dart
index 89f401f..1b991ca 100644
--- a/tests/dart2js/native/native_field_name_test.dart
+++ b/tests/dart2js/native/native_field_name_test.dart
@@ -43,10 +43,11 @@
return a;
}
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
/*A*/ makeA() native;
diff --git a/tests/dart2js/native/native_field_optimization_test.dart b/tests/dart2js/native/native_field_optimization_test.dart
index 5b7e061..7ce2740 100644
--- a/tests/dart2js/native/native_field_optimization_test.dart
+++ b/tests/dart2js/native/native_field_optimization_test.dart
@@ -42,10 +42,11 @@
}
});
- makeFoo = function() { return new Foo() };
+ self.makeFoo = function() { return new Foo() };
self.nativeConstructor(Foo);
})()""");
+ applyTestExtensions(['Foo']);
}
test1() {
diff --git a/tests/dart2js/native/native_field_rename_1_frog_test.dart b/tests/dart2js/native/native_field_rename_1_frog_test.dart
index 27b4710..7c3202e 100644
--- a/tests/dart2js/native/native_field_rename_1_frog_test.dart
+++ b/tests/dart2js/native/native_field_rename_1_frog_test.dart
@@ -45,12 +45,13 @@
function X(){}
X.prototype.key = function(){return 666;};
- makeA = function(){return new A()};
- makeX = function(){return new X()};
+ self.makeA = function(){return new A()};
+ self.makeX = function(){return new X()};
self.nativeConstructor(A);
self.nativeConstructor(X);
})()""");
+ applyTestExtensions(['A', 'X']);
}
testDynamic() {
diff --git a/tests/dart2js/native/native_field_rename_2_frog_test.dart b/tests/dart2js/native/native_field_rename_2_frog_test.dart
index 93fce23..022c5ce 100644
--- a/tests/dart2js/native/native_field_rename_2_frog_test.dart
+++ b/tests/dart2js/native/native_field_rename_2_frog_test.dart
@@ -48,12 +48,13 @@
function X(){}
X.prototype.key = function(){return 666;};
- makeA = function(){return new A()};
- makeX = function(){return new X()};
+ self.makeA = function(){return new A()};
+ self.makeX = function(){return new X()};
self.nativeConstructor(A);
self.nativeConstructor(X);
})()""");
+ applyTestExtensions(['A', 'X']);
}
testDynamic() {
diff --git a/tests/dart2js/native/native_method_inlining_test.dart b/tests/dart2js/native/native_method_inlining_test.dart
index ba0ee3b..3cdb5e8 100644
--- a/tests/dart2js/native/native_method_inlining_test.dart
+++ b/tests/dart2js/native/native_method_inlining_test.dart
@@ -64,7 +64,7 @@
A.prototype.foo = function () { return arguments.length; };
A.prototype.callFun = function (fn) { return fn ? fn(123) : 1; };
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
findMethodTextContaining = function (instance, string) {
var proto = Object.getPrototypeOf(instance);
@@ -79,6 +79,7 @@
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
void match(String s, String pattern1) {
diff --git a/tests/dart2js/native/native_method_rename1_frog_test.dart b/tests/dart2js/native/native_method_rename1_frog_test.dart
index 5d05694..52ba44f 100644
--- a/tests/dart2js/native/native_method_rename1_frog_test.dart
+++ b/tests/dart2js/native/native_method_rename1_frog_test.dart
@@ -35,10 +35,11 @@
A.prototype.barA = function(){return 200;};
A.prototype.bazA = function(){return 300;};
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
testDynamic() {
diff --git a/tests/dart2js/native/native_method_rename2_frog_test.dart b/tests/dart2js/native/native_method_rename2_frog_test.dart
index 35713a2..8db0eca 100644
--- a/tests/dart2js/native/native_method_rename2_frog_test.dart
+++ b/tests/dart2js/native/native_method_rename2_frog_test.dart
@@ -41,12 +41,13 @@
inherits(B, A);
B.prototype.fooB = function(){return 200;};
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testDynamic() {
diff --git a/tests/dart2js/native/native_method_rename3_frog_test.dart b/tests/dart2js/native/native_method_rename3_frog_test.dart
index c5759b2..2100427 100644
--- a/tests/dart2js/native/native_method_rename3_frog_test.dart
+++ b/tests/dart2js/native/native_method_rename3_frog_test.dart
@@ -48,12 +48,13 @@
inherits(B, A);
B.prototype.fooB = function(){return 200;};
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testDynamic() {
diff --git a/tests/dart2js/native/native_method_with_keyword_name_test.dart b/tests/dart2js/native/native_method_with_keyword_name_test.dart
index c535d90..2198634 100644
--- a/tests/dart2js/native/native_method_with_keyword_name_test.dart
+++ b/tests/dart2js/native/native_method_with_keyword_name_test.dart
@@ -19,9 +19,10 @@
function A() {}
A.prototype.delete = function() { return 87; };
-makeA = function(){return new A()};
+self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/native_missing_method1_frog_test.dart b/tests/dart2js/native/native_missing_method1_frog_test.dart
index d0595f6..13e8277 100644
--- a/tests/dart2js/native/native_missing_method1_frog_test.dart
+++ b/tests/dart2js/native/native_missing_method1_frog_test.dart
@@ -14,9 +14,10 @@
(function(){
function A() {};
A.prototype.foo = function() { return 99; };
- makeA = function() { return new A(); };
+ self.makeA = function() { return new A(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
class B {
diff --git a/tests/dart2js/native/native_missing_method2_frog_test.dart b/tests/dart2js/native/native_missing_method2_frog_test.dart
index ae5799f..6e1f694 100644
--- a/tests/dart2js/native/native_missing_method2_frog_test.dart
+++ b/tests/dart2js/native/native_missing_method2_frog_test.dart
@@ -14,9 +14,10 @@
(function(){
function A() {};
A.prototype.foo = function() { return 42; };
- makeA = function() { return new A() };
+ self.makeA = function() { return new A() };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
class B {
diff --git a/tests/dart2js/native/native_mixin_field2_test.dart b/tests/dart2js/native/native_mixin_field2_test.dart
index 4612391..80370ce 100644
--- a/tests/dart2js/native/native_mixin_field2_test.dart
+++ b/tests/dart2js/native/native_mixin_field2_test.dart
@@ -44,12 +44,13 @@
(function(){
function A() {this.foo='A-foo';}
function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
@pragma('dart2js:assumeDynamic')
diff --git a/tests/dart2js/native/native_mixin_field_test.dart b/tests/dart2js/native/native_mixin_field_test.dart
index 7f1aebb..e9c80e9 100644
--- a/tests/dart2js/native/native_mixin_field_test.dart
+++ b/tests/dart2js/native/native_mixin_field_test.dart
@@ -34,12 +34,13 @@
(function(){
function A() {this.foo='A-foo';}
function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js/native/native_mixin_multiple2_test.dart b/tests/dart2js/native/native_mixin_multiple2_test.dart
index 0747e6b..04f5b71 100644
--- a/tests/dart2js/native/native_mixin_multiple2_test.dart
+++ b/tests/dart2js/native/native_mixin_multiple2_test.dart
@@ -30,10 +30,11 @@
JS('', r"""
(function(){
function B() {}
- makeB = function(){return new B()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['B']);
}
main() {
diff --git a/tests/dart2js/native/native_mixin_multiple3_test.dart b/tests/dart2js/native/native_mixin_multiple3_test.dart
index 1963186..ac3442d 100644
--- a/tests/dart2js/native/native_mixin_multiple3_test.dart
+++ b/tests/dart2js/native/native_mixin_multiple3_test.dart
@@ -44,14 +44,15 @@
function A() {}
function B() {}
function C() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
- makeC = function(){return new C()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
+ self.makeC = function(){return new C()};
self.nativeConstructor(A);
self.nativeConstructor(B);
self.nativeConstructor(C);
})()""");
+ applyTestExtensions(['A', 'B', 'C']);
}
var g;
diff --git a/tests/dart2js/native/native_mixin_multiple_test.dart b/tests/dart2js/native/native_mixin_multiple_test.dart
index 310d75b..68e6714 100644
--- a/tests/dart2js/native/native_mixin_multiple_test.dart
+++ b/tests/dart2js/native/native_mixin_multiple_test.dart
@@ -34,12 +34,13 @@
(function(){
function A() {}
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js/native/native_mixin_test.dart b/tests/dart2js/native/native_mixin_test.dart
index 64bd3e4..2ba3523 100644
--- a/tests/dart2js/native/native_mixin_test.dart
+++ b/tests/dart2js/native/native_mixin_test.dart
@@ -30,12 +30,13 @@
(function(){
function A() {}
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js/native/native_mixin_with_plain_test.dart b/tests/dart2js/native/native_mixin_with_plain_test.dart
index 5130caa..e31b904 100644
--- a/tests/dart2js/native/native_mixin_with_plain_test.dart
+++ b/tests/dart2js/native/native_mixin_with_plain_test.dart
@@ -45,12 +45,13 @@
(function(){
function A() {this.aa = 'aa'}
function B() {this.aa = 'bb'}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js/native/native_named_constructors2_frog_test.dart b/tests/dart2js/native/native_named_constructors2_frog_test.dart
index b200628..8e25687 100644
--- a/tests/dart2js/native/native_named_constructors2_frog_test.dart
+++ b/tests/dart2js/native/native_named_constructors2_frog_test.dart
@@ -31,9 +31,10 @@
// This code is inside 'setup' and so not accessible from the global scope.
function A(arg) { this._x = arg; }
A.prototype.foo = function() { return this._x; };
- makeA = function(arg) { return new A(arg); };
+ self.makeA = function(arg) { return new A(arg); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/native_named_constructors3_frog_test.dart b/tests/dart2js/native/native_named_constructors3_frog_test.dart
index 949a405..809bca4 100644
--- a/tests/dart2js/native/native_named_constructors3_frog_test.dart
+++ b/tests/dart2js/native/native_named_constructors3_frog_test.dart
@@ -30,9 +30,10 @@
// This code is inside 'setup' and so not accessible from the global scope.
function A(arg) { this._x = arg; }
A.prototype.foo = function(){ return this._x; };
- makeA = function(arg) { return new A(arg); };
+ self.makeA = function(arg) { return new A(arg); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/native_no_such_method_exception2_frog_test.dart b/tests/dart2js/native/native_no_such_method_exception2_frog_test.dart
index 5df3c12..ccc4787 100644
--- a/tests/dart2js/native/native_no_such_method_exception2_frog_test.dart
+++ b/tests/dart2js/native/native_no_such_method_exception2_frog_test.dart
@@ -31,13 +31,14 @@
function A() {}
function B() {}
inherits(B, A);
- makeA = function() { return new A() };
- makeB = function() { return new B() };
+ self.makeA = function() { return new A() };
+ self.makeB = function() { return new B() };
B.prototype.foo = function() { return 42; };
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js/native/native_no_such_method_exception_frog_test.dart b/tests/dart2js/native/native_no_such_method_exception_frog_test.dart
index c4a7951..1c8aa01f 100644
--- a/tests/dart2js/native/native_no_such_method_exception_frog_test.dart
+++ b/tests/dart2js/native/native_no_such_method_exception_frog_test.dart
@@ -20,9 +20,10 @@
JS('', r"""
(function(){
function A() {}
- makeA = function() { return new A(); };
+ self.makeA = function() { return new A(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/native_novel_html_test.dart b/tests/dart2js/native/native_novel_html_test.dart
index 3738ff0..cafd607 100644
--- a/tests/dart2js/native/native_novel_html_test.dart
+++ b/tests/dart2js/native/native_novel_html_test.dart
@@ -23,17 +23,18 @@
HTMLGoofyElement.prototype.nativeMethod = function(a) {
return 'Goofy.nativeMethod(' + a + ')';
};
- makeE = function(){return new HTMLGoofyElement()};
+ self.makeE = function(){return new HTMLGoofyElement()};
// A non-HTML element with a misleading name.
function HTMLFakeyElement(){}
HTMLFakeyElement.prototype.nativeMethod = function(a) {
return 'Fakey.nativeMethod(' + a + ')';
};
- makeF = function(){return new HTMLFakeyElement()};
+ self.makeF = function(){return new HTMLFakeyElement()};
self.nativeConstructor(HTMLGoofyElement);
})()""");
+ applyTestExtensions(['HTMLElement']);
}
main() {
diff --git a/tests/dart2js/native/native_null_assertions/null_assertions_test_lib.dart b/tests/dart2js/native/native_null_assertions/null_assertions_test_lib.dart
index 049cd36..85a5540 100644
--- a/tests/dart2js/native/native_null_assertions/null_assertions_test_lib.dart
+++ b/tests/dart2js/native/native_null_assertions/null_assertions_test_lib.dart
@@ -41,10 +41,10 @@
AAA.prototype.method2 = function(){return this._m2};
AAA.prototype.optMethod = function(){return this._m2};
- makeA = function() {
+ self.makeA = function() {
return new AAA(100, 'Albert', 200, 'amazing!');
};
- makeAX = function() {
+ self.makeAX = function() {
return new AAA(void 0, void 0, void 0, void 0);
};
@@ -55,15 +55,16 @@
this.optName = n;
}
- makeC = function() {
+ self.makeC = function() {
return new CCC('Carol');
};
- makeCX = function() {
+ self.makeCX = function() {
return new CCC(void 0);
};
self.nativeConstructor(CCC);
})()""");
+ applyTestExtensions(['AAA', 'CCC']);
}
// The 'NativeInterface' version of the code is passed both native and Dart
diff --git a/tests/dart2js/native/native_null_closure_frog_test.dart b/tests/dart2js/native/native_null_closure_frog_test.dart
index f5fd85e..7e18b4e 100644
--- a/tests/dart2js/native/native_null_closure_frog_test.dart
+++ b/tests/dart2js/native/native_null_closure_frog_test.dart
@@ -24,10 +24,11 @@
A.prototype.setClosure = function(f) { this.f = f; };
A.prototype.check = function(f) { return this.f === f; };
A.prototype.invoke = function() { return this.f(); };
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/native_null_frog_test.dart b/tests/dart2js/native/native_null_frog_test.dart
index 0abdd35..359562b 100644
--- a/tests/dart2js/native/native_null_frog_test.dart
+++ b/tests/dart2js/native/native_null_frog_test.dart
@@ -24,9 +24,10 @@
A.prototype.returnUndefined = function() { return void 0; };
A.prototype.returnEmptyString = function() { return ""; };
A.prototype.returnZero = function() { return 0; };
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
@pragma('dart2js:noInline')
diff --git a/tests/dart2js/native/native_property_frog_test.dart b/tests/dart2js/native/native_property_frog_test.dart
index 0c4d3ef..1fd10b8 100644
--- a/tests/dart2js/native/native_property_frog_test.dart
+++ b/tests/dart2js/native/native_property_frog_test.dart
@@ -38,10 +38,11 @@
set: function (v) { this._x = v; }
});
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/native_testing.dart b/tests/dart2js/native/native_testing.dart
index 5dcaa24..bc214b5 100644
--- a/tests/dart2js/native/native_testing.dart
+++ b/tests/dart2js/native/native_testing.dart
@@ -10,7 +10,8 @@
import 'dart:_foreign_helper' show JS;
export "package:expect/expect.dart";
-export 'dart:_js_helper' show Creates, Native, JSName, Returns;
+export 'dart:_js_helper'
+ show Creates, Native, JSName, Returns, applyTestExtensions;
export 'dart:_foreign_helper' show JS;
void nativeTesting() {
@@ -35,9 +36,14 @@
// self.nativeConstructor(Foo);
//
// to the JavaScript code.
+ //
+ // Internally this exports the name on the top scope (needed for dartdevc) and
+ // overrides the toString show the name of the constructor like browsers do
+ // for native types (needed for dart2js).
self.nativeConstructor = function(constructor, opt_name) {
var toStringResult = "[object " + (opt_name || constructor.name) + "]";
constructor[toStringResultProperty] = toStringResult;
+ self[constructor.name] = constructor;
};
})())
''');
diff --git a/tests/dart2js/native/native_to_string_frog_test.dart b/tests/dart2js/native/native_to_string_frog_test.dart
index 6fdca6f..eadce8f 100644
--- a/tests/dart2js/native/native_to_string_frog_test.dart
+++ b/tests/dart2js/native/native_to_string_frog_test.dart
@@ -15,9 +15,10 @@
JS('', r"""
(function(){
function A() {}
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/native_use_native_name_in_table_frog_test.dart b/tests/dart2js/native/native_use_native_name_in_table_frog_test.dart
index 0bd930a..44dc4cf 100644
--- a/tests/dart2js/native/native_use_native_name_in_table_frog_test.dart
+++ b/tests/dart2js/native/native_use_native_name_in_table_frog_test.dart
@@ -36,12 +36,13 @@
inherits(NativeB, NativeA);
NativeA.prototype.foo = function() { return 42; };
- makeA = function(){return new NativeA()};
- makeB = function(){return new NativeB()};
+ self.makeA = function(){return new NativeA()};
+ self.makeB = function(){return new NativeB()};
self.nativeConstructor(NativeA);
self.nativeConstructor(NativeB);
})()""");
+ applyTestExtensions(['NativeA', 'NativeB']);
}
main() {
diff --git a/tests/dart2js/native/native_wrapping_function3_frog_test.dart b/tests/dart2js/native/native_wrapping_function3_frog_test.dart
index 111e2f5..cfe6fee 100644
--- a/tests/dart2js/native/native_wrapping_function3_frog_test.dart
+++ b/tests/dart2js/native/native_wrapping_function3_frog_test.dart
@@ -24,9 +24,10 @@
A.prototype.foo2 = function(closure, arg1, arg2) {
return closure(arg1, arg2);
};
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/native_wrapping_function_frog_test.dart b/tests/dart2js/native/native_wrapping_function_frog_test.dart
index 53473b8..8a9984f 100644
--- a/tests/dart2js/native/native_wrapping_function_frog_test.dart
+++ b/tests/dart2js/native/native_wrapping_function_frog_test.dart
@@ -26,9 +26,10 @@
A.prototype.foo2 = function(closure, arg1, arg2) {
return closure(arg1, arg2);
};
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js/native/oddly_named_fields_test.dart b/tests/dart2js/native/oddly_named_fields_test.dart
index 7a93c95..4eda90a 100644
--- a/tests/dart2js/native/oddly_named_fields_test.dart
+++ b/tests/dart2js/native/oddly_named_fields_test.dart
@@ -1385,9 +1385,10 @@
JS('', r"""
(function(){
function NativeClassWithOddNames() {}
- makeNativeClassWithOddNames = function() {return new NativeClassWithOddNames()};
+ self.makeNativeClassWithOddNames = function() {return new NativeClassWithOddNames()};
self.nativeConstructor(NativeClassWithOddNames);
})()""");
+ applyTestExtensions(['NativeClassWithOddNames']);
}
main() {
diff --git a/tests/dart2js/native/runtimetype_test.dart b/tests/dart2js/native/runtimetype_test.dart
index 558f7ee..4581e3b 100644
--- a/tests/dart2js/native/runtimetype_test.dart
+++ b/tests/dart2js/native/runtimetype_test.dart
@@ -31,12 +31,13 @@
function TAGY(){}
inherits(TAGY, TAGX);
- makeA = function(){return new TAGX()};
- makeB = function(){return new TAGY()};
+ self.makeA = function(){return new TAGX()};
+ self.makeB = function(){return new TAGY()};
self.nativeConstructor(TAGX);
self.nativeConstructor(TAGY);
})()""");
+ applyTestExtensions(['TAGX', 'TAGY']);
}
testDynamicContext() {
diff --git a/tests/dart2js/native/subclassing_1_test.dart b/tests/dart2js/native/subclassing_1_test.dart
index 77a636f..c34f307 100644
--- a/tests/dart2js/native/subclassing_1_test.dart
+++ b/tests/dart2js/native/subclassing_1_test.dart
@@ -35,13 +35,13 @@
function A() {}
function B() {}
function C() {}
- makeA = function(){return new A()};
- makeB1 = function(){return new B()};
- makeB2 = function(){return new B()};
- makeC = function(){return new C()};
+ self.makeA = function(){return new A()};
+ self.makeB1 = function(){return new B()};
+ self.makeB2 = function(){return new B()};
+ self.makeC = function(){return new C()};
- getBPrototype = function(){return B.prototype;};
- getCPrototype = function(){return C.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
+ self.getCPrototype = function(){return C.prototype;};
})()""");
}
diff --git a/tests/dart2js/native/subclassing_2_test.dart b/tests/dart2js/native/subclassing_2_test.dart
index 66c8d68..7fcef99 100644
--- a/tests/dart2js/native/subclassing_2_test.dart
+++ b/tests/dart2js/native/subclassing_2_test.dart
@@ -32,10 +32,10 @@
(function(){
function A() {}
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js/native/subclassing_3_test.dart b/tests/dart2js/native/subclassing_3_test.dart
index 5a2c3d9..b7f89d3 100644
--- a/tests/dart2js/native/subclassing_3_test.dart
+++ b/tests/dart2js/native/subclassing_3_test.dart
@@ -38,9 +38,9 @@
JS('', r"""
(function(){
function B() {}
- makeB = function(){return new B();};
+ self.makeB = function(){return new B();};
- getBPrototype = function(){return B.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js/native/subclassing_4_test.dart b/tests/dart2js/native/subclassing_4_test.dart
index 07a2d4c..7dd5e72 100644
--- a/tests/dart2js/native/subclassing_4_test.dart
+++ b/tests/dart2js/native/subclassing_4_test.dart
@@ -36,8 +36,8 @@
JS('', r"""
(function(){
function B() {}
- makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.makeB = function(){return new B()};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js/native/subclassing_5_test.dart b/tests/dart2js/native/subclassing_5_test.dart
index 220563b..553b1f8 100644
--- a/tests/dart2js/native/subclassing_5_test.dart
+++ b/tests/dart2js/native/subclassing_5_test.dart
@@ -43,8 +43,8 @@
JS('', r"""
(function(){
function B() {}
- makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.makeB = function(){return new B()};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js/native/subclassing_constructor_1_test.dart b/tests/dart2js/native/subclassing_constructor_1_test.dart
index 45934f8..8570020 100644
--- a/tests/dart2js/native/subclassing_constructor_1_test.dart
+++ b/tests/dart2js/native/subclassing_constructor_1_test.dart
@@ -65,9 +65,9 @@
(function(){
function B() { this.a2 = 102; }
- makeB = function(){return new B()};
+ self.makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js/native/subclassing_super_call_test.dart b/tests/dart2js/native/subclassing_super_call_test.dart
index b157933..124f463 100644
--- a/tests/dart2js/native/subclassing_super_call_test.dart
+++ b/tests/dart2js/native/subclassing_super_call_test.dart
@@ -50,9 +50,9 @@
N2.prototype.foo = function() { return "foo:" + this.text; };
function BB() {}
BB.prototype.__proto__ = N2.prototype;
- makeBB = function(){return new BB()};
+ self.makeBB = function(){return new BB()};
- getBBPrototype = function(){return BB.prototype;};
+ self.getBBPrototype = function(){return BB.prototype;};
})()""");
}
diff --git a/tests/dart2js/native/subclassing_super_field_1_test.dart b/tests/dart2js/native/subclassing_super_field_1_test.dart
index 827cb358..68bd8d3 100644
--- a/tests/dart2js/native/subclassing_super_field_1_test.dart
+++ b/tests/dart2js/native/subclassing_super_field_1_test.dart
@@ -36,9 +36,9 @@
JS('', r"""
(function(){
function B() { }
-makeB = function(){return new B()};
+self.makeB = function(){return new B()};
-getBPrototype = function(){return B.prototype;};
+self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js/native/subclassing_super_field_2_test.dart b/tests/dart2js/native/subclassing_super_field_2_test.dart
index 837568a..79c7016 100644
--- a/tests/dart2js/native/subclassing_super_field_2_test.dart
+++ b/tests/dart2js/native/subclassing_super_field_2_test.dart
@@ -40,9 +40,9 @@
JS('', r"""
(function(){
function B() { this.foo = 111; } // N.foo
- makeB = function(){return new B()};
+ self.makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js/native/subclassing_type_test.dart b/tests/dart2js/native/subclassing_type_test.dart
index ce52e5b..e5cc2be 100644
--- a/tests/dart2js/native/subclassing_type_test.dart
+++ b/tests/dart2js/native/subclassing_type_test.dart
@@ -33,9 +33,9 @@
JS('', r"""
(function(){
function B() {}
- makeB = function(){return new B()};
+ self.makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js/native/super_call_test.dart b/tests/dart2js/native/super_call_test.dart
index 5238bb5..ebae644 100644
--- a/tests/dart2js/native/super_call_test.dart
+++ b/tests/dart2js/native/super_call_test.dart
@@ -59,16 +59,17 @@
function D(){}
inherits(D, C);
- makeA = function(){return new A()};
- makeB = function(){return new B()};
- makeC = function(){return new C()};
- makeD = function(){return new D()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
+ self.makeC = function(){return new C()};
+ self.makeD = function(){return new D()};
self.nativeConstructor(A);
self.nativeConstructor(B);
self.nativeConstructor(C);
self.nativeConstructor(D);
})()""");
+ applyTestExtensions(['A', 'B', 'C', 'D']);
}
main() {
diff --git a/tests/dart2js/native/super_property_test.dart b/tests/dart2js/native/super_property_test.dart
index 68e815a..9482cb7 100644
--- a/tests/dart2js/native/super_property_test.dart
+++ b/tests/dart2js/native/super_property_test.dart
@@ -46,11 +46,12 @@
// This code is inside 'setup' and so not accessible from the global scope.
function A(){}
function B(){}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testThing(a) {
diff --git a/tests/dart2js_2/native/abstract_class_test.dart b/tests/dart2js_2/native/abstract_class_test.dart
index 988157c..2657b25 100644
--- a/tests/dart2js_2/native/abstract_class_test.dart
+++ b/tests/dart2js_2/native/abstract_class_test.dart
@@ -29,12 +29,12 @@
function A(){}
function B(){}
B.prototype.foo = function() { return 'B.foo'; };
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
-})()
-""");
+})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js_2/native/bound_closure_test.dart b/tests/dart2js_2/native/bound_closure_test.dart
index 09bc341..8b6f309 100644
--- a/tests/dart2js_2/native/bound_closure_test.dart
+++ b/tests/dart2js_2/native/bound_closure_test.dart
@@ -42,13 +42,14 @@
return 'CC.foo(' + u + ', ' + v + ')';
};
- makeBB = function(){return new BB()};
- makeCC = function(){return new CC()};
- inscrutable = function(a){return a;};
+ self.makeBB = function(){return new BB()};
+ self.makeCC = function(){return new CC()};
+ self.inscrutable = function(a){return a;};
self.nativeConstructor(BB);
self.nativeConstructor(CC);
})()""");
+ applyTestExtensions(['BB', 'CC']);
}
main() {
diff --git a/tests/dart2js_2/native/browser_compat_1_prepatched_test.dart b/tests/dart2js_2/native/browser_compat_1_prepatched_test.dart
index 01fb0fe..895029e 100644
--- a/tests/dart2js_2/native/browser_compat_1_prepatched_test.dart
+++ b/tests/dart2js_2/native/browser_compat_1_prepatched_test.dart
@@ -39,9 +39,9 @@
window.T1A = T1A;
window.T1CrazyB = T1CrazyB;
- makeT1A = function(){return new T1A()};
- makeT1B = function(){return new T1CrazyB()};
- makeT1C = function(){return new T1fakeA()};
+ self.makeT1A = function(){return new T1A()};
+ self.makeT1B = function(){return new T1CrazyB()};
+ self.makeT1C = function(){return new T1fakeA()};
self.nativeConstructor(T1A);
self.nativeConstructor(T1CrazyB);
@@ -73,6 +73,7 @@
dartNativeDispatchHooksTransformer = [transformer1];
})()''');
+ applyTestExtensions(['T1A', 'T1CrazyB', 'T1fakeA']);
}
main() {
diff --git a/tests/dart2js_2/native/browser_compat_1_unpatched_test.dart b/tests/dart2js_2/native/browser_compat_1_unpatched_test.dart
index 1f1e0fc..c08dd57 100644
--- a/tests/dart2js_2/native/browser_compat_1_unpatched_test.dart
+++ b/tests/dart2js_2/native/browser_compat_1_unpatched_test.dart
@@ -40,9 +40,9 @@
window.T1A = T1A;
window.T1CrazyB = T1CrazyB;
- makeT1A = function(){return new T1A()};
- makeT1B = function(){return new T1CrazyB()};
- makeT1C = function(){return new T1fakeA()};
+ self.makeT1A = function(){return new T1A()};
+ self.makeT1B = function(){return new T1CrazyB()};
+ self.makeT1C = function(){return new T1fakeA()};
self.nativeConstructor(T1A);
self.nativeConstructor(T1CrazyB);
@@ -76,6 +76,7 @@
dartNativeDispatchHooksTransformer = [transformer1];
})()""");
+ applyTestExtensions(['T1A', 'T1CrazyB', 'T1fakeA']);
}
main() {
diff --git a/tests/dart2js_2/native/browser_compat_2_test.dart b/tests/dart2js_2/native/browser_compat_2_test.dart
index 349c9a7..1a404f5 100644
--- a/tests/dart2js_2/native/browser_compat_2_test.dart
+++ b/tests/dart2js_2/native/browser_compat_2_test.dart
@@ -106,6 +106,7 @@
dartNativeDispatchHooksTransformer = [transformer1, transformer2];
})()''');
+ applyTestExtensions(['T1A', 'T1B', 'T1C', 'T1D']);
}
main() {
diff --git a/tests/dart2js_2/native/core_type_check_native_test.dart b/tests/dart2js_2/native/core_type_check_native_test.dart
index a7b6d8b..8bdeee9 100644
--- a/tests/dart2js_2/native/core_type_check_native_test.dart
+++ b/tests/dart2js_2/native/core_type_check_native_test.dart
@@ -33,20 +33,20 @@
JS('', r"""
(function(){
function A() {};
- makeA = function() { return new A(); };
+ self.makeA = function() { return new A(); };
function B() {};
- makeB = function() { return new B(); };
+ self.makeB = function() { return new B(); };
function C() {};
- makeC = function() { return new C(); };
+ self.makeC = function() { return new C(); };
function D() {};
- makeD = function() { return new D(); };
+ self.makeD = function() { return new D(); };
self.nativeConstructor(A);
self.nativeConstructor(B);
self.nativeConstructor(C);
self.nativeConstructor(D);
-})()
-""");
+})()""");
+ applyTestExtensions(['A', 'B', 'C', 'D']);
}
checkTest(value, expectComparable, expectPattern) {
diff --git a/tests/dart2js_2/native/dispatch_property_initialization_test.dart b/tests/dart2js_2/native/dispatch_property_initialization_test.dart
index d5c90b7..de6a9a9 100644
--- a/tests/dart2js_2/native/dispatch_property_initialization_test.dart
+++ b/tests/dart2js_2/native/dispatch_property_initialization_test.dart
@@ -25,6 +25,7 @@
self.nativeConstructor(Foo);
})()""");
+ applyTestExtensions(['Foo']);
}
main() {
diff --git a/tests/dart2js_2/native/downcast_test.dart b/tests/dart2js_2/native/downcast_test.dart
index f479b77..90e744b 100644
--- a/tests/dart2js_2/native/downcast_test.dart
+++ b/tests/dart2js_2/native/downcast_test.dart
@@ -48,12 +48,13 @@
inherits(B, A);
A.prototype.read = function() { return this._x; };
A.prototype.write = function(x) { this._x = x; };
-makeA = function(){return new A()};
-makeB = function(){return new B()};
+self.makeA = function(){return new A()};
+self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
class C {}
diff --git a/tests/dart2js_2/native/error_safeToString_test.dart b/tests/dart2js_2/native/error_safeToString_test.dart
index 8b9acce0..cc9acbc 100644
--- a/tests/dart2js_2/native/error_safeToString_test.dart
+++ b/tests/dart2js_2/native/error_safeToString_test.dart
@@ -38,45 +38,46 @@
void setup() {
JS('', r"""
(function(){
- makeA = function(){return {hello: 123};};
+ self.makeA = function(){return {hello: 123};};
function BB(){}
- makeB = function(){return new BB();};
+ self.makeB = function(){return new BB();};
function CC(){}
- makeC = function(){
+ self.makeC = function(){
var x = new CC();
x.constructor = null; // Foils constructor lookup.
return x;
};
function DD(){}
- makeD = function(){
+ self.makeD = function(){
var x = new DD();
x.constructor = {name: 'DDxxx'}; // Foils constructor lookup.
return x;
};
function EE(){}
- makeE = function(){
+ self.makeE = function(){
var x = new EE();
x.constructor = function Liar(){}; // Looks like a legitimate constructor.
return x;
};
function PPPP(){}
- makeP = function(){return new PPPP();};
+ self.makeP = function(){return new PPPP();};
function QQQQ(){}
- makeQ = function(){return new QQQQ();};
+ self.makeQ = function(){return new QQQQ();};
function RRRR(){}
- makeR = function(){return new RRRR();};
+ self.makeR = function(){return new RRRR();};
self.nativeConstructor(PPPP);
self.nativeConstructor(QQQQ);
self.nativeConstructor(RRRR);
})()""");
+ applyTestExtensions(['PPPP', 'QQQQ', 'RRRR']);
}
expectTypeName(expectedName, s) {
diff --git a/tests/dart2js_2/native/event_loop_test.dart b/tests/dart2js_2/native/event_loop_test.dart
index 1fc7b1d..45f57ec 100644
--- a/tests/dart2js_2/native/event_loop_test.dart
+++ b/tests/dart2js_2/native/event_loop_test.dart
@@ -22,9 +22,10 @@
(function(){
function A() {}
A.prototype.foo = function(f) { return f(); };
-makeA = function() { return new A(); };
+self.makeA = function() { return new A(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/fake_thing_2_test.dart b/tests/dart2js_2/native/fake_thing_2_test.dart
index 7209073..e1634c4 100644
--- a/tests/dart2js_2/native/fake_thing_2_test.dart
+++ b/tests/dart2js_2/native/fake_thing_2_test.dart
@@ -25,14 +25,15 @@
(function(){
function A() {}
A.prototype.$isThing = true;
- make1 = function(){return new A()};
- make2 = function(){return {$isThing: true}};
+ self.make1 = function(){return new A()};
+ self.make2 = function(){return {$isThing: true}};
function NT() {}
NT.prototype.$isThing = true;
- make3 = function(){return new NT()};
+ self.make3 = function(){return new NT()};
self.nativeConstructor(NT);
})()""");
+ applyTestExtensions(['NT']);
}
main() {
diff --git a/tests/dart2js_2/native/fake_thing_test.dart b/tests/dart2js_2/native/fake_thing_test.dart
index 63fda12..5d83f94 100644
--- a/tests/dart2js_2/native/fake_thing_test.dart
+++ b/tests/dart2js_2/native/fake_thing_test.dart
@@ -23,8 +23,8 @@
(function(){
function A() {}
A.prototype.$isThing = true;
- make1 = function(){return new A();};
- make2 = function(){return {$isThing: true}};
+ self.make1 = function(){return new A();};
+ self.make2 = function(){return {$isThing: true}};
})()""");
}
diff --git a/tests/dart2js_2/native/field_type2_test.dart b/tests/dart2js_2/native/field_type2_test.dart
index 2a9ff0c..113987f 100644
--- a/tests/dart2js_2/native/field_type2_test.dart
+++ b/tests/dart2js_2/native/field_type2_test.dart
@@ -21,10 +21,11 @@
(function(){
// This code is all inside 'setup' and so not accessible from the global scope.
function Node(parent){ this.parentNode = parent; }
-makeNode = function(p){return new Node(p);};
+self.makeNode = function(p){return new Node(p);};
self.nativeConstructor(Node);
})()""");
+ applyTestExtensions(['Node']);
}
main() {
diff --git a/tests/dart2js_2/native/field_type_test.dart b/tests/dart2js_2/native/field_type_test.dart
index 7ce0db3..c5b3be2 100644
--- a/tests/dart2js_2/native/field_type_test.dart
+++ b/tests/dart2js_2/native/field_type_test.dart
@@ -50,9 +50,10 @@
(function(){
// This code is inside 'setup' and so not accessible from the global scope.
function Node(parent){ this.parentNode = parent; }
- makeNode = function(p){return new Node(p);};
+ self.makeNode = function(p){return new Node(p);};
self.nativeConstructor(Node);
})()""");
+ applyTestExtensions(['Node']);
}
main() {
diff --git a/tests/dart2js_2/native/fixup_get_tag_test.dart b/tests/dart2js_2/native/fixup_get_tag_test.dart
index 8853041..4f5bbee 100644
--- a/tests/dart2js_2/native/fixup_get_tag_test.dart
+++ b/tests/dart2js_2/native/fixup_get_tag_test.dart
@@ -35,11 +35,12 @@
function B(){ }
B.prototype.token = function () { return 'isB'; };
- makeA = function() { return new A(); };
- makeB = function() { return new B(); };
+ self.makeA = function() { return new A(); };
+ self.makeB = function() { return new B(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
makeA() native;
diff --git a/tests/dart2js_2/native/hash_code_test.dart b/tests/dart2js_2/native/hash_code_test.dart
index 9024625..6debbae 100644
--- a/tests/dart2js_2/native/hash_code_test.dart
+++ b/tests/dart2js_2/native/hash_code_test.dart
@@ -22,12 +22,13 @@
(function(){
function A() {}
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js_2/native/issue9182_test.dart b/tests/dart2js_2/native/issue9182_test.dart
index cfbb2b2..8b6f819 100644
--- a/tests/dart2js_2/native/issue9182_test.dart
+++ b/tests/dart2js_2/native/issue9182_test.dart
@@ -30,9 +30,10 @@
JS('', r"""
(function(){
function A(){}
- makeA = function() { return new A() };
+ self.makeA = function() { return new A() };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
makeA() native;
diff --git a/tests/dart2js_2/native/jsobject_test.dart b/tests/dart2js_2/native/jsobject_test.dart
index f5febe0..5b8ed68 100644
--- a/tests/dart2js_2/native/jsobject_test.dart
+++ b/tests/dart2js_2/native/jsobject_test.dart
@@ -29,16 +29,17 @@
void setup() {
JS('', r"""
(function(){
-makeA = function(){return {hello: 123};};
+self.makeA = function(){return {hello: 123};};
function BB(){}
-makeB = function(){return new BB();};
+self.makeB = function(){return new BB();};
function QQ(){}
-makeQ = function(){return new QQ();};
+self.makeQ = function(){return new QQ();};
self.nativeConstructor(QQ);
})()""");
+ applyTestExtensions(['QQ']);
}
class Is<T> {
diff --git a/tests/dart2js_2/native/name_conflict_test.dart b/tests/dart2js_2/native/name_conflict_test.dart
index d39bf3b..ef72d1c 100644
--- a/tests/dart2js_2/native/name_conflict_test.dart
+++ b/tests/dart2js_2/native/name_conflict_test.dart
@@ -37,9 +37,10 @@
function I(){}
I.prototype.read = function() { return this._x; };
I.prototype.write = function(x) { this._x = x; };
- makeI = function(){return new I()};
+ self.makeI = function(){return new I()};
self.nativeConstructor(I);
})()""");
+ applyTestExtensions(['I']);
}
// A pure Dart implementation of I.
diff --git a/tests/dart2js_2/native/native_call_arity1_frog_test.dart b/tests/dart2js_2/native/native_call_arity1_frog_test.dart
index c7041fd..35549c1 100644
--- a/tests/dart2js_2/native/native_call_arity1_frog_test.dart
+++ b/tests/dart2js_2/native/native_call_arity1_frog_test.dart
@@ -39,12 +39,13 @@
function B() {}
B.prototype.foo = function () { return arguments.length; };
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testDynamicContext() {
diff --git a/tests/dart2js_2/native/native_call_arity2_frog_test.dart b/tests/dart2js_2/native/native_call_arity2_frog_test.dart
index b66ddce..7be1152 100644
--- a/tests/dart2js_2/native/native_call_arity2_frog_test.dart
+++ b/tests/dart2js_2/native/native_call_arity2_frog_test.dart
@@ -42,12 +42,13 @@
B.prototype.foo = function () { return arguments.length; };
inherits(B, A);
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testDynamicContext() {
diff --git a/tests/dart2js_2/native/native_call_arity3_frog_test.dart b/tests/dart2js_2/native/native_call_arity3_frog_test.dart
index 28e0412..bf4435c 100644
--- a/tests/dart2js_2/native/native_call_arity3_frog_test.dart
+++ b/tests/dart2js_2/native/native_call_arity3_frog_test.dart
@@ -35,12 +35,13 @@
function B() {}
B.prototype.foo = function () { return arguments.length; };
- makeA = function(){return new A();};
- makeB = function(){return new B();};
+ self.makeA = function(){return new A();};
+ self.makeB = function(){return new B();};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testDynamicContext() {
diff --git a/tests/dart2js_2/native/native_checked_arguments1_frog_test.dart b/tests/dart2js_2/native/native_checked_arguments1_frog_test.dart
index ff52fa3..23fcc34 100644
--- a/tests/dart2js_2/native/native_checked_arguments1_frog_test.dart
+++ b/tests/dart2js_2/native/native_checked_arguments1_frog_test.dart
@@ -34,12 +34,13 @@
B.prototype.foo = function (x) { return x + 'ha!'; };
B.prototype.cmp = function (x) { return 1; };
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
expectThrows(action()) {
diff --git a/tests/dart2js_2/native/native_checked_fields_frog_test.dart b/tests/dart2js_2/native/native_checked_fields_frog_test.dart
index 76f512d..df76fdb 100644
--- a/tests/dart2js_2/native/native_checked_fields_frog_test.dart
+++ b/tests/dart2js_2/native/native_checked_fields_frog_test.dart
@@ -28,12 +28,13 @@
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
expectThrows(action()) {
diff --git a/tests/dart2js_2/native/native_class_avoids_hidden_name_frog_test.dart b/tests/dart2js_2/native/native_class_avoids_hidden_name_frog_test.dart
index 488cd67..d183807 100644
--- a/tests/dart2js_2/native/native_class_avoids_hidden_name_frog_test.dart
+++ b/tests/dart2js_2/native/native_class_avoids_hidden_name_frog_test.dart
@@ -37,6 +37,7 @@
BB = null;
CC = null;
})()""");
+ applyTestExtensions(['BB', 'CC']);
}
void setup2() {
@@ -45,8 +46,8 @@
// This code is inside 'setup' and so not accessible from the global scope.
function BB(){}
function CC(){}
- makeA = function(){return new BB()}; // AA is native "BB"
- makeB = function(){return new CC()}; // BB is native "CC"
+ self.makeA = function(){return new BB()}; // AA is native "BB"
+ self.makeB = function(){return new CC()}; // BB is native "CC"
self.nativeConstructor(BB);
self.nativeConstructor(CC);
})()""");
diff --git a/tests/dart2js_2/native/native_class_fields_2_test.dart b/tests/dart2js_2/native/native_class_fields_2_test.dart
index b8b031e..1d11429 100644
--- a/tests/dart2js_2/native/native_class_fields_2_test.dart
+++ b/tests/dart2js_2/native/native_class_fields_2_test.dart
@@ -35,9 +35,10 @@
return a;
}
- makeA = function() { return new A(); };
+ self.makeA = function() { return new A(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
A makeA() native;
diff --git a/tests/dart2js_2/native/native_class_fields_3_test.dart b/tests/dart2js_2/native/native_class_fields_3_test.dart
index ad96532..98791e9 100644
--- a/tests/dart2js_2/native/native_class_fields_3_test.dart
+++ b/tests/dart2js_2/native/native_class_fields_3_test.dart
@@ -61,9 +61,10 @@
return a;
}
- makeA = function() { return new A(); };
+ self.makeA = function() { return new A(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
A makeA() native;
diff --git a/tests/dart2js_2/native/native_class_fields_test.dart b/tests/dart2js_2/native/native_class_fields_test.dart
index a960803..1239904 100644
--- a/tests/dart2js_2/native/native_class_fields_test.dart
+++ b/tests/dart2js_2/native/native_class_fields_test.dart
@@ -42,6 +42,7 @@
makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
A makeA() native;
diff --git a/tests/dart2js_2/native/native_class_inheritance1_frog_test.dart b/tests/dart2js_2/native/native_class_inheritance1_frog_test.dart
index 298a5f7..e527e3e 100644
--- a/tests/dart2js_2/native/native_class_inheritance1_frog_test.dart
+++ b/tests/dart2js_2/native/native_class_inheritance1_frog_test.dart
@@ -59,8 +59,8 @@
A1.prototype.foo = function(){return 100;};
B1.prototype.foo = function(){return 200;};
- makeA1 = function(){return new A1()};
- makeB1 = function(){return new B1()};
+ self.makeA1 = function(){return new A1()};
+ self.makeB1 = function(){return new B1()};
function A2(){}
function B2(){}
@@ -68,14 +68,15 @@
A2.prototype.foo = function(a){return a + 10000;};
B2.prototype.foo = function(z){return z + 20000;};
- makeA2 = function(){return new A2()};
- makeB2 = function(){return new B2()};
+ self.makeA2 = function(){return new A2()};
+ self.makeB2 = function(){return new B2()};
self.nativeConstructor(A1);
self.nativeConstructor(A2);
self.nativeConstructor(B1);
self.nativeConstructor(B2);
})()""");
+ applyTestExtensions(['A1', 'A2', 'B1', 'B2']);
}
main() {
diff --git a/tests/dart2js_2/native/native_class_inheritance2_frog_test.dart b/tests/dart2js_2/native/native_class_inheritance2_frog_test.dart
index 865ff93..489502c 100644
--- a/tests/dart2js_2/native/native_class_inheritance2_frog_test.dart
+++ b/tests/dart2js_2/native/native_class_inheritance2_frog_test.dart
@@ -58,16 +58,17 @@
A.prototype.foo = function(a){return 'A.foo(' + a + ')'};
C.prototype.foo = function(z){return 'C.foo(' + z + ')'};
- makeA = function(){return new A()};
- makeB = function(){return new B()};
- makeC = function(){return new C()};
- makeD = function(){return new D()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
+ self.makeC = function(){return new C()};
+ self.makeD = function(){return new D()};
self.nativeConstructor(A);
self.nativeConstructor(B);
self.nativeConstructor(C);
self.nativeConstructor(D);
})()""");
+ applyTestExtensions(['A', 'B', 'C', 'D']);
}
main() {
diff --git a/tests/dart2js_2/native/native_class_inheritance3_frog_test.dart b/tests/dart2js_2/native/native_class_inheritance3_frog_test.dart
index d6bc323..73834f4 100644
--- a/tests/dart2js_2/native/native_class_inheritance3_frog_test.dart
+++ b/tests/dart2js_2/native/native_class_inheritance3_frog_test.dart
@@ -50,24 +50,25 @@
function B1(){}
inherits(B1, A1);
- makeA1 = function(){return new A1()};
- makeB1 = function(){return new B1()};
+ self.makeA1 = function(){return new A1()};
+ self.makeB1 = function(){return new B1()};
function A2(){}
function B2(){}
inherits(B2, A2);
A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';};
- makeA2 = function(){return new A2()};
- makeB2 = function(){return new B2()};
+ self.makeA2 = function(){return new A2()};
+ self.makeB2 = function(){return new B2()};
- makeObject = function(){return new Object()};
+ self.makeObject = function(){return new Object()};
self.nativeConstructor(A1);
self.nativeConstructor(A2);
self.nativeConstructor(B1);
self.nativeConstructor(B2);
})()""");
+ applyTestExtensions(['A1', 'A2', 'B1', 'B2']);
}
main() {
diff --git a/tests/dart2js_2/native/native_class_inheritance4_frog_test.dart b/tests/dart2js_2/native/native_class_inheritance4_frog_test.dart
index c230a0e..b83b8e1 100644
--- a/tests/dart2js_2/native/native_class_inheritance4_frog_test.dart
+++ b/tests/dart2js_2/native/native_class_inheritance4_frog_test.dart
@@ -54,12 +54,13 @@
function A(){}
function B(){}
inherits(B, A);
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testBasicA_dynamic() {
diff --git a/tests/dart2js_2/native/native_class_is_check1_frog_test.dart b/tests/dart2js_2/native/native_class_is_check1_frog_test.dart
index 0294507..83123db 100644
--- a/tests/dart2js_2/native/native_class_is_check1_frog_test.dart
+++ b/tests/dart2js_2/native/native_class_is_check1_frog_test.dart
@@ -31,9 +31,10 @@
function A(){}
A.prototype.read = function() { return this._x; };
A.prototype.write = function(x) { this._x = x; };
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
class B {}
diff --git a/tests/dart2js_2/native/native_class_is_check3_frog_test.dart b/tests/dart2js_2/native/native_class_is_check3_frog_test.dart
index fdd225a..fe7b154 100644
--- a/tests/dart2js_2/native/native_class_is_check3_frog_test.dart
+++ b/tests/dart2js_2/native/native_class_is_check3_frog_test.dart
@@ -49,11 +49,12 @@
inherits(B, A);
A.prototype.read = function() { return this._x; };
A.prototype.write = function(x) { this._x = x; };
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
class C {}
diff --git a/tests/dart2js_2/native/native_class_with_dart_methods_frog_test.dart b/tests/dart2js_2/native/native_class_with_dart_methods_frog_test.dart
index c3061d8..8bd6b66 100644
--- a/tests/dart2js_2/native/native_class_with_dart_methods_frog_test.dart
+++ b/tests/dart2js_2/native/native_class_with_dart_methods_frog_test.dart
@@ -26,9 +26,10 @@
JS('', r"""
(function(){
function A() {}
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/native_closure_identity_frog_test.dart b/tests/dart2js_2/native/native_closure_identity_frog_test.dart
index 2f85058..3d3a44c 100644
--- a/tests/dart2js_2/native/native_closure_identity_frog_test.dart
+++ b/tests/dart2js_2/native/native_closure_identity_frog_test.dart
@@ -24,10 +24,11 @@
A.prototype.setClosure = function(f) { this.f = f; };
A.prototype.check = function(f) { return this.f === f; };
A.prototype.invoke = function() { return this.f(); };
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
var staticClosure;
diff --git a/tests/dart2js_2/native/native_constructor_name_test.dart b/tests/dart2js_2/native/native_constructor_name_test.dart
index 1dc6d6c..bde29a4 100644
--- a/tests/dart2js_2/native/native_constructor_name_test.dart
+++ b/tests/dart2js_2/native/native_constructor_name_test.dart
@@ -25,9 +25,10 @@
JS('', r"""
(function(){
function A(){}
- makeZ = function(){return new A()};
+ self.makeZ = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/native_equals_frog_test.dart b/tests/dart2js_2/native/native_equals_frog_test.dart
index 1b5b38b..657c923 100644
--- a/tests/dart2js_2/native/native_equals_frog_test.dart
+++ b/tests/dart2js_2/native/native_equals_frog_test.dart
@@ -29,11 +29,12 @@
(function(){
function A() {}
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['B']);
}
main() {
diff --git a/tests/dart2js_2/native/native_exception2_test.dart b/tests/dart2js_2/native/native_exception2_test.dart
index 4bbc029..b1751c8 100644
--- a/tests/dart2js_2/native/native_exception2_test.dart
+++ b/tests/dart2js_2/native/native_exception2_test.dart
@@ -23,9 +23,10 @@
JS('', r"""
(function(){
function NativeClass() {}
- makeNativeClass = function() { return new NativeClass(); };
+ self.makeNativeClass = function() { return new NativeClass(); };
self.nativeConstructor(NativeClass);
})()""");
+ applyTestExtensions(['NativeClass']);
}
main() {
diff --git a/tests/dart2js_2/native/native_exceptions1_frog_test.dart b/tests/dart2js_2/native/native_exceptions1_frog_test.dart
index 8617219..c82bb98 100644
--- a/tests/dart2js_2/native/native_exceptions1_frog_test.dart
+++ b/tests/dart2js_2/native/native_exceptions1_frog_test.dart
@@ -49,6 +49,7 @@
A = null;
E = null;
})()""");
+ applyTestExtensions(['E', 'A']);
}
void setup2() {
@@ -62,7 +63,7 @@
if (x & 1) throw new E(100);
return x / 2;
};
-makeA = function(){return new A()};
+self.makeA = function(){return new A()};
self.nativeConstructor(E);
self.nativeConstructor(A);
diff --git a/tests/dart2js_2/native/native_field_invocation2_test.dart b/tests/dart2js_2/native/native_field_invocation2_test.dart
index 2a4d013..046a03d 100644
--- a/tests/dart2js_2/native/native_field_invocation2_test.dart
+++ b/tests/dart2js_2/native/native_field_invocation2_test.dart
@@ -38,7 +38,7 @@
void setup() {
JS('', r"""
(function(){
-nativeId = function(x) { return x; }
+self.nativeId = function(x) { return x; }
})()""");
}
diff --git a/tests/dart2js_2/native/native_field_invocation3_test.dart b/tests/dart2js_2/native/native_field_invocation3_test.dart
index 8e0d918..a492116 100644
--- a/tests/dart2js_2/native/native_field_invocation3_test.dart
+++ b/tests/dart2js_2/native/native_field_invocation3_test.dart
@@ -12,9 +12,10 @@
JS('', r"""
(function(){
function CC() {}
- makeCC = function() { return new CC() };
+ self.makeCC = function() { return new CC() };
self.nativeConstructor(CC);
})()""");
+ applyTestExtensions(['CC']);
}
@Native("CC")
diff --git a/tests/dart2js_2/native/native_field_invocation4_test.dart b/tests/dart2js_2/native/native_field_invocation4_test.dart
index 7e5b0d4..abc22af 100644
--- a/tests/dart2js_2/native/native_field_invocation4_test.dart
+++ b/tests/dart2js_2/native/native_field_invocation4_test.dart
@@ -20,7 +20,7 @@
void setup() {
JS('', r"""
(function(){
-nativeId = function(x) { return x; }
+self.nativeId = function(x) { return x; }
})()""");
}
diff --git a/tests/dart2js_2/native/native_field_invocation5_test.dart b/tests/dart2js_2/native/native_field_invocation5_test.dart
index 5e9e853..eca547d 100644
--- a/tests/dart2js_2/native/native_field_invocation5_test.dart
+++ b/tests/dart2js_2/native/native_field_invocation5_test.dart
@@ -13,10 +13,11 @@
JS('', r"""
(function(){
function CC() {}
- makeCC = function() { return new CC() };
- nativeFirst = function(x, y) { return x; };
+ self.makeCC = function() { return new CC() };
+ self.nativeFirst = function(x, y) { return x; };
self.nativeConstructor(CC);
})()""");
+ applyTestExtensions(['CC']);
}
class C {
diff --git a/tests/dart2js_2/native/native_field_invocation6_test.dart b/tests/dart2js_2/native/native_field_invocation6_test.dart
index 3ca229f..9dafb45 100644
--- a/tests/dart2js_2/native/native_field_invocation6_test.dart
+++ b/tests/dart2js_2/native/native_field_invocation6_test.dart
@@ -12,12 +12,13 @@
void setup() {
JS('', r"""
(function(){
- nativeFirst = function(x, y) { return x; };
+ self.nativeFirst = function(x, y) { return x; };
function A() {}
- makeA = function() { return new A() };
+ self.makeA = function() { return new A() };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
@Native("A")
diff --git a/tests/dart2js_2/native/native_field_invocation_test.dart b/tests/dart2js_2/native/native_field_invocation_test.dart
index 65077fe..6531ff2 100644
--- a/tests/dart2js_2/native/native_field_invocation_test.dart
+++ b/tests/dart2js_2/native/native_field_invocation_test.dart
@@ -20,7 +20,7 @@
void setup() {
JS('', r"""
(function(){
- nativeId = function(x) { return x; }
+ self.nativeId = function(x) { return x; }
})()""");
}
diff --git a/tests/dart2js_2/native/native_field_name_test.dart b/tests/dart2js_2/native/native_field_name_test.dart
index c03a88d..8c1a623 100644
--- a/tests/dart2js_2/native/native_field_name_test.dart
+++ b/tests/dart2js_2/native/native_field_name_test.dart
@@ -43,10 +43,11 @@
return a;
}
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
/*A*/ makeA() native;
diff --git a/tests/dart2js_2/native/native_field_optimization_test.dart b/tests/dart2js_2/native/native_field_optimization_test.dart
index 6b5a976..6aa3aa4 100644
--- a/tests/dart2js_2/native/native_field_optimization_test.dart
+++ b/tests/dart2js_2/native/native_field_optimization_test.dart
@@ -44,10 +44,11 @@
}
});
- makeFoo = function() { return new Foo() };
+ self.makeFoo = function() { return new Foo() };
self.nativeConstructor(Foo);
})()""");
+ applyTestExtensions(['Foo']);
}
test1() {
diff --git a/tests/dart2js_2/native/native_field_rename_1_frog_test.dart b/tests/dart2js_2/native/native_field_rename_1_frog_test.dart
index 11420c4..4277754 100644
--- a/tests/dart2js_2/native/native_field_rename_1_frog_test.dart
+++ b/tests/dart2js_2/native/native_field_rename_1_frog_test.dart
@@ -45,12 +45,13 @@
function X(){}
X.prototype.key = function(){return 666;};
- makeA = function(){return new A()};
- makeX = function(){return new X()};
+ self.makeA = function(){return new A()};
+ self.makeX = function(){return new X()};
self.nativeConstructor(A);
self.nativeConstructor(X);
})()""");
+ applyTestExtensions(['A', 'X']);
}
testDynamic() {
diff --git a/tests/dart2js_2/native/native_field_rename_2_frog_test.dart b/tests/dart2js_2/native/native_field_rename_2_frog_test.dart
index 1591a28..37c9c36 100644
--- a/tests/dart2js_2/native/native_field_rename_2_frog_test.dart
+++ b/tests/dart2js_2/native/native_field_rename_2_frog_test.dart
@@ -48,12 +48,13 @@
function X(){}
X.prototype.key = function(){return 666;};
- makeA = function(){return new A()};
- makeX = function(){return new X()};
+ self.makeA = function(){return new A()};
+ self.makeX = function(){return new X()};
self.nativeConstructor(A);
self.nativeConstructor(X);
})()""");
+ applyTestExtensions(['A', 'X']);
}
testDynamic() {
diff --git a/tests/dart2js_2/native/native_method_inlining_test.dart b/tests/dart2js_2/native/native_method_inlining_test.dart
index 0df556d..5ae5cce 100644
--- a/tests/dart2js_2/native/native_method_inlining_test.dart
+++ b/tests/dart2js_2/native/native_method_inlining_test.dart
@@ -66,7 +66,7 @@
A.prototype.foo = function () { return arguments.length; };
A.prototype.callFun = function (fn) { return fn ? fn(123) : 1; };
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
findMethodTextContaining = function (instance, string) {
var proto = Object.getPrototypeOf(instance);
@@ -81,6 +81,7 @@
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
void match(String s, String pattern1) {
diff --git a/tests/dart2js_2/native/native_method_rename1_frog_test.dart b/tests/dart2js_2/native/native_method_rename1_frog_test.dart
index 65d0741..cdac340 100644
--- a/tests/dart2js_2/native/native_method_rename1_frog_test.dart
+++ b/tests/dart2js_2/native/native_method_rename1_frog_test.dart
@@ -37,10 +37,11 @@
A.prototype.barA = function(){return 200;};
A.prototype.bazA = function(){return 300;};
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
testDynamic() {
diff --git a/tests/dart2js_2/native/native_method_rename2_frog_test.dart b/tests/dart2js_2/native/native_method_rename2_frog_test.dart
index d2c5b49..51058f1 100644
--- a/tests/dart2js_2/native/native_method_rename2_frog_test.dart
+++ b/tests/dart2js_2/native/native_method_rename2_frog_test.dart
@@ -43,12 +43,13 @@
inherits(B, A);
B.prototype.fooB = function(){return 200;};
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testDynamic() {
diff --git a/tests/dart2js_2/native/native_method_rename3_frog_test.dart b/tests/dart2js_2/native/native_method_rename3_frog_test.dart
index b2875a9..2cb4951 100644
--- a/tests/dart2js_2/native/native_method_rename3_frog_test.dart
+++ b/tests/dart2js_2/native/native_method_rename3_frog_test.dart
@@ -50,12 +50,13 @@
inherits(B, A);
B.prototype.fooB = function(){return 200;};
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testDynamic() {
diff --git a/tests/dart2js_2/native/native_method_with_keyword_name_test.dart b/tests/dart2js_2/native/native_method_with_keyword_name_test.dart
index 1245550..89b5d25 100644
--- a/tests/dart2js_2/native/native_method_with_keyword_name_test.dart
+++ b/tests/dart2js_2/native/native_method_with_keyword_name_test.dart
@@ -24,6 +24,7 @@
makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/native_missing_method1_frog_test.dart b/tests/dart2js_2/native/native_missing_method1_frog_test.dart
index e083b17..df551ab 100644
--- a/tests/dart2js_2/native/native_missing_method1_frog_test.dart
+++ b/tests/dart2js_2/native/native_missing_method1_frog_test.dart
@@ -16,9 +16,10 @@
(function(){
function A() {};
A.prototype.foo = function() { return 99; };
- makeA = function() { return new A(); };
+ self.makeA = function() { return new A(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
class B {
diff --git a/tests/dart2js_2/native/native_missing_method2_frog_test.dart b/tests/dart2js_2/native/native_missing_method2_frog_test.dart
index 7b96c87..ca407b2 100644
--- a/tests/dart2js_2/native/native_missing_method2_frog_test.dart
+++ b/tests/dart2js_2/native/native_missing_method2_frog_test.dart
@@ -16,9 +16,10 @@
(function(){
function A() {};
A.prototype.foo = function() { return 42; };
- makeA = function() { return new A() };
+ self.makeA = function() { return new A() };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
class B {
diff --git a/tests/dart2js_2/native/native_mixin_field2_test.dart b/tests/dart2js_2/native/native_mixin_field2_test.dart
index a2b9062..0736aaf 100644
--- a/tests/dart2js_2/native/native_mixin_field2_test.dart
+++ b/tests/dart2js_2/native/native_mixin_field2_test.dart
@@ -46,12 +46,13 @@
(function(){
function A() {this.foo='A-foo';}
function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
@pragma('dart2js:assumeDynamic')
diff --git a/tests/dart2js_2/native/native_mixin_field_test.dart b/tests/dart2js_2/native/native_mixin_field_test.dart
index bc7d36c..4a92fc2 100644
--- a/tests/dart2js_2/native/native_mixin_field_test.dart
+++ b/tests/dart2js_2/native/native_mixin_field_test.dart
@@ -36,12 +36,13 @@
(function(){
function A() {this.foo='A-foo';}
function B() {A.call(this);this.bar='B-bar';this.baz='M1-baz';}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js_2/native/native_mixin_multiple2_test.dart b/tests/dart2js_2/native/native_mixin_multiple2_test.dart
index aa95f87..3ad645b 100644
--- a/tests/dart2js_2/native/native_mixin_multiple2_test.dart
+++ b/tests/dart2js_2/native/native_mixin_multiple2_test.dart
@@ -32,10 +32,11 @@
JS('', r"""
(function(){
function B() {}
- makeB = function(){return new B()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['B']);
}
main() {
diff --git a/tests/dart2js_2/native/native_mixin_multiple3_test.dart b/tests/dart2js_2/native/native_mixin_multiple3_test.dart
index 9992295..2fc6dc1 100644
--- a/tests/dart2js_2/native/native_mixin_multiple3_test.dart
+++ b/tests/dart2js_2/native/native_mixin_multiple3_test.dart
@@ -46,14 +46,15 @@
function A() {}
function B() {}
function C() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
- makeC = function(){return new C()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
+ self.makeC = function(){return new C()};
self.nativeConstructor(A);
self.nativeConstructor(B);
self.nativeConstructor(C);
})()""");
+ applyTestExtensions(['A', 'B', 'C']);
}
var g;
diff --git a/tests/dart2js_2/native/native_mixin_multiple_test.dart b/tests/dart2js_2/native/native_mixin_multiple_test.dart
index 377353c..f657023 100644
--- a/tests/dart2js_2/native/native_mixin_multiple_test.dart
+++ b/tests/dart2js_2/native/native_mixin_multiple_test.dart
@@ -36,12 +36,13 @@
(function(){
function A() {}
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js_2/native/native_mixin_test.dart b/tests/dart2js_2/native/native_mixin_test.dart
index 096f39e..f0f055a 100644
--- a/tests/dart2js_2/native/native_mixin_test.dart
+++ b/tests/dart2js_2/native/native_mixin_test.dart
@@ -32,12 +32,13 @@
(function(){
function A() {}
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js_2/native/native_mixin_with_plain_test.dart b/tests/dart2js_2/native/native_mixin_with_plain_test.dart
index a7bd565..b896ad1 100644
--- a/tests/dart2js_2/native/native_mixin_with_plain_test.dart
+++ b/tests/dart2js_2/native/native_mixin_with_plain_test.dart
@@ -47,12 +47,13 @@
(function(){
function A() {this.aa = 'aa'}
function B() {this.aa = 'bb'}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js_2/native/native_named_constructors2_frog_test.dart b/tests/dart2js_2/native/native_named_constructors2_frog_test.dart
index 916b9ec..a8a5f20 100644
--- a/tests/dart2js_2/native/native_named_constructors2_frog_test.dart
+++ b/tests/dart2js_2/native/native_named_constructors2_frog_test.dart
@@ -33,9 +33,10 @@
// This code is inside 'setup' and so not accessible from the global scope.
function A(arg) { this._x = arg; }
A.prototype.foo = function() { return this._x; };
- makeA = function(arg) { return new A(arg); };
+ self.makeA = function(arg) { return new A(arg); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/native_named_constructors3_frog_test.dart b/tests/dart2js_2/native/native_named_constructors3_frog_test.dart
index d90df20..c98aaa3 100644
--- a/tests/dart2js_2/native/native_named_constructors3_frog_test.dart
+++ b/tests/dart2js_2/native/native_named_constructors3_frog_test.dart
@@ -32,9 +32,10 @@
// This code is inside 'setup' and so not accessible from the global scope.
function A(arg) { this._x = arg; }
A.prototype.foo = function(){ return this._x; };
- makeA = function(arg) { return new A(arg); };
+ self.makeA = function(arg) { return new A(arg); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/native_no_such_method_exception2_frog_test.dart b/tests/dart2js_2/native/native_no_such_method_exception2_frog_test.dart
index b562085..6fb278b 100644
--- a/tests/dart2js_2/native/native_no_such_method_exception2_frog_test.dart
+++ b/tests/dart2js_2/native/native_no_such_method_exception2_frog_test.dart
@@ -33,13 +33,14 @@
function A() {}
function B() {}
inherits(B, A);
- makeA = function() { return new A() };
- makeB = function() { return new B() };
+ self.makeA = function() { return new A() };
+ self.makeB = function() { return new B() };
B.prototype.foo = function() { return 42; };
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
main() {
diff --git a/tests/dart2js_2/native/native_no_such_method_exception_frog_test.dart b/tests/dart2js_2/native/native_no_such_method_exception_frog_test.dart
index 857bf54..c01d397 100644
--- a/tests/dart2js_2/native/native_no_such_method_exception_frog_test.dart
+++ b/tests/dart2js_2/native/native_no_such_method_exception_frog_test.dart
@@ -22,9 +22,10 @@
JS('', r"""
(function(){
function A() {}
- makeA = function() { return new A(); };
+ self.makeA = function() { return new A(); };
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/native_novel_html_test.dart b/tests/dart2js_2/native/native_novel_html_test.dart
index 5330028..1e2d20d 100644
--- a/tests/dart2js_2/native/native_novel_html_test.dart
+++ b/tests/dart2js_2/native/native_novel_html_test.dart
@@ -25,17 +25,18 @@
HTMLGoofyElement.prototype.nativeMethod = function(a) {
return 'Goofy.nativeMethod(' + a + ')';
};
- makeE = function(){return new HTMLGoofyElement()};
+ self.makeE = function(){return new HTMLGoofyElement()};
// A non-HTML element with a misleading name.
function HTMLFakeyElement(){}
HTMLFakeyElement.prototype.nativeMethod = function(a) {
return 'Fakey.nativeMethod(' + a + ')';
};
- makeF = function(){return new HTMLFakeyElement()};
+ self.makeF = function(){return new HTMLFakeyElement()};
self.nativeConstructor(HTMLGoofyElement);
})()""");
+ applyTestExtensions(['HTMLGoofyElement']);
}
main() {
diff --git a/tests/dart2js_2/native/native_null_closure_frog_test.dart b/tests/dart2js_2/native/native_null_closure_frog_test.dart
index a7c83a3..1ec0bfd 100644
--- a/tests/dart2js_2/native/native_null_closure_frog_test.dart
+++ b/tests/dart2js_2/native/native_null_closure_frog_test.dart
@@ -26,10 +26,11 @@
A.prototype.setClosure = function(f) { this.f = f; };
A.prototype.check = function(f) { return this.f === f; };
A.prototype.invoke = function() { return this.f(); };
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/native_null_frog_test.dart b/tests/dart2js_2/native/native_null_frog_test.dart
index 9cf083d..14f19c2 100644
--- a/tests/dart2js_2/native/native_null_frog_test.dart
+++ b/tests/dart2js_2/native/native_null_frog_test.dart
@@ -26,9 +26,10 @@
A.prototype.returnUndefined = function() { return void 0; };
A.prototype.returnEmptyString = function() { return ""; };
A.prototype.returnZero = function() { return 0; };
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
@pragma('dart2js:noInline')
diff --git a/tests/dart2js_2/native/native_property_frog_test.dart b/tests/dart2js_2/native/native_property_frog_test.dart
index 2deeed5..026dd6a 100644
--- a/tests/dart2js_2/native/native_property_frog_test.dart
+++ b/tests/dart2js_2/native/native_property_frog_test.dart
@@ -40,10 +40,11 @@
set: function (v) { this._x = v; }
});
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/native_testing.dart b/tests/dart2js_2/native/native_testing.dart
index 9eb9246..19d5bae 100644
--- a/tests/dart2js_2/native/native_testing.dart
+++ b/tests/dart2js_2/native/native_testing.dart
@@ -12,7 +12,8 @@
import 'dart:_foreign_helper' show JS;
export "package:expect/expect.dart";
-export 'dart:_js_helper' show Creates, Native, JSName, Returns;
+export 'dart:_js_helper'
+ show Creates, Native, JSName, Returns, applyTestExtensions;
export 'dart:_foreign_helper' show JS;
void nativeTesting() {
diff --git a/tests/dart2js_2/native/native_to_string_frog_test.dart b/tests/dart2js_2/native/native_to_string_frog_test.dart
index f17ad7b..aafb8f1 100644
--- a/tests/dart2js_2/native/native_to_string_frog_test.dart
+++ b/tests/dart2js_2/native/native_to_string_frog_test.dart
@@ -17,9 +17,10 @@
JS('', r"""
(function(){
function A() {}
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/native_use_native_name_in_table_frog_test.dart b/tests/dart2js_2/native/native_use_native_name_in_table_frog_test.dart
index ef7b2a7..7a9b283 100644
--- a/tests/dart2js_2/native/native_use_native_name_in_table_frog_test.dart
+++ b/tests/dart2js_2/native/native_use_native_name_in_table_frog_test.dart
@@ -38,12 +38,13 @@
inherits(NativeB, NativeA);
NativeA.prototype.foo = function() { return 42; };
- makeA = function(){return new NativeA()};
- makeB = function(){return new NativeB()};
+ self.makeA = function(){return new NativeA()};
+ self.makeB = function(){return new NativeB()};
self.nativeConstructor(NativeA);
self.nativeConstructor(NativeB);
})()""");
+ applyTestExtensions(['NativeA', 'NativeB']);
}
main() {
diff --git a/tests/dart2js_2/native/native_wrapping_function3_frog_test.dart b/tests/dart2js_2/native/native_wrapping_function3_frog_test.dart
index e3de1ed..da2ea28 100644
--- a/tests/dart2js_2/native/native_wrapping_function3_frog_test.dart
+++ b/tests/dart2js_2/native/native_wrapping_function3_frog_test.dart
@@ -26,9 +26,10 @@
A.prototype.foo2 = function(closure, arg1, arg2) {
return closure(arg1, arg2);
};
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/native_wrapping_function_frog_test.dart b/tests/dart2js_2/native/native_wrapping_function_frog_test.dart
index e05b809..325705e 100644
--- a/tests/dart2js_2/native/native_wrapping_function_frog_test.dart
+++ b/tests/dart2js_2/native/native_wrapping_function_frog_test.dart
@@ -28,9 +28,10 @@
A.prototype.foo2 = function(closure, arg1, arg2) {
return closure(arg1, arg2);
};
- makeA = function(){return new A()};
+ self.makeA = function(){return new A()};
self.nativeConstructor(A);
})()""");
+ applyTestExtensions(['A']);
}
main() {
diff --git a/tests/dart2js_2/native/oddly_named_fields_test.dart b/tests/dart2js_2/native/oddly_named_fields_test.dart
index e59f247..19c2777 100644
--- a/tests/dart2js_2/native/oddly_named_fields_test.dart
+++ b/tests/dart2js_2/native/oddly_named_fields_test.dart
@@ -1387,9 +1387,10 @@
JS('', r"""
(function(){
function NativeClassWithOddNames() {}
- makeNativeClassWithOddNames = function() {return new NativeClassWithOddNames()};
+ self.makeNativeClassWithOddNames = function() {return new NativeClassWithOddNames()};
self.nativeConstructor(NativeClassWithOddNames);
})()""");
+ applyTestExtensions(['NativeClassWithOddNames']);
}
main() {
diff --git a/tests/dart2js_2/native/runtimetype_test.dart b/tests/dart2js_2/native/runtimetype_test.dart
index 4465ae1..62911e2 100644
--- a/tests/dart2js_2/native/runtimetype_test.dart
+++ b/tests/dart2js_2/native/runtimetype_test.dart
@@ -33,12 +33,13 @@
function TAGY(){}
inherits(TAGY, TAGX);
- makeA = function(){return new TAGX()};
- makeB = function(){return new TAGY()};
+ self.makeA = function(){return new TAGX()};
+ self.makeB = function(){return new TAGY()};
self.nativeConstructor(TAGX);
self.nativeConstructor(TAGY);
})()""");
+ applyTestExtensions(['TAGX', 'TAGY']);
}
testDynamicContext() {
diff --git a/tests/dart2js_2/native/subclassing_1_test.dart b/tests/dart2js_2/native/subclassing_1_test.dart
index fd3dc84..c19ce2b 100644
--- a/tests/dart2js_2/native/subclassing_1_test.dart
+++ b/tests/dart2js_2/native/subclassing_1_test.dart
@@ -37,13 +37,13 @@
function A() {}
function B() {}
function C() {}
- makeA = function(){return new A()};
- makeB1 = function(){return new B()};
- makeB2 = function(){return new B()};
- makeC = function(){return new C()};
+ self.makeA = function(){return new A()};
+ self.makeB1 = function(){return new B()};
+ self.makeB2 = function(){return new B()};
+ self.makeC = function(){return new C()};
- getBPrototype = function(){return B.prototype;};
- getCPrototype = function(){return C.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
+ self.getCPrototype = function(){return C.prototype;};
})()""");
}
diff --git a/tests/dart2js_2/native/subclassing_2_test.dart b/tests/dart2js_2/native/subclassing_2_test.dart
index 63f3711..d5ee89d 100644
--- a/tests/dart2js_2/native/subclassing_2_test.dart
+++ b/tests/dart2js_2/native/subclassing_2_test.dart
@@ -34,10 +34,10 @@
(function(){
function A() {}
function B() {}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js_2/native/subclassing_3_test.dart b/tests/dart2js_2/native/subclassing_3_test.dart
index fb7a794..d033b08 100644
--- a/tests/dart2js_2/native/subclassing_3_test.dart
+++ b/tests/dart2js_2/native/subclassing_3_test.dart
@@ -40,9 +40,9 @@
JS('', r"""
(function(){
function B() {}
- makeB = function(){return new B();};
+ self.makeB = function(){return new B();};
- getBPrototype = function(){return B.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js_2/native/subclassing_4_test.dart b/tests/dart2js_2/native/subclassing_4_test.dart
index 089f134..c80a161 100644
--- a/tests/dart2js_2/native/subclassing_4_test.dart
+++ b/tests/dart2js_2/native/subclassing_4_test.dart
@@ -38,8 +38,8 @@
JS('', r"""
(function(){
function B() {}
- makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.makeB = function(){return new B()};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js_2/native/subclassing_5_test.dart b/tests/dart2js_2/native/subclassing_5_test.dart
index 3ae3859..5599399 100644
--- a/tests/dart2js_2/native/subclassing_5_test.dart
+++ b/tests/dart2js_2/native/subclassing_5_test.dart
@@ -45,8 +45,8 @@
JS('', r"""
(function(){
function B() {}
- makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.makeB = function(){return new B()};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js_2/native/subclassing_constructor_1_test.dart b/tests/dart2js_2/native/subclassing_constructor_1_test.dart
index d70e1e3..9ee71bb 100644
--- a/tests/dart2js_2/native/subclassing_constructor_1_test.dart
+++ b/tests/dart2js_2/native/subclassing_constructor_1_test.dart
@@ -67,9 +67,9 @@
(function(){
function B() { this.a2 = 102; }
- makeB = function(){return new B()};
+ self.makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js_2/native/subclassing_super_call_test.dart b/tests/dart2js_2/native/subclassing_super_call_test.dart
index 71a77e5..b94cfd6 100644
--- a/tests/dart2js_2/native/subclassing_super_call_test.dart
+++ b/tests/dart2js_2/native/subclassing_super_call_test.dart
@@ -51,9 +51,9 @@
N2.prototype.foo = function() { return "foo:" + this.text; };
function BB() {}
BB.prototype.__proto__ = N2.prototype;
- makeBB = function(){return new BB()};
+ self.makeBB = function(){return new BB()};
- getBBPrototype = function(){return BB.prototype;};
+ self.getBBPrototype = function(){return BB.prototype;};
})()""");
}
diff --git a/tests/dart2js_2/native/subclassing_super_field_1_test.dart b/tests/dart2js_2/native/subclassing_super_field_1_test.dart
index a1e3c2a..f14bb3d 100644
--- a/tests/dart2js_2/native/subclassing_super_field_1_test.dart
+++ b/tests/dart2js_2/native/subclassing_super_field_1_test.dart
@@ -38,9 +38,9 @@
JS('', r"""
(function(){
function B() { }
-makeB = function(){return new B()};
+self.makeB = function(){return new B()};
-getBPrototype = function(){return B.prototype;};
+self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js_2/native/subclassing_super_field_2_test.dart b/tests/dart2js_2/native/subclassing_super_field_2_test.dart
index efd1bf6..334e83a 100644
--- a/tests/dart2js_2/native/subclassing_super_field_2_test.dart
+++ b/tests/dart2js_2/native/subclassing_super_field_2_test.dart
@@ -42,9 +42,9 @@
JS('', r"""
(function(){
function B() { this.foo = 111; } // N.foo
- makeB = function(){return new B()};
+ self.makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js_2/native/subclassing_type_test.dart b/tests/dart2js_2/native/subclassing_type_test.dart
index 3abc875..39f9745 100644
--- a/tests/dart2js_2/native/subclassing_type_test.dart
+++ b/tests/dart2js_2/native/subclassing_type_test.dart
@@ -35,9 +35,9 @@
JS('', r"""
(function(){
function B() {}
- makeB = function(){return new B()};
+ self.makeB = function(){return new B()};
- getBPrototype = function(){return B.prototype;};
+ self.getBPrototype = function(){return B.prototype;};
})()""");
}
diff --git a/tests/dart2js_2/native/super_call_test.dart b/tests/dart2js_2/native/super_call_test.dart
index 2dfff1a..1e91195 100644
--- a/tests/dart2js_2/native/super_call_test.dart
+++ b/tests/dart2js_2/native/super_call_test.dart
@@ -61,16 +61,17 @@
function D(){}
inherits(D, C);
- makeA = function(){return new A()};
- makeB = function(){return new B()};
- makeC = function(){return new C()};
- makeD = function(){return new D()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
+ self.makeC = function(){return new C()};
+ self.makeD = function(){return new D()};
self.nativeConstructor(A);
self.nativeConstructor(B);
self.nativeConstructor(C);
self.nativeConstructor(D);
})()""");
+ applyTestExtensions(['A', 'B', 'C', 'D']);
}
main() {
diff --git a/tests/dart2js_2/native/super_property_test.dart b/tests/dart2js_2/native/super_property_test.dart
index 5efcf62..ada33df 100644
--- a/tests/dart2js_2/native/super_property_test.dart
+++ b/tests/dart2js_2/native/super_property_test.dart
@@ -48,11 +48,12 @@
// This code is inside 'setup' and so not accessible from the global scope.
function A(){}
function B(){}
- makeA = function(){return new A()};
- makeB = function(){return new B()};
+ self.makeA = function(){return new A()};
+ self.makeB = function(){return new B()};
self.nativeConstructor(A);
self.nativeConstructor(B);
})()""");
+ applyTestExtensions(['A', 'B']);
}
testThing(a) {
diff --git a/tests/lib/js/native_as_js_classes_static_test/default_library_namespace_test.dart b/tests/lib/js/native_as_js_classes_static_test/default_library_namespace_test.dart
new file mode 100644
index 0000000..d230129
--- /dev/null
+++ b/tests/lib/js/native_as_js_classes_static_test/default_library_namespace_test.dart
@@ -0,0 +1,75 @@
+// 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.
+
+// Test errors with a library with the default namespace.
+
+@JS()
+library default_library_namespace_test;
+
+import 'package:js/js.dart';
+
+// Test same class name as a native class.
+@JS()
+class HTMLDocument {}
+// ^
+// [web] JS interop class 'HTMLDocument' conflicts with natively supported class 'HtmlDocument' in 'dart:html'.
+
+// Test same annotation name as a native class.
+@JS('HTMLDocument')
+class HtmlDocument {}
+// ^
+// [web] JS interop class 'HtmlDocument' conflicts with natively supported class 'HtmlDocument' in 'dart:html'.
+
+// Test annotation name with 'self' and 'window' prefixes.
+@JS('self.Window')
+class WindowWithSelf {}
+// ^
+// [web] JS interop class 'WindowWithSelf' conflicts with natively supported class 'Window' in 'dart:html'.
+
+@JS('window.Window')
+class WindowWithWindow {}
+// ^
+// [web] JS interop class 'WindowWithWindow' conflicts with natively supported class 'Window' in 'dart:html'.
+
+@JS('self.window.self.window.self.Window')
+class WindowWithMultipleSelfsAndWindows {}
+// ^
+// [web] JS interop class 'WindowWithMultipleSelfsAndWindows' conflicts with natively supported class 'Window' in 'dart:html'.
+
+// Test annotation with native class name but with a prefix that isn't 'self' or
+// 'window'.
+@JS('foo.Window')
+class WindowWithDifferentPrefix {}
+
+// Test same class name as a native class with multiple annotation names.
+// dart:html.Window uses both "Window" and "DOMWindow".
+@JS()
+class DOMWindow {}
+// ^
+// [web] JS interop class 'DOMWindow' conflicts with natively supported class 'Window' in 'dart:html'.
+
+// Test same annotation name as a native class with multiple annotation names
+// dart:html.Window uses both "Window" and "DOMWindow".
+@JS('DOMWindow')
+class DomWindow {}
+// ^
+// [web] JS interop class 'DomWindow' conflicts with natively supported class 'Window' in 'dart:html'.
+
+// Test different annotation name but with same class name as a @Native class.
+@JS('Foo')
+class Window {}
+
+// Dart classes don't have to worry about conflicts.
+class Element {}
+
+// Anonymous classes don't have to worry about conflicts either.
+@JS()
+@anonymous
+class HTMLElement {}
+
+@JS('HTMLElement')
+@anonymous
+class HtmlElement {}
+
+void main() {}
diff --git a/tests/lib/js/native_as_js_classes_static_test/global_library_namespace_test.dart b/tests/lib/js/native_as_js_classes_static_test/global_library_namespace_test.dart
new file mode 100644
index 0000000..fb55aa6
--- /dev/null
+++ b/tests/lib/js/native_as_js_classes_static_test/global_library_namespace_test.dart
@@ -0,0 +1,63 @@
+// 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.
+
+// Test errors with a library with a global namespace.
+
+@JS('window')
+library global_library_namespace_test;
+
+import 'package:js/js.dart';
+
+@JS()
+class HTMLDocument {}
+// ^
+// [web] JS interop class 'HTMLDocument' conflicts with natively supported class 'HtmlDocument' in 'dart:html'.
+
+@JS('HTMLDocument')
+class HtmlDocument {}
+// ^
+// [web] JS interop class 'HtmlDocument' conflicts with natively supported class 'HtmlDocument' in 'dart:html'.
+
+@JS('self.Window')
+class WindowWithSelf {}
+// ^
+// [web] JS interop class 'WindowWithSelf' conflicts with natively supported class 'Window' in 'dart:html'.
+
+@JS('window.Window')
+class WindowWithWindow {}
+// ^
+// [web] JS interop class 'WindowWithWindow' conflicts with natively supported class 'Window' in 'dart:html'.
+
+@JS('self.window.self.window.self.Window')
+class WindowWithMultipleSelfsAndWindows {}
+// ^
+// [web] JS interop class 'WindowWithMultipleSelfsAndWindows' conflicts with natively supported class 'Window' in 'dart:html'.
+
+@JS('foo.Window')
+class WindowWithDifferentPrefix {}
+
+@JS()
+class DOMWindow {}
+// ^
+// [web] JS interop class 'DOMWindow' conflicts with natively supported class 'Window' in 'dart:html'.
+
+@JS('DOMWindow')
+class DomWindow {}
+// ^
+// [web] JS interop class 'DomWindow' conflicts with natively supported class 'Window' in 'dart:html'.
+
+@JS('Foo')
+class Window {}
+
+class Element {}
+
+@JS()
+@anonymous
+class HTMLElement {}
+
+@JS('HTMLElement')
+@anonymous
+class HtmlElement {}
+
+void main() {}
diff --git a/tests/lib/js/native_as_js_classes_static_test/local_library_namespace_test.dart b/tests/lib/js/native_as_js_classes_static_test/local_library_namespace_test.dart
new file mode 100644
index 0000000..e529bfa
--- /dev/null
+++ b/tests/lib/js/native_as_js_classes_static_test/local_library_namespace_test.dart
@@ -0,0 +1,50 @@
+// 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.
+
+// Test errors with a library with a non-default or non-global namespace.
+// Note that none of the following should be errors in this case.
+
+@JS('foo')
+library global_library_namespace_test;
+
+import 'package:js/js.dart';
+
+@JS()
+class HTMLDocument {}
+
+@JS('HTMLDocument')
+class HtmlDocument {}
+
+@JS('self.Window')
+class WindowWithSelf {}
+
+@JS('window.Window')
+class WindowWithWindow {}
+
+@JS('self.window.self.window.self.Window')
+class WindowWithMultipleSelfsAndWindows {}
+
+@JS('foo.Window')
+class WindowWithDifferentPrefix {}
+
+@JS()
+class DOMWindow {}
+
+@JS('DOMWindow')
+class DomWindow {}
+
+@JS('Foo')
+class Window {}
+
+class Element {}
+
+@JS()
+@anonymous
+class HTMLElement {}
+
+@JS('HTMLElement')
+@anonymous
+class HtmlElement {}
+
+void main() {}
diff --git a/tools/VERSION b/tools/VERSION
index 3cd2a88..f03f533 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 12
PATCH 0
-PRERELEASE 226
+PRERELEASE 227
PRERELEASE_PATCH 0
\ No newline at end of file