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

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

Issue 2656363003: Fix mocking native classes and add a regression test. (Closed)
Patch Set: Fix mocking native classes and add a regression test. Created 3 years, 11 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 | tests/lib_strong/html/html_mock_test.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 3db18c433c4eaabe163af9c417d873e8151ec40b..76292e44a0094bd56c23647772c75b82cc9d4bb2 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -1463,7 +1463,8 @@ class CodeGenerator extends GeneralizingAstVisitor
// Doing better is a bit tricky, as our current codegen strategy for the
// mock methods encodes information about the number of arguments (and type
// arguments) that D expects.
- return _collectMockMethods(type).map(_implementMockMethod);
+ return _collectMockMethods(type)
+ .map((method) => _implementMockMethod(method, type));
}
/// Given a class C that implements method M from interface I, but does not
@@ -1485,7 +1486,7 @@ class CodeGenerator extends GeneralizingAstVisitor
/// return core.bool.as(this.noSuchMethod(
/// new dart.InvocationImpl('eatFood', args)));
/// }
- JS.Method _implementMockMethod(ExecutableElement method) {
+ JS.Method _implementMockMethod(ExecutableElement method, InterfaceType type) {
var invocationProps = <JS.Property>[];
addProperty(String name, JS.Expression value) {
invocationProps.add(new JS.Property(js.string(name), value));
@@ -1536,8 +1537,7 @@ class CodeGenerator extends GeneralizingAstVisitor
// We have a similar issue with `dgsend` helpers.
return new JS.Method(
_declareMemberName(method,
- useExtension:
- _extensionTypes.isNativeClass(method.enclosingElement)),
+ useExtension: _extensionTypes.isNativeClass(type.element)),
_makeGenericFunction(fn),
isGetter: method is PropertyAccessorElement && method.isGetter,
isSetter: method is PropertyAccessorElement && method.isSetter,
« no previous file with comments | « no previous file | tests/lib_strong/html/html_mock_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698