Skip to content

Commit 0aa5cbd

Browse files
author
John Messerly
committed
fix #620, infer the input files from sources
also simplifies build of packages used by our tests this caused a bunch of tests that use parts to start passing R=nweiz@google.com Review URL: https://codereview.chromium.org/2234343003 .
1 parent 3d43b1d commit 0aa5cbd

40 files changed

+1301
-8827
lines changed

pkg/dev_compiler/karma.conf.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ module.exports = function(config) {
1515
files: [
1616
'lib/runtime/dart_*.js',
1717
// {pattern: 'test/browser/*.js', included: false}
18-
'gen/codegen_output/async_helper/async_helper.js',
19-
'gen/codegen_output/expect/expect.js',
20-
'gen/codegen_output/path/path.js',
21-
'gen/codegen_output/stack_trace/stack_trace.js',
22-
'gen/codegen_output/js/js.js',
23-
'gen/codegen_output/matcher/matcher.js',
24-
'gen/codegen_output/unittest/unittest.js',
18+
'gen/codegen_output/pkg/*.js',
2519
'gen/codegen_output/language/**.js',
2620
'gen/codegen_output/language/**.err',
2721
'gen/codegen_output/corelib/**.js',

pkg/dev_compiler/lib/src/compiler/code_generator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class CodeGenerator extends GeneralizingAstVisitor
236236
items.add(new JS.ExportDeclaration(
237237
js.call('const # = Object.create(null)', [libraryTemp])));
238238

239-
// dart:_runtime has a magic module that holds extenstion method symbols.
239+
// dart:_runtime has a magic module that holds extension method symbols.
240240
// TODO(jmesserly): find a cleaner design for this.
241241
if (_isDartRuntime(library)) {
242242
items.add(new JS.ExportDeclaration(

pkg/dev_compiler/lib/src/compiler/compiler.dart

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'dart:collection' show HashSet;
6-
import 'package:args/args.dart' show ArgParser, ArgResults;
7-
import 'package:args/src/usage_exception.dart' show UsageException;
5+
import 'dart:collection' show HashSet, Queue;
6+
import 'package:analyzer/dart/element/element.dart' show LibraryElement;
87
import 'package:analyzer/analyzer.dart'
9-
show
10-
AnalysisError,
11-
CompilationUnit,
12-
CompileTimeErrorCode,
13-
ErrorSeverity,
14-
StaticWarningCode;
8+
show AnalysisError, CompilationUnit, ErrorSeverity;
159
import 'package:analyzer/file_system/file_system.dart' show ResourceProvider;
1610
import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
1711
import 'package:analyzer/src/generated/source.dart' show DartUriResolver;
1812
import 'package:analyzer/src/generated/source_io.dart'
1913
show Source, SourceKind, UriResolver;
14+
import 'package:analyzer/src/summary/package_bundle_reader.dart'
15+
show InSummarySource;
16+
import 'package:args/args.dart' show ArgParser, ArgResults;
17+
import 'package:args/src/usage_exception.dart' show UsageException;
2018
import 'package:func/func.dart' show Func1;
2119
import 'package:path/path.dart' as path;
2220

@@ -76,14 +74,15 @@ class ModuleCompiler {
7674
var trees = <CompilationUnit>[];
7775
var errors = <AnalysisError>[];
7876

79-
// Validate that all parts were explicitly passed in.
80-
// If not, it's an error.
81-
var explicitParts = new HashSet<Source>();
82-
var usedParts = new HashSet<Source>();
77+
var librariesToCompile = new Queue<LibraryElement>();
78+
79+
var compilingSdk = false;
8380
for (var sourcePath in unit.sources) {
8481
var sourceUri = Uri.parse(sourcePath);
8582
if (sourceUri.scheme == '') {
8683
sourceUri = path.toUri(path.absolute(sourcePath));
84+
} else if (sourceUri.scheme == 'dart') {
85+
compilingSdk = true;
8786
}
8887
Source source = context.sourceFactory.forUri2(sourceUri);
8988

@@ -101,31 +100,32 @@ class ModuleCompiler {
101100

102101
// Ignore parts. They need to be handled in the context of their library.
103102
if (context.computeKindOf(source) == SourceKind.PART) {
104-
explicitParts.add(source);
105103
continue;
106104
}
107105

108-
var resolvedTree = context.resolveCompilationUnit2(source, source);
109-
trees.add(resolvedTree);
110-
errors.addAll(context.computeErrors(source));
106+
librariesToCompile.add(context.computeLibraryElement(source));
107+
}
108+
109+
var libraries = new HashSet<LibraryElement>();
110+
while (librariesToCompile.isNotEmpty) {
111+
var library = librariesToCompile.removeFirst();
112+
if (library.source is InSummarySource) continue;
113+
if (!compilingSdk && library.source.isInSystemLibrary) continue;
114+
if (!libraries.add(library)) continue;
115+
116+
librariesToCompile.addAll(library.importedLibraries);
117+
librariesToCompile.addAll(library.exportedLibraries);
118+
119+
var tree = context.resolveCompilationUnit(library.source, library);
120+
trees.add(tree);
121+
errors.addAll(context.computeErrors(library.source));
111122

112-
var library = resolvedTree.element.library;
113123
for (var part in library.parts) {
114-
if (!library.isInSdk) usedParts.add(part.source);
115124
trees.add(context.resolveCompilationUnit(part.source, library));
116125
errors.addAll(context.computeErrors(part.source));
117126
}
118127
}
119128

120-
// Check if all parts were explicitly passed in.
121-
// Also verify all explicitly parts were used.
122-
var missingParts = usedParts.difference(explicitParts);
123-
var unusedParts = explicitParts.difference(usedParts);
124-
errors.addAll(missingParts
125-
.map((s) => new AnalysisError(s, 0, 0, missingPartErrorCode)));
126-
errors.addAll(unusedParts
127-
.map((s) => new AnalysisError(s, 0, 0, unusedPartWarningCode)));
128-
129129
sortErrors(context, errors);
130130
var messages = <String>[];
131131
for (var e in errors) {
@@ -365,11 +365,3 @@ class JSModuleFile {
365365
return map;
366366
}
367367
}
368-
369-
/// (Public for tests) the error code used when a part is missing.
370-
final missingPartErrorCode = const CompileTimeErrorCode(
371-
'MISSING_PART', 'The part was not supplied as an input to the compiler.');
372-
373-
/// (Public for tests) the error code used when a part is unused.
374-
final unusedPartWarningCode = const StaticWarningCode('UNUSED_PART',
375-
'The part was not used by any libraries being compiled.', null, false);

pkg/dev_compiler/pubspec.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,5 @@ packages:
319319
url: "https://pub.dartlang.org"
320320
source: hosted
321321
version: "2.1.10"
322-
sdk: ">=1.17.0-dev.6.2 <2.0.0"
322+
sdks:
323+
dart: ">=1.17.0-dev.6.2 <2.0.0"

pkg/dev_compiler/test/browser/language_tests.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
'generic_field_mixin4_test': skip_fail,
203203
'generic_field_mixin5_test': skip_fail,
204204
'generic_field_mixin_test': skip_fail,
205+
'generic_instanceof_test': fail, // runtime strong mode reject
205206
'generic_instanceof2_test': skip_fail,
206207
'generic_is_check_test': skip_fail,
207208
'getter_closure_execution_order_test': skip_fail,
@@ -338,7 +339,6 @@
338339
'abstract_runtime_error_test_03_multi': notyetstrong,
339340
'abstract_syntax_test_00_multi': notyetstrong,
340341
'abstract_syntax_test_01_multi': notyetstrong,
341-
'application_test': notyetstrong,
342342
'argument_definition_test_01_multi': notyetstrong,
343343
'arithmetic_test': notyetstrong,
344344
'assign_static_type_test_01_multi': notyetstrong,
@@ -937,9 +937,6 @@
937937
'enum_syntax_test_30_multi': notyetstrong,
938938
'error_stacktrace_test': notyetstrong,
939939
'example_constructor_test': notyetstrong,
940-
'export_double_same_main_test': notyetstrong,
941-
'export_main_override_test': notyetstrong,
942-
'export_main_test': notyetstrong,
943940
'external_test_01_multi': notyetstrong,
944941
'external_test_02_multi': notyetstrong,
945942
'external_test_11_multi': notyetstrong,
@@ -1118,7 +1115,6 @@
11181115
'generic_constructor_mixin_test': notyetstrong,
11191116
'generic_field_mixin6_test_01_multi': notyetstrong,
11201117
'generic_field_mixin6_test_none_multi': notyetstrong,
1121-
'generic_instanceof_test': notyetstrong,
11221118
'generic_list_checked_test': notyetstrong,
11231119
'generic_test': notyetstrong,
11241120
'generics_test': notyetstrong,
@@ -1157,7 +1153,6 @@
11571153
'getter_setter_in_lib_test': notyetstrong,
11581154
'getters_setters2_test_02_multi': notyetstrong,
11591155
'getters_setters2_test_03_multi': notyetstrong,
1160-
'hello_script_test': notyetstrong,
11611156
'hidden_import_test_01_multi': notyetstrong,
11621157
'hidden_import_test_02_multi': notyetstrong,
11631158
'identical_const_test_01_multi': notyetstrong,
@@ -1239,7 +1234,6 @@
12391234
'inferrer_this_access_test': notyetstrong,
12401235
'inline_effect_context_test': notyetstrong,
12411236
'inline_in_for_initializer_and_bailout_test': notyetstrong,
1242-
'inline_super_test': notyetstrong,
12431237
'inline_test_context_test': notyetstrong,
12441238
'inline_value_context_test': notyetstrong,
12451239
'inlined_throw_test': notyetstrong,
@@ -1281,7 +1275,6 @@
12811275
'keyword_type_expression_test_02_multi': notyetstrong,
12821276
'keyword_type_expression_test_03_multi': notyetstrong,
12831277
'label_test': notyetstrong,
1284-
'lazy_static6_test': notyetstrong,
12851278
'least_upper_bound_expansive_test_01_multi': notyetstrong,
12861279
'least_upper_bound_expansive_test_02_multi': notyetstrong,
12871280
'least_upper_bound_expansive_test_03_multi': notyetstrong,
@@ -1305,15 +1298,12 @@
13051298
'least_upper_bound_test_29_multi': notyetstrong,
13061299
'least_upper_bound_test_30_multi': notyetstrong,
13071300
'least_upper_bound_test_32_multi': notyetstrong,
1308-
'library1_test': notyetstrong,
13091301
'library_ambiguous_test_00_multi': notyetstrong,
13101302
'library_ambiguous_test_01_multi': notyetstrong,
13111303
'library_ambiguous_test_02_multi': notyetstrong,
13121304
'library_ambiguous_test_03_multi': notyetstrong,
13131305
'library_ambiguous_test_04_multi': notyetstrong,
13141306
'library_ambiguous_test_05_multi': notyetstrong,
1315-
'library_juxtaposition_test': notyetstrong,
1316-
'library_prefixes_test': notyetstrong,
13171307
'list_double_index_in_loop2_test': notyetstrong,
13181308
'list_double_index_in_loop_test': notyetstrong,
13191309
'list_literal1_test_01_multi': notyetstrong,
@@ -1565,8 +1555,6 @@
15651555
'mixin_type_parameters_super_extends_test': notyetstrong,
15661556
'mixin_type_parameters_super_test': notyetstrong,
15671557
'mixin_with_two_implicit_constructors_test': notyetstrong,
1568-
'multi_pass2_test': notyetstrong,
1569-
'multi_pass_test': notyetstrong,
15701558
'multiline_newline_test_01_multi': notyetstrong,
15711559
'multiline_newline_test_02_multi': notyetstrong,
15721560
'multiline_newline_test_03_multi': notyetstrong,
@@ -1754,7 +1742,6 @@
17541742
'parameter_initializer_test': notyetstrong,
17551743
'parser_quirks_test': notyetstrong,
17561744
'part2_test': notyetstrong,
1757-
'part_test': notyetstrong,
17581745
'positional_parameters_type_test_01_multi': notyetstrong,
17591746
'positional_parameters_type_test_02_multi': notyetstrong,
17601747
'prefix14_test': notyetstrong,
@@ -1771,7 +1758,6 @@
17711758
'prefix_identifier_reference_test_05_multi': notyetstrong,
17721759
'prefix_unqualified_invocation_test_01_multi': notyetstrong,
17731760
'prefix_unqualified_invocation_test_02_multi': notyetstrong,
1774-
'private2_test': notyetstrong,
17751761
'private3_test': notyetstrong,
17761762
'private_access_test_01_multi': notyetstrong,
17771763
'private_access_test_02_multi': notyetstrong,
@@ -2051,10 +2037,8 @@
20512037
'this_test_07_multi': notyetstrong,
20522038
'this_test_08_multi': notyetstrong,
20532039
'throw_expr_test': notyetstrong,
2054-
'top_level_entry_test': notyetstrong,
20552040
'top_level_getter_no_setter1_test_01_multi': notyetstrong,
20562041
'top_level_getter_no_setter2_test_01_multi': notyetstrong,
2057-
'top_level_multiple_files_test': notyetstrong,
20582042
'toplevel_collision1_test_00_multi': notyetstrong,
20592043
'toplevel_collision1_test_01_multi': notyetstrong,
20602044
'toplevel_collision1_test_02_multi': notyetstrong,
@@ -2496,7 +2480,7 @@
24962480
'package_resource_test': notyetstrong,
24972481
'print_test_01_multi': notyetstrong,
24982482
'print_test_none_multi': notyetstrong,
2499-
'set_test': notyetstrong,
2483+
'set_test': fail, // runtime strong mode reject
25002484
'splay_tree_test': notyetstrong,
25012485
'string_base_vm_test': notyetstrong,
25022486
'string_from_environment3_test_01_multi': notyetstrong,

pkg/dev_compiler/test/codegen_expected/async_helper/async_helper.js

Lines changed: 0 additions & 76 deletions
This file was deleted.

pkg/dev_compiler/test/codegen_expected/destructuring.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ dart_library.library('destructuring', null, /* Imports */[
66
const dart = dart_sdk.dart;
77
const dartx = dart_sdk.dartx;
88
const destructuring = Object.create(null);
9+
const src__varargs = Object.create(null);
910
let intAnddynamic__Todynamic = () => (intAnddynamic__Todynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.int, dart.dynamic], [dart.dynamic])))();
1011
let intAnddynamic__Todynamic$ = () => (intAnddynamic__Todynamic$ = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.int, dart.dynamic], {c: dart.dynamic})))();
1112
let intAnddynamicTodynamic = () => (intAnddynamicTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.int, dart.dynamic])))();
1213
let intAnddynamicAnddynamicTodynamic = () => (intAnddynamicAnddynamicTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [core.int, dart.dynamic, dart.dynamic])))();
1314
let __Todynamic = () => (__Todynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [], [core.int, dart.dynamic, dart.dynamic])))();
1415
let __Todynamic$ = () => (__Todynamic$ = dart.constFn(dart.definiteFunctionType(dart.dynamic, [], {let: core.int, function: dart.dynamic, arguments: dart.dynamic})))();
1516
let __Todynamic$0 = () => (__Todynamic$0 = dart.constFn(dart.definiteFunctionType(dart.dynamic, [], {constructor: core.int, valueOf: dart.dynamic, hasOwnProperty: dart.dynamic})))();
17+
let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic])))();
1618
destructuring.f = function(a, b, c = 1) {
1719
destructuring.f(a, b, c);
1820
};
@@ -71,6 +73,19 @@ dart_library.library('destructuring', null, /* Imports */[
7173
destructuring.f(constructor, valueOf, hasOwnProperty);
7274
};
7375
dart.fn(destructuring.names_clashing_with_object_props, __Todynamic$0());
76+
src__varargs._Rest = class _Rest extends core.Object {
77+
new() {
78+
}
79+
};
80+
dart.setSignature(src__varargs._Rest, {
81+
constructors: () => ({new: dart.definiteFunctionType(src__varargs._Rest, [])})
82+
});
83+
src__varargs.rest = dart.const(new src__varargs._Rest());
84+
src__varargs.spread = function(args) {
85+
dart.throw(new core.StateError('The spread function cannot be called, ' + 'it should be compiled away.'));
86+
};
87+
dart.fn(src__varargs.spread, dynamicTodynamic());
7488
// Exports:
7589
exports.destructuring = destructuring;
90+
exports.src__varargs = src__varargs;
7691
});

0 commit comments

Comments
 (0)