Version 2.17.0-2.0.dev
Merge commit '5f68998865f222ee8de6e637b4eb153dfed7f854' into 'dev'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 039502f..7428a56 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -63,7 +63,16 @@
#### Linter
-Updated the Linter to `1.17.1`, which includes changes that
+Updated the Linter to `1.18.0`, which includes changes that
+
+- extends `camel_case_types` to cover enums.
+- fixes `no_leading_underscores_for_local_identifiers` to not
+ mis-flag field formal parameters with default values.
+- fixes `prefer_function_declarations_over_variables` to not
+ mis-flag non-final fields.
+- improves performance for `prefer_contains`.
+- updates `exhaustive_cases` to skip deprecated values that
+ redirect to other values.
- adds new lint: `unnecessary_late`.
- improves docs for `prefer_initializing_formals`.
- updates `secure_pubspec_urls` to check `issue_tracker` and
diff --git a/DEPS b/DEPS
index 3497c49..f89e94c 100644
--- a/DEPS
+++ b/DEPS
@@ -124,7 +124,7 @@
"intl_tag": "0.17.0-nullsafety",
"jinja2_rev": "2222b31554f03e62600cd7e383376a7c187967a1",
"json_rpc_2_rev": "7e00f893440a72de0637970325e4ea44bd1e8c8e",
- "linter_tag": "1.17.1",
+ "linter_tag": "1.18.0",
"lints_tag": "f9670df2a66e0ec12eb51554e70c1cbf56c8f5d0",
"logging_rev": "575781ef196e4fed4fb737e38fb4b73d62727187",
"markupsafe_rev": "8f45f5cfa0009d2a70589bcda0349b8cb2b72783",
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 55b94a9..9a0d773 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
@@ -44,6 +44,9 @@
final Set<AssignedVariablesNodeInfo<Variable>> _deferredInfos =
new Set<AssignedVariablesNodeInfo<Variable>>.identity();
+ /// Keeps track of whether [finish] has been called.
+ bool _isFinished = false;
+
/// This method should be called during pre-traversal, to mark the start of a
/// loop statement, switch statement, try statement, loop collection element,
/// local function, closure, or late variable initializer which might need to
@@ -56,6 +59,7 @@
/// statement, the body of the switch statement should be covered, but the
/// switch expression should not.
void beginNode() {
+ assert(!_isFinished);
_stack.add(new AssignedVariablesNodeInfo<Variable>());
}
@@ -65,7 +69,9 @@
/// It is not required for the declaration to be seen prior to its use (this
/// is to allow for error recovery in the analyzer).
void declare(Variable variable) {
+ assert(!_isFinished);
_stack.last._declared.add(variable);
+ _anywhere._declared.add(variable);
}
/// This method may be called during pre-traversal, to mark the end of a
@@ -83,6 +89,7 @@
/// See [beginNode] for more details.
AssignedVariablesNodeInfo<Variable> deferNode(
{bool isClosureOrLateVariableInitializer: false}) {
+ assert(!_isFinished);
AssignedVariablesNodeInfo<Variable> info = _stack.removeLast();
info._read.removeAll(info._declared);
info._written.removeAll(info._declared);
@@ -116,6 +123,7 @@
/// needed, use [discardNode] to discard the effects of one of the [beginNode]
/// calls.
void discardNode() {
+ assert(!_isFinished);
AssignedVariablesNodeInfo<Variable> discarded = _stack.removeLast();
AssignedVariablesNodeInfo<Variable> last = _stack.last;
last._declared.addAll(discarded._declared);
@@ -138,6 +146,7 @@
///
/// See [beginNode] for more details.
void endNode(Node node, {bool isClosureOrLateVariableInitializer: false}) {
+ assert(!_isFinished);
storeInfo(
node,
deferNode(
@@ -148,6 +157,7 @@
/// Call this after visiting the code to be analyzed, to check invariants.
void finish() {
assert(() {
+ assert(!_isFinished);
assert(
_deferredInfos.isEmpty, "Deferred infos not stored: $_deferredInfos");
assert(_stack.length == 1, "Unexpected stack: $_stack");
@@ -164,6 +174,7 @@
'Variables captured but not declared: $undeclaredCaptures');
return true;
}());
+ _isFinished = true;
}
/// Call this method between calls to [beginNode] and [endNode]/[deferNode],
@@ -174,15 +185,18 @@
/// and sets; their initializers are partially built after building their
/// loop conditions but before completely building their bodies.
AssignedVariablesNodeInfo<Variable> popNode() {
+ assert(!_isFinished);
return _stack.removeLast();
}
/// Call this method to un-do the effect of [popNode].
void pushNode(AssignedVariablesNodeInfo<Variable> node) {
+ assert(!_isFinished);
_stack.add(node);
}
void read(Variable variable) {
+ assert(!_isFinished);
_stack.last._read.add(variable);
_anywhere._read.add(variable);
}
@@ -205,6 +219,7 @@
/// This method may be called at any time between a call to [deferNode] and
/// the call to [finish], to store assigned variable info for the node.
void storeInfo(Node node, AssignedVariablesNodeInfo<Variable> info) {
+ assert(!_isFinished);
// Caller should not try to store the same piece of info more than once.
assert(_deferredInfos.remove(info));
_info[node] = info;
@@ -221,6 +236,7 @@
/// This method should be called during pre-traversal, to mark a write to a
/// variable.
void write(Variable variable) {
+ assert(!_isFinished);
_stack.last._written.add(variable);
_anywhere._written.add(variable);
}
@@ -1722,7 +1738,8 @@
Map<Variable?, VariableModel<Variable, Type>>? newVariableInfo;
for (Variable variable in writtenVariables) {
- VariableModel<Variable, Type> info = infoFor(variable);
+ VariableModel<Variable, Type>? info = variableInfo[variable];
+ if (info == null) continue;
VariableModel<Variable, Type> newInfo =
info.discardPromotionsAndMarkNotUnassigned();
if (!identical(info, newInfo)) {
@@ -1734,16 +1751,8 @@
for (Variable variable in capturedVariables) {
VariableModel<Variable, Type>? info = variableInfo[variable];
- if (info == null) {
- (newVariableInfo ??=
- new Map<Variable?, VariableModel<Variable, Type>>.of(
- variableInfo))[variable] = new VariableModel<Variable, Type>(
- promotedTypes: null,
- tested: const [],
- assigned: false,
- unassigned: false,
- ssaNode: null);
- } else if (!info.writeCaptured) {
+ if (info == null) continue;
+ if (!info.writeCaptured) {
(newVariableInfo ??=
new Map<Variable?, VariableModel<Variable, Type>>.of(
variableInfo))[variable] = info.writeCapture();
@@ -3468,7 +3477,20 @@
final bool respectImplicitlyTypedVarInitializers;
_FlowAnalysisImpl(this.typeOperations, this._assignedVariables,
- {required this.respectImplicitlyTypedVarInitializers});
+ {required this.respectImplicitlyTypedVarInitializers}) {
+ if (!_assignedVariables._isFinished) {
+ _assignedVariables.finish();
+ }
+ AssignedVariablesNodeInfo<Variable> anywhere = _assignedVariables._anywhere;
+ Set<Variable> implicitlyDeclaredVars = {
+ ...anywhere._read,
+ ...anywhere._written
+ };
+ implicitlyDeclaredVars.removeAll(anywhere._declared);
+ for (Variable variable in implicitlyDeclaredVars) {
+ declare(variable, true);
+ }
+ }
@override
bool get isReachable => _current.reachable.overallReachable;
diff --git a/pkg/_fe_analyzer_shared/lib/src/util/libraries_specification.dart b/pkg/_fe_analyzer_shared/lib/src/util/libraries_specification.dart
index bcbe485..7bc929b 100644
--- a/pkg/_fe_analyzer_shared/lib/src/util/libraries_specification.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/util/libraries_specification.dart
@@ -76,6 +76,9 @@
/// report that such library is still not supported in conditional imports
/// and const `fromEnvironment` expressions.
///
+/// Internal libraries are never supported through conditional imports and
+/// const `fromEnvironment` expressions.
+///
///
/// Note: we currently have several different files that need to be updated
/// when changing libraries, sources, and patch files:
@@ -270,8 +273,10 @@
if (supported is! bool) {
_reportError(messageSupportedIsNotABool(supported));
}
- libraries[libraryName] =
- new LibraryInfo(libraryName, uri, patches, isSupported: supported);
+ libraries[libraryName] = new LibraryInfo(libraryName, uri, patches,
+ // Internal libraries are never supported through conditional
+ // imports and const `fromEnvironment` expressions.
+ isSupported: supported && !libraryName.startsWith('_'));
});
currentTargets.remove(targetName);
return targets[targetName] =
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/constructor.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/constructor.dart
index 5dd4825..1b7e731 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/constructor.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/constructor.dart
@@ -8,3 +8,14 @@
a = 0;
}
}
+
+class D {
+ const D(bool b) : assert(b);
+}
+
+class E {
+ final String a;
+ final String? b;
+
+ const E(this.a, {this.b});
+}
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/topLevelVariable.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/topLevelVariable.dart
index b2b8e7d..40b86c3 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/topLevelVariable.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/assigned_variables/data/topLevelVariable.dart
@@ -2,6 +2,9 @@
// 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.
-dynamic /*member: x:assigned={a}*/ x = /*declared={a, b}*/ (int a, int b) {
+dynamic /*member: x1:assigned={a}*/ x1 = /*declared={a, b}*/ (int a, int b) {
a = 0;
};
+
+/*member: x2:none*/
+final x2 = new List.filled(0, null);
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
index b33704b..a3700cd 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
@@ -34,6 +34,7 @@
var h = Harness();
var x = Var('x', 'int?');
h.run([
+ declare(x, initialized: true),
assert_(x.expr.eq(nullLiteral),
checkPromoted(x, 'int').thenExpr(expr('String'))),
]);
@@ -45,6 +46,9 @@
var y = Var('y', 'int?');
var z = Var('z', 'int?');
h.run([
+ declare(x, initialized: true),
+ declare(y, initialized: true),
+ declare(z, initialized: true),
x.expr.as_('int').stmt,
z.expr.as_('int').stmt,
assert_(block([
@@ -1008,9 +1012,10 @@
var x = Var('x', 'int?');
var y = Var('y', 'int?');
h.run([
+ declare(x, initialized: true),
declare(y, initialized: true),
y.expr.as_('int').stmt,
- getSsaNodes((nodes) => expect(nodes[x], null)),
+ getSsaNodes((nodes) => expect(nodes[x], isNotNull)),
localFunction([
getSsaNodes((nodes) => expect(nodes[x], isNot(nodes[y]))),
x.expr.as_('int').stmt,
@@ -1019,7 +1024,6 @@
checkNotPromoted(x),
]),
localFunction([
- declare(x, initialized: true),
x.write(expr('Null')).stmt,
]),
]);
@@ -1384,6 +1388,7 @@
var y = Var('y', 'int?');
late ExpressionInfo<Var, Type> writtenValueInfo;
h.run([
+ declare(y, initialized: true),
declareInitialized(
x,
y.expr.eq(nullLiteral).getExpressionInfo((info) {
@@ -1401,6 +1406,7 @@
var x = Var('x', 'Object', isLate: true);
var y = Var('y', 'int?');
h.run([
+ declare(y, initialized: true),
declareInitialized(x, y.expr.eq(nullLiteral)),
getSsaNodes((nodes) {
expect(nodes[x]!.expressionInfo, isNull);
@@ -1415,6 +1421,7 @@
var x = Var('x', 'Object', isImplicitlyTyped: true);
var y = Var('y', 'int?');
h.run([
+ declare(y, initialized: true),
declareInitialized(x, y.expr.eq(nullLiteral)),
getSsaNodes((nodes) {
expect(nodes[x]!.expressionInfo, isNull);
@@ -1429,6 +1436,7 @@
var x = Var('x', 'Object', isImplicitlyTyped: true);
var y = Var('y', 'int?');
h.run([
+ declare(y, initialized: true),
declareInitialized(x, y.expr.eq(nullLiteral)),
getSsaNodes((nodes) {
expect(nodes[x]!.expressionInfo, isNotNull);
@@ -1443,6 +1451,7 @@
var x = Var('x', 'Object');
var y = Var('y', 'int?');
h.run([
+ declare(y, initialized: true),
declareInitialized(x, y.expr.eq(nullLiteral)),
getSsaNodes((nodes) {
expect(nodes[x]!.expressionInfo, isNotNull);
@@ -1853,6 +1862,7 @@
var h = Harness();
var x = Var('x', 'int?');
h.run([
+ declare(x, initialized: true),
if_(
x.expr.parenthesized.notEq(nullLiteral.parenthesized).parenthesized,
[
@@ -3039,6 +3049,7 @@
late ExpressionInfo<Var, Type> writtenValueInfo;
h.run([
declare(x, initialized: true),
+ declare(y, initialized: true),
getSsaNodes((nodes) => ssaBeforeWrite = nodes[x]!),
x
.write(y.expr.eq(nullLiteral).getExpressionInfo((info) {
@@ -3186,6 +3197,25 @@
x.expr.as_('int').stmt, checkNotPromoted(x),
]);
});
+
+ test('issue 47991', () {
+ var h = Harness();
+ var b = Var('b', 'bool');
+ var i = Var('i', 'int', isFinal: true);
+ h.run([
+ localFunction([
+ declareInitialized(b, expr('bool').or(expr('bool'))),
+ declare(i, initialized: false),
+ if_(b.expr, [
+ checkUnassigned(i, true),
+ i.write(expr('int')).stmt,
+ ], [
+ checkUnassigned(i, true),
+ i.write(expr('int')).stmt,
+ ]),
+ ]),
+ ]);
+ });
});
group('Reachability', () {
diff --git a/pkg/_fe_analyzer_shared/test/mini_ast.dart b/pkg/_fe_analyzer_shared/test/mini_ast.dart
index 85ae066..0c71378 100644
--- a/pkg/_fe_analyzer_shared/test/mini_ast.dart
+++ b/pkg/_fe_analyzer_shared/test/mini_ast.dart
@@ -963,6 +963,7 @@
@override
void _preVisit(AssignedVariables<Node, Var> assignedVariables) {
+ assignedVariables.declare(variable);
initializer?._preVisit(assignedVariables);
}
diff --git a/pkg/analysis_server/test/domain_completion_test.dart b/pkg/analysis_server/test/domain_completion_test.dart
index c7b86d9..0597706 100644
--- a/pkg/analysis_server/test/domain_completion_test.dart
+++ b/pkg/analysis_server/test/domain_completion_test.dart
@@ -27,6 +27,7 @@
import 'domain_completion_util.dart';
import 'mocks.dart';
+import 'services/completion/dart/completion_check.dart';
import 'src/plugin/plugin_manager_test.dart';
import 'utils/change_check.dart';
@@ -239,30 +240,30 @@
await _configureWithWorkspaceRoot();
// Send three requests, the first two should be aborted.
- var response0 = _sendTestCompletionRequest('0', 0);
- var response1 = _sendTestCompletionRequest('1', 0);
- var response2 = _sendTestCompletionRequest('2', 0);
+ var request0 = _sendTestCompletionRequest('0', 0);
+ var request1 = _sendTestCompletionRequest('1', 0);
+ var request2 = _sendTestCompletionRequest('2', 0);
// Wait for all three.
- var validator0 = await response0.toResult();
- var validator1 = await response1.toResult();
- var validator2 = await response2.toResult();
+ var response0 = await request0.toResponse();
+ var response1 = await request1.toResponse();
+ var response2 = await request2.toResponse();
// The first two should be aborted.
expect(abortedIdSet, {'0', '1'});
- validator0
+ check(response0)
..assertIncomplete()
- ..suggestions.assertEmpty();
+ ..suggestions.isEmpty;
- validator1
+ check(response1)
..assertIncomplete()
- ..suggestions.assertEmpty();
+ ..suggestions.isEmpty;
- validator2
+ check(response2)
..assertComplete()
- ..suggestions.assertCompletionsContainsAll(
- ['int', 'double', 'Future', 'Directory'],
+ ..suggestions.containsMatch(
+ (suggestion) => suggestion.completion.isEqualTo('int'),
);
}
@@ -277,7 +278,7 @@
await _configureWithWorkspaceRoot();
// Schedule a completion request.
- var response = _sendTestCompletionRequest('0', 0);
+ var request = _sendTestCompletionRequest('0', 0);
// Simulate typing in the IDE.
await _handleSuccessfulRequest(
@@ -287,26 +288,26 @@
);
// The request should be aborted.
- var validator = await response.toResult();
+ var response = await request.toResponse();
expect(abortedIdSet, {'0'});
- validator
+ check(response)
..assertIncomplete()
- ..suggestions.assertEmpty();
+ ..suggestions.isEmpty;
}
Future<void> test_notImported_dart() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
void f() {
Rand^
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4)
+ ..hasReplacement(left: 4)
..assertLibrariesToImport(includes: [
'dart:math',
], excludes: [
@@ -315,11 +316,11 @@
'package:test/test.dart',
]);
- var classes = responseValidator.suggestions.withElementClass();
- classes.assertCompletions(['Random']);
- classes.withCompletion('Random').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('dart:math');
+ check(response).suggestions.withElementClass.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('Random')
+ ..libraryUriToImport.isEqualTo('dart:math'),
+ ]);
}
Future<void> test_notImported_emptyBudget() async {
@@ -328,21 +329,20 @@
// Empty budget, so no not yet imported libraries.
completionDomain.budgetDuration = const Duration(milliseconds: 0);
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
void f() {
Rand^
}
''');
- responseValidator
+ check(response)
..assertIncomplete()
- ..assertReplacementBack(4)
+ ..hasReplacement(left: 4)
..assertLibrariesToImport(includes: [], excludes: [
'dart:core',
'dart:math',
- ]);
-
- responseValidator.suggestions.withElementClass().assertEmpty();
+ ])
+ ..suggestions.withElementClass.isEmpty;
}
Future<void> test_notImported_pub_dependencies_inLib() async {
@@ -378,15 +378,15 @@
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
void f() {
A0^
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(2)
+ ..hasReplacement(left: 2)
..assertLibrariesToImport(includes: [
'package:aaa/f.dart',
], excludes: [
@@ -395,11 +395,11 @@
'package:test/test.dart',
]);
- var classes = responseValidator.suggestions.withElementClass();
- classes.assertCompletions(['A01']);
- classes.withCompletion('A01').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:aaa/f.dart');
+ check(response).suggestions.withElementClass.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A01')
+ ..libraryUriToImport.isEqualTo('package:aaa/f.dart'),
+ ]);
}
Future<void> test_notImported_pub_dependencies_inTest() async {
@@ -436,7 +436,7 @@
await _configureWithWorkspaceRoot();
var test_path = convertPath('$testPackageTestPath/test.dart');
- var responseValidator = await _getCodeSuggestions(
+ var response = await _getCodeSuggestions(
path: test_path,
content: '''
void f() {
@@ -445,9 +445,9 @@
''',
);
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(2)
+ ..hasReplacement(left: 2)
..assertLibrariesToImport(includes: [
'package:aaa/f.dart',
'package:bbb/f.dart',
@@ -456,14 +456,14 @@
'package:test/test.dart',
]);
- var classes = responseValidator.suggestions.withElementClass();
- classes.assertCompletions(['A01', 'A03']);
- classes.withCompletion('A01').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:aaa/f.dart');
- classes.withCompletion('A03').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:bbb/f.dart');
+ check(response).suggestions.withElementClass.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A01')
+ ..libraryUriToImport.isEqualTo('package:aaa/f.dart'),
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A03')
+ ..libraryUriToImport.isEqualTo('package:bbb/f.dart'),
+ ]);
}
Future<void> test_notImported_pub_this() async {
@@ -477,15 +477,15 @@
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
void f() {
A0^
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(2)
+ ..hasReplacement(left: 2)
..assertLibrariesToImport(includes: [
'package:test/a.dart',
'package:test/b.dart',
@@ -496,14 +496,14 @@
'package:test/test.dart',
]);
- var classes = responseValidator.suggestions.withElementClass();
- classes.assertCompletions(['A01', 'A02']);
- classes.withCompletion('A01').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:test/a.dart');
- classes.withCompletion('A02').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:test/b.dart');
+ check(response).suggestions.withElementClass.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A01')
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A02')
+ ..libraryUriToImport.isEqualTo('package:test/b.dart'),
+ ]);
}
Future<void> test_notImported_pub_this_hasImport() async {
@@ -518,7 +518,7 @@
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
import 'a.dart';
void f() {
@@ -526,9 +526,9 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(2)
+ ..hasReplacement(left: 2)
..assertLibrariesToImport(includes: [
'package:test/b.dart',
], excludes: [
@@ -539,17 +539,17 @@
'package:test/test.dart',
]);
- var classes = responseValidator.suggestions.withElementClass();
- classes.assertCompletions(['A01', 'A02', 'A03']);
- classes.withCompletion('A01').assertSingle()
- ..assertClass()
- ..assertLibraryToImport(isNull);
- classes.withCompletion('A02').assertSingle()
- ..assertClass()
- ..assertLibraryToImport(isNull);
- classes.withCompletion('A03').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:test/b.dart');
+ check(response).suggestions.withElementClass.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A01')
+ ..libraryUriToImport.isNull,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A02')
+ ..libraryUriToImport.isNull,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A03')
+ ..libraryUriToImport.isEqualTo('package:test/b.dart'),
+ ]);
}
Future<void> test_notImported_pub_this_hasImport_hasShow() async {
@@ -564,7 +564,7 @@
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
import 'a.dart' show A01;
void f() {
@@ -572,9 +572,9 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(2)
+ ..hasReplacement(left: 2)
..assertLibrariesToImport(includes: [
'package:test/a.dart',
'package:test/b.dart',
@@ -585,17 +585,17 @@
'package:test/test.dart',
]);
- var classes = responseValidator.suggestions.withElementClass();
- classes.assertCompletions(['A01', 'A02', 'A03']);
- classes.withCompletion('A01').assertSingle()
- ..assertClass()
- ..assertLibraryToImport(isNull);
- classes.withCompletion('A02').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:test/a.dart');
- classes.withCompletion('A03').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:test/b.dart');
+ check(response).suggestions.withElementClass.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A01')
+ ..libraryUriToImport.isNull,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A02')
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A03')
+ ..libraryUriToImport.isEqualTo('package:test/b.dart'),
+ ]);
}
Future<void> test_notImported_pub_this_inLib_excludesTest() async {
@@ -613,15 +613,15 @@
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
void f() {
A0^
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(2)
+ ..hasReplacement(left: 2)
..assertLibrariesToImport(includes: [
'package:test/a.dart',
], excludes: [
@@ -630,11 +630,11 @@
toUriStr(b.path),
]);
- var classes = responseValidator.suggestions.withElementClass();
- classes.assertCompletions(['A01']);
- classes.withCompletion('A01').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:test/a.dart');
+ check(response).suggestions.withElementClass.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A01')
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ ]);
}
Future<void> test_notImported_pub_this_inLib_includesThisSrc() async {
@@ -652,15 +652,15 @@
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
void f() {
A0^
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(2)
+ ..hasReplacement(left: 2)
..assertLibrariesToImport(includes: [
'package:test/f.dart',
'package:test/src/f.dart',
@@ -669,14 +669,14 @@
'package:test/test.dart',
]);
- var classes = responseValidator.suggestions.withElementClass();
- classes.assertCompletions(['A01', 'A02']);
- classes.withCompletion('A01').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:test/f.dart');
- classes.withCompletion('A02').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:test/src/f.dart');
+ check(response).suggestions.withElementClass.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A01')
+ ..libraryUriToImport.isEqualTo('package:test/f.dart'),
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A02')
+ ..libraryUriToImport.isEqualTo('package:test/src/f.dart'),
+ ]);
}
Future<void> test_notImported_pub_this_inTest_includesTest() async {
@@ -696,7 +696,7 @@
await _configureWithWorkspaceRoot();
var test_path = convertPath('$testPackageTestPath/test.dart');
- var responseValidator = await _getCodeSuggestions(
+ var response = await _getCodeSuggestions(
path: test_path,
content: '''
void f() {
@@ -705,9 +705,9 @@
''',
);
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(2)
+ ..hasReplacement(left: 2)
..assertLibrariesToImport(includes: [
'package:test/a.dart',
b_uriStr,
@@ -716,14 +716,14 @@
toUriStr(test_path),
]);
- var classes = responseValidator.suggestions.withElementClass();
- classes.assertCompletions(['A01', 'A02']);
- classes.withCompletion('A01').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:test/a.dart');
- classes.withCompletion('A02').assertSingle()
- ..assertClass()
- ..assertLibraryToImport(b_uriStr);
+ check(response).suggestions.withElementClass.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A01')
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A02')
+ ..libraryUriToImport.isEqualTo(b_uriStr),
+ ]);
}
Future<void> test_notImported_pub_this_inTest_includesThisSrc() async {
@@ -742,7 +742,7 @@
await _configureWithWorkspaceRoot();
var test_path = convertPath('$testPackageTestPath/test.dart');
- var responseValidator = await _getCodeSuggestions(
+ var response = await _getCodeSuggestions(
path: test_path,
content: '''
void f() {
@@ -751,9 +751,9 @@
''',
);
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(2)
+ ..hasReplacement(left: 2)
..assertLibrariesToImport(includes: [
'package:test/f.dart',
'package:test/src/f.dart',
@@ -762,20 +762,20 @@
'package:test/test.dart',
]);
- var classes = responseValidator.suggestions.withElementClass();
- classes.assertCompletions(['A01', 'A02']);
- classes.withCompletion('A01').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:test/f.dart');
- classes.withCompletion('A02').assertSingle()
- ..assertClass()
- ..assertLibraryToImport('package:test/src/f.dart');
+ check(response).suggestions.withElementClass.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A01')
+ ..libraryUriToImport.isEqualTo('package:test/f.dart'),
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A02')
+ ..libraryUriToImport.isEqualTo('package:test/src/f.dart'),
+ ]);
}
Future<void> test_numResults_class_methods() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
class A {
void foo01() {}
void foo02() {}
@@ -787,18 +787,24 @@
}
''', maxResults: 2);
- responseValidator
+ check(response)
..assertIncomplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isMethodInvocation,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isMethodInvocation,
+ ]);
}
Future<void> test_numResults_topLevelVariables() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
var foo01 = 0;
var foo02 = 0;
var foo03 = 0;
@@ -808,20 +814,18 @@
}
''', maxResults: 2);
- responseValidator
+ check(response)
..assertIncomplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
- suggestionsValidator
- .withCompletion('foo01')
- .assertSingle()
- .assertTopLevelVariable();
- suggestionsValidator
- .withCompletion('foo02')
- .assertSingle()
- .assertTopLevelVariable();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isTopLevelVariable,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isTopLevelVariable,
+ ]);
}
Future<void> test_numResults_topLevelVariables_imported_withPrefix() async {
@@ -833,7 +837,7 @@
var foo03 = 0;
''');
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
import 'a.dart' as prefix;
void f() {
@@ -841,18 +845,24 @@
}
''', maxResults: 2);
- responseValidator
+ check(response)
..assertIncomplete()
- ..assertEmptyReplacement();
+ ..hasEmptyReplacement();
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isTopLevelVariable,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isTopLevelVariable,
+ ]);
}
Future<void> test_prefixed_class_constructors() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
class A {
A.foo01();
A.foo02();
@@ -863,20 +873,24 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestions = responseValidator.suggestions;
- suggestions.assertCompletions(['foo01', 'foo02']);
- suggestions.withCompletion('foo01').assertSingle().assertConstructor();
- suggestions.withCompletion('foo02').assertSingle().assertConstructor();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isConstructorInvocation,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isConstructorInvocation,
+ ]);
}
Future<void> test_prefixed_class_getters() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
class A {
int get foo01 => 0;
int get foo02 => 0;
@@ -887,20 +901,24 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestions = responseValidator.suggestions;
- suggestions.assertCompletions(['foo01', 'foo02']);
- suggestions.withCompletion('foo01').assertSingle().assertGetter();
- suggestions.withCompletion('foo02').assertSingle().assertGetter();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isGetter,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isGetter,
+ ]);
}
Future<void> test_prefixed_class_methods_instance() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
class A {
void foo01() {}
void foo02() {}
@@ -911,20 +929,24 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestions = responseValidator.suggestions;
- suggestions.assertCompletions(['foo01', 'foo02']);
- suggestions.withCompletion('foo01').assertSingle().assertMethod();
- suggestions.withCompletion('foo02').assertSingle().assertMethod();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isMethodInvocation,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isMethodInvocation,
+ ]);
}
Future<void> test_prefixed_class_methods_static() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
class A {
static void foo01() {}
static void foo02() {}
@@ -935,20 +957,24 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestions = responseValidator.suggestions;
- suggestions.assertCompletions(['foo01', 'foo02']);
- suggestions.withCompletion('foo01').assertSingle().assertMethod();
- suggestions.withCompletion('foo02').assertSingle().assertMethod();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isMethodInvocation,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isMethodInvocation,
+ ]);
}
Future<void> test_prefixed_expression_extensionGetters() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
extension E1 on int {
int get foo01 => 0;
int get foo02 => 0;
@@ -964,15 +990,18 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
-
- suggestionsValidator.withCompletion('foo01').assertSingle().assertGetter();
- suggestionsValidator.withCompletion('foo02').assertSingle().assertGetter();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isGetter,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isGetter,
+ ]);
}
Future<void> test_prefixed_expression_extensionGetters_notImported() async {
@@ -993,25 +1022,26 @@
}
''');
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
void f() {
0.foo0^
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
-
- suggestionsValidator.withCompletion('foo01').assertSingle()
- ..assertGetter()
- ..assertLibraryToImport('package:test/a.dart');
- suggestionsValidator.withCompletion('foo02').assertSingle()
- ..assertGetter()
- ..assertLibraryToImport('package:test/a.dart');
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isGetter
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isGetter
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ ]);
}
Future<void>
@@ -1032,28 +1062,28 @@
}
''');
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
void f() {
0.foo0^
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01']);
-
- suggestionsValidator.withCompletion('foo01').assertSingle()
- ..assertGetter()
- ..assertLibraryToImport('package:test/a.dart');
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isGetter
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ ]);
}
Future<void> test_prefixed_expression_extensionMethods() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
extension E1 on int {
void foo01() {}
void foo02() {}
@@ -1069,15 +1099,18 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
-
- suggestionsValidator.withCompletion('foo01').assertSingle().assertMethod();
- suggestionsValidator.withCompletion('foo02').assertSingle().assertMethod();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isMethodInvocation,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isMethodInvocation,
+ ]);
}
Future<void> test_prefixed_expression_extensionMethods_notImported() async {
@@ -1098,31 +1131,32 @@
}
''');
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
void f() {
0.foo0^
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
-
- suggestionsValidator.withCompletion('foo01').assertSingle()
- ..assertMethod()
- ..assertLibraryToImport('package:test/a.dart');
- suggestionsValidator.withCompletion('foo02').assertSingle()
- ..assertMethod()
- ..assertLibraryToImport('package:test/a.dart');
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isMethodInvocation
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isMethodInvocation
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ ]);
}
Future<void> test_prefixed_expression_extensionSetters() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
extension E1 on int {
set foo01(int _) {}
set foo02(int _) {}
@@ -1138,15 +1172,18 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
-
- suggestionsValidator.withCompletion('foo01').assertSingle().assertSetter();
- suggestionsValidator.withCompletion('foo02').assertSingle().assertSetter();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isSetter,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isSetter,
+ ]);
}
Future<void> test_prefixed_expression_extensionSetters_notImported() async {
@@ -1167,25 +1204,26 @@
}
''');
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
void f() {
0.foo0^
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
-
- suggestionsValidator.withCompletion('foo01').assertSingle()
- ..assertSetter()
- ..assertLibraryToImport('package:test/a.dart');
- suggestionsValidator.withCompletion('foo02').assertSingle()
- ..assertSetter()
- ..assertLibraryToImport('package:test/a.dart');
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isSetter
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isSetter
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ ]);
}
Future<void>
@@ -1206,22 +1244,22 @@
}
''');
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
void f() {
0.foo0^
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01']);
-
- suggestionsValidator.withCompletion('foo01').assertSingle()
- ..assertSetter()
- ..assertLibraryToImport('package:test/a.dart');
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isSetter
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ ]);
}
Future<void> test_prefixed_extensionGetters_imported() async {
@@ -1239,7 +1277,7 @@
}
''');
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
import 'a.dart';
void f() {
@@ -1247,21 +1285,24 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
-
- suggestionsValidator.withCompletion('foo01').assertSingle().assertGetter();
- suggestionsValidator.withCompletion('foo02').assertSingle().assertGetter();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isGetter,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isGetter,
+ ]);
}
Future<void> test_prefixed_extensionOverride_extensionGetters() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
extension E1 on int {
int get foo01 => 0;
}
@@ -1275,19 +1316,21 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01']);
- suggestionsValidator.withCompletion('foo01').assertSingle().assertGetter();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isGetter,
+ ]);
}
Future<void> test_prefixed_extensionOverride_extensionMethods() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
extension E1 on int {
void foo01() {}
}
@@ -1301,19 +1344,21 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01']);
- suggestionsValidator.withCompletion('foo01').assertSingle().assertMethod();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isMethodInvocation,
+ ]);
}
Future<void> test_unprefixed_filters() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
var foo01 = 0;
var foo02 = 0;
var bar01 = 0;
@@ -1324,23 +1369,18 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
-
- suggestionsValidator
- .withCompletion('foo01')
- .assertSingle()
- .assertTopLevelVariable();
- suggestionsValidator
- .withCompletion('foo02')
- .assertSingle()
- .assertTopLevelVariable();
- suggestionsValidator.withCompletion('bar01').assertEmpty();
- suggestionsValidator.withCompletion('bar02').assertEmpty();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isTopLevelVariable,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isTopLevelVariable,
+ ]);
}
Future<void> test_unprefixed_imported_class() async {
@@ -1354,7 +1394,7 @@
class A02 {}
''');
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
import 'a.dart';
import 'b.dart';
@@ -1363,14 +1403,18 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(2);
+ ..hasReplacement(left: 2);
- var classes = responseValidator.suggestions.withElementClass();
- classes.assertCompletions(['A01', 'A02']);
- classes.withCompletion('A01').assertSingle().assertClass();
- classes.withCompletion('A02').assertSingle().assertClass();
+ check(response).suggestions.withElementClass.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A01')
+ ..isClass,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('A02')
+ ..isClass,
+ ]);
}
Future<void> test_unprefixed_imported_topLevelVariable() async {
@@ -1384,7 +1428,7 @@
var foo02 = 0;
''');
- var responseValidator = await _getTestCodeSuggestions('''
+ var response = await _getTestCodeSuggestions('''
import 'a.dart';
import 'b.dart';
@@ -1393,26 +1437,24 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
- suggestionsValidator.assertCompletions(['foo01', 'foo02']);
- suggestionsValidator
- .withCompletion('foo01')
- .assertSingle()
- .assertTopLevelVariable();
- suggestionsValidator
- .withCompletion('foo02')
- .assertSingle()
- .assertTopLevelVariable();
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isTopLevelVariable,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isTopLevelVariable,
+ ]);
}
Future<void> test_unprefixed_sorts_byScore() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
var fooAB = 0;
var fooBB = 0;
@@ -1421,19 +1463,25 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
// `fooBB` has better score than `fooAB` - prefix match
- suggestionsValidator.assertCompletions(['fooBB', 'fooAB']);
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('fooBB')
+ ..isTopLevelVariable,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('fooAB')
+ ..isTopLevelVariable,
+ ]);
}
Future<void> test_unprefixed_sorts_byType() async {
await _configureWithWorkspaceRoot();
- var responseValidator = await _getTestCodeSuggestions(r'''
+ var response = await _getTestCodeSuggestions(r'''
var foo01 = 0.0;
var foo02 = 0;
@@ -1442,34 +1490,44 @@
}
''');
- responseValidator
+ check(response)
..assertComplete()
- ..assertReplacementBack(4);
+ ..hasReplacement(left: 4);
- var suggestionsValidator = responseValidator.suggestions;
// `foo02` has better relevance, its type matches the context type
- suggestionsValidator.assertCompletions(['foo02', 'foo01']);
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isTopLevelVariable,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isTopLevelVariable,
+ ]);
}
Future<void> test_yaml_analysisOptions_root() async {
await _configureWithWorkspaceRoot();
var path = convertPath('$testPackageRootPath/analysis_options.yaml');
- var responseValidator = await _getCodeSuggestions(
+ var response = await _getCodeSuggestions(
path: path,
content: '^',
);
- responseValidator
+ check(response)
..assertComplete()
- ..assertEmptyReplacement();
+ ..hasEmptyReplacement();
- responseValidator.suggestions
- .withKindIdentifier()
- .assertCompletionsContainsAll([
- 'analyzer: ',
- 'include: ',
- 'linter: ',
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('analyzer: ')
+ ..kind.isIdentifier,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('include: ')
+ ..kind.isIdentifier,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('linter: ')
+ ..kind.isIdentifier,
]);
}
@@ -1477,20 +1535,22 @@
await _configureWithWorkspaceRoot();
var path = convertPath('$testPackageRootPath/fix_data.yaml');
- var responseValidator = await _getCodeSuggestions(
+ var response = await _getCodeSuggestions(
path: path,
content: '^',
);
- responseValidator
+ check(response)
..assertComplete()
- ..assertEmptyReplacement();
+ ..hasEmptyReplacement();
- responseValidator.suggestions
- .withKindIdentifier()
- .assertCompletionsContainsAll([
- 'version: ',
- 'transforms:',
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('version: ')
+ ..kind.isIdentifier,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('transforms:')
+ ..kind.isIdentifier,
]);
}
@@ -1498,25 +1558,29 @@
await _configureWithWorkspaceRoot();
var path = convertPath('$testPackageRootPath/pubspec.yaml');
- var responseValidator = await _getCodeSuggestions(
+ var response = await _getCodeSuggestions(
path: path,
content: '^',
);
- responseValidator
+ check(response)
..assertComplete()
- ..assertEmptyReplacement();
+ ..hasEmptyReplacement();
- responseValidator.suggestions
- .withKindIdentifier()
- .assertCompletionsContainsAll([
- 'name: ',
- 'dependencies: ',
- 'dev_dependencies: ',
+ check(response).suggestions.includesAll([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('name: ')
+ ..kind.isIdentifier,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('dependencies: ')
+ ..kind.isIdentifier,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('dev_dependencies: ')
+ ..kind.isIdentifier,
]);
}
- Future<CompletionGetSuggestions2ResponseValidator> _getCodeSuggestions({
+ Future<CompletionResponseForTesting> _getCodeSuggestions({
required String path,
required String content,
int maxResults = 1 << 10,
@@ -1538,7 +1602,7 @@
);
}
- Future<CompletionGetSuggestions2ResponseValidator> _getSuggestions({
+ Future<CompletionResponseForTesting> _getSuggestions({
required String path,
required int completionOffset,
required int maxResults,
@@ -1551,13 +1615,20 @@
var response = await _handleSuccessfulRequest(request);
var result = CompletionGetSuggestions2Result.fromResponse(response);
- return CompletionGetSuggestions2ResponseValidator(completionOffset, result);
+ return CompletionResponseForTesting(
+ requestOffset: completionOffset,
+ replacementOffset: result.replacementOffset,
+ replacementLength: result.replacementLength,
+ isIncomplete: result.isIncomplete,
+ librariesToImport: result.libraryUrisToImport,
+ suggestions: result.suggestions,
+ );
}
- Future<CompletionGetSuggestions2ResponseValidator> _getTestCodeSuggestions(
+ Future<CompletionResponseForTesting> _getTestCodeSuggestions(
String content, {
int maxResults = 1 << 10,
- }) async {
+ }) {
return _getCodeSuggestions(
path: convertPath(testFilePath),
content: content,
@@ -2474,45 +2545,16 @@
this.result,
);
- SuggestionsValidator get suggestions {
- return SuggestionsValidator(
- result.suggestions,
- libraryUrisToImport: result.libraryUrisToImport,
+ CompletionResponseForTesting get asResponse {
+ return CompletionResponseForTesting(
+ requestOffset: completionOffset,
+ replacementOffset: result.replacementOffset,
+ replacementLength: result.replacementLength,
+ isIncomplete: result.isIncomplete,
+ librariesToImport: result.libraryUrisToImport,
+ suggestions: result.suggestions,
);
}
-
- void assertComplete() {
- expect(result.isIncomplete, isFalse);
- }
-
- void assertEmptyReplacement() {
- assertReplacement(completionOffset, 0);
- }
-
- void assertIncomplete() {
- expect(result.isIncomplete, isTrue);
- }
-
- void assertLibrariesToImport({
- required List<String> includes,
- List<String>? excludes,
- }) {
- expect(result.libraryUrisToImport, containsAll(includes));
- if (excludes != null) {
- for (var exclude in excludes) {
- expect(result.libraryUrisToImport, isNot(contains(exclude)));
- }
- }
- }
-
- void assertReplacement(int offset, int length) {
- expect(result.replacementOffset, offset);
- expect(result.replacementLength, length);
- }
-
- void assertReplacementBack(int length) {
- assertReplacement(completionOffset - length, length);
- }
}
class PubPackageAnalysisServerTest with ResourceProviderMixin {
@@ -2635,150 +2677,19 @@
RequestWithFutureResponse(this.offset, this.request, this.futureResponse);
- Future<CompletionGetSuggestions2ResponseValidator> toResult() async {
+ Future<CompletionResponseForTesting> toResponse() async {
var response = await futureResponse;
expect(response, isResponseSuccess(request.id));
var result = CompletionGetSuggestions2Result.fromResponse(response);
- return CompletionGetSuggestions2ResponseValidator(offset, result);
- }
-}
-
-class SingleSuggestionValidator {
- final CompletionSuggestion suggestion;
- final List<String>? libraryUrisToImport;
-
- SingleSuggestionValidator(
- this.suggestion, {
- this.libraryUrisToImport,
- });
-
- void assertClass() {
- expect(suggestion.kind, CompletionSuggestionKind.IDENTIFIER);
- expect(suggestion.element?.kind, ElementKind.CLASS);
- }
-
- void assertConstructor() {
- expect(suggestion.kind, CompletionSuggestionKind.INVOCATION);
- expect(suggestion.element?.kind, ElementKind.CONSTRUCTOR);
- }
-
- void assertGetter() {
- expect(suggestion.kind, CompletionSuggestionKind.IDENTIFIER);
- expect(suggestion.element?.kind, ElementKind.GETTER);
- }
-
- void assertLibraryToImport(Object matcher) {
- final libraryUrisToImport = this.libraryUrisToImport;
- final index = suggestion.libraryUriToImportIndex;
- var libraryUri = libraryUrisToImport != null && index != null
- ? libraryUrisToImport[index]
- : null;
- expect(libraryUri, matcher);
- }
-
- void assertMethod() {
- expect(suggestion.kind, CompletionSuggestionKind.INVOCATION);
- expect(suggestion.element?.kind, ElementKind.METHOD);
- }
-
- void assertSetter() {
- expect(suggestion.kind, CompletionSuggestionKind.IDENTIFIER);
- expect(suggestion.element?.kind, ElementKind.SETTER);
- }
-
- void assertTopLevelVariable() {
- expect(suggestion.kind, CompletionSuggestionKind.IDENTIFIER);
- expect(suggestion.element?.kind, ElementKind.TOP_LEVEL_VARIABLE);
- }
-}
-
-class SuggestionsValidator {
- final List<CompletionSuggestion> suggestions;
- final List<String>? libraryUrisToImport;
-
- SuggestionsValidator(
- this.suggestions, {
- this.libraryUrisToImport,
- });
-
- int get length => suggestions.length;
-
- /// Assert that this has suggestions with exactly the given completions,
- /// with the exact order.
- ///
- /// Does not check suggestion kinds, elements, etc.
- void assertCompletions(Iterable<String> completions) {
- var actual = suggestions.map((e) => e.completion).toList();
- expect(actual, completions);
- }
-
- /// Assert that this has suggestions with all [expected] completions.
- /// There might be more suggestions, with other completions.
- ///
- /// Does not check the order, kinds, elements, etc.
- void assertCompletionsContainsAll(Iterable<String> expected) {
- var actual = suggestions.map((e) => e.completion).toSet();
- expect(actual, containsAll(expected));
- }
-
- void assertEmpty() {
- check(suggestions).isEmpty;
- }
-
- void assertLength(Object matcher) {
- expect(suggestions, hasLength(matcher));
- }
-
- SingleSuggestionValidator assertSingle() {
- assertLength(1);
- return SingleSuggestionValidator(
- suggestions.single,
- libraryUrisToImport: libraryUrisToImport,
+ return CompletionResponseForTesting(
+ requestOffset: offset,
+ replacementOffset: result.replacementOffset,
+ replacementLength: result.replacementLength,
+ isIncomplete: result.isIncomplete,
+ librariesToImport: result.libraryUrisToImport,
+ suggestions: result.suggestions,
);
}
-
- SuggestionsValidator withCompletion(String completion) {
- return SuggestionsValidator(
- suggestions.where((suggestion) {
- return suggestion.completion == completion;
- }).toList(),
- libraryUrisToImport: libraryUrisToImport,
- );
- }
-
- SuggestionsValidator withElementClass() {
- return withElementKind(ElementKind.CLASS);
- }
-
- SuggestionsValidator withElementConstructor() {
- return withElementKind(ElementKind.CONSTRUCTOR);
- }
-
- SuggestionsValidator withElementGetter() {
- return withElementKind(ElementKind.GETTER);
- }
-
- SuggestionsValidator withElementKind(ElementKind kind) {
- return SuggestionsValidator(
- suggestions.where((suggestion) {
- return suggestion.element?.kind == kind;
- }).toList(),
- libraryUrisToImport: libraryUrisToImport,
- );
- }
-
- SuggestionsValidator withKind(CompletionSuggestionKind kind) {
- return SuggestionsValidator(
- suggestions.where((suggestion) {
- return suggestion.kind == kind;
- }).toList(),
- libraryUrisToImport: libraryUrisToImport,
- );
- }
-
- SuggestionsValidator withKindIdentifier() {
- return withKind(CompletionSuggestionKind.IDENTIFIER);
- }
}
extension on CheckTarget<CompletionGetSuggestionDetails2Result> {
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_check.dart b/pkg/analysis_server/test/services/completion/dart/completion_check.dart
index 4c15bd2..3e6c785 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_check.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_check.dart
@@ -9,12 +9,16 @@
final int requestOffset;
final int replacementOffset;
final int replacementLength;
+ final bool isIncomplete;
+ final List<String> librariesToImport;
final List<CompletionSuggestion> suggestions;
CompletionResponseForTesting({
required this.requestOffset,
required this.replacementOffset,
required this.replacementLength,
+ required this.isIncomplete,
+ required this.librariesToImport,
required this.suggestions,
});
@@ -26,6 +30,8 @@
requestOffset: requestOffset,
replacementOffset: parameters.replacementOffset,
replacementLength: parameters.replacementLength,
+ isIncomplete: false,
+ librariesToImport: const [],
suggestions: parameters.results,
);
}
@@ -55,6 +61,20 @@
extension CompletionResponseExtension
on CheckTarget<CompletionResponseForTesting> {
+ CheckTarget<bool> get isIncomplete {
+ return nest(
+ value.isIncomplete,
+ (selected) => 'has isIncomplete ${valueStr(selected)}',
+ );
+ }
+
+ CheckTarget<List<String>> get librariesToImport {
+ return nest(
+ value.librariesToImport,
+ (selected) => 'has librariesToImport ${valueStr(selected)}',
+ );
+ }
+
CheckTarget<int> get replacementLength {
return nest(
value.replacementLength,
@@ -82,6 +102,32 @@
);
}
+ void assertComplete() {
+ isIncomplete.isFalse;
+ }
+
+ void assertIncomplete() {
+ isIncomplete.isTrue;
+ }
+
+ void assertLibrariesToImport({
+ required List<String> includes,
+ List<String>? excludes,
+ }) {
+ librariesToImport.includesAll(
+ includes.map(
+ (e) => (v) => v.isEqualTo(e),
+ ),
+ );
+ if (excludes != null) {
+ librariesToImport.excludesAll(
+ excludes.map(
+ (e) => (v) => v.isEqualTo(e),
+ ),
+ );
+ }
+ }
+
/// Check that the replacement offset is the completion request offset,
/// and the length of the replacement is zero.
void hasEmptyReplacement() {
@@ -140,16 +186,46 @@
);
}
+ void get isClass {
+ kind.isIdentifier;
+ element.isNotNull.kind.isClass;
+ }
+
+ void get isConstructorInvocation {
+ kind.isInvocation;
+ element.isNotNull.kind.isConstructor;
+ }
+
void get isField {
kind.isIdentifier;
element.isNotNull.kind.isField;
}
+ void get isGetter {
+ kind.isIdentifier;
+ element.isNotNull.kind.isGetter;
+ }
+
+ void get isMethodInvocation {
+ kind.isInvocation;
+ element.isNotNull.kind.isMethod;
+ }
+
void get isParameter {
kind.isIdentifier;
element.isNotNull.kind.isParameter;
}
+ void get isSetter {
+ kind.isIdentifier;
+ element.isNotNull.kind.isSetter;
+ }
+
+ void get isTopLevelVariable {
+ kind.isIdentifier;
+ element.isNotNull.kind.isTopLevelVariable;
+ }
+
CheckTarget<CompletionSuggestionKind> get kind {
return nest(
value.suggestion.kind,
@@ -157,6 +233,14 @@
);
}
+ CheckTarget<String?> get libraryUriToImport {
+ var index = value.suggestion.libraryUriToImportIndex;
+ return nest(
+ index != null ? value.response.librariesToImport[index] : null,
+ (selected) => 'has libraryUriToImport ${valueStr(selected)}',
+ );
+ }
+
CheckTarget<String?> get parameterType {
return nest(
value.suggestion.parameterType,
@@ -225,6 +309,29 @@
void get isIdentifier {
isEqualTo(CompletionSuggestionKind.IDENTIFIER);
}
+
+ void get isInvocation {
+ isEqualTo(CompletionSuggestionKind.INVOCATION);
+ }
+}
+
+extension CompletionSuggestionListExtension
+ on CheckTarget<List<CompletionSuggestionForTesting>> {
+ CheckTarget<Iterable<String>> get completions {
+ return nest(
+ value.map((e) => e.suggestion.completion).toList(),
+ (selected) => 'has completions ${valueStr(selected)}',
+ );
+ }
+
+ CheckTarget<Iterable<CompletionSuggestionForTesting>> get withElementClass {
+ return nest(
+ value.where((e) {
+ return e.suggestion.element?.kind == ElementKind.CLASS;
+ }).toList(),
+ (selected) => 'withElementClass ${valueStr(selected)}',
+ );
+ }
}
extension CompletionSuggestionsExtension
@@ -266,11 +373,35 @@
}
extension ElementKindExtension on CheckTarget<ElementKind> {
+ void get isClass {
+ isEqualTo(ElementKind.CLASS);
+ }
+
+ void get isConstructor {
+ isEqualTo(ElementKind.CONSTRUCTOR);
+ }
+
void get isField {
isEqualTo(ElementKind.FIELD);
}
+ void get isGetter {
+ isEqualTo(ElementKind.GETTER);
+ }
+
+ void get isMethod {
+ isEqualTo(ElementKind.METHOD);
+ }
+
void get isParameter {
isEqualTo(ElementKind.PARAMETER);
}
+
+ void get isSetter {
+ isEqualTo(ElementKind.SETTER);
+ }
+
+ void get isTopLevelVariable {
+ isEqualTo(ElementKind.TOP_LEVEL_VARIABLE);
+ }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
index a750956..bcf730f 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
@@ -582,6 +582,8 @@
requestOffset: completionOffset,
replacementOffset: replacementOffset,
replacementLength: replacementLength,
+ isIncomplete: false,
+ librariesToImport: const [],
suggestions: suggestions,
);
}
diff --git a/pkg/analyzer_utilities/lib/check/iterable.dart b/pkg/analyzer_utilities/lib/check/iterable.dart
index 5b43453..547643b 100644
--- a/pkg/analyzer_utilities/lib/check/iterable.dart
+++ b/pkg/analyzer_utilities/lib/check/iterable.dart
@@ -41,6 +41,34 @@
fail('Does not contain at least one element that matches');
}
+ /// Fails if for any matcher there is an element that matches.
+ void excludesAll(
+ Iterable<void Function(CheckTarget<T> element)> matchers,
+ ) {
+ var elementList = value.toList();
+ var matcherList = matchers.toList();
+ var included = <int>[];
+ for (var i = 0; i < matcherList.length; i++) {
+ var matcher = matcherList[i];
+ for (var element in elementList) {
+ var elementTarget = nest(
+ element,
+ (element) => 'element ${valueStr(element)}',
+ );
+ try {
+ matcher(elementTarget);
+ included.add(i);
+ break;
+ } on test_package.TestFailure {
+ // ignore
+ }
+ }
+ }
+ if (included.isNotEmpty) {
+ fail('Unexpectedly includes matchers at ${valueStr(included)}');
+ }
+ }
+
@UseResult.unless(parameterDefined: 'expected')
CheckTarget<int> hasLength([int? expected]) {
var actual = value.length;
@@ -52,6 +80,61 @@
return nest(actual, (length) => 'has length $length');
}
+ /// Succeeds if for each matcher in [matchers] there is at least one
+ /// matching element.
+ void includesAll(
+ Iterable<void Function(CheckTarget<T> element)> matchers,
+ ) {
+ var elementList = value.toList();
+ var matcherList = matchers.toList();
+ var notIncluded = <int>[];
+ for (var i = 0; i < matcherList.length; i++) {
+ var matcher = matcherList[i];
+ notIncluded.add(i);
+ for (var element in elementList) {
+ var elementTarget = nest(
+ element,
+ (element) => 'element ${valueStr(element)}',
+ );
+ try {
+ matcher(elementTarget);
+ notIncluded.removeLast();
+ break;
+ } on test_package.TestFailure {
+ // ignore
+ }
+ }
+ }
+ if (notIncluded.isNotEmpty) {
+ fail('Does not include matchers at ${valueStr(notIncluded)}');
+ }
+ }
+
+ /// Succeeds if the number of [matchers] is exactly the same as the number
+ /// of elements in [value], and each matcher matches the element at the
+ /// corresponding index.
+ void matches(
+ Iterable<void Function(CheckTarget<T> element)> matchers,
+ ) {
+ var elementList = value.toList();
+ var matcherList = matchers.toList();
+ if (elementList.length != matcherList.length) {
+ fail('Expected ${valueStr(matcherList.length)} elements, '
+ 'actually ${valueStr(elementList.length)}');
+ }
+
+ for (var index = 0; index < matcherList.length; index++) {
+ var element = elementList[index];
+ var matcher = matcherList[index];
+ matcher(
+ nest(
+ element,
+ (element) => 'element ${valueStr(element)} at ${valueStr(index)}',
+ ),
+ );
+ }
+ }
+
/// Succeeds if the number of [matchers] is exactly the same as the number
/// of elements in [value], and for each matcher there is exactly one element
/// that matches.
diff --git a/pkg/analyzer_utilities/test/check/check_test.dart b/pkg/analyzer_utilities/test/check/check_test.dart
index 20873c0..4e77441 100644
--- a/pkg/analyzer_utilities/test/check/check_test.dart
+++ b/pkg/analyzer_utilities/test/check/check_test.dart
@@ -68,6 +68,33 @@
_fails(() => check(<int>[]).containsMatch((e) => e.isZero));
_fails(() => check(<int>[1]).containsMatch((e) => e.isZero));
});
+ test('excludesAll', () {
+ check(<int>[]).excludesAll([
+ (e) => e.isEqualTo(0),
+ ]);
+ check([1]).excludesAll([
+ (e) => e.isEqualTo(0),
+ (e) => e.isEqualTo(2),
+ ]);
+ // Fails if any match.
+ _fails(() {
+ check(<int>[0]).excludesAll([
+ (e) => e.isEqualTo(0),
+ ]);
+ });
+ _fails(() {
+ check(<int>[0]).excludesAll([
+ (e) => e.isZero,
+ ]);
+ });
+ _fails(() {
+ check(<int>[0]).excludesAll([
+ (e) => e.isEqualTo(2),
+ (e) => e.isEqualTo(1),
+ (e) => e.isEqualTo(0),
+ ]);
+ });
+ });
test('hasLength', () {
check(<int>[]).hasLength().isZero;
check(<int>[0]).hasLength().isEqualTo(1);
@@ -86,6 +113,36 @@
_fails(() => check(<int>[]).hasLength().isEqualTo(1));
_fails(() => check(<int>[0]).hasLength().isEqualTo(0));
});
+ test('includesAll', () {
+ // Extra elements are OK.
+ check([0, 1, 2]).includesAll([
+ (e) => e.isEqualTo(0),
+ (e) => e.isEqualTo(1),
+ ]);
+ // Order does not matter.
+ check([0, 1, 2]).includesAll([
+ (e) => e.isEqualTo(1),
+ (e) => e.isEqualTo(0),
+ ]);
+ // Must have all elements.
+ _fails(() {
+ check(<int>[]).includesAll([
+ (e) => e.isEqualTo(0),
+ ]);
+ });
+ _fails(() {
+ check([0]).includesAll([
+ (e) => e.isEqualTo(0),
+ (e) => e.isEqualTo(1),
+ ]);
+ });
+ _fails(() {
+ check([1]).includesAll([
+ (e) => e.isEqualTo(0),
+ (e) => e.isEqualTo(1),
+ ]);
+ });
+ });
test('isEmpty', () {
check(<int>[]).isEmpty;
check(<int>{}).isEmpty;
@@ -102,6 +159,36 @@
_fails(() => check(<int>[]).isNotEmpty);
_fails(() => check(<int>{}).isNotEmpty);
});
+ test('matches', () {
+ check(<int>[]).matches([]);
+ check(<int>[0]).matches([
+ (e) => e.isEqualTo(0),
+ ]);
+ check(<int>[0, 1]).matches([
+ (e) => e.isEqualTo(0),
+ (e) => e.isEqualTo(1),
+ ]);
+ // Order is important.
+ _fails(
+ () => check([0, 1]).matches([
+ (e) => e.isEqualTo(1),
+ (e) => e.isEqualTo(0),
+ ]),
+ );
+ // Too few matchers.
+ _fails(
+ () => check([0, 1]).matches([
+ (e) => e.isEqualTo(0),
+ ]),
+ );
+ // Too many matchers.
+ _fails(
+ () => check([0]).matches([
+ (e) => e.isEqualTo(0),
+ (e) => e.isEqualTo(1),
+ ]),
+ );
+ });
test('matchesInAnyOrder', () {
// Order does not matter.
check([0, 1]).matchesInAnyOrder([
diff --git a/pkg/compiler/lib/src/apiimpl.dart b/pkg/compiler/lib/src/apiimpl.dart
index 2b0ad7d..ed1087c 100644
--- a/pkg/compiler/lib/src/apiimpl.dart
+++ b/pkg/compiler/lib/src/apiimpl.dart
@@ -5,10 +5,6 @@
library leg_apiimpl;
import 'dart:async';
-import 'dart:convert' show utf8;
-
-import 'package:front_end/src/api_unstable/dart2js.dart'
- show getSupportedLibraryNames;
import '../compiler_new.dart' as api;
import 'common/metrics.dart' show Metrics, Metric;
@@ -17,7 +13,6 @@
import 'compiler.dart';
import 'diagnostics/messages.dart' show Message;
import 'environment.dart';
-import 'io/source_file.dart';
import 'options.dart' show CompilerOptions;
/// Implements the [Compiler] using a [api.CompilerInput] for supplying the
@@ -58,61 +53,22 @@
null, null, null, null, message, api.Diagnostic.VERBOSE_INFO);
}
- Future setupSdk() {
- var future = Future.value(null);
- _Environment env = environment;
- if (env.supportedLibraries == null) {
- future = future.then((_) {
- Uri specificationUri = options.librariesSpecificationUri;
-
- Future<String> readJson(Uri uri) async {
- api.Input spec = await provider.readFromUri(specificationUri);
- String json = null;
- // TODO(sigmund): simplify this, we have some API inconsistencies when
- // our internal input adds a terminating zero.
- if (spec is SourceFile) {
- json = spec.slowText();
- } else if (spec is Binary) {
- json = utf8.decode(spec.data);
- }
- return json;
- }
-
- // TODO(sigmund): would be nice to front-load some of the CFE option
- // processing and parse this .json file only once.
- return getSupportedLibraryNames(specificationUri,
- options.compileForServer ? "dart2js_server" : "dart2js",
- readJson: readJson)
- .then((libraries) {
- env.supportedLibraries = libraries.toSet();
- });
- });
- }
- // TODO(johnniwinther): This does not apply anymore.
- // The incremental compiler sets up the sdk before run.
- // Therefore this will be called a second time.
- return future;
- }
-
@override
Future<bool> run() {
Duration setupDuration = measurer.elapsedWallClock;
- return selfTask.measureSubtask("impl.run", () {
- return setupSdk().then((_) {
- return super.run();
- }).then((bool success) {
- if (options.verbose) {
- StringBuffer timings = StringBuffer();
- computeTimings(setupDuration, timings);
- logVerbose('$timings');
- }
- if (options.reportPrimaryMetrics || options.reportSecondaryMetrics) {
- StringBuffer metrics = StringBuffer();
- collectMetrics(metrics);
- logInfo('$metrics');
- }
- return success;
- });
+ return selfTask.measureSubtask("impl.run", () async {
+ bool success = await super.run();
+ if (options.verbose) {
+ StringBuffer timings = StringBuffer();
+ computeTimings(setupDuration, timings);
+ logVerbose('$timings');
+ }
+ if (options.reportPrimaryMetrics || options.reportSecondaryMetrics) {
+ StringBuffer metrics = StringBuffer();
+ collectMetrics(metrics);
+ logInfo('$metrics');
+ }
+ return success;
});
}
@@ -239,50 +195,18 @@
class _Environment implements Environment {
final Map<String, String> definitions;
Map<String, String> _completeMap;
- Set<String> supportedLibraries;
_Environment(this.definitions);
@override
- String valueOf(String name) {
- if (_completeMap != null) return _completeMap[name];
- var result = definitions[name];
- if (result != null || definitions.containsKey(name)) return result;
- if (!name.startsWith(_dartLibraryEnvironmentPrefix)) return null;
-
- String libraryName = name.substring(_dartLibraryEnvironmentPrefix.length);
-
- // Private libraries are not exposed to the users.
- if (libraryName.startsWith("_")) return null;
- if (supportedLibraries.contains(libraryName)) return "true";
- return null;
- }
-
- @override
Map<String, String> toMap() {
if (_completeMap == null) {
_completeMap = Map<String, String>.from(definitions);
- for (String libraryName in supportedLibraries) {
- if (!libraryName.startsWith("_")) {
- String key = '${_dartLibraryEnvironmentPrefix}${libraryName}';
- if (!definitions.containsKey(key)) {
- _completeMap[key] = "true";
- }
- }
- }
}
return _completeMap;
}
}
-/// For every 'dart:' library, a corresponding environment variable is set
-/// to "true". The environment variable's name is the concatenation of
-/// this prefix and the name (without the 'dart:'.
-///
-/// For example 'dart:html' has the environment variable 'dart.library.html' set
-/// to "true".
-const String _dartLibraryEnvironmentPrefix = 'dart.library.';
-
class _TimingData {
final String description;
final int milliseconds;
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index dad3d720..35d9f52 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -1087,9 +1087,6 @@
const _EmptyEnvironment();
@override
- String valueOf(String key) => null;
-
- @override
Map<String, String> toMap() => const {};
}
diff --git a/pkg/compiler/lib/src/environment.dart b/pkg/compiler/lib/src/environment.dart
index 67db9ac..efc2bb0 100644
--- a/pkg/compiler/lib/src/environment.dart
+++ b/pkg/compiler/lib/src/environment.dart
@@ -8,12 +8,6 @@
/// conditional imports, and from `const String.fromEnvironment` and
/// other similar constructors.
abstract class Environment {
- /// Return the string value of the given key.
- ///
- /// Note that `bool.fromEnvironment` and `int.fromEnvironment` are also
- /// implemented in terms of `String.fromEnvironment`.
- String valueOf(String key);
-
/// Returns the full environment as map.
Map<String, String> toMap();
}
diff --git a/pkg/compiler/lib/src/ir/constants.dart b/pkg/compiler/lib/src/ir/constants.dart
index 6994046..d95ffb2 100644
--- a/pkg/compiler/lib/src/ir/constants.dart
+++ b/pkg/compiler/lib/src/ir/constants.dart
@@ -2,11 +2,11 @@
// 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:front_end/src/api_prototype/constant_evaluator.dart' as ir;
+import 'package:front_end/src/api_unstable/dart2js.dart' as ir;
import 'package:kernel/ast.dart' as ir;
import 'package:kernel/src/printer.dart' as ir;
import 'package:kernel/type_environment.dart' as ir;
-import 'package:front_end/src/api_prototype/constant_evaluator.dart' as ir;
-import 'package:front_end/src/api_unstable/dart2js.dart' as ir;
import '../kernel/dart2js_target.dart';
@@ -18,7 +18,7 @@
bool requiresConstant;
- Dart2jsConstantEvaluator(
+ Dart2jsConstantEvaluator(ir.Component component,
ir.TypeEnvironment typeEnvironment, ReportErrorFunction reportError,
{Map<String, String> environment = const {},
bool supportReevaluationForTesting = false,
@@ -26,7 +26,9 @@
: _supportReevaluationForTesting = supportReevaluationForTesting,
assert(evaluationMode != null),
super(
+ const Dart2jsDartLibrarySupport(),
const Dart2jsConstantsBackend(supportsUnevaluatedConstants: false),
+ component,
environment,
typeEnvironment,
ErrorReporter(reportError),
diff --git a/pkg/compiler/lib/src/js_model/element_map_impl.dart b/pkg/compiler/lib/src/js_model/element_map_impl.dart
index 3bb766f..ae9a0a0 100644
--- a/pkg/compiler/lib/src/js_model/element_map_impl.dart
+++ b/pkg/compiler/lib/src/js_model/element_map_impl.dart
@@ -1164,14 +1164,15 @@
}
Dart2jsConstantEvaluator get constantEvaluator {
- return _constantEvaluator ??= Dart2jsConstantEvaluator(typeEnvironment,
- (ir.LocatedMessage message, List<ir.LocatedMessage> context) {
+ return _constantEvaluator ??=
+ Dart2jsConstantEvaluator(programEnv.mainComponent, typeEnvironment,
+ (ir.LocatedMessage message, List<ir.LocatedMessage> context) {
reportLocatedMessage(reporter, message, context);
},
- environment: _environment.toMap(),
- evaluationMode: options.useLegacySubtyping
- ? ir.EvaluationMode.weak
- : ir.EvaluationMode.strong);
+ environment: _environment.toMap(),
+ evaluationMode: options.useLegacySubtyping
+ ? ir.EvaluationMode.weak
+ : ir.EvaluationMode.strong);
}
@override
diff --git a/pkg/compiler/lib/src/kernel/dart2js_target.dart b/pkg/compiler/lib/src/kernel/dart2js_target.dart
index 01f42be..156e7a4 100644
--- a/pkg/compiler/lib/src/kernel/dart2js_target.dart
+++ b/pkg/compiler/lib/src/kernel/dart2js_target.dart
@@ -221,6 +221,10 @@
@override
ConstantsBackend get constantsBackend =>
const Dart2jsConstantsBackend(supportsUnevaluatedConstants: true);
+
+ @override
+ DartLibrarySupport get dartLibrarySupport =>
+ const Dart2jsDartLibrarySupport();
}
// TODO(sigmund): this "extraRequiredLibraries" needs to be removed...
@@ -314,3 +318,8 @@
@override
NumberSemantics get numberSemantics => NumberSemantics.js;
}
+
+class Dart2jsDartLibrarySupport extends CustomizedDartLibrarySupport {
+ const Dart2jsDartLibrarySupport()
+ : super(supported: const {'_dart2js_runtime_metrics'});
+}
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart
index f82c5ef..b4a93af 100644
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart
@@ -812,14 +812,15 @@
}
Dart2jsConstantEvaluator get constantEvaluator {
- return _constantEvaluator ??= Dart2jsConstantEvaluator(typeEnvironment,
- (ir.LocatedMessage message, List<ir.LocatedMessage> context) {
+ return _constantEvaluator ??=
+ Dart2jsConstantEvaluator(env.mainComponent, typeEnvironment,
+ (ir.LocatedMessage message, List<ir.LocatedMessage> context) {
reportLocatedMessage(reporter, message, context);
},
- environment: _environment.toMap(),
- evaluationMode: options.useLegacySubtyping
- ? ir.EvaluationMode.weak
- : ir.EvaluationMode.strong);
+ environment: _environment.toMap(),
+ evaluationMode: options.useLegacySubtyping
+ ? ir.EvaluationMode.weak
+ : ir.EvaluationMode.strong);
}
@override
diff --git a/pkg/compiler/test/analyses/analysis_helper.dart b/pkg/compiler/test/analyses/analysis_helper.dart
index 559d972..b104a00 100644
--- a/pkg/compiler/test/analyses/analysis_helper.dart
+++ b/pkg/compiler/test/analyses/analysis_helper.dart
@@ -86,7 +86,7 @@
classHierarchy,
new StaticTypeCacheImpl()) {
_constantEvaluator = new Dart2jsConstantEvaluator(
- typeEnvironment, const ir.SimpleErrorReporter().report,
+ component, typeEnvironment, const ir.SimpleErrorReporter().report,
evaluationMode: evaluationMode);
}
diff --git a/pkg/compiler/test/end_to_end/dill_loader_test.dart b/pkg/compiler/test/end_to_end/dill_loader_test.dart
index 7bf0330..46626f4 100644
--- a/pkg/compiler/test/end_to_end/dill_loader_test.dart
+++ b/pkg/compiler/test/end_to_end/dill_loader_test.dart
@@ -43,7 +43,6 @@
memorySourceFiles: {'main.dill': kernelBinary},
diagnosticHandler: diagnostics,
outputProvider: output);
- await compiler.setupSdk();
KernelResult result = await compiler.kernelLoader.load();
compiler.frontendStrategy.registerLoadedLibraries(result);
diff --git a/pkg/compiler/test/end_to_end/library_env_test.dart b/pkg/compiler/test/end_to_end/library_env_test.dart
deleted file mode 100644
index f194f37..0000000
--- a/pkg/compiler/test/end_to_end/library_env_test.dart
+++ /dev/null
@@ -1,146 +0,0 @@
-// Copyright (c) 2016, 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.
-
-// @dart = 2.7
-
-/// Check that 'dart:' libraries have their corresponding dart.library.X
-/// environment variable set.
-
-import 'dart:async';
-
-import '../helpers/memory_compiler.dart';
-import '../helpers/memory_source_file_helper.dart';
-
-import "package:async_helper/async_helper.dart";
-
-import 'package:expect/expect.dart' show Expect;
-
-import 'package:compiler/src/null_compiler_output.dart' show NullCompilerOutput;
-
-import 'package:compiler/src/options.dart' show CompilerOptions;
-
-import 'package:compiler/src/commandline_options.dart';
-
-import 'package:compiler/src/io/source_file.dart' show Binary;
-
-import 'package:compiler/compiler_new.dart'
- show CompilerInput, CompilerDiagnostics, Input, InputKind;
-
-const String librariesJson = r'''
-{
- "dart2js": {
- "libraries": {
- "mock.client": {"uri": "mock1.dart"},
- "mock.shared": {"uri": "mock3.dart"},
- "collection": {"uri": "collection/collection.dart"},
- "html": {"uri": "html/dart2js/html_dart2js.dart"}
- }
- },
- "dart2js_server": {
- "libraries": {
- "mock.server": {"uri": "mock2.dart"},
- "mock.shared": {"uri": "mock3.dart"},
- "collection": {"uri": "collection/collection.dart"},
- "io": {"uri": "io/io.dart"}
- }
- }
-}
-''';
-
-class DummyCompilerInput implements CompilerInput {
- const DummyCompilerInput();
-
- @override
- Future<Input> readFromUri(Uri uri,
- {InputKind inputKind: InputKind.UTF8}) async {
- if (uri.path.endsWith("libraries.json")) {
- return new Binary(uri, librariesJson.codeUnits);
- } else {
- throw "should not be needed $uri";
- }
- }
-}
-
-class DummyCompilerDiagnostics implements CompilerDiagnostics {
- const DummyCompilerDiagnostics();
-
- @override
- report(code, uri, begin, end, text, kind) {
- throw "should not be needed";
- }
-}
-
-class CustomCompiler extends CompilerImpl {
- CustomCompiler(List<String> options, Map<String, String> environment)
- : super(
- const DummyCompilerInput(),
- const NullCompilerOutput(),
- const DummyCompilerDiagnostics(),
- CompilerOptions.parse(
- ['--platform-binaries=$sdkPlatformBinariesPath']
- ..addAll(options),
- librariesSpecificationUri: sdkLibrariesSpecificationUri)
- ..environment = environment);
-}
-
-runTest() async {
- {
- final compiler = new CustomCompiler([], {});
-
- await compiler.setupSdk();
- final lookup = compiler.environment.valueOf;
-
- // Core libraries are always present.
- Expect.equals("true", lookup("dart.library.collection"));
- // Non-existing entries in the environment return 'null'.
- Expect.isNull(lookup("not in env"));
- // Check for client libraries (default if there are no flags to the compiler).
- Expect.equals("true", lookup("dart.library.mock.client"));
- Expect.equals("true", lookup("dart.library.html"));
- // Check for shared libraries..
- Expect.equals("true", lookup("dart.library.mock.shared"));
- // Check server libraries are not present.
- Expect.equals(null, lookup("dart.library.mock.server"));
- Expect.equals(null, lookup("dart.library.io"));
- }
- {
- final compiler = new CustomCompiler([Flags.serverMode], {});
-
- await compiler.setupSdk();
- final lookup = compiler.environment.valueOf;
-
- // Core libraries are always present.
- Expect.equals("true", lookup("dart.library.collection"));
- // Non-existing entries in the environment return 'null'.
- Expect.isNull(lookup("not in env"));
- // Check client libraries are not present.
- Expect.equals(null, lookup("dart.library.mock.client"));
- Expect.equals(null, lookup("dart.library.html"));
- // Check for shared libraries..
- Expect.equals("true", lookup("dart.library.mock.shared"));
- // Check for server libraries.
- Expect.equals("true", lookup("dart.library.mock.server"));
- Expect.equals("true", lookup("dart.library.io"));
- }
- {
- // Check that user-defined env-variables win.
- final compiler = new CustomCompiler([], {
- 'dart.library.collection': "false",
- 'dart.library.mock.client': "foo"
- });
-
- await compiler.setupSdk();
- final lookup = compiler.environment.valueOf;
-
- Expect.equals("false", lookup("dart.library.collection"));
- Expect.equals("foo", lookup("dart.library.mock.client"));
- }
-}
-
-main() {
- asyncStart();
- runTest().then((_) {
- asyncEnd();
- });
-}
diff --git a/pkg/compiler/test/end_to_end/modular_loader_test.dart b/pkg/compiler/test/end_to_end/modular_loader_test.dart
index 35c1066..b5819f0 100644
--- a/pkg/compiler/test/end_to_end/modular_loader_test.dart
+++ b/pkg/compiler/test/end_to_end/modular_loader_test.dart
@@ -44,7 +44,6 @@
memorySourceFiles: {'a.dill': aDill, 'b.dill': bDill, 'c.dill': cDill},
diagnosticHandler: diagnostics,
outputProvider: output);
- await compiler.setupSdk();
KernelResult result = await compiler.kernelLoader.load();
compiler.frontendStrategy.registerLoadedLibraries(result);
diff --git a/pkg/compiler/test/model/cfe_constant_evaluation_test.dart b/pkg/compiler/test/model/cfe_constant_evaluation_test.dart
index b133fd4..24c4a58 100644
--- a/pkg/compiler/test/model/cfe_constant_evaluation_test.dart
+++ b/pkg/compiler/test/model/cfe_constant_evaluation_test.dart
@@ -596,9 +596,9 @@
expectedResults
.forEach((Map<String, String> environment, String expectedText) {
List<String> errors = [];
- Dart2jsConstantEvaluator evaluator =
- new Dart2jsConstantEvaluator(elementMap.typeEnvironment,
- (ir.LocatedMessage message, List<ir.LocatedMessage> context) {
+ Dart2jsConstantEvaluator evaluator = new Dart2jsConstantEvaluator(
+ elementMap.env.mainComponent, elementMap.typeEnvironment,
+ (ir.LocatedMessage message, List<ir.LocatedMessage> context) {
// TODO(johnniwinther): Assert that `message.uri != null`. Currently
// all unevaluated constants have no uri.
// The actual message is a "constant errors starts here" message,
@@ -606,11 +606,11 @@
errors.add(context.first.code.name);
reportLocatedMessage(elementMap.reporter, message, context);
},
- environment: environment,
- supportReevaluationForTesting: true,
- evaluationMode: compiler.options.useLegacySubtyping
- ? ir.EvaluationMode.weak
- : ir.EvaluationMode.strong);
+ environment: environment,
+ supportReevaluationForTesting: true,
+ evaluationMode: compiler.options.useLegacySubtyping
+ ? ir.EvaluationMode.weak
+ : ir.EvaluationMode.strong);
ir.Constant evaluatedConstant = evaluator.evaluate(
new ir.StaticTypeContext(node, typeEnvironment), initializer);
diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart
index 5b514be..9b9fd08 100644
--- a/pkg/dev_compiler/lib/src/kernel/command.dart
+++ b/pkg/dev_compiler/lib/src/kernel/command.dart
@@ -825,10 +825,6 @@
}
}
- // Add platform defined variables
- // TODO(47243) Remove when all code paths read these from the `Target`.
- declaredVariables.addAll(sdkLibraryEnvironmentDefines);
-
return declaredVariables;
}
diff --git a/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart b/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart
index 6d5c418..215ba19 100644
--- a/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart
+++ b/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart
@@ -25,7 +25,6 @@
import '../compiler/js_names.dart';
import 'asset_file_system.dart';
import 'command.dart';
-import 'target.dart' show sdkLibraryEnvironmentDefines;
/// The service that handles expression compilation requests from
/// the debugger.
@@ -231,8 +230,6 @@
..omitPlatform = true
..environmentDefines = {
if (environmentDefines != null) ...environmentDefines,
- // TODO(47243) Remove when all code paths read these from the `Target`.
- ...sdkLibraryEnvironmentDefines
}
..explicitExperimentalFlags = explicitExperimentalFlags
..onDiagnostic = _onDiagnosticHandler(errors, warnings, infos)
diff --git a/pkg/dev_compiler/lib/src/kernel/target.dart b/pkg/dev_compiler/lib/src/kernel/target.dart
index bb79eb8..90dc78e 100644
--- a/pkg/dev_compiler/lib/src/kernel/target.dart
+++ b/pkg/dev_compiler/lib/src/kernel/target.dart
@@ -20,34 +20,6 @@
import 'constants.dart' show DevCompilerConstantsBackend;
import 'kernel_helpers.dart';
-/// Boolean environment variables that indicate which libraries are available in
-/// dev compiler.
-// TODO(jmesserly): provide an option to compile without dart:html & friends?
-const sdkLibraryEnvironmentDefines = {
- 'dart.isVM': 'false',
- 'dart.library.async': 'true',
- 'dart.library.core': 'true',
- 'dart.library.collection': 'true',
- 'dart.library.convert': 'true',
- // TODO(jmesserly): this is not really supported in dart4web other than
- // `debugger()`
- 'dart.library.developer': 'true',
- 'dart.library.io': 'false',
- 'dart.library.isolate': 'false',
- 'dart.library.js': 'true',
- 'dart.library.js_util': 'true',
- 'dart.library.math': 'true',
- 'dart.library.mirrors': 'false',
- 'dart.library.typed_data': 'true',
- 'dart.library.indexed_db': 'true',
- 'dart.library.html': 'true',
- 'dart.library.html_common': 'true',
- 'dart.library.svg': 'true',
- 'dart.library.ui': 'false',
- 'dart.library.web_audio': 'true',
- 'dart.library.web_gl': 'true',
-};
-
/// A kernel [Target] to configure the Dart Front End for dartdevc.
class DevCompilerTarget extends Target {
DevCompilerTarget(this.flags);
@@ -60,10 +32,6 @@
Map<String, Class>? _nativeClasses;
@override
- Map<String, String> updateEnvironmentDefines(Map<String, String> map) =>
- map..addAll(sdkLibraryEnvironmentDefines);
-
- @override
bool get enableSuperMixins => true;
@override
diff --git a/pkg/front_end/lib/src/api_unstable/dart2js.dart b/pkg/front_end/lib/src/api_unstable/dart2js.dart
index d008fd6..357b21f 100644
--- a/pkg/front_end/lib/src/api_unstable/dart2js.dart
+++ b/pkg/front_end/lib/src/api_unstable/dart2js.dart
@@ -12,9 +12,6 @@
import 'package:_fe_analyzer_shared/src/scanner/scanner.dart' show StringToken;
-import 'package:_fe_analyzer_shared/src/util/libraries_specification.dart'
- show LibrariesSpecification;
-
import 'package:kernel/kernel.dart' show Component;
import 'package:kernel/ast.dart' as ir;
@@ -217,28 +214,6 @@
return compilerResult?.component;
}
-/// Retrieve the name of the libraries that are supported by [target] according
-/// to the libraries specification [json] file.
-///
-/// Dart2js uses these names to determine the value of library environment
-/// constants, such as `const bool.fromEnvironment("dart.library.io")`.
-// TODO(sigmund): refactor dart2js so that we can retrieve this data later in
-// the compilation pipeline. At that point we can get it from the CFE
-// results directly and completely hide the libraries specification file from
-// dart2js.
-// TODO(sigmund): delete after all constant evaluation is done in the CFE, as
-// this data will no longer be needed on the dart2js side.
-Future<Iterable<String>> getSupportedLibraryNames(
- Uri librariesSpecificationUri, String target,
- {required Future<String> readJson(Uri uri)}) async {
- return (await LibrariesSpecification.load(
- librariesSpecificationUri, readJson))
- .specificationFor(target)
- .allLibraries
- .where((l) => l.isSupported)
- .map((l) => l.name);
-}
-
/// Desugar API to determine whether [member] is a redirecting factory
/// constructor.
// TODO(sigmund): Delete this API once `member.isRedirectingFactory`
diff --git a/pkg/front_end/lib/src/fasta/builder/library_builder.dart b/pkg/front_end/lib/src/fasta/builder/library_builder.dart
index f2c63b8..c86c3c0 100644
--- a/pkg/front_end/lib/src/fasta/builder/library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/library_builder.dart
@@ -69,6 +69,10 @@
/// This is the canonical uri for the library, for instance 'dart:core'.
Uri get importUri;
+ /// If true, the library is not supported through the 'dart.library.*' value
+ /// used in conditional imports and `bool.fromEnvironment` constants.
+ bool get isUnsupported;
+
Iterator<Builder> get iterator;
NameIterator get nameIterator;
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
index b367503..d09fac5 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
@@ -131,6 +131,9 @@
}
@override
+ bool get isUnsupported => library.isUnsupported;
+
+ @override
bool get isSynthetic => library.isSynthetic;
@override
diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
index 6e01246..8152374 100644
--- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart
+++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
@@ -1735,6 +1735,7 @@
loader: lastGoodKernelTarget.loader,
scope: libraryBuilder.scope.createNestedScope("expression"),
nameOrigin: libraryBuilder,
+ isUnsupported: libraryBuilder.isUnsupported,
);
_ticker.logMs("Created debug library");
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 887ed4c..197632f 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -393,12 +393,13 @@
DeclarationBuilder? declarationBuilder,
ModifierBuilder member,
Scope scope,
- Uri fileUri)
+ Uri fileUri,
+ {Scope? formalParameterScope})
: this(
libraryBuilder: library,
member: member,
enclosingScope: scope,
- formalParameterScope: null,
+ formalParameterScope: formalParameterScope,
hierarchy: library.loader.hierarchy,
coreTypes: library.loader.coreTypes,
declarationBuilder: declarationBuilder,
diff --git a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
index f9bfef4..63f0ffd 100644
--- a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart
@@ -39,8 +39,8 @@
part 'constant_collection_builders.dart';
Component transformComponent(
+ Target target,
Component component,
- ConstantsBackend backend,
Map<String, String> environmentDefines,
ErrorReporter errorReporter,
EvaluationMode evaluationMode,
@@ -70,7 +70,7 @@
final TypeEnvironment typeEnvironment =
new TypeEnvironment(coreTypes, hierarchy);
- transformLibraries(component.libraries, backend, environmentDefines,
+ transformLibraries(component, component.libraries, target, environmentDefines,
typeEnvironment, errorReporter, evaluationMode,
enableTripleShift: enableTripleShift,
enableConstFunctions: enableConstFunctions,
@@ -81,8 +81,9 @@
}
ConstantEvaluationData transformLibraries(
+ Component component,
List<Library> libraries,
- ConstantsBackend backend,
+ Target target,
Map<String, String>? environmentDefines,
TypeEnvironment typeEnvironment,
ErrorReporter errorReporter,
@@ -103,13 +104,14 @@
// ignore: unnecessary_null_comparison
assert(enableConstructorTearOff != null);
final ConstantsTransformer constantsTransformer = new ConstantsTransformer(
- backend,
+ target,
environmentDefines,
evaluateAnnotations,
enableTripleShift,
enableConstFunctions,
enableConstructorTearOff,
errorOnUnevaluatedConstant,
+ component,
typeEnvironment,
errorReporter,
evaluationMode);
@@ -124,7 +126,8 @@
void transformProcedure(
Procedure procedure,
- ConstantsBackend backend,
+ Target target,
+ Component component,
Map<String, String>? environmentDefines,
TypeEnvironment typeEnvironment,
ErrorReporter errorReporter,
@@ -145,13 +148,14 @@
// ignore: unnecessary_null_comparison
assert(enableConstructorTearOff != null);
final ConstantsTransformer constantsTransformer = new ConstantsTransformer(
- backend,
+ target,
environmentDefines,
evaluateAnnotations,
enableTripleShift,
enableConstFunctions,
enableConstructorTearOff,
errorOnUnevaluatedConstant,
+ component,
typeEnvironment,
errorReporter,
evaluationMode);
@@ -341,18 +345,25 @@
final bool errorOnUnevaluatedConstant;
ConstantsTransformer(
- this.backend,
+ Target target,
Map<String, String>? environmentDefines,
this.evaluateAnnotations,
this.enableTripleShift,
this.enableConstFunctions,
this.enableConstructorTearOff,
this.errorOnUnevaluatedConstant,
+ Component component,
this.typeEnvironment,
ErrorReporter errorReporter,
EvaluationMode evaluationMode)
- : constantEvaluator = new ConstantEvaluator(
- backend, environmentDefines, typeEnvironment, errorReporter,
+ : this.backend = target.constantsBackend,
+ constantEvaluator = new ConstantEvaluator(
+ target.dartLibrarySupport,
+ target.constantsBackend,
+ component,
+ environmentDefines,
+ typeEnvironment,
+ errorReporter,
enableTripleShift: enableTripleShift,
enableConstFunctions: enableConstFunctions,
errorOnUnevaluatedConstant: errorOnUnevaluatedConstant,
@@ -871,11 +882,13 @@
}
class ConstantEvaluator implements ExpressionVisitor<Constant> {
+ final DartLibrarySupport dartLibrarySupport;
final ConstantsBackend backend;
final NumberSemantics numberSemantics;
late ConstantIntFolder intFolder;
- Map<String, String>? environmentDefines;
+ Map<String, String>? _environmentDefines;
final bool errorOnUnevaluatedConstant;
+ final Component component;
final CoreTypes coreTypes;
final TypeEnvironment typeEnvironment;
StaticTypeContext? _staticTypeContext;
@@ -914,8 +927,8 @@
late ConstantWeakener _weakener;
- ConstantEvaluator(this.backend, this.environmentDefines, this.typeEnvironment,
- this.errorReporter,
+ ConstantEvaluator(this.dartLibrarySupport, this.backend, this.component,
+ this._environmentDefines, this.typeEnvironment, this.errorReporter,
{this.enableTripleShift = false,
this.enableConstFunctions = false,
this.errorOnUnevaluatedConstant = false,
@@ -925,7 +938,7 @@
canonicalizationCache = <Constant, Constant>{},
nodeCache = <Node, Constant?>{},
env = new EvaluationEnvironment() {
- if (environmentDefines == null && !backend.supportsUnevaluatedConstants) {
+ if (_environmentDefines == null && !backend.supportsUnevaluatedConstants) {
throw new ArgumentError(
"No 'environmentDefines' passed to the constant evaluator but the "
"ConstantsBackend does not support unevaluated constants.");
@@ -947,6 +960,43 @@
_weakener = new ConstantWeakener(this);
}
+ Map<String, String>? _supportedLibrariesCache;
+
+ Map<String, String> _computeSupportedLibraries() {
+ Map<String, String> map = {};
+ for (Library library in component.libraries) {
+ if (library.importUri.scheme == 'dart') {
+ map[library.importUri.path] =
+ DartLibrarySupport.getDartLibrarySupportValue(
+ library.importUri.path,
+ libraryExists: true,
+ isSynthetic: library.isSynthetic,
+ isUnsupported: library.isUnsupported,
+ dartLibrarySupport: dartLibrarySupport);
+ }
+ }
+ return map;
+ }
+
+ String? lookupEnvironment(String key) {
+ if (DartLibrarySupport.isDartLibraryQualifier(key)) {
+ String libraryName = DartLibrarySupport.getDartLibraryName(key);
+ String? value = (_supportedLibrariesCache ??=
+ _computeSupportedLibraries())[libraryName];
+ return value ?? "";
+ }
+ return _environmentDefines![key];
+ }
+
+ bool hasEnvironmentKey(String key) {
+ if (key.startsWith(DartLibrarySupport.dartLibraryPrefix)) {
+ return true;
+ }
+ return _environmentDefines!.containsKey(key);
+ }
+
+ bool get hasEnvironment => _environmentDefines != null;
+
DartType convertType(DartType type) {
switch (evaluationMode) {
case EvaluationMode.strong:
@@ -1375,7 +1425,7 @@
Constant constant = node.constant;
Constant result = constant;
if (constant is UnevaluatedConstant) {
- if (environmentDefines != null) {
+ if (hasEnvironment) {
result = _evaluateSubexpression(constant.expression);
if (result is AbortConstant) return result;
} else {
@@ -2902,7 +2952,7 @@
Constant _handleFromEnvironment(
Procedure target, StringConstant name, Map<String, Constant> named) {
- String? value = environmentDefines![name.value];
+ String? value = lookupEnvironment(name.value);
Constant? defaultValue = named["defaultValue"];
if (target.enclosingClass == coreTypes.boolClass) {
Constant boolConstant;
@@ -2961,9 +3011,7 @@
}
Constant _handleHasEnvironment(StringConstant name) {
- return environmentDefines!.containsKey(name.value)
- ? trueConstant
- : falseConstant;
+ return hasEnvironmentKey(name.value) ? trueConstant : falseConstant;
}
@override
@@ -3015,7 +3063,7 @@
positionals.length == 1 &&
(target.name.text == "fromEnvironment" ||
target.name.text == "hasEnvironment")) {
- if (environmentDefines != null) {
+ if (hasEnvironment) {
// Evaluate environment constant.
Constant name = positionals.single;
if (name is StringConstant) {
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
index 0073678..79ff78d 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -1343,8 +1343,9 @@
constants.ConstantEvaluationData constantEvaluationData =
constants.transformLibraries(
+ component!,
loader.libraries,
- backendTarget.constantsBackend,
+ backendTarget,
environmentDefines,
environment,
new KernelConstantErrorReporter(loader),
@@ -1400,7 +1401,8 @@
constants.transformProcedure(
procedure,
- backendTarget.constantsBackend,
+ backendTarget,
+ component!,
environmentDefines,
environment,
new KernelConstantErrorReporter(loader),
diff --git a/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart b/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart
index cb8ee92..c880b78 100644
--- a/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_constructor_builder.dart
@@ -38,6 +38,7 @@
messageRedirectingConstructorWithSuperInitializer,
messageSuperInitializerNotLast,
noLength;
+import '../scope.dart';
import '../source/source_class_builder.dart';
import '../source/source_library_builder.dart' show SourceLibraryBuilder;
import '../source/source_loader.dart' show SourceLoader;
@@ -435,9 +436,19 @@
// initializers to infer types of the super-initializing parameters.
if ((isConst || _hasSuperInitializingFormals) &&
beginInitializers != null) {
+ final Scope? formalParameterScope;
+ if (isConst) {
+ // We're going to fully build the constructor so we need scopes.
+ formalParameterScope = computeFormalParameterInitializerScope(
+ computeFormalParameterScope(
+ computeTypeParameterScope(declarationBuilder!.scope)));
+ } else {
+ formalParameterScope = null;
+ }
BodyBuilder bodyBuilder = library.loader
.createBodyBuilderForOutlineExpression(
- library, classBuilder, this, classBuilder.scope, fileUri);
+ library, classBuilder, this, classBuilder.scope, fileUri,
+ formalParameterScope: formalParameterScope);
bodyBuilder.constantContext = ConstantContext.required;
bodyBuilder.parseInitializers(beginInitializers!,
doFinishConstructor: isConst);
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index 01f02a8..915ff8d 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -139,6 +139,9 @@
Uri? get packageUriForTesting => _packageUri;
+ @override
+ final bool isUnsupported;
+
final List<Object> accessors = <Object>[];
@override
@@ -250,7 +253,8 @@
Library library,
LibraryBuilder? nameOrigin,
Library? referencesFrom,
- bool? referenceIsPartOwner)
+ bool? referenceIsPartOwner,
+ bool isUnsupported)
: this.fromScopes(
loader,
fileUri,
@@ -261,7 +265,8 @@
origin,
library,
nameOrigin,
- referencesFrom);
+ referencesFrom,
+ isUnsupported);
SourceLibraryBuilder.fromScopes(
this.loader,
@@ -273,7 +278,8 @@
SourceLibraryBuilder? origin,
this.library,
this._nameOrigin,
- this.referencesFrom)
+ this.referencesFrom,
+ this.isUnsupported)
: _languageVersion = packageLanguageVersion,
currentTypeParameterScopeBuilder = _libraryTypeParameterScopeBuilder,
referencesFromIndexed =
@@ -462,7 +468,8 @@
Library? target,
LibraryBuilder? nameOrigin,
Library? referencesFrom,
- bool? referenceIsPartOwner})
+ bool? referenceIsPartOwner,
+ required bool isUnsupported})
: this.internal(
loader,
fileUri,
@@ -480,7 +487,8 @@
..setLanguageVersion(packageLanguageVersion.version)),
nameOrigin,
referencesFrom,
- referenceIsPartOwner);
+ referenceIsPartOwner,
+ isUnsupported);
@override
bool get isPart => partOfName != null || partOfUri != null;
@@ -703,7 +711,8 @@
int uriOffset) {
if (configurations != null) {
for (Configuration config in configurations) {
- if (lookupImportCondition(config.dottedName) == config.condition) {
+ if (loader.getLibrarySupportValue(config.dottedName) ==
+ config.condition) {
uri = config.importUri;
break;
}
@@ -717,26 +726,6 @@
exports.add(new Export(this, exportedLibrary, combinators, charOffset));
}
- String lookupImportCondition(String dottedName) {
- const String prefix = "dart.library.";
- if (!dottedName.startsWith(prefix)) return "";
- dottedName = dottedName.substring(prefix.length);
- if (!loader.target.uriTranslator.isLibrarySupported(dottedName)) return "";
-
- LibraryBuilder? imported =
- loader.lookupLibraryBuilder(new Uri(scheme: "dart", path: dottedName));
-
- if (imported == null) {
- LibraryBuilder coreLibrary = loader.readAsEntryPoint(resolve(
- this.importUri,
- new Uri(scheme: "dart", path: "core").toString(),
- -1));
- imported = coreLibrary.loader
- .lookupLibraryBuilder(new Uri(scheme: 'dart', path: dottedName));
- }
- return imported != null && !imported.isSynthetic ? "true" : "";
- }
-
void addImport(
List<MetadataBuilder>? metadata,
String uri,
@@ -750,7 +739,8 @@
int importIndex) {
if (configurations != null) {
for (Configuration config in configurations) {
- if (lookupImportCondition(config.dottedName) == config.condition) {
+ if (loader.getLibrarySupportValue(config.dottedName) ==
+ config.condition) {
uri = config.importUri;
break;
}
@@ -1076,6 +1066,7 @@
if (!modifyTarget) return library;
library.isSynthetic = isSynthetic;
+ library.isUnsupported = isUnsupported;
addDependencies(library, new Set<SourceLibraryBuilder>());
library.name = name;
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index afd4413..a731d66 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -26,6 +26,7 @@
show ClassHierarchy, HandleAmbiguousSupertypes;
import 'package:kernel/core_types.dart' show CoreTypes;
import 'package:kernel/reference_from_index.dart' show ReferenceFromIndex;
+import 'package:kernel/target/targets.dart';
import 'package:kernel/type_environment.dart';
import 'package:kernel/util/graph.dart';
import 'package:package_config/package_config.dart' as package_config;
@@ -318,7 +319,32 @@
loader: this,
origin: origin,
referencesFrom: referencesFrom,
- referenceIsPartOwner: referenceIsPartOwner);
+ referenceIsPartOwner: referenceIsPartOwner,
+ isUnsupported: origin?.library.isUnsupported ??
+ importUri.scheme == 'dart' &&
+ !target.uriTranslator.isLibrarySupported(importUri.path));
+ }
+
+ /// Return `"true"` if the [dottedName] is a 'dart.library.*' qualifier for a
+ /// supported dart:* library, and `""` otherwise.
+ ///
+ /// This is used to determine conditional imports and `bool.fromEnvironment`
+ /// constant values for "dart.library.[libraryName]" values.
+ String getLibrarySupportValue(String dottedName) {
+ if (!DartLibrarySupport.isDartLibraryQualifier(dottedName)) {
+ return "";
+ }
+ String libraryName = DartLibrarySupport.getDartLibraryName(dottedName);
+ Uri uri = new Uri(scheme: "dart", path: libraryName);
+ LibraryBuilder? library = lookupLibraryBuilder(uri);
+ // TODO(johnniwinther): Why is the dill target sometimes not loaded at this
+ // point? And does it matter?
+ library ??= target.dillTarget.loader.lookupLibraryBuilder(uri);
+ return DartLibrarySupport.getDartLibrarySupportValue(libraryName,
+ libraryExists: library != null,
+ isSynthetic: library?.isSynthetic ?? true,
+ isUnsupported: library?.isUnsupported ?? true,
+ dartLibrarySupport: target.backendTarget.dartLibrarySupport);
}
SourceLibraryBuilder _createSourceLibraryBuilder(
@@ -728,9 +754,11 @@
DeclarationBuilder? declarationBuilder,
ModifierBuilder member,
Scope scope,
- Uri fileUri) {
+ Uri fileUri,
+ {Scope? formalParameterScope}) {
return new BodyBuilder.forOutlineExpression(
- library, declarationBuilder, member, scope, fileUri);
+ library, declarationBuilder, member, scope, fileUri,
+ formalParameterScope: formalParameterScope);
}
NnbdMode get nnbdMode => target.context.options.nnbdMode;
@@ -1136,6 +1164,9 @@
builder, dietListener.memberScope,
isDeclarationInstanceMember: isClassInstanceMember,
extensionThis: extensionThis);
+ for (VariableDeclaration variable in parameters.positionalParameters) {
+ listener.typeInferrer.assignedVariables.declare(variable);
+ }
return listener.parseSingleExpression(
new Parser(listener,
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index 44a61a4..bdf3e38 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -170,8 +170,17 @@
final TypeInferenceEngine engine;
@override
- final FlowAnalysis<TreeNode, Statement, Expression, VariableDeclaration,
- DartType> flowAnalysis;
+ late final FlowAnalysis<TreeNode, Statement, Expression, VariableDeclaration,
+ DartType> flowAnalysis =
+ library.isNonNullableByDefault
+ ? new FlowAnalysis(
+ new TypeOperationsCfe(engine.typeSchemaEnvironment),
+ assignedVariables,
+ respectImplicitlyTypedVarInitializers:
+ library.enableConstructorTearOffsInLibrary)
+ : new FlowAnalysis.legacy(
+ new TypeOperationsCfe(engine.typeSchemaEnvironment),
+ assignedVariables);
@override
final AssignedVariables<TreeNode, VariableDeclaration> assignedVariables;
@@ -213,16 +222,7 @@
classHierarchy = engine.classHierarchy,
instrumentation = topLevel ? null : engine.instrumentation,
typeSchemaEnvironment = engine.typeSchemaEnvironment,
- isTopLevel = topLevel,
- flowAnalysis = library.isNonNullableByDefault
- ? new FlowAnalysis(
- new TypeOperationsCfe(engine.typeSchemaEnvironment),
- assignedVariables,
- respectImplicitlyTypedVarInitializers:
- library.enableConstructorTearOffsInLibrary)
- : new FlowAnalysis.legacy(
- new TypeOperationsCfe(engine.typeSchemaEnvironment),
- assignedVariables) {}
+ isTopLevel = topLevel {}
CoreTypes get coreTypes => engine.coreTypes;
diff --git a/pkg/front_end/lib/src/fasta/uri_translator.dart b/pkg/front_end/lib/src/fasta/uri_translator.dart
index cf624b4..dac8845 100644
--- a/pkg/front_end/lib/src/fasta/uri_translator.dart
+++ b/pkg/front_end/lib/src/fasta/uri_translator.dart
@@ -50,9 +50,7 @@
}
bool isLibrarySupported(String libraryName) {
- // TODO(sigmund): change this to `?? false` when all backends provide the
- // `libraries.json` file by default (Issue #32657).
- return dartLibraries.libraryInfoFor(libraryName)?.isSupported ?? true;
+ return dartLibraries.libraryInfoFor(libraryName)?.isSupported ?? false;
}
Uri? _translateDartUri(Uri uri) {
diff --git a/pkg/front_end/test/constant_evaluator_benchmark.dart b/pkg/front_end/test/constant_evaluator_benchmark.dart
index 35f5faa..c86c066 100644
--- a/pkg/front_end/test/constant_evaluator_benchmark.dart
+++ b/pkg/front_end/test/constant_evaluator_benchmark.dart
@@ -7,43 +7,33 @@
import 'package:_fe_analyzer_shared/src/messages/codes.dart';
import 'package:compiler/src/kernel/dart2js_target.dart' show Dart2jsTarget;
-
import 'package:dev_compiler/src/kernel/target.dart' show DevCompilerTarget;
-
import 'package:front_end/src/api_prototype/compiler_options.dart'
show CompilerOptions, DiagnosticMessage;
-
import 'package:front_end/src/api_prototype/experimental_flags.dart'
show ExperimentalFlag;
-
import 'package:front_end/src/base/processed_options.dart'
show ProcessedOptions;
-
import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext;
-
import 'package:front_end/src/fasta/incremental_compiler.dart'
show IncrementalCompiler;
import 'package:front_end/src/fasta/kernel/constant_evaluator.dart' as constants
show EvaluationMode, transformLibraries, ErrorReporter;
-
import 'package:front_end/src/fasta/kernel/kernel_target.dart';
+import 'package:front_end/src/fasta/kernel/utils.dart' show serializeComponent;
import 'package:kernel/ast.dart';
import 'package:kernel/binary/ast_from_binary.dart';
-import 'package:kernel/core_types.dart';
import 'package:kernel/class_hierarchy.dart';
+import 'package:kernel/core_types.dart';
import 'package:kernel/target/changed_structure_notifier.dart';
import 'package:kernel/target/targets.dart'
- show ConstantsBackend, DiagnosticReporter, Target, TargetFlags;
+ show DiagnosticReporter, Target, TargetFlags;
import 'package:kernel/type_environment.dart';
-
import "package:vm/target/flutter.dart" show FlutterTarget;
-
import "package:vm/target/vm.dart" show VmTarget;
import 'incremental_suite.dart' show getOptions;
-import 'package:front_end/src/fasta/kernel/utils.dart' show serializeComponent;
-
bool? tryWithNoEnvironment;
bool verbose = false;
bool skipNonNullEnvironment = false;
@@ -80,8 +70,6 @@
stopwatch.reset();
CoreTypes coreTypes = new CoreTypes(component);
- ConstantsBackend constantsBackend =
- target.backendTarget.constantsBackend;
ClassHierarchy hierarchy = new ClassHierarchy(component, coreTypes);
TypeEnvironment environment = new TypeEnvironment(coreTypes, hierarchy);
if (verbose) {
@@ -91,8 +79,9 @@
stopwatch.reset();
constants.transformLibraries(
+ component,
component.libraries,
- constantsBackend,
+ target.backendTarget,
environmentDefines,
environment,
new SilentErrorReporter(),
diff --git a/pkg/front_end/test/explicit_creation_git_test.dart b/pkg/front_end/test/explicit_creation_git_test.dart
index dc8e3a1..726ffae 100644
--- a/pkg/front_end/test/explicit_creation_git_test.dart
+++ b/pkg/front_end/test/explicit_creation_git_test.dart
@@ -137,9 +137,11 @@
DeclarationBuilder? declarationBuilder,
ModifierBuilder member,
Scope scope,
- Uri fileUri) {
+ Uri fileUri,
+ {Scope? formalParameterScope}) {
return new BodyBuilderTest.forOutlineExpression(
- library, declarationBuilder, member, scope, fileUri);
+ library, declarationBuilder, member, scope, fileUri,
+ formalParameterScope: formalParameterScope);
}
@override
@@ -220,9 +222,11 @@
DeclarationBuilder? declarationBuilder,
ModifierBuilder member,
Scope scope,
- Uri fileUri)
+ Uri fileUri,
+ {Scope? formalParameterScope})
: super.forOutlineExpression(
- library, declarationBuilder, member, scope, fileUri);
+ library, declarationBuilder, member, scope, fileUri,
+ formalParameterScope: formalParameterScope);
@override
Expression buildConstructorInvocation(
diff --git a/pkg/front_end/test/fasta/generator_to_string_test.dart b/pkg/front_end/test/fasta/generator_to_string_test.dart
index f4790b9..787ad86 100644
--- a/pkg/front_end/test/fasta/generator_to_string_test.dart
+++ b/pkg/front_end/test/fasta/generator_to_string_test.dart
@@ -94,7 +94,8 @@
new DillTarget(c.options.ticker, uriTranslator,
new NoneTarget(new TargetFlags())),
uriTranslator)
- .loader);
+ .loader,
+ isUnsupported: false);
libraryBuilder.markLanguageVersionFinal();
LoadLibraryBuilder loadLibraryBuilder =
new LoadLibraryBuilder(libraryBuilder, dummyLibraryDependency, -1);
diff --git a/pkg/front_end/test/fasta/testing/suite.dart b/pkg/front_end/test/fasta/testing/suite.dart
index f7221fd..2c4da28 100644
--- a/pkg/front_end/test/fasta/testing/suite.dart
+++ b/pkg/front_end/test/fasta/testing/suite.dart
@@ -5,91 +5,63 @@
library fasta.testing.suite;
import 'dart:convert' show jsonDecode, utf8;
-
import 'dart:io' show Directory, File, Platform;
-
import 'dart:typed_data' show Uint8List;
import 'package:_fe_analyzer_shared/src/scanner/token.dart'
show LanguageVersionToken, Token;
-
import 'package:_fe_analyzer_shared/src/util/colors.dart' as colors;
import 'package:_fe_analyzer_shared/src/util/libraries_specification.dart'
show LibraryInfo;
import 'package:_fe_analyzer_shared/src/util/options.dart';
import 'package:compiler/src/kernel/dart2js_target.dart';
import 'package:dev_compiler/src/kernel/target.dart';
-
import 'package:front_end/src/api_prototype/compiler_options.dart'
show
CompilerOptions,
DiagnosticMessage,
parseExperimentalArguments,
parseExperimentalFlags;
-
import 'package:front_end/src/api_prototype/constant_evaluator.dart'
show ConstantEvaluator, ErrorReporter, EvaluationMode;
-
import 'package:front_end/src/api_prototype/experimental_flags.dart'
show
AllowedExperimentalFlags,
ExperimentalFlag,
defaultAllowedExperimentalFlags,
isExperimentEnabled;
-
import 'package:front_end/src/api_prototype/file_system.dart'
show FileSystem, FileSystemEntity, FileSystemException;
-
import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
show IncrementalCompilerResult;
-
import 'package:front_end/src/api_prototype/standard_file_system.dart'
show StandardFileSystem;
-
+import 'package:front_end/src/base/command_line_options.dart';
+import 'package:front_end/src/base/nnbd_mode.dart' show NnbdMode;
import 'package:front_end/src/base/processed_options.dart'
show ProcessedOptions;
-
import 'package:front_end/src/compute_platform_binaries_location.dart'
show computePlatformBinariesLocation, computePlatformDillName;
-
-import 'package:front_end/src/base/command_line_options.dart';
-
-import 'package:front_end/src/base/nnbd_mode.dart' show NnbdMode;
-
import 'package:front_end/src/fasta/builder/library_builder.dart'
show LibraryBuilder;
-
import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext;
-
import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget;
-
import 'package:front_end/src/fasta/incremental_compiler.dart'
show IncrementalCompiler;
-
import 'package:front_end/src/fasta/kernel/hierarchy/hierarchy_builder.dart'
show ClassHierarchyBuilder;
-
import 'package:front_end/src/fasta/kernel/hierarchy/hierarchy_node.dart'
show ClassHierarchyNode;
-
import 'package:front_end/src/fasta/kernel/kernel_target.dart'
show KernelTarget;
-
import 'package:front_end/src/fasta/kernel/utils.dart' show ByteSink;
-
-import 'package:front_end/src/fasta/messages.dart' show LocatedMessage;
-
-import 'package:front_end/src/fasta/ticker.dart' show Ticker;
-
-import 'package:front_end/src/fasta/uri_translator.dart' show UriTranslator;
-
import 'package:front_end/src/fasta/kernel/verifier.dart' show verifyComponent;
-
+import 'package:front_end/src/fasta/messages.dart' show LocatedMessage;
+import 'package:front_end/src/fasta/ticker.dart' show Ticker;
+import 'package:front_end/src/fasta/uri_translator.dart' show UriTranslator;
import 'package:front_end/src/fasta/util/parser_ast.dart'
show ParserAstVisitor, getAST;
-
import 'package:front_end/src/fasta/util/parser_ast_helper.dart';
-
import 'package:kernel/ast.dart'
show
AwaitExpression,
@@ -111,24 +83,16 @@
Version,
Visitor,
VisitorVoidMixin;
-
import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
-
import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
-
import 'package:kernel/core_types.dart' show CoreTypes;
-
import 'package:kernel/kernel.dart'
show RecursiveResultVisitor, loadComponentFromBytes;
-
import 'package:kernel/reference_from_index.dart' show ReferenceFromIndex;
-
import 'package:kernel/target/changed_structure_notifier.dart'
show ChangedStructureNotifier;
-
import 'package:kernel/target/targets.dart'
show
- ConstantsBackend,
DiagnosticReporter,
NoneConstantsBackend,
NoneTarget,
@@ -137,10 +101,8 @@
TestTargetFlags,
TestTargetMixin,
TestTargetWrapper;
-
import 'package:kernel/type_environment.dart'
show StaticTypeContext, TypeEnvironment;
-
import 'package:testing/testing.dart'
show
Chain,
@@ -151,11 +113,9 @@
Step,
TestDescription,
StdioProcess;
-
import 'package:vm/target/vm.dart' show VmTarget;
import '../../testing_utils.dart' show checkEnvironment;
-
import '../../utils/kernel_chain.dart'
show
ComponentResult,
@@ -165,7 +125,6 @@
Print,
TypeCheck,
WriteDill;
-
import '../../utils/validating_instrumentation.dart'
show ValidatingInstrumentation;
@@ -901,12 +860,12 @@
Future<Result<ComponentResult>> run(
ComponentResult result, FastaContext context) {
KernelTarget target = result.sourceTarget;
- ConstantsBackend constantsBackend = target.backendTarget.constantsBackend;
TypeEnvironment environment =
new TypeEnvironment(target.loader.coreTypes, target.loader.hierarchy);
StressConstantEvaluatorVisitor stressConstantEvaluatorVisitor =
new StressConstantEvaluatorVisitor(
- constantsBackend,
+ target.backendTarget,
+ result.component,
result.options.environmentDefines,
target.isExperimentEnabledGlobally(ExperimentalFlag.tripleShift),
environment,
@@ -937,7 +896,8 @@
List<String> output = [];
StressConstantEvaluatorVisitor(
- ConstantsBackend backend,
+ Target target,
+ Component component,
Map<String, String>? environmentDefines,
bool enableTripleShift,
TypeEnvironment typeEnvironment,
@@ -945,12 +905,22 @@
bool errorOnUnevaluatedConstant,
EvaluationMode evaluationMode) {
constantEvaluator = new ConstantEvaluator(
- backend, environmentDefines, typeEnvironment, this,
+ target.dartLibrarySupport,
+ target.constantsBackend,
+ component,
+ environmentDefines,
+ typeEnvironment,
+ this,
enableTripleShift: enableTripleShift,
errorOnUnevaluatedConstant: errorOnUnevaluatedConstant,
evaluationMode: evaluationMode);
constantEvaluatorWithEmptyEnvironment = new ConstantEvaluator(
- backend, {}, typeEnvironment, this,
+ target.dartLibrarySupport,
+ target.constantsBackend,
+ component,
+ {},
+ typeEnvironment,
+ this,
enableTripleShift: enableTripleShift,
errorOnUnevaluatedConstant: errorOnUnevaluatedConstant,
evaluationMode: evaluationMode);
@@ -990,7 +960,7 @@
}
}
if (!evaluate) return node;
- if (constantEvaluator.environmentDefines != null) {
+ if (constantEvaluator.hasEnvironment) {
throw "Unexpected UnevaluatedConstant "
"when the environment is not null.";
}
@@ -1010,7 +980,7 @@
bool evaluatedWithEmptyEnvironment = false;
if (x is UnevaluatedConstant && x.expression is! InvalidExpression) {
// try with an environment
- if (constantEvaluator.environmentDefines != null) {
+ if (constantEvaluator.hasEnvironment) {
throw "Unexpected UnevaluatedConstant (with an InvalidExpression in "
"it) when the environment is not null.";
}
@@ -1760,6 +1730,8 @@
forceConstructorTearOffLoweringForTesting:
folderOptions.forceConstructorTearOffLowering,
enableNullSafety: context.soundNullSafety,
+ supportedDartLibraries: {'_supported.by.target'},
+ unsupportedDartLibraries: {'unsupported.by.target'},
);
Target target;
switch (folderOptions.target) {
diff --git a/pkg/front_end/test/spell_checking_list_code.txt b/pkg/front_end/test/spell_checking_list_code.txt
index 8b9b65b4..7cfd23a 100644
--- a/pkg/front_end/test/spell_checking_list_code.txt
+++ b/pkg/front_end/test/spell_checking_list_code.txt
@@ -688,6 +688,7 @@
java
jenkins
jensj
+jit
job
johnniwinther
js
diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart b/pkg/front_end/testcases/dart2js/conditional_import.dart
index 6122451..58ccbe7 100644
--- a/pkg/front_end/testcases/dart2js/conditional_import.dart
+++ b/pkg/front_end/testcases/dart2js/conditional_import.dart
@@ -8,7 +8,11 @@
if (dart.library.html) "dart:html" as a;
// All three libraries have an HttpRequest class.
-import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
+import "conditional_import.dart"
+ if (dart.library.html) "dart:html"
+ if (dart.library.io) "dart:io" as b;
+
+import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c;
class HttpRequest {}
@@ -20,6 +24,13 @@
}
testB(b.HttpRequest request) {
+ request.certificate; // error (from dart:io)
+ request.response; // ok (from dart:io and dart:html)
+ request.readyState; // ok (from dart:html)
+ request.hashCode; // ok
+}
+
+testC(c.HttpRequest request) {
request.certificate; // error
request.response; // error
request.readyState; // error
diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.expect
index 5f33ec1..560176d 100644
--- a/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.expect
+++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
-// - 'HttpRequest' is from 'dart:_http'.
-// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
-// request.readyState; // ok (from dart:html)
-// ^^^^^^^^^^
+// pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
+//
+// pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -28,11 +34,12 @@
//
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
-import "dart:io" as io;
+import "dart:html" as html;
+import "dart:_interceptors" as _in;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -41,28 +48,38 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic {
- request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
- request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- - 'HttpRequest' is from 'dart:_http'.
-Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
- request.readyState; // ok (from dart:html)
- ^^^^^^^^^^" in request{<unresolved>}.readyState;
- request.{core::Object::hashCode}{core::int};
+static method testA(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{_in::Interceptor::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{_in::Interceptor::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -71,7 +88,7 @@
}
static method main() → void {
self::expect(false, #C1);
- self::expect(true, #C1);
+ self::expect(true, #C2);
self::expect(false, #C1);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
@@ -81,4 +98,5 @@
constants {
#C1 = false
+ #C2 = true
}
diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.transformed.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.transformed.expect
index 5f33ec1..560176d 100644
--- a/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.strong.transformed.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
-// - 'HttpRequest' is from 'dart:_http'.
-// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
-// request.readyState; // ok (from dart:html)
-// ^^^^^^^^^^
+// pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
+//
+// pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -28,11 +34,12 @@
//
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
-import "dart:io" as io;
+import "dart:html" as html;
+import "dart:_interceptors" as _in;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -41,28 +48,38 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic {
- request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
- request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- - 'HttpRequest' is from 'dart:_http'.
-Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
- request.readyState; // ok (from dart:html)
- ^^^^^^^^^^" in request{<unresolved>}.readyState;
- request.{core::Object::hashCode}{core::int};
+static method testA(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{_in::Interceptor::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{_in::Interceptor::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -71,7 +88,7 @@
}
static method main() → void {
self::expect(false, #C1);
- self::expect(true, #C1);
+ self::expect(true, #C2);
self::expect(false, #C1);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
@@ -81,4 +98,5 @@
constants {
#C1 = false
+ #C2 = true
}
diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline.expect
index dc10727..a62da80 100644
--- a/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline.expect
@@ -1,11 +1,15 @@
import "conditional_import.dart"
if (dart.library.io) "dart:io"
if (dart.library.html) "dart:html" as a;
-import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
+import "conditional_import.dart"
+ if (dart.library.html) "dart:html"
+ if (dart.library.io) "dart:io" as b;
+import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c;
class HttpRequest {}
testA(a.HttpRequest request) {}
testB(b.HttpRequest request) {}
+testC(c.HttpRequest request) {}
void main() {}
expect(expected, actual) {}
diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline_modelled.expect
index 6e90f3d..7af9c6f 100644
--- a/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.textual_outline_modelled.expect
@@ -1,4 +1,7 @@
-import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
+import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c;
+import "conditional_import.dart"
+ if (dart.library.html) "dart:html"
+ if (dart.library.io) "dart:io" as b;
import "conditional_import.dart"
if (dart.library.io) "dart:io"
if (dart.library.html) "dart:html" as a;
@@ -8,4 +11,5 @@
expect(expected, actual) {}
testA(a.HttpRequest request) {}
testB(b.HttpRequest request) {}
+testC(c.HttpRequest request) {}
void main() {}
diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.expect
index 5f33ec1..560176d 100644
--- a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.expect
+++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
-// - 'HttpRequest' is from 'dart:_http'.
-// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
-// request.readyState; // ok (from dart:html)
-// ^^^^^^^^^^
+// pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
+//
+// pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -28,11 +34,12 @@
//
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
-import "dart:io" as io;
+import "dart:html" as html;
+import "dart:_interceptors" as _in;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -41,28 +48,38 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic {
- request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
- request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- - 'HttpRequest' is from 'dart:_http'.
-Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
- request.readyState; // ok (from dart:html)
- ^^^^^^^^^^" in request{<unresolved>}.readyState;
- request.{core::Object::hashCode}{core::int};
+static method testA(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{_in::Interceptor::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{_in::Interceptor::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -71,7 +88,7 @@
}
static method main() → void {
self::expect(false, #C1);
- self::expect(true, #C1);
+ self::expect(true, #C2);
self::expect(false, #C1);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
@@ -81,4 +98,5 @@
constants {
#C1 = false
+ #C2 = true
}
diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.modular.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.modular.expect
index 5f33ec1..560176d 100644
--- a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.modular.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
-// - 'HttpRequest' is from 'dart:_http'.
-// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
-// request.readyState; // ok (from dart:html)
-// ^^^^^^^^^^
+// pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
+//
+// pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -28,11 +34,12 @@
//
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
-import "dart:io" as io;
+import "dart:html" as html;
+import "dart:_interceptors" as _in;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -41,28 +48,38 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic {
- request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
- request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- - 'HttpRequest' is from 'dart:_http'.
-Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
- request.readyState; // ok (from dart:html)
- ^^^^^^^^^^" in request{<unresolved>}.readyState;
- request.{core::Object::hashCode}{core::int};
+static method testA(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{_in::Interceptor::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{_in::Interceptor::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -71,7 +88,7 @@
}
static method main() → void {
self::expect(false, #C1);
- self::expect(true, #C1);
+ self::expect(true, #C2);
self::expect(false, #C1);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
@@ -81,4 +98,5 @@
constants {
#C1 = false
+ #C2 = true
}
diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.outline.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.outline.expect
index 8e7ea0f..b5be69a 100644
--- a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.outline.expect
@@ -1,10 +1,11 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
+import "dart:html" as html;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -12,9 +13,11 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic
+static method testA(html::HttpRequest request) → dynamic
;
-static method testB(self::HttpRequest request) → dynamic
+static method testB(html::HttpRequest request) → dynamic
+ ;
+static method testC(self::HttpRequest request) → dynamic
;
static method main() → void
;
diff --git a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.transformed.expect b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.transformed.expect
index 5f33ec1..560176d 100644
--- a/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/dart2js/conditional_import.dart.weak.transformed.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
-// - 'HttpRequest' is from 'dart:_http'.
-// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
-// request.readyState; // ok (from dart:html)
-// ^^^^^^^^^^
+// pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
+//
+// pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -28,11 +34,12 @@
//
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
-import "dart:io" as io;
+import "dart:html" as html;
+import "dart:_interceptors" as _in;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -41,28 +48,38 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic {
- request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
- request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- - 'HttpRequest' is from 'dart:_http'.
-Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
- request.readyState; // ok (from dart:html)
- ^^^^^^^^^^" in request{<unresolved>}.readyState;
- request.{core::Object::hashCode}{core::int};
+static method testA(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{_in::Interceptor::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{_in::Interceptor::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -71,7 +88,7 @@
}
static method main() → void {
self::expect(false, #C1);
- self::expect(true, #C1);
+ self::expect(true, #C2);
self::expect(false, #C1);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
@@ -81,4 +98,5 @@
constants {
#C1 = false
+ #C2 = true
}
diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart b/pkg/front_end/testcases/dartdevc/conditional_import.dart
index 6122451..58ccbe7 100644
--- a/pkg/front_end/testcases/dartdevc/conditional_import.dart
+++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart
@@ -8,7 +8,11 @@
if (dart.library.html) "dart:html" as a;
// All three libraries have an HttpRequest class.
-import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
+import "conditional_import.dart"
+ if (dart.library.html) "dart:html"
+ if (dart.library.io) "dart:io" as b;
+
+import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c;
class HttpRequest {}
@@ -20,6 +24,13 @@
}
testB(b.HttpRequest request) {
+ request.certificate; // error (from dart:io)
+ request.response; // ok (from dart:io and dart:html)
+ request.readyState; // ok (from dart:html)
+ request.hashCode; // ok
+}
+
+testC(c.HttpRequest request) {
request.certificate; // error
request.response; // error
request.readyState; // error
diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.expect
index 3b668f7..efcac9a 100644
--- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.expect
+++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
-// - 'HttpRequest' is from 'dart:_http'.
-// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
-// request.readyState; // ok (from dart:html)
-// ^^^^^^^^^^
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
+//
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -28,11 +34,11 @@
//
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
-import "dart:io" as io;
+import "dart:html" as html;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -41,28 +47,38 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic {
- request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
- request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- - 'HttpRequest' is from 'dart:_http'.
-Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
- request.readyState; // ok (from dart:html)
- ^^^^^^^^^^" in request{<unresolved>}.readyState;
+static method testA(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
request.{core::Object::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{core::Object::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -71,7 +87,7 @@
}
static method main() → void {
self::expect(false, #C1);
- self::expect(true, #C1);
+ self::expect(true, #C2);
self::expect(false, #C1);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
@@ -81,4 +97,5 @@
constants {
#C1 = false
+ #C2 = true
}
diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.transformed.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.transformed.expect
index 3b668f7..efcac9a 100644
--- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.strong.transformed.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
-// - 'HttpRequest' is from 'dart:_http'.
-// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
-// request.readyState; // ok (from dart:html)
-// ^^^^^^^^^^
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
+//
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -28,11 +34,11 @@
//
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
-import "dart:io" as io;
+import "dart:html" as html;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -41,28 +47,38 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic {
- request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
- request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- - 'HttpRequest' is from 'dart:_http'.
-Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
- request.readyState; // ok (from dart:html)
- ^^^^^^^^^^" in request{<unresolved>}.readyState;
+static method testA(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
request.{core::Object::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{core::Object::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -71,7 +87,7 @@
}
static method main() → void {
self::expect(false, #C1);
- self::expect(true, #C1);
+ self::expect(true, #C2);
self::expect(false, #C1);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
@@ -81,4 +97,5 @@
constants {
#C1 = false
+ #C2 = true
}
diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline.expect
index dc10727..a62da80 100644
--- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline.expect
@@ -1,11 +1,15 @@
import "conditional_import.dart"
if (dart.library.io) "dart:io"
if (dart.library.html) "dart:html" as a;
-import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
+import "conditional_import.dart"
+ if (dart.library.html) "dart:html"
+ if (dart.library.io) "dart:io" as b;
+import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c;
class HttpRequest {}
testA(a.HttpRequest request) {}
testB(b.HttpRequest request) {}
+testC(c.HttpRequest request) {}
void main() {}
expect(expected, actual) {}
diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline_modelled.expect
index 6e90f3d..7af9c6f 100644
--- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.textual_outline_modelled.expect
@@ -1,4 +1,7 @@
-import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
+import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c;
+import "conditional_import.dart"
+ if (dart.library.html) "dart:html"
+ if (dart.library.io) "dart:io" as b;
import "conditional_import.dart"
if (dart.library.io) "dart:io"
if (dart.library.html) "dart:html" as a;
@@ -8,4 +11,5 @@
expect(expected, actual) {}
testA(a.HttpRequest request) {}
testB(b.HttpRequest request) {}
+testC(c.HttpRequest request) {}
void main() {}
diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.expect
index 3b668f7..efcac9a 100644
--- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.expect
+++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
-// - 'HttpRequest' is from 'dart:_http'.
-// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
-// request.readyState; // ok (from dart:html)
-// ^^^^^^^^^^
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
+//
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -28,11 +34,11 @@
//
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
-import "dart:io" as io;
+import "dart:html" as html;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -41,28 +47,38 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic {
- request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
- request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- - 'HttpRequest' is from 'dart:_http'.
-Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
- request.readyState; // ok (from dart:html)
- ^^^^^^^^^^" in request{<unresolved>}.readyState;
+static method testA(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
request.{core::Object::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{core::Object::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -71,7 +87,7 @@
}
static method main() → void {
self::expect(false, #C1);
- self::expect(true, #C1);
+ self::expect(true, #C2);
self::expect(false, #C1);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
@@ -81,4 +97,5 @@
constants {
#C1 = false
+ #C2 = true
}
diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.modular.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.modular.expect
index 3b668f7..efcac9a 100644
--- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.modular.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
-// - 'HttpRequest' is from 'dart:_http'.
-// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
-// request.readyState; // ok (from dart:html)
-// ^^^^^^^^^^
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
+//
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -28,11 +34,11 @@
//
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
-import "dart:io" as io;
+import "dart:html" as html;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -41,28 +47,38 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic {
- request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
- request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- - 'HttpRequest' is from 'dart:_http'.
-Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
- request.readyState; // ok (from dart:html)
- ^^^^^^^^^^" in request{<unresolved>}.readyState;
+static method testA(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
request.{core::Object::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{core::Object::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -71,7 +87,7 @@
}
static method main() → void {
self::expect(false, #C1);
- self::expect(true, #C1);
+ self::expect(true, #C2);
self::expect(false, #C1);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
@@ -81,4 +97,5 @@
constants {
#C1 = false
+ #C2 = true
}
diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.outline.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.outline.expect
index 8e7ea0f..b5be69a 100644
--- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.outline.expect
@@ -1,10 +1,11 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
+import "dart:html" as html;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -12,9 +13,11 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic
+static method testA(html::HttpRequest request) → dynamic
;
-static method testB(self::HttpRequest request) → dynamic
+static method testB(html::HttpRequest request) → dynamic
+ ;
+static method testC(self::HttpRequest request) → dynamic
;
static method main() → void
;
diff --git a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.transformed.expect b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.transformed.expect
index 3b668f7..efcac9a 100644
--- a/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/dartdevc/conditional_import.dart.weak.transformed.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
-// - 'HttpRequest' is from 'dart:_http'.
-// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
-// request.readyState; // ok (from dart:html)
-// ^^^^^^^^^^
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:html'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+// request.certificate; // error (from dart:io)
+// ^^^^^^^^^^^
+//
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -28,11 +34,11 @@
//
import self as self;
import "dart:core" as core;
-import "dart:_http" as _ht;
-import "dart:io" as io;
+import "dart:html" as html;
-import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:html" as a;
+import "dart:html" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -41,28 +47,38 @@
static method _#new#tearOff() → self::HttpRequest
return new self::HttpRequest::•();
}
-static method testA(_ht::HttpRequest request) → dynamic {
- request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
- request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- - 'HttpRequest' is from 'dart:_http'.
-Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
- request.readyState; // ok (from dart:html)
- ^^^^^^^^^^" in request{<unresolved>}.readyState;
+static method testA(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:20:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
request.{core::Object::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(html::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:27:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:html'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
+ request.certificate; // error (from dart:io)
+ ^^^^^^^^^^^" in request{<unresolved>}.certificate;
+ request.{html::HttpRequest::response}{dynamic};
+ request.{html::HttpRequest::readyState}{core::int};
+ request.{core::Object::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -71,7 +87,7 @@
}
static method main() → void {
self::expect(false, #C1);
- self::expect(true, #C1);
+ self::expect(true, #C2);
self::expect(false, #C1);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
@@ -81,4 +97,5 @@
constants {
#C1 = false
+ #C2 = true
}
diff --git a/pkg/front_end/testcases/general/conditional_import.dart b/pkg/front_end/testcases/general/conditional_import.dart
index 067c784..648ea9b 100644
--- a/pkg/front_end/testcases/general/conditional_import.dart
+++ b/pkg/front_end/testcases/general/conditional_import.dart
@@ -8,7 +8,11 @@
if (dart.library.html) "dart:html" as a;
// All three libraries have an HttpRequest class.
-import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
+import "conditional_import.dart"
+ if (dart.library.html) "dart:html"
+ if (dart.library.io) "dart:io" as b;
+
+import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c;
class HttpRequest {}
@@ -20,6 +24,13 @@
}
testB(b.HttpRequest request) {
+ request.certificate; // ok (from dart:io)
+ request.response; // ok (from dart:io and dart:html)
+ request.readyState; // error (from dart:html)
+ request.hashCode; // ok
+}
+
+testC(c.HttpRequest request) {
request.certificate; // error
request.response; // error
request.readyState; // error
diff --git a/pkg/front_end/testcases/general/conditional_import.dart.textual_outline.expect b/pkg/front_end/testcases/general/conditional_import.dart.textual_outline.expect
index dc10727..a62da80 100644
--- a/pkg/front_end/testcases/general/conditional_import.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/general/conditional_import.dart.textual_outline.expect
@@ -1,11 +1,15 @@
import "conditional_import.dart"
if (dart.library.io) "dart:io"
if (dart.library.html) "dart:html" as a;
-import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
+import "conditional_import.dart"
+ if (dart.library.html) "dart:html"
+ if (dart.library.io) "dart:io" as b;
+import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c;
class HttpRequest {}
testA(a.HttpRequest request) {}
testB(b.HttpRequest request) {}
+testC(c.HttpRequest request) {}
void main() {}
expect(expected, actual) {}
diff --git a/pkg/front_end/testcases/general/conditional_import.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/conditional_import.dart.textual_outline_modelled.expect
index 6e90f3d..7af9c6f 100644
--- a/pkg/front_end/testcases/general/conditional_import.dart.textual_outline_modelled.expect
+++ b/pkg/front_end/testcases/general/conditional_import.dart.textual_outline_modelled.expect
@@ -1,4 +1,7 @@
-import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
+import "conditional_import.dart" if (dart.library.foo) "dart:foo" as c;
+import "conditional_import.dart"
+ if (dart.library.html) "dart:html"
+ if (dart.library.io) "dart:io" as b;
import "conditional_import.dart"
if (dart.library.io) "dart:io"
if (dart.library.html) "dart:html" as a;
@@ -8,4 +11,5 @@
expect(expected, actual) {}
testA(a.HttpRequest request) {}
testB(b.HttpRequest request) {}
+testC(c.HttpRequest request) {}
void main() {}
diff --git a/pkg/front_end/testcases/general/conditional_import.dart.weak.expect b/pkg/front_end/testcases/general/conditional_import.dart.weak.expect
index 0ae3432..00999c9 100644
--- a/pkg/front_end/testcases/general/conditional_import.dart.weak.expect
+++ b/pkg/front_end/testcases/general/conditional_import.dart.weak.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'dart:_http'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error (from dart:html)
// ^^^^^^^^^^
//
-// pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:_http'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
+// request.readyState; // error (from dart:html)
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -32,7 +38,8 @@
import "dart:io" as io;
import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:io" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -42,25 +49,35 @@
static method testA(_ht::HttpRequest request) → dynamic {
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'dart:_http'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error (from dart:html)
^^^^^^^^^^" in request{<unresolved>}.readyState;
request.{core::Object::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(_ht::HttpRequest request) → dynamic {
+ request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
+ request.{_ht::HttpRequest::response}{_ht::HttpResponse};
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:_http'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
+ request.readyState; // error (from dart:html)
+ ^^^^^^^^^^" in request{<unresolved>}.readyState;
+ request.{core::Object::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -69,8 +86,8 @@
}
static method main() → void {
self::expect(true, #C1);
- self::expect(false, #C1);
- self::expect(false, #C1);
+ self::expect(false, #C2);
+ self::expect(false, #C2);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
@@ -78,5 +95,6 @@
}
constants {
- #C1 = false
+ #C1 = true
+ #C2 = false
}
diff --git a/pkg/front_end/testcases/general/conditional_import.dart.weak.modular.expect b/pkg/front_end/testcases/general/conditional_import.dart.weak.modular.expect
index 0ae3432..00999c9 100644
--- a/pkg/front_end/testcases/general/conditional_import.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/general/conditional_import.dart.weak.modular.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'dart:_http'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error (from dart:html)
// ^^^^^^^^^^
//
-// pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:_http'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
+// request.readyState; // error (from dart:html)
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -32,7 +38,8 @@
import "dart:io" as io;
import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:io" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -42,25 +49,35 @@
static method testA(_ht::HttpRequest request) → dynamic {
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'dart:_http'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error (from dart:html)
^^^^^^^^^^" in request{<unresolved>}.readyState;
request.{core::Object::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(_ht::HttpRequest request) → dynamic {
+ request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
+ request.{_ht::HttpRequest::response}{_ht::HttpResponse};
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:_http'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
+ request.readyState; // error (from dart:html)
+ ^^^^^^^^^^" in request{<unresolved>}.readyState;
+ request.{core::Object::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -69,8 +86,8 @@
}
static method main() → void {
self::expect(true, #C1);
- self::expect(false, #C1);
- self::expect(false, #C1);
+ self::expect(false, #C2);
+ self::expect(false, #C2);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
@@ -78,5 +95,6 @@
}
constants {
- #C1 = false
+ #C1 = true
+ #C2 = false
}
diff --git a/pkg/front_end/testcases/general/conditional_import.dart.weak.outline.expect b/pkg/front_end/testcases/general/conditional_import.dart.weak.outline.expect
index 17e396c..98d7644 100644
--- a/pkg/front_end/testcases/general/conditional_import.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/conditional_import.dart.weak.outline.expect
@@ -4,7 +4,8 @@
import "dart:_http" as _ht;
import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:io" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -12,7 +13,9 @@
}
static method testA(_ht::HttpRequest request) → dynamic
;
-static method testB(self::HttpRequest request) → dynamic
+static method testB(_ht::HttpRequest request) → dynamic
+ ;
+static method testC(self::HttpRequest request) → dynamic
;
static method main() → void
;
diff --git a/pkg/front_end/testcases/general/conditional_import.dart.weak.transformed.expect b/pkg/front_end/testcases/general/conditional_import.dart.weak.transformed.expect
index 0ae3432..00999c9 100644
--- a/pkg/front_end/testcases/general/conditional_import.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/conditional_import.dart.weak.transformed.expect
@@ -2,25 +2,31 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'dart:_http'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error (from dart:html)
// ^^^^^^^^^^
//
-// pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// - 'HttpRequest' is from 'dart:_http'.
+// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
+// request.readyState; // error (from dart:html)
+// ^^^^^^^^^^
+//
+// pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
// request.certificate; // error
// ^^^^^^^^^^^
//
-// pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
// request.response; // error
// ^^^^^^^^
//
-// pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+// pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
// request.readyState; // error
@@ -32,7 +38,8 @@
import "dart:io" as io;
import "dart:io" as a;
-import "org-dartlang-testcase:///conditional_import.dart" as b;
+import "dart:io" as b;
+import "org-dartlang-testcase:///conditional_import.dart" as c;
class HttpRequest extends core::Object {
synthetic constructor •() → self::HttpRequest
@@ -42,25 +49,35 @@
static method testA(_ht::HttpRequest request) → dynamic {
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:22:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'dart:_http'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error (from dart:html)
^^^^^^^^^^" in request{<unresolved>}.readyState;
request.{core::Object::hashCode}{core::int};
}
-static method testB(self::HttpRequest request) → dynamic {
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
+static method testB(_ht::HttpRequest request) → dynamic {
+ request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
+ request.{_ht::HttpRequest::response}{_ht::HttpResponse};
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:29:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ - 'HttpRequest' is from 'dart:_http'.
+Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
+ request.readyState; // error (from dart:html)
+ ^^^^^^^^^^" in request{<unresolved>}.readyState;
+ request.{core::Object::hashCode}{core::int};
+}
+static method testC(self::HttpRequest request) → dynamic {
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:34:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
request.certificate; // error
^^^^^^^^^^^" in request{<unresolved>}.certificate;
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:35:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
request.response; // error
^^^^^^^^" in request{<unresolved>}.response;
- invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
+ invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:36:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
request.readyState; // error
@@ -69,8 +86,8 @@
}
static method main() → void {
self::expect(true, #C1);
- self::expect(false, #C1);
- self::expect(false, #C1);
+ self::expect(false, #C2);
+ self::expect(false, #C2);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
@@ -78,5 +95,6 @@
}
constants {
- #C1 = false
+ #C1 = true
+ #C2 = false
}
diff --git a/pkg/front_end/testcases/general/supported_libraries/import_default_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_default_lib.dart
new file mode 100644
index 0000000..00ee769
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/import_default_lib.dart
@@ -0,0 +1,5 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+String field = 'default';
diff --git a/pkg/front_end/testcases/general/supported_libraries/import_supported.by.spec_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_supported.by.spec_lib.dart
new file mode 100644
index 0000000..1c3a6c7
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/import_supported.by.spec_lib.dart
@@ -0,0 +1,5 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+String field = 'supported.by.spec';
diff --git a/pkg/front_end/testcases/general/supported_libraries/import_supported.by.target_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_supported.by.target_lib.dart
new file mode 100644
index 0000000..36d5727
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/import_supported.by.target_lib.dart
@@ -0,0 +1,5 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+String field = 'supported.by.target';
diff --git a/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_internal_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_internal_lib.dart
new file mode 100644
index 0000000..27ca303
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_internal_lib.dart
@@ -0,0 +1,5 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+String field = 'unsupported.by.spec_internal';
diff --git a/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_lib.dart
new file mode 100644
index 0000000..3b9f7f27
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.spec_lib.dart
@@ -0,0 +1,5 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+String field = 'unsupported.by.spec';
diff --git a/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.target_lib.dart b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.target_lib.dart
new file mode 100644
index 0000000..d0216e7
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/import_unsupported.by.target_lib.dart
@@ -0,0 +1,5 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+String field = 'unsupported.by.target';
diff --git a/pkg/front_end/testcases/general/supported_libraries/libraries.json b/pkg/front_end/testcases/general/supported_libraries/libraries.json
new file mode 100644
index 0000000..13d244b
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/libraries.json
@@ -0,0 +1,23 @@
+{
+ "none": {
+ "libraries": {
+ "supported.by.spec": {
+ "uri": "supported.by.spec_lib.dart"
+ },
+ "_supported.by.target": {
+ "uri": "supported.by.target_lib.dart"
+ },
+ "unsupported.by.spec": {
+ "uri": "unsupported.by.spec_lib.dart",
+ "supported": false
+ },
+ "unsupported.by.target": {
+ "uri": "unsupported.by.target_lib.dart",
+ "supported": true
+ },
+ "_unsupported.by.spec_internal": {
+ "uri": "unsupported.by.spec_internal_lib.dart"
+ }
+ }
+ }
+}
diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart b/pkg/front_end/testcases/general/supported_libraries/main.dart
new file mode 100644
index 0000000..0677973
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/main.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:supported.by.spec';
+import 'dart:unsupported.by.spec';
+import 'dart:unsupported.by.target';
+
+import 'import_default_lib.dart'
+ if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart'
+ if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart'
+ if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart'
+ if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart'
+ if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart'
+ as from_supported_by_spec_first;
+
+import 'import_default_lib.dart'
+ if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart'
+ if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart'
+ if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart'
+ if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart'
+ if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart'
+ as from_supported_by_target;
+
+import 'import_default_lib.dart'
+ if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart'
+ if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart'
+ if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart'
+ if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart'
+ if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart'
+ as from_supported_by_spec_last;
+
+main() {
+ supportedBySpec();
+ supportedByTarget(); // Exported through dart:supported.by.spec
+ unsupportedBySpec();
+ unsupportedByTarget();
+ unsupportedBySpecInternal(); // Exported through dart:unsupported.by.spec
+
+ expect('supported.by.spec', from_supported_by_spec_first.field);
+ expect('supported.by.target', from_supported_by_target.field);
+ expect('supported.by.spec', from_supported_by_spec_last.field);
+
+ // `dart:supported.by.spec` is supported by the libraries specification.
+ expect(true, const bool.fromEnvironment('dart.library.supported.by.spec'));
+ // `dart:_supported.by.target` is internal and therefore not supported by
+ // the libraries specification, but the test target supports it explicitly.
+ expect(true, const bool.fromEnvironment('dart.library._supported.by.target'));
+ // `dart:unsupported.by.spec` is unsupported by the libraries specification.
+ expect(false, const bool.fromEnvironment('dart.library.unsupported.by.spec'));
+ // `dart:unsupported.by.target` is unsupported by the libraries specification,
+ // but the test target explicitly marks it as unsupported.
+ expect(
+ false, const bool.fromEnvironment('dart.library.unsupported.by.target'));
+ // `dart:_unsupported.by.spec_internal` is internal and therefore not
+ // supported by the libraries specification.
+ expect(false,
+ const bool.fromEnvironment('dart.library._unsupported.by.spec_internal'));
+}
+
+expect(expected, actual) {
+ if (expected != actual) throw 'Expected $expected, actual $actual';
+}
diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline.expect
new file mode 100644
index 0000000..da8d39f
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline.expect
@@ -0,0 +1,27 @@
+import 'dart:supported.by.spec';
+import 'dart:unsupported.by.spec';
+import 'dart:unsupported.by.target';
+import 'import_default_lib.dart'
+ if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart'
+ if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart'
+ if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart'
+ if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart'
+ if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart'
+ as from_supported_by_spec_first;
+import 'import_default_lib.dart'
+ if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart'
+ if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart'
+ if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart'
+ if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart'
+ if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart'
+ as from_supported_by_target;
+import 'import_default_lib.dart'
+ if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart'
+ if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart'
+ if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart'
+ if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart'
+ if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart'
+ as from_supported_by_spec_last;
+
+main() {}
+expect(expected, actual) {}
diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..29001ab
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.textual_outline_modelled.expect
@@ -0,0 +1,27 @@
+import 'dart:supported.by.spec';
+import 'dart:unsupported.by.spec';
+import 'dart:unsupported.by.target';
+import 'import_default_lib.dart'
+ if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart'
+ if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart'
+ if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart'
+ if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart'
+ if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart'
+ as from_supported_by_spec_first;
+import 'import_default_lib.dart'
+ if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart'
+ if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart'
+ if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart'
+ if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart'
+ if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart'
+ as from_supported_by_target;
+import 'import_default_lib.dart'
+ if (dart.library.unsupported.by.spec) 'import_unsupported.by.spec_lib.dart'
+ if (dart.library.unsupported.by.target) 'import_unsupported.by.target_lib.dart'
+ if (dart.library._unsupported.by.spec_internal) 'import_unsupported.by.spec_internal_lib.dart'
+ if (dart.library.supported.by.spec) 'import_supported.by.spec_lib.dart'
+ if (dart.library._supported.by.target) 'import_supported.by.target_lib.dart'
+ as from_supported_by_spec_last;
+
+expect(expected, actual) {}
+main() {}
diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.expect
new file mode 100644
index 0000000..85a3cb7
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.expect
@@ -0,0 +1,87 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:supported.by.spec" as spec;
+import "dart:_supported.by.target" as by_;
+import "dart:unsupported.by.spec" as spec2;
+import "dart:unsupported.by.target" as tar;
+import "dart:_unsupported.by.spec_internal" as spe;
+import "import_supported.by.spec_lib.dart" as spe2;
+import "import_supported.by.target_lib.dart" as tar2;
+import "dart:core" as core;
+
+import "dart:supported.by.spec";
+import "dart:unsupported.by.spec";
+import "dart:unsupported.by.target";
+import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_first;
+import "org-dartlang-testcase:///import_supported.by.target_lib.dart" as from_supported_by_target;
+import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_last;
+
+static method main() → dynamic {
+ spec::supportedBySpec();
+ by_::supportedByTarget();
+ spec2::unsupportedBySpec();
+ tar::unsupportedByTarget();
+ spe::unsupportedBySpecInternal();
+ self::expect("supported.by.spec", spe2::field);
+ self::expect("supported.by.target", tar2::field);
+ self::expect("supported.by.spec", spe2::field);
+ self::expect(true, #C1);
+ self::expect(true, #C1);
+ self::expect(false, #C2);
+ self::expect(false, #C2);
+ self::expect(false, #C2);
+}
+static method expect(dynamic expected, dynamic actual) → dynamic {
+ if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
+ throw "Expected ${expected}, actual ${actual}";
+}
+
+library dart.supported.by.spec /*isNonNullableByDefault*/;
+import self as spec;
+import "dart:_supported.by.target" as by_;
+additionalExports = (by_::supportedByTarget)
+
+export "dart:_supported.by.target";
+
+static method supportedBySpec() → void {}
+
+library dart.unsupported.by.spec /*isUnsupported,isNonNullableByDefault*/;
+import self as spec2;
+import "dart:_unsupported.by.spec_internal" as spe;
+additionalExports = (spe::unsupportedBySpecInternal)
+
+export "dart:_unsupported.by.spec_internal";
+
+static method unsupportedBySpec() → void {}
+
+library dart.unsupported.by.target /*isNonNullableByDefault*/;
+import self as tar;
+
+static method unsupportedByTarget() → void {}
+
+library /*isNonNullableByDefault*/;
+import self as spe2;
+import "dart:core" as core;
+
+static field core::String field = "supported.by.spec";
+
+library /*isNonNullableByDefault*/;
+import self as tar2;
+import "dart:core" as core;
+
+static field core::String field = "supported.by.target";
+
+library dart._supported.by_target /*isUnsupported,isNonNullableByDefault*/;
+import self as by_;
+
+static method supportedByTarget() → void {}
+
+library dart._unsupported.by.spec_internal /*isUnsupported,isNonNullableByDefault*/;
+import self as spe;
+
+static method unsupportedBySpecInternal() → void {}
+
+constants {
+ #C1 = true
+ #C2 = false
+}
diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.modular.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.modular.expect
new file mode 100644
index 0000000..85a3cb7
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.modular.expect
@@ -0,0 +1,87 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:supported.by.spec" as spec;
+import "dart:_supported.by.target" as by_;
+import "dart:unsupported.by.spec" as spec2;
+import "dart:unsupported.by.target" as tar;
+import "dart:_unsupported.by.spec_internal" as spe;
+import "import_supported.by.spec_lib.dart" as spe2;
+import "import_supported.by.target_lib.dart" as tar2;
+import "dart:core" as core;
+
+import "dart:supported.by.spec";
+import "dart:unsupported.by.spec";
+import "dart:unsupported.by.target";
+import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_first;
+import "org-dartlang-testcase:///import_supported.by.target_lib.dart" as from_supported_by_target;
+import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_last;
+
+static method main() → dynamic {
+ spec::supportedBySpec();
+ by_::supportedByTarget();
+ spec2::unsupportedBySpec();
+ tar::unsupportedByTarget();
+ spe::unsupportedBySpecInternal();
+ self::expect("supported.by.spec", spe2::field);
+ self::expect("supported.by.target", tar2::field);
+ self::expect("supported.by.spec", spe2::field);
+ self::expect(true, #C1);
+ self::expect(true, #C1);
+ self::expect(false, #C2);
+ self::expect(false, #C2);
+ self::expect(false, #C2);
+}
+static method expect(dynamic expected, dynamic actual) → dynamic {
+ if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
+ throw "Expected ${expected}, actual ${actual}";
+}
+
+library dart.supported.by.spec /*isNonNullableByDefault*/;
+import self as spec;
+import "dart:_supported.by.target" as by_;
+additionalExports = (by_::supportedByTarget)
+
+export "dart:_supported.by.target";
+
+static method supportedBySpec() → void {}
+
+library dart.unsupported.by.spec /*isUnsupported,isNonNullableByDefault*/;
+import self as spec2;
+import "dart:_unsupported.by.spec_internal" as spe;
+additionalExports = (spe::unsupportedBySpecInternal)
+
+export "dart:_unsupported.by.spec_internal";
+
+static method unsupportedBySpec() → void {}
+
+library dart.unsupported.by.target /*isNonNullableByDefault*/;
+import self as tar;
+
+static method unsupportedByTarget() → void {}
+
+library /*isNonNullableByDefault*/;
+import self as spe2;
+import "dart:core" as core;
+
+static field core::String field = "supported.by.spec";
+
+library /*isNonNullableByDefault*/;
+import self as tar2;
+import "dart:core" as core;
+
+static field core::String field = "supported.by.target";
+
+library dart._supported.by_target /*isUnsupported,isNonNullableByDefault*/;
+import self as by_;
+
+static method supportedByTarget() → void {}
+
+library dart._unsupported.by.spec_internal /*isUnsupported,isNonNullableByDefault*/;
+import self as spe;
+
+static method unsupportedBySpecInternal() → void {}
+
+constants {
+ #C1 = true
+ #C2 = false
+}
diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.outline.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.outline.expect
new file mode 100644
index 0000000..5e500ab
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.outline.expect
@@ -0,0 +1,64 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+
+import "dart:supported.by.spec";
+import "dart:unsupported.by.spec";
+import "dart:unsupported.by.target";
+import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_first;
+import "org-dartlang-testcase:///import_supported.by.target_lib.dart" as from_supported_by_target;
+import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_last;
+
+static method main() → dynamic
+ ;
+static method expect(dynamic expected, dynamic actual) → dynamic
+ ;
+
+library dart.supported.by.spec /*isNonNullableByDefault*/;
+import self as self2;
+import "dart:_supported.by.target" as by_;
+additionalExports = (by_::supportedByTarget)
+
+export "dart:_supported.by.target";
+
+static method supportedBySpec() → void
+ ;
+
+library dart.unsupported.by.spec /*isUnsupported,isNonNullableByDefault*/;
+import self as self3;
+import "dart:_unsupported.by.spec_internal" as spe;
+additionalExports = (spe::unsupportedBySpecInternal)
+
+export "dart:_unsupported.by.spec_internal";
+
+static method unsupportedBySpec() → void
+ ;
+
+library dart.unsupported.by.target /*isNonNullableByDefault*/;
+import self as self4;
+
+static method unsupportedByTarget() → void
+ ;
+
+library /*isNonNullableByDefault*/;
+import self as self5;
+import "dart:core" as core;
+
+static field core::String field;
+
+library /*isNonNullableByDefault*/;
+import self as self6;
+import "dart:core" as core;
+
+static field core::String field;
+
+library dart._supported.by_target /*isUnsupported,isNonNullableByDefault*/;
+import self as by_;
+
+static method supportedByTarget() → void
+ ;
+
+library dart._unsupported.by.spec_internal /*isUnsupported,isNonNullableByDefault*/;
+import self as spe;
+
+static method unsupportedBySpecInternal() → void
+ ;
diff --git a/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.transformed.expect b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.transformed.expect
new file mode 100644
index 0000000..85a3cb7
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/main.dart.weak.transformed.expect
@@ -0,0 +1,87 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:supported.by.spec" as spec;
+import "dart:_supported.by.target" as by_;
+import "dart:unsupported.by.spec" as spec2;
+import "dart:unsupported.by.target" as tar;
+import "dart:_unsupported.by.spec_internal" as spe;
+import "import_supported.by.spec_lib.dart" as spe2;
+import "import_supported.by.target_lib.dart" as tar2;
+import "dart:core" as core;
+
+import "dart:supported.by.spec";
+import "dart:unsupported.by.spec";
+import "dart:unsupported.by.target";
+import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_first;
+import "org-dartlang-testcase:///import_supported.by.target_lib.dart" as from_supported_by_target;
+import "org-dartlang-testcase:///import_supported.by.spec_lib.dart" as from_supported_by_spec_last;
+
+static method main() → dynamic {
+ spec::supportedBySpec();
+ by_::supportedByTarget();
+ spec2::unsupportedBySpec();
+ tar::unsupportedByTarget();
+ spe::unsupportedBySpecInternal();
+ self::expect("supported.by.spec", spe2::field);
+ self::expect("supported.by.target", tar2::field);
+ self::expect("supported.by.spec", spe2::field);
+ self::expect(true, #C1);
+ self::expect(true, #C1);
+ self::expect(false, #C2);
+ self::expect(false, #C2);
+ self::expect(false, #C2);
+}
+static method expect(dynamic expected, dynamic actual) → dynamic {
+ if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
+ throw "Expected ${expected}, actual ${actual}";
+}
+
+library dart.supported.by.spec /*isNonNullableByDefault*/;
+import self as spec;
+import "dart:_supported.by.target" as by_;
+additionalExports = (by_::supportedByTarget)
+
+export "dart:_supported.by.target";
+
+static method supportedBySpec() → void {}
+
+library dart.unsupported.by.spec /*isUnsupported,isNonNullableByDefault*/;
+import self as spec2;
+import "dart:_unsupported.by.spec_internal" as spe;
+additionalExports = (spe::unsupportedBySpecInternal)
+
+export "dart:_unsupported.by.spec_internal";
+
+static method unsupportedBySpec() → void {}
+
+library dart.unsupported.by.target /*isNonNullableByDefault*/;
+import self as tar;
+
+static method unsupportedByTarget() → void {}
+
+library /*isNonNullableByDefault*/;
+import self as spe2;
+import "dart:core" as core;
+
+static field core::String field = "supported.by.spec";
+
+library /*isNonNullableByDefault*/;
+import self as tar2;
+import "dart:core" as core;
+
+static field core::String field = "supported.by.target";
+
+library dart._supported.by_target /*isUnsupported,isNonNullableByDefault*/;
+import self as by_;
+
+static method supportedByTarget() → void {}
+
+library dart._unsupported.by.spec_internal /*isUnsupported,isNonNullableByDefault*/;
+import self as spe;
+
+static method unsupportedBySpecInternal() → void {}
+
+constants {
+ #C1 = true
+ #C2 = false
+}
diff --git a/pkg/front_end/testcases/general/supported_libraries/supported.by.spec_lib.dart b/pkg/front_end/testcases/general/supported_libraries/supported.by.spec_lib.dart
new file mode 100644
index 0000000..ea5edc0
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/supported.by.spec_lib.dart
@@ -0,0 +1,9 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dart.supported.by.spec;
+
+export 'dart:_supported.by.target';
+
+void supportedBySpec() {}
diff --git a/pkg/front_end/testcases/general/supported_libraries/supported.by.target_lib.dart b/pkg/front_end/testcases/general/supported_libraries/supported.by.target_lib.dart
new file mode 100644
index 0000000..673f03d
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/supported.by.target_lib.dart
@@ -0,0 +1,7 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dart._supported.by_target;
+
+void supportedByTarget() {}
diff --git a/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_internal_lib.dart b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_internal_lib.dart
new file mode 100644
index 0000000..7171f88
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_internal_lib.dart
@@ -0,0 +1,7 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dart._unsupported.by.spec_internal;
+
+void unsupportedBySpecInternal() {}
diff --git a/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_lib.dart b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_lib.dart
new file mode 100644
index 0000000..ac010bb
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.spec_lib.dart
@@ -0,0 +1,9 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dart.unsupported.by.spec;
+
+export 'dart:_unsupported.by.spec_internal';
+
+void unsupportedBySpec() {}
diff --git a/pkg/front_end/testcases/general/supported_libraries/unsupported.by.target_lib.dart b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.target_lib.dart
new file mode 100644
index 0000000..0ef61dc
--- /dev/null
+++ b/pkg/front_end/testcases/general/supported_libraries/unsupported.by.target_lib.dart
@@ -0,0 +1,7 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dart.unsupported.by.target;
+
+void unsupportedByTarget() {}
diff --git a/pkg/front_end/testcases/rasta/supports_reflection.dart b/pkg/front_end/testcases/rasta/supports_reflection.dart
index 4b53e52..3aaf5ea 100644
--- a/pkg/front_end/testcases/rasta/supports_reflection.dart
+++ b/pkg/front_end/testcases/rasta/supports_reflection.dart
@@ -1,7 +1,9 @@
// Copyright (c) 2016, 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.md file.
+
// @dart=2.9
+
main() {
print(const bool.fromEnvironment("dart.library.mirrors"));
}
diff --git a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.expect b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.expect
index d2d46a3..362665c 100644
--- a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.expect
+++ b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.expect
@@ -7,5 +7,5 @@
}
constants {
- #C1 = false
+ #C1 = true
}
diff --git a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.modular.expect b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.modular.expect
index d2d46a3..362665c 100644
--- a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.modular.expect
@@ -7,5 +7,5 @@
}
constants {
- #C1 = false
+ #C1 = true
}
diff --git a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.transformed.expect b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.transformed.expect
index d2d46a3..362665c 100644
--- a/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/rasta/supports_reflection.dart.weak.transformed.expect
@@ -7,5 +7,5 @@
}
constants {
- #C1 = false
+ #C1 = true
}
diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status
index 577ee4a..b66d7f8 100644
--- a/pkg/front_end/testcases/text_serialization.status
+++ b/pkg/front_end/testcases/text_serialization.status
@@ -33,7 +33,6 @@
general/bug31124: RuntimeError
general/call: RuntimeError
general/cascade: RuntimeError
-general/conditional_import: RuntimeError # Issue 47814
general/constructor_initializer_invalid: RuntimeError
general/covariant_field: TypeCheckError
general/covariant_generic: RuntimeError
diff --git a/pkg/front_end/testcases/weak.status b/pkg/front_end/testcases/weak.status
index 699bd29..8898c1a 100644
--- a/pkg/front_end/testcases/weak.status
+++ b/pkg/front_end/testcases/weak.status
@@ -47,7 +47,6 @@
general/bug31124: RuntimeError # Test has no main method (and we shouldn't add one).
general/call: RuntimeError
general/cascade: RuntimeError
-general/conditional_import: RuntimeError # Issue 47814
general/constructor_initializer_invalid: RuntimeError # Fails execution after recovery
general/covariant_field: TypeCheckError
general/covariant_generic: RuntimeError
diff --git a/pkg/front_end/tool/dart_doctest_impl.dart b/pkg/front_end/tool/dart_doctest_impl.dart
index b03351a..c47c27b 100644
--- a/pkg/front_end/tool/dart_doctest_impl.dart
+++ b/pkg/front_end/tool/dart_doctest_impl.dart
@@ -832,6 +832,7 @@
loader: loader,
scope: libraryBuilder.scope.createNestedScope("dartdoctest"),
nameOrigin: libraryBuilder,
+ isUnsupported: false,
);
if (libraryBuilder is DillLibraryBuilder) {
diff --git a/pkg/frontend_server/lib/frontend_server.dart b/pkg/frontend_server/lib/frontend_server.dart
index 7563736..c1dac11 100644
--- a/pkg/frontend_server/lib/frontend_server.dart
+++ b/pkg/frontend_server/lib/frontend_server.dart
@@ -51,6 +51,10 @@
..addFlag('aot',
help: 'Run compiler in AOT mode (enables whole-program transformations)',
defaultsTo: false)
+ ..addFlag('support-mirrors',
+ help: 'Whether dart:mirrors is supported. By default dart:mirrors is '
+ 'supported when --aot and --minimal-kernel are not used.',
+ defaultsTo: null)
..addFlag('tfa',
help:
'Enable global type flow analysis and related transformations in AOT mode.',
@@ -487,6 +491,18 @@
}
}
+ if (options['support-mirrors'] == true) {
+ if (options['aot']) {
+ print('Error: --support-mirrors option cannot be used with --aot');
+ return false;
+ }
+ if (options['minimal-kernel']) {
+ print('Error: --support-mirrors option cannot be used with '
+ '--minimal-kernel');
+ return false;
+ }
+ }
+
if (options['incremental']) {
if (options['from-dill'] != null) {
print('Error: --from-dill option cannot be used with --incremental');
@@ -505,6 +521,8 @@
options['target'],
trackWidgetCreation: options['track-widget-creation'],
nullSafety: compilerOptions.nnbdMode == NnbdMode.Strong,
+ supportMirrors: options['support-mirrors'] ??
+ !(options['aot'] || options['minimal-kernel']),
);
if (compilerOptions.target == null) {
print('Failed to create front-end target ${options['target']}.');
diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md
index b75aba6..3df728f 100644
--- a/pkg/kernel/binary.md
+++ b/pkg/kernel/binary.md
@@ -147,7 +147,7 @@
type ComponentFile {
UInt32 magic = 0x90ABCDEF;
- UInt32 formatVersion = 75;
+ UInt32 formatVersion = 76;
Byte[10] shortSdkHash;
List<String> problemsAsJson; // Described in problems.md.
Library[] libraries;
@@ -237,7 +237,7 @@
}
type Library {
- Byte flags (isSynthetic, isNonNullableByDefault, nnbdModeBit1, nnbdModeBit2);
+ Byte flags (isSynthetic, isNonNullableByDefault, nnbdModeBit1, nnbdModeBit2, isUnsupported);
UInt languageVersionMajor;
UInt languageVersionMinor;
CanonicalNameReference canonicalName;
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 99a2f86..51270c4 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -273,6 +273,7 @@
static const int NonNullableByDefaultFlag = 1 << 1;
static const int NonNullableByDefaultModeBit1 = 1 << 2;
static const int NonNullableByDefaultModeBit2 = 1 << 3;
+ static const int IsUnsupportedFlag = 1 << 4;
int flags = 0;
@@ -322,6 +323,13 @@
}
}
+ /// If true, the library is not supported through the 'dart.library.*' value
+ /// used in conditional imports and `bool.fromEnvironment` constants.
+ bool get isUnsupported => flags & IsUnsupportedFlag != 0;
+ void set isUnsupported(bool value) {
+ flags = value ? (flags | IsUnsupportedFlag) : (flags & ~IsUnsupportedFlag);
+ }
+
String? name;
/// Problems in this [Library] encoded as json objects.
diff --git a/pkg/kernel/lib/binary/tag.dart b/pkg/kernel/lib/binary/tag.dart
index ceaae4a..a8a29ff 100644
--- a/pkg/kernel/lib/binary/tag.dart
+++ b/pkg/kernel/lib/binary/tag.dart
@@ -176,7 +176,7 @@
/// Internal version of kernel binary format.
/// Bump it when making incompatible changes in kernel binaries.
/// Keep in sync with runtime/vm/kernel_binary.h, pkg/kernel/binary.md.
- static const int BinaryFormatVersion = 75;
+ static const int BinaryFormatVersion = 76;
}
abstract class ConstantTag {
diff --git a/pkg/kernel/lib/target/targets.dart b/pkg/kernel/lib/target/targets.dart
index 804f26a..173d367 100644
--- a/pkg/kernel/lib/target/targets.dart
+++ b/pkg/kernel/lib/target/targets.dart
@@ -15,16 +15,20 @@
class TargetFlags {
final bool trackWidgetCreation;
final bool enableNullSafety;
+ final bool supportMirrors;
const TargetFlags(
- {this.trackWidgetCreation = false, this.enableNullSafety = false});
+ {this.trackWidgetCreation = false,
+ this.enableNullSafety = false,
+ this.supportMirrors = true});
@override
bool operator ==(other) {
if (identical(this, other)) return true;
return other is TargetFlags &&
trackWidgetCreation == other.trackWidgetCreation &&
- enableNullSafety == other.enableNullSafety;
+ enableNullSafety == other.enableNullSafety &&
+ supportMirrors == other.supportMirrors;
}
@override
@@ -32,6 +36,7 @@
int hash = 485786;
hash = 0x3fffffff & (hash * 31 + (hash ^ trackWidgetCreation.hashCode));
hash = 0x3fffffff & (hash * 31 + (hash ^ enableNullSafety.hashCode));
+ hash = 0x3fffffff & (hash * 31 + (hash ^ supportMirrors.hashCode));
return hash;
}
}
@@ -151,6 +156,95 @@
bool get keepLocals => false;
}
+/// Interface used for determining whether a `dart:*` is considered supported
+/// for the current target.
+abstract class DartLibrarySupport {
+ /// Returns `true` if the 'dart:[libraryName]' library is supported.
+ ///
+ /// [isSupportedBySpec] is `true` if the dart library was supported by the
+ /// libraries specification.
+ ///
+ /// This is used to allow AOT to consider `dart:mirrors` as unsupported
+ /// despite it being supported in the platform dill, and dart2js to consider
+ /// `dart:_dart2js_runtime_metrics` to be supported despite it being an
+ /// internal library.
+ bool computeDartLibrarySupport(String libraryName,
+ {required bool isSupportedBySpec});
+
+ static const String dartLibraryPrefix = "dart.library.";
+
+ static bool isDartLibraryQualifier(String dottedName) {
+ return dottedName.startsWith(dartLibraryPrefix);
+ }
+
+ static String getDartLibraryName(String dottedName) {
+ assert(isDartLibraryQualifier(dottedName));
+ return dottedName.substring(dartLibraryPrefix.length);
+ }
+
+ /// Returns `"true"` if the "dart:[libraryName]" is supported and `""`
+ /// otherwise.
+ ///
+ /// This is used to determine conditional imports and `bool.fromEnvironment`
+ /// constant values for "dart.library.[libraryName]" values.
+ static String getDartLibrarySupportValue(String libraryName,
+ {required bool libraryExists,
+ required bool isSynthetic,
+ required bool isUnsupported,
+ required DartLibrarySupport dartLibrarySupport}) {
+ // A `dart:` library can be unsupported for several reasons:
+ // * If the library doesn't exist from source or from dill, it is not
+ // supported.
+ // * If the library has been synthesized, then it doesn't exist, but has
+ // been synthetically created due to an explicit import or export of it,
+ // in which case it is also not supported.
+ // * If the library is marked as not supported in the libraries
+ // specification, it does exist, but is not supported.
+ // * If the library is marked as supported in the libraries specification,
+ // it does exist and is potentially supported. Still the [Target] can
+ // consider it unsupported. This is for instance used to consider
+ // `dart:mirrors` as unsupported in AOT. The platform dill is shared with
+ // JIT, so the library exists and is marked as supported, but for AOT
+ // compilation it is still unsupported.
+ bool isSupported = libraryExists && !isSynthetic && !isUnsupported;
+ isSupported = dartLibrarySupport.computeDartLibrarySupport(libraryName,
+ isSupportedBySpec: isSupported);
+ return isSupported ? "true" : "";
+ }
+}
+
+/// [DartLibrarySupport] that only relies on the "supported" property of
+/// the libraries specification.
+class DefaultDartLibrarySupport implements DartLibrarySupport {
+ const DefaultDartLibrarySupport();
+
+ @override
+ bool computeDartLibrarySupport(String libraryName,
+ {required bool isSupportedBySpec}) =>
+ isSupportedBySpec;
+}
+
+/// [DartLibrarySupport] that supports overriding `dart:*` library support
+/// otherwise defined by the libraries specification.
+class CustomizedDartLibrarySupport implements DartLibrarySupport {
+ final Set<String> supported;
+ final Set<String> unsupported;
+
+ const CustomizedDartLibrarySupport(
+ {this.supported: const {}, this.unsupported: const {}});
+
+ @override
+ bool computeDartLibrarySupport(String libraryName,
+ {required bool isSupportedBySpec}) {
+ if (supported.contains(libraryName)) {
+ return true;
+ } else if (unsupported.contains(libraryName)) {
+ return false;
+ }
+ return isSupportedBySpec;
+ }
+}
+
/// A target provides backend-specific options for generating kernel IR.
abstract class Target {
TargetFlags get flags;
@@ -434,7 +528,7 @@
/// Returns the configured component.
Component configureComponent(Component component) => component;
- // Configure environment defines in a target-specific way.
+ /// Configure environment defines in a target-specific way.
Map<String, String> updateEnvironmentDefines(Map<String, String> map) => map;
@override
@@ -453,6 +547,16 @@
Class? concreteStringLiteralClass(CoreTypes coreTypes, String value) => null;
ConstantsBackend get constantsBackend;
+
+ /// Returns an [DartLibrarySupport] the defines which, if any, of the
+ /// `dart:` libraries supported in the platform, that should not be
+ /// considered supported when queried in conditional imports and
+ /// `bool.fromEnvironment` constants.
+ ///
+ /// This is used treat `dart:mirrors` as unsupported in AOT but supported
+ /// in JIT.
+ DartLibrarySupport get dartLibrarySupport =>
+ const DefaultDartLibrarySupport();
}
class NoneConstantsBackend extends ConstantsBackend {
@@ -657,6 +761,8 @@
final bool? forceStaticFieldLoweringForTesting;
final bool? forceNoExplicitGetterCallsForTesting;
final int? forceConstructorTearOffLoweringForTesting;
+ final Set<String> supportedDartLibraries;
+ final Set<String> unsupportedDartLibraries;
const TestTargetFlags(
{bool trackWidgetCreation = false,
@@ -665,7 +771,9 @@
this.forceStaticFieldLoweringForTesting,
this.forceNoExplicitGetterCallsForTesting,
this.forceConstructorTearOffLoweringForTesting,
- bool enableNullSafety = false})
+ bool enableNullSafety = false,
+ this.supportedDartLibraries: const {},
+ this.unsupportedDartLibraries: const {}})
: super(
trackWidgetCreation: trackWidgetCreation,
enableNullSafety: enableNullSafety);
@@ -698,6 +806,29 @@
int get enabledConstructorTearOffLowerings =>
flags.forceConstructorTearOffLoweringForTesting ??
super.enabledConstructorTearOffLowerings;
+
+ @override
+ late final DartLibrarySupport dartLibrarySupport =
+ new TestDartLibrarySupport(super.dartLibrarySupport, flags);
+}
+
+class TestDartLibrarySupport implements DartLibrarySupport {
+ final DartLibrarySupport delegate;
+ final TestTargetFlags flags;
+
+ TestDartLibrarySupport(this.delegate, this.flags);
+
+ @override
+ bool computeDartLibrarySupport(String libraryName,
+ {required bool isSupportedBySpec}) {
+ if (flags.supportedDartLibraries.contains(libraryName)) {
+ return true;
+ } else if (flags.unsupportedDartLibraries.contains(libraryName)) {
+ return false;
+ }
+ return delegate.computeDartLibrarySupport(libraryName,
+ isSupportedBySpec: isSupportedBySpec);
+ }
}
class TargetWrapper extends Target {
diff --git a/pkg/kernel/lib/text/ast_to_text.dart b/pkg/kernel/lib/text/ast_to_text.dart
index 4f718b9..7f0ce5d 100644
--- a/pkg/kernel/lib/text/ast_to_text.dart
+++ b/pkg/kernel/lib/text/ast_to_text.dart
@@ -454,8 +454,15 @@
if (name != null) {
writeWord(name);
}
+ List<String> flags = [];
+ if (library.isUnsupported) {
+ flags.add('isUnsupported');
+ }
if (library.isNonNullableByDefault) {
- writeWord("/*isNonNullableByDefault*/");
+ flags.add('isNonNullableByDefault');
+ }
+ if (flags.isNotEmpty) {
+ writeWord('/*${flags.join(',')}*/');
}
endLine(';');
diff --git a/pkg/vm/lib/kernel_front_end.dart b/pkg/vm/lib/kernel_front_end.dart
index 871ee7d..74c8888 100644
--- a/pkg/vm/lib/kernel_front_end.dart
+++ b/pkg/vm/lib/kernel_front_end.dart
@@ -77,6 +77,10 @@
help:
'Produce kernel file for AOT compilation (enables global transformations).',
defaultsTo: false);
+ args.addFlag('support-mirrors',
+ help: 'Whether dart:mirrors is supported. By default dart:mirrors is '
+ 'supported when --aot and --minimal-kernel are not used.',
+ defaultsTo: null);
args.addOption('depfile', help: 'Path to output Ninja depfile');
args.addOption('from-dill',
help: 'Read existing dill file instead of compiling from sources',
@@ -193,6 +197,7 @@
final bool splitOutputByPackages = options['split-output-by-packages'];
final String? manifestFilename = options['manifest'];
final String? dataDir = options['component-name'] ?? options['data-dir'];
+ final bool? supportMirrors = options['support-mirrors'];
final bool minimalKernel = options['minimal-kernel'];
final bool treeShakeWriteOnlyFields = options['tree-shake-write-only-fields'];
@@ -215,6 +220,18 @@
}
}
+ if (supportMirrors == true) {
+ if (aot) {
+ print('Error: --support-mirrors option cannot be used with --aot');
+ return badUsageExitCode;
+ }
+ if (minimalKernel) {
+ print('Error: --support-mirrors option cannot be used with '
+ '--minimal-kernel');
+ return badUsageExitCode;
+ }
+ }
+
final fileSystem =
createFrontEndFileSystem(fileSystemScheme, fileSystemRoots);
@@ -258,11 +275,10 @@
await autoDetectNullSafetyMode(mainUri, compilerOptions);
}
- compilerOptions.target = createFrontEndTarget(
- targetName,
- trackWidgetCreation: options['track-widget-creation'],
- nullSafety: compilerOptions.nnbdMode == NnbdMode.Strong,
- );
+ compilerOptions.target = createFrontEndTarget(targetName,
+ trackWidgetCreation: options['track-widget-creation'],
+ nullSafety: compilerOptions.nnbdMode == NnbdMode.Strong,
+ supportMirrors: supportMirrors ?? !(aot || minimalKernel));
if (compilerOptions.target == null) {
print('Failed to create front-end target $targetName.');
return badUsageExitCode;
@@ -442,6 +458,7 @@
{bool minimalKernel: false,
bool treeShakeWriteOnlyFields: false,
bool useRapidTypeAnalysis: true}) async {
+ assert(!target.flags.supportMirrors);
if (errorDetector.hasCompilationErrors) return;
final coreTypes = new CoreTypes(component);
@@ -585,12 +602,16 @@
/// Create front-end target with given name.
Target? createFrontEndTarget(String targetName,
- {bool trackWidgetCreation = false, bool nullSafety = false}) {
+ {bool trackWidgetCreation = false,
+ bool nullSafety = false,
+ bool supportMirrors = true}) {
// Make sure VM-specific targets are available.
installAdditionalTargets();
final TargetFlags targetFlags = new TargetFlags(
- trackWidgetCreation: trackWidgetCreation, enableNullSafety: nullSafety);
+ trackWidgetCreation: trackWidgetCreation,
+ enableNullSafety: nullSafety,
+ supportMirrors: supportMirrors);
return getTarget(targetName, targetFlags);
}
diff --git a/pkg/vm/lib/target/vm.dart b/pkg/vm/lib/target/vm.dart
index cb866c8..da77a9e 100644
--- a/pkg/vm/lib/target/vm.dart
+++ b/pkg/vm/lib/target/vm.dart
@@ -500,18 +500,11 @@
// TODO(alexmarkov): Call this from the front-end in order to have
// the same defines when compiling platform.
map['dart.isVM'] = 'true';
- // TODO(dartbug.com/36460): Derive dart.library.* definitions from platform.
- for (String library in extraRequiredLibraries) {
- Uri libraryUri = Uri.parse(library);
- if (libraryUri.scheme == 'dart') {
- final path = libraryUri.path;
- if (!path.startsWith('_')) {
- map['dart.library.${path}'] = 'true';
- }
- }
- }
- // dart:core is not mentioned in Target.extraRequiredLibraries.
- map['dart.library.core'] = 'true';
return map;
}
+
+ @override
+ DartLibrarySupport get dartLibrarySupport => flags.supportMirrors
+ ? const DefaultDartLibrarySupport()
+ : const CustomizedDartLibrarySupport(unsupported: {'mirrors'});
}
diff --git a/pkg/vm/test/modular_kernel_plus_aot_test.dart b/pkg/vm/test/modular_kernel_plus_aot_test.dart
index 090a08d..8e05c6c 100644
--- a/pkg/vm/test/modular_kernel_plus_aot_test.dart
+++ b/pkg/vm/test/modular_kernel_plus_aot_test.dart
@@ -28,7 +28,7 @@
final Uri packagesFile = sdkRootFile('.packages');
final Uri librariesFile = sdkRootFile('sdk/lib/libraries.json');
- final vmTarget = VmTarget(TargetFlags());
+ final vmTarget = VmTarget(TargetFlags(supportMirrors: false));
await withTempDirectory((Uri uri) async {
final mixinFilename = uri.resolve('mixin.dart');
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 4febdf9..cf616ed 100644
--- a/pkg/vm/test/transformations/protobuf_aware_treeshaker/treeshaker_test.dart
+++ b/pkg/vm/test/transformations/protobuf_aware_treeshaker/treeshaker_test.dart
@@ -71,7 +71,7 @@
}
Future<void> compileAOT(Uri source) async {
- final target = TestingVmTarget(TargetFlags());
+ final target = TestingVmTarget(TargetFlags(supportMirrors: false));
Component component =
await compileTestCaseToKernelProgram(source, target: target);
diff --git a/runtime/vm/compiler/frontend/kernel_translation_helper.h b/runtime/vm/compiler/frontend/kernel_translation_helper.h
index ea30fa5..315e468 100644
--- a/runtime/vm/compiler/frontend/kernel_translation_helper.h
+++ b/runtime/vm/compiler/frontend/kernel_translation_helper.h
@@ -817,6 +817,7 @@
kIsNonNullableByDefault = 1 << 1,
kNonNullableByDefaultCompiledModeBit1 = 1 << 2,
kNonNullableByDefaultCompiledModeBit2 = 1 << 3,
+ kUnsupported = 1 << 4,
};
explicit LibraryHelper(KernelReaderHelper* helper, uint32_t binary_version)
diff --git a/runtime/vm/kernel_binary.h b/runtime/vm/kernel_binary.h
index 891a2b7..ff0cfa2 100644
--- a/runtime/vm/kernel_binary.h
+++ b/runtime/vm/kernel_binary.h
@@ -20,8 +20,8 @@
static const uint32_t kMagicProgramFile = 0x90ABCDEFu;
// Both version numbers are inclusive.
-static const uint32_t kMinSupportedKernelFormatVersion = 75;
-static const uint32_t kMaxSupportedKernelFormatVersion = 75;
+static const uint32_t kMinSupportedKernelFormatVersion = 76;
+static const uint32_t kMaxSupportedKernelFormatVersion = 76;
// Keep in sync with package:kernel/lib/binary/tag.dart
#define KERNEL_TAG_LIST(V) \
diff --git a/sdk/lib/io/process.dart b/sdk/lib/io/process.dart
index 453f333..bf2058f 100644
--- a/sdk/lib/io/process.dart
+++ b/sdk/lib/io/process.dart
@@ -85,6 +85,12 @@
///
/// Use this with care, as no asynchronous operations can be processed
/// in a isolate while it is blocked in a [sleep] call.
+/// ```dart
+/// var duration = const Duration(seconds: 5);
+/// print('Start sleeping');
+/// sleep(duration);
+/// print('5 seconds has passed');
+/// ```
void sleep(Duration duration) {
int milliseconds = duration.inMilliseconds;
if (milliseconds < 0) {
diff --git a/tests/language/final/initialize_inside_closure_test.dart b/tests/language/final/initialize_inside_closure_test.dart
new file mode 100644
index 0000000..f8fbcc8
--- /dev/null
+++ b/tests/language/final/initialize_inside_closure_test.dart
@@ -0,0 +1,20 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test - see https://github.com/dart-lang/sdk/issues/47991
+
+import 'dart:math';
+
+void main() {
+ () {
+ final should = Random().nextBool() || Random().nextBool();
+ final int a;
+
+ if (should) {
+ a = 1;
+ } else {
+ a = 2;
+ }
+ };
+}
diff --git a/tools/VERSION b/tools/VERSION
index 0477199..28c95b7 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 1
+PRERELEASE 2
PRERELEASE_PATCH 0
\ No newline at end of file