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

Unified Diff: tests/language/no_such_method2_test.dart

Issue 12045019: Fix braino with return types, and make sure the compiler knows we might call noSuchMethod with a JS… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
Index: tests/language/no_such_method2_test.dart
===================================================================
--- tests/language/no_such_method2_test.dart (revision 0)
+++ tests/language/no_such_method2_test.dart (revision 0)
@@ -0,0 +1,31 @@
+// Copyright (c) 2013, 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 for https://code.google.com/p/dart/issues/detail?id=7697.
+// dart2js used to optimize [noSuchMethod] based on the user-provided
+// argument, and forget that the runtime might call it with its own
+// [InvocationMirror] implementation.
+
+class Hey {
+ foo() => noSuchMethod(new FakeInvocationMirror());
+ noSuchMethod(x) => x;
+}
+
+class You extends Hey {
+ // We used to think this method is always called with a
+ // FakeInvocationMirror instance, but it's also called with the
+ // internal mirror implementation.
+ noSuchMethod(x) => x.isGetter;
+}
+
+class FakeInvocationMirror implements InvocationMirror {
+ final bool isGetter = false;
+}
+
+main() {
+ var x = new Hey();
+ Expect.isTrue(x.foo() is FakeInvocationMirror);
+ var y = [new You()];
+ Expect.isTrue(y[0].bar);
+}

Powered by Google App Engine
This is Rietveld 408576698