Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2920223009: fix "unresolved names" code generation (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/dev_compiler/test/codegen/unresolved_names.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index 59a7f832b79479f30df2454005008fc8638f2ffd..e16da07ab5c59fa6ad5d6010b79f5b4f741aa216 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -2811,8 +2811,8 @@ class CodeGenerator extends Object
JS.Expression _emitSimpleIdentifier(SimpleIdentifier node) {
var accessor = resolutionMap.staticElementForIdentifier(node);
if (accessor == null) {
- return js.commentExpression(
- 'Unimplemented unknown name', new JS.Identifier(node.name));
+ return _callHelper('throw("compile error: unresolved identifier: " + #)',
+ js.escapedString(node.name ?? '<null>'));
}
// Get the original declaring element. If we had a property accessor, this
@@ -4101,14 +4101,11 @@ class CodeGenerator extends Object
bool isFactory = false;
bool isNative = false;
if (element == null) {
- // TODO(jmesserly): this only happens if we had a static error.
- // Should we generate a throw instead?
- ctor = _emitConstructorAccess(type,
- nameType: options.hoistInstanceCreation,
- hoistType: options.hoistInstanceCreation);
- if (name != null) {
- ctor = new JS.PropertyAccess(ctor, _propertyName(name.name));
- }
+ ctor = _callHelper(
+ 'throw("compile error: unresolved constructor: " + # + "." + #)', [
+ js.escapedString(type?.name ?? '<null>'),
+ js.escapedString(name?.name ?? '<unnamed>')
+ ]);
} else {
ctor = _emitConstructorName(element, type, name);
isFactory = element.isFactory;
« no previous file with comments | « no previous file | pkg/dev_compiler/test/codegen/unresolved_names.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698