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

Unified Diff: tests/language/src/MethodOverrideTest.dart

Issue 8393033: Fix type tests involving an implicit closure of a non-parameterized class (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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 | « tests/language/language.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/src/MethodOverrideTest.dart
===================================================================
--- tests/language/src/MethodOverrideTest.dart (revision 0)
+++ tests/language/src/MethodOverrideTest.dart (revision 0)
@@ -0,0 +1,59 @@
+// Copyright (c) 2011, 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.
+
+// Checks that a method with an instantiated return type can override a method
+// with a generic return type.
+
+typedef Collection<K> GetKeysFunctionType<K>();
+
+class MapBase<K, V> implements Map<K, V> {
+ Collection<K> getKeys() {
+ throw 'Must be implemented';
+ }
+
+ void Tests() {
+ Expect.isTrue(this is MapBase<int, int>);
+
+ Expect.isTrue(getKeys is GetKeysFunctionType);
+ Expect.isTrue(getKeys is GetKeysFunctionType<int>);
+ Expect.isTrue(getKeys is !GetKeysFunctionType<String>);
+ Expect.isTrue(getKeys is !GetKeysFunctionType<MapBase<int, int>>);
+ }
+}
+
+
+class MethodOverrideTest extends MapBase<String, String> {
+ Collection<String> getKeys() {
+ throw 'Is implemented';
+ }
+
+ void Tests() {
+ Expect.isTrue(this is MethodOverrideTest);
+ Expect.isTrue(this is MapBase<String, String>);
+
+ Expect.isTrue(getKeys is GetKeysFunctionType);
+ Expect.isTrue(getKeys is GetKeysFunctionType<String>);
+ Expect.isTrue(getKeys is !GetKeysFunctionType<int>);
+ Expect.isTrue(super.getKeys is GetKeysFunctionType);
+ Expect.isTrue(super.getKeys is GetKeysFunctionType<String>);
+ Expect.isTrue(super.getKeys is !GetKeysFunctionType<int>);
+ }
+}
+
+
+main() {
+ // Since method overriding is only checked statically, explicitly check
+ // the subtyping relation using a function type alias.
+ var x = new MethodOverrideTest();
+ Expect.isTrue(x.getKeys is GetKeysFunctionType<String>);
+
+ // Perform a few more tests.
+ x.Tests();
+
+ var m = new MapBase<int, int>();
+ Expect.isTrue(m.getKeys is GetKeysFunctionType<int>);
+
+ // Perform a few more tests.
+ m.Tests();
+}
« no previous file with comments | « tests/language/language.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698