Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a325ab0

Browse files
author
Dart CI
committed
Version 2.14.0-367.0.dev
Merge commit 'f5a98e7676030e96f55263ff987c0acb39f5256f' into 'dev'
2 parents 6e821af + f5a98e7 commit a325ab0

File tree

164 files changed

+6088
-7451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+6088
-7451
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,16 @@ Updated the Linter to `1.8.0`, which includes changes that
264264
[#46545]: https://github.com/dart-lang/sdk/issues/46545
265265
[1]: https://dart.dev/faq#q-what-browsers-do-you-support-as-javascript-compilation-targets
266266

267+
#### Dart Dev Compiler (DDC)
268+
269+
- **Breaking Change** [#44154][]: Subtyping relations of `package:js` classes
270+
have been changed to be more correct and consistent with Dart2JS.
271+
Like `anonymous` classes, non-`anonymous` classes will no longer check the
272+
underlying type in DDC. The internal type representation of these objects have
273+
changed as well, which will affect the `toString` value of these types.
274+
275+
[#44154]: https://github.com/dart-lang/sdk/issues/44154
276+
267277
## 2.13.4 - 2021-06-28
268278

269279
This is a patch release that fixes:

pkg/compiler/lib/src/compiler.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ abstract class Compiler {
9191
ImpactCacheDeleter get impactCacheDeleter => _impactCacheDeleter;
9292

9393
final Environment environment;
94-
// TODO(sigmund): delete once we migrate the rest of the compiler to use
95-
// `environment` directly.
96-
@deprecated
97-
fromEnvironment(String name) => environment.valueOf(name);
9894

9995
Entity get currentElement => _reporter.currentElement;
10096

pkg/compiler/test/codegen/data_2/unused_empty_map.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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+
// ignore_for_file: unused_local_variable
6+
57
@pragma('dart2js:noInline')
68
// No code to construct unused map.
79
/*member: foo1:function() {

pkg/compiler/test/deferred/load_graph_segmentation_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void main() {
4242

4343
var mainOutputUnit = closedWorld.outputUnitData.mainOutputUnit;
4444
var backendStrategy = compiler.backendStrategy;
45+
// ignore: deprecated_member_use_from_same_package
4546
var classes = backendStrategy.emitterTask.neededClasses;
4647
var inputElement = classes.where((e) => e.name == 'InputElement').single;
4748
dynamic lib1 = lookupLibrary("memory:lib1.dart");

pkg/compiler/test/end_to_end/diagnostic_reporter_helper.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ abstract class DiagnosticReporterWrapper extends DiagnosticReporter {
5656
@override
5757
void reportInfoMessage(Spannable node, MessageKind errorCode,
5858
[Map<String, String> arguments = const {}]) {
59+
// ignore: deprecated_member_use_from_same_package
5960
reporter.reportInfoMessage(node, errorCode, arguments);
6061
}
6162

pkg/compiler/test/end_to_end/library_env_test.dart

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -85,48 +85,57 @@ class CustomCompiler extends CompilerImpl {
8585
}
8686

8787
runTest() async {
88-
var compiler = new CustomCompiler([], {});
89-
90-
await compiler.setupSdk();
91-
92-
// Core libraries are always present.
93-
Expect.equals("true", compiler.fromEnvironment("dart.library.collection"));
94-
// Non-existing entries in the environment return 'null'.
95-
Expect.isNull(compiler.fromEnvironment("not in env"));
96-
// Check for client libraries (default if there are no flags to the compiler).
97-
Expect.equals("true", compiler.fromEnvironment("dart.library.mock.client"));
98-
Expect.equals("true", compiler.fromEnvironment("dart.library.html"));
99-
// Check for shared libraries..
100-
Expect.equals("true", compiler.fromEnvironment("dart.library.mock.shared"));
101-
// Check server libraries are not present.
102-
Expect.equals(null, compiler.fromEnvironment("dart.library.mock.server"));
103-
Expect.equals(null, compiler.fromEnvironment("dart.library.io"));
104-
105-
compiler = new CustomCompiler([Flags.serverMode], {});
106-
107-
await compiler.setupSdk();
108-
109-
// Core libraries are always present.
110-
Expect.equals("true", compiler.fromEnvironment("dart.library.collection"));
111-
// Non-existing entries in the environment return 'null'.
112-
Expect.isNull(compiler.fromEnvironment("not in env"));
113-
// Check client libraries are not present.
114-
Expect.equals(null, compiler.fromEnvironment("dart.library.mock.client"));
115-
Expect.equals(null, compiler.fromEnvironment("dart.library.html"));
116-
// Check for shared libraries..
117-
Expect.equals("true", compiler.fromEnvironment("dart.library.mock.shared"));
118-
// Check for server libraries.
119-
Expect.equals("true", compiler.fromEnvironment("dart.library.mock.server"));
120-
Expect.equals("true", compiler.fromEnvironment("dart.library.io"));
121-
122-
// Check that user-defined env-variables win.
123-
compiler = new CustomCompiler([],
124-
{'dart.library.collection': "false", 'dart.library.mock.client': "foo"});
125-
126-
await compiler.setupSdk();
127-
128-
Expect.equals("false", compiler.fromEnvironment("dart.library.collection"));
129-
Expect.equals("foo", compiler.fromEnvironment("dart.library.mock.client"));
88+
{
89+
final compiler = new CustomCompiler([], {});
90+
91+
await compiler.setupSdk();
92+
final lookup = compiler.environment.valueOf;
93+
94+
// Core libraries are always present.
95+
Expect.equals("true", lookup("dart.library.collection"));
96+
// Non-existing entries in the environment return 'null'.
97+
Expect.isNull(lookup("not in env"));
98+
// Check for client libraries (default if there are no flags to the compiler).
99+
Expect.equals("true", lookup("dart.library.mock.client"));
100+
Expect.equals("true", lookup("dart.library.html"));
101+
// Check for shared libraries..
102+
Expect.equals("true", lookup("dart.library.mock.shared"));
103+
// Check server libraries are not present.
104+
Expect.equals(null, lookup("dart.library.mock.server"));
105+
Expect.equals(null, lookup("dart.library.io"));
106+
}
107+
{
108+
final compiler = new CustomCompiler([Flags.serverMode], {});
109+
110+
await compiler.setupSdk();
111+
final lookup = compiler.environment.valueOf;
112+
113+
// Core libraries are always present.
114+
Expect.equals("true", lookup("dart.library.collection"));
115+
// Non-existing entries in the environment return 'null'.
116+
Expect.isNull(lookup("not in env"));
117+
// Check client libraries are not present.
118+
Expect.equals(null, lookup("dart.library.mock.client"));
119+
Expect.equals(null, lookup("dart.library.html"));
120+
// Check for shared libraries..
121+
Expect.equals("true", lookup("dart.library.mock.shared"));
122+
// Check for server libraries.
123+
Expect.equals("true", lookup("dart.library.mock.server"));
124+
Expect.equals("true", lookup("dart.library.io"));
125+
}
126+
{
127+
// Check that user-defined env-variables win.
128+
final compiler = new CustomCompiler([], {
129+
'dart.library.collection': "false",
130+
'dart.library.mock.client': "foo"
131+
});
132+
133+
await compiler.setupSdk();
134+
final lookup = compiler.environment.valueOf;
135+
136+
Expect.equals("false", lookup("dart.library.collection"));
137+
Expect.equals("foo", lookup("dart.library.mock.client"));
138+
}
130139
}
131140

132141
main() {

pkg/dev_compiler/lib/src/kernel/command.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,13 +748,17 @@ ModuleSymbols _emitSymbols(ProgramCompiler compiler, String moduleName,
748748
for (var e in compiler.classIdentifiers.entries)
749749
e.key: identifierNames[e.value],
750750
};
751+
var procedureJsNames = <Procedure, String>{
752+
for (var e in compiler.procedureIdentifiers.entries)
753+
e.key: identifierNames[e.value],
754+
};
751755
var variableJsNames = <VariableDeclaration, String>{
752756
for (var e in compiler.variableIdentifiers.entries)
753757
e.key: identifierNames[e.value],
754758
};
755759

756-
return ModuleSymbolsCollector(
757-
moduleName, classJsNames, compiler.memberNames, variableJsNames)
760+
return ModuleSymbolsCollector(moduleName, classJsNames, compiler.memberNames,
761+
procedureJsNames, variableJsNames)
758762
.collectSymbolInfo(component);
759763
}
760764

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

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
6161
/// module.
6262
final memberNames = <Member, String>{};
6363

64+
/// Maps each `Procedure` node compiled in the module to the `Identifier`s
65+
/// used to name the class in JavaScript.
66+
///
67+
/// This mapping is used when generating the symbol information for the
68+
/// module.
69+
final procedureIdentifiers = <Procedure, js_ast.Identifier>{};
70+
6471
/// Maps each `VariableDeclaration` node compiled in the module to the name
6572
/// used for the variable in JavaScript.
6673
///
@@ -1670,7 +1677,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
16701677
ctorFields = ctor.initializers
16711678
.map((c) => c is FieldInitializer ? c.field : null)
16721679
.toSet()
1673-
..remove(null);
1680+
..remove(null);
16741681
}
16751682

16761683
var body = <js_ast.Statement>[];
@@ -2368,8 +2375,9 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
23682375
Class memberClass}) {
23692376
// Static members skip the rename steps and may require JS interop renames.
23702377
if (isStatic) {
2371-
// TODO(nshahan) Record the name for this member in memberNames.
2372-
return _emitStaticMemberName(name, member);
2378+
var memberName = _emitStaticMemberName(name, member);
2379+
memberNames[member] = memberName.valueWithoutQuotes;
2380+
return memberName;
23732381
}
23742382

23752383
// We allow some (illegal in Dart) member names to be used in our private
@@ -2379,6 +2387,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
23792387
var runtimeName = _jsExportName(member);
23802388
if (runtimeName != null) {
23812389
var parts = runtimeName.split('.');
2390+
// TODO(nshahan) Record the name for this member in memberNames.
23822391
if (parts.length < 2) return propertyName(runtimeName);
23832392

23842393
js_ast.Expression result = _emitIdentifier(parts[0]);
@@ -2652,8 +2661,9 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
26522661
_currentUri = node.fileUri;
26532662

26542663
var name = node.name.text;
2664+
memberNames[node] = name;
26552665
var result = js_ast.Method(
2656-
propertyName(name), _emitFunction(node.function, node.name.text),
2666+
propertyName(name), _emitFunction(node.function, name),
26572667
isGetter: node.isGetter, isSetter: node.isSetter)
26582668
..sourceInformation = _nodeEnd(node.fileEndOffset);
26592669

@@ -2678,8 +2688,10 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
26782688

26792689
var nameExpr = _emitTopLevelName(p);
26802690
var jsName = _safeFunctionNameForSafari(p.name.text, fn);
2681-
body.add(js.statement('# = #',
2682-
[nameExpr, js_ast.NamedFunction(_emitTemporaryId(jsName), fn)]));
2691+
var functionName = _emitTemporaryId(jsName);
2692+
procedureIdentifiers[p] = functionName;
2693+
body.add(js.statement(
2694+
'# = #', [nameExpr, js_ast.NamedFunction(functionName, fn)]));
26832695

26842696
_currentUri = savedUri;
26852697
_staticTypeContext.leaveMember(p);
@@ -2872,27 +2884,15 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
28722884
js_ast.Expression typeRep;
28732885

28742886
// Type parameters don't matter as JS interop types cannot be reified.
2875-
// We have to use lazy JS types because until we have proper module
2876-
// loading for JS libraries bundled with Dart libraries, we will sometimes
2877-
// need to load Dart libraries before the corresponding JS libraries are
2878-
// actually loaded.
2879-
// Given a JS type such as:
2880-
// @JS('google.maps.Location')
2881-
// class Location { ... }
2882-
// We can't emit a reference to MyType because the JS library that defines
2883-
// it may be loaded after our code. So for now, we use a special lazy type
2884-
// object to represent MyType.
2885-
// Anonymous JS types do not have a corresponding concrete JS type so we
2886-
// have to use a helper to define them.
2887-
if (isJSAnonymousType(c)) {
2888-
typeRep = runtimeCall(
2889-
'anonymousJSType(#)', [js.escapedString(getLocalClassName(c))]);
2890-
} else {
2891-
var jsName = _emitJsNameWithoutGlobal(c);
2892-
if (jsName != null) {
2893-
typeRep = runtimeCall('lazyJSType(() => #, #)',
2894-
[_emitJSInteropForGlobal(jsName), js.escapedString(jsName)]);
2895-
}
2887+
// package:js types fall under either named or anonymous types. Named types
2888+
// are used to correspond to JS types that exist, but we do not use the
2889+
// underlying type for type checks, so they operate virtually the same as
2890+
// anonymous types. We represent package:js types with a corresponding type
2891+
// object.
2892+
var jsName = isJSAnonymousType(c) ?
2893+
getLocalClassName(c) : _emitJsNameWithoutGlobal(c);
2894+
if (jsName != null) {
2895+
typeRep = runtimeCall('packageJSType(#)', [js.escapedString(jsName)]);
28962896
}
28972897

28982898
if (typeRep != null) {
@@ -3605,7 +3605,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
36053605
}
36063606

36073607
for (var p in f.positionalParameters) {
3608-
var jsParam = _emitVariableDef(p);
3608+
var jsParam = _emitVariableRef(p);
36093609
if (_checkParameters) {
36103610
initParameter(p, jsParam);
36113611
}
@@ -4510,21 +4510,19 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
45104510
var name = v.name;
45114511
if (name == null || name.startsWith('#')) {
45124512
name = name == null ? 't${_tempVariables.length}' : name.substring(1);
4513-
// TODO(nshahan) Record the Identifier for this variable in
4514-
// variableIdentifiers.
45154513
return _tempVariables.putIfAbsent(v, () => _emitTemporaryId(name));
45164514
}
4517-
var identifier = _emitIdentifier(name);
4518-
variableIdentifiers[v] = identifier;
4519-
return identifier;
4515+
return _emitIdentifier(name);
45204516
}
45214517

45224518
/// Emits the declaration of a variable.
45234519
///
45244520
/// This is similar to [_emitVariableRef] but it also attaches source
45254521
/// location information, so hover will work as expected.
45264522
js_ast.Identifier _emitVariableDef(VariableDeclaration v) {
4527-
return _emitVariableRef(v)..sourceInformation = _nodeStart(v);
4523+
var identifier = _emitVariableRef(v)..sourceInformation = _nodeStart(v);
4524+
variableIdentifiers[v] = identifier;
4525+
return identifier;
45284526
}
45294527

45304528
js_ast.Statement _initLetVariables() {
@@ -6403,8 +6401,9 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
64036401
Library library, String className, Member member,
64046402
[js_ast.TemporaryId id]) {
64056403
var name = '$className.${member.name.text}';
6406-
// Names used in the symbols for the public fields
6407-
// memberNames[member] = 'Symbol($name)';
6404+
// Wrap the name as a symbol here so it matches what you would find at
6405+
// runtime when you get all properties and symbols from an instance.
6406+
memberNames[member] = 'Symbol($name)';
64086407
return emitPrivateNameSymbol(library, name, id);
64096408
}
64106409

pkg/dev_compiler/lib/src/kernel/module_symbols_collector.dart

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ class ModuleSymbolsCollector extends RecursiveVisitor {
1414
/// The first scope added to the stack should always be the library scope. The
1515
/// last element in the list represents the current scope.
1616
final _scopes = <ScopeSymbol>[];
17+
1718
final ModuleSymbols _moduleSymbols;
1819
final Map<Class, String> _classJsNames;
1920
final Map<Member, String> _memberJsNames;
21+
final Map<Procedure, String> _procedureJsNames;
2022
final Map<VariableDeclaration, String> _variableJsNames;
2123

2224
ModuleSymbolsCollector(String moduleName, this._classJsNames,
23-
this._memberJsNames, this._variableJsNames)
25+
this._memberJsNames, this._procedureJsNames, this._variableJsNames)
2426
: _moduleSymbols = ModuleSymbols(
2527
version: ModuleSymbols.current.version,
2628
moduleName: moduleName,
2729
libraries: <LibrarySymbol>[],
2830
scripts: <Script>[],
2931
classes: <ClassSymbol>[],
3032
// TODO(nshahan) functionTypes
31-
// TODO(nshahan) functions
33+
functions: <FunctionSymbol>[],
3234
// TODO(nshahan) scopes
3335
variables: <VariableSymbol>[]);
3436

@@ -142,8 +144,27 @@ class ModuleSymbolsCollector extends RecursiveVisitor {
142144
// Legacy libraries contain procedures with no bodies for all Object methods
143145
// in every class. We can ignore these unless they actually contain a body.
144146
if (node.function.body == null) return;
145-
// TODO(nshahan) implement visitProcedure
146-
super.visitProcedure(node);
147+
var functionSymbol = FunctionSymbol(
148+
name: node.name.text,
149+
// TODO(nshahan) typeId - probably should canonicalize but keep original
150+
// type argument names.
151+
isStatic: node.isStatic,
152+
isConst: node.isConst,
153+
localId: _memberJsNames[node] ?? _procedureJsNames[node],
154+
scopeId: _scopes.last.id,
155+
variableIds: <String>[],
156+
scopeIds: <String>[],
157+
location: SourceLocation(
158+
scriptId: _scriptId(node.location.file),
159+
tokenPos: node.fileOffset,
160+
endTokenPos: node.fileEndOffset));
161+
162+
_scopes.add(functionSymbol);
163+
node.visitChildren(this);
164+
_scopes
165+
..removeLast()
166+
..last.scopeIds.add(functionSymbol.id);
167+
_moduleSymbols.functions.add(functionSymbol);
147168
}
148169

149170
@override

0 commit comments

Comments
 (0)