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

Unified Diff: tests/compiler/dart2js/type_checker_test.dart

Issue 17447003: Correctly type check type variable expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « sdk/lib/_internal/compiler/implementation/warnings.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/type_checker_test.dart
diff --git a/tests/compiler/dart2js/type_checker_test.dart b/tests/compiler/dart2js/type_checker_test.dart
index 08a8630b6d37ba7a24d2fb437ec38d16ff4214cc..c10aa774ad32a730d202d1a725b143441f13c891 100644
--- a/tests/compiler/dart2js/type_checker_test.dart
+++ b/tests/compiler/dart2js/type_checker_test.dart
@@ -46,7 +46,8 @@ main() {
testThis,
testSuper,
testOperatorsAssignability,
- testFieldInitializers];
+ testFieldInitializers,
+ testTypeVariableExpressions];
for (Function test in tests) {
setup();
test();
@@ -1025,6 +1026,25 @@ void testFieldInitializers() {
}""", MessageKind.NOT_ASSIGNABLE);
}
+void testTypeVariableExpressions() {
+ String script = """class Foo<T> {
+ void method() {}
+ }""";
+ LibraryElement library = mockLibrary(compiler, script);
+ compiler.parseScript(script, library);
+ ClassElement foo = library.find(const SourceString("Foo"));
+ foo.ensureResolved(compiler);
+ Element method = foo.lookupLocalMember(const SourceString('method'));
+
+ analyzeIn(method, "{ Type type = T; }");
+ analyzeIn(method, "{ T type = T; }", MessageKind.NOT_ASSIGNABLE);
+ analyzeIn(method, "{ int type = T; }", MessageKind.NOT_ASSIGNABLE);
+
+ analyzeIn(method, "{ String typeName = T.toString(); }");
+ analyzeIn(method, "{ T.foo; }", MessageKind.PROPERTY_NOT_FOUND);
+ analyzeIn(method, "{ T.foo(); }", MessageKind.METHOD_NOT_FOUND);
+ analyzeIn(method, "{ T + 1; }", MessageKind.OPERATOR_NOT_FOUND);
+}
const CLASS_WITH_METHODS = '''
class ClassWithMethods {
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/warnings.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698