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

Side by Side Diff: pkg/analyzer/test/generated/compile_time_error_code_test.dart

Issue 705553003: Avoid traversing classes when looking for circular references in typedefs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.compile_time_error_code_test; 5 library engine.compile_time_error_code_test;
6 6
7 import 'package:analyzer/src/generated/source_io.dart'; 7 import 'package:analyzer/src/generated/source_io.dart';
8 import 'package:analyzer/src/generated/error.dart'; 8 import 'package:analyzer/src/generated/error.dart';
9 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; 9 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 4397 matching lines...) Expand 10 before | Expand all | Expand 10 after
4408 F foo(G g) => g; 4408 F foo(G g) => g;
4409 }'''); 4409 }''');
4410 resolve(source); 4410 resolve(source);
4411 assertErrors(source, [ 4411 assertErrors(source, [
4412 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 4412 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF,
4413 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, 4413 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF,
4414 StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); 4414 StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
4415 verify([source]); 4415 verify([source]);
4416 } 4416 }
4417 4417
4418 void test_typeAliasCannotReferenceItself_19459() {
4419 // A complex example involving multiple classes. This is legal, since
4420 // typedef F references itself only via a class.
4421 Source source = addSource(r'''
4422 class A<B, C> {}
4423 abstract class D {
4424 f(E e);
4425 }
4426 abstract class E extends A<dynamic, F> {}
4427 typedef D F();
4428 ''');
4429 resolve(source);
4430 assertNoErrors(source);
4431 verify([source]);
4432 }
4433
4418 void test_typeAliasCannotReferenceItself_parameterType_named() { 4434 void test_typeAliasCannotReferenceItself_parameterType_named() {
4419 Source source = addSource("typedef A({A a});"); 4435 Source source = addSource("typedef A({A a});");
4420 resolve(source); 4436 resolve(source);
4421 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]); 4437 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
4422 verify([source]); 4438 verify([source]);
4423 } 4439 }
4424 4440
4425 void test_typeAliasCannotReferenceItself_parameterType_positional() { 4441 void test_typeAliasCannotReferenceItself_parameterType_positional() {
4426 Source source = addSource("typedef A([A a]);"); 4442 Source source = addSource("typedef A([A a]);");
4427 resolve(source); 4443 resolve(source);
4428 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]); 4444 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
4429 verify([source]); 4445 verify([source]);
4430 } 4446 }
4431 4447
4432 void test_typeAliasCannotReferenceItself_parameterType_required() { 4448 void test_typeAliasCannotReferenceItself_parameterType_required() {
4433 Source source = addSource("typedef A(A a);"); 4449 Source source = addSource("typedef A(A a);");
4434 resolve(source); 4450 resolve(source);
4435 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]); 4451 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
4436 verify([source]); 4452 verify([source]);
4437 } 4453 }
4438 4454
4439 void test_typeAliasCannotReferenceItself_parameterType_typeArgument() { 4455 void test_typeAliasCannotReferenceItself_parameterType_typeArgument() {
4440 Source source = addSource("typedef A(List<A> a);"); 4456 Source source = addSource("typedef A(List<A> a);");
4441 resolve(source); 4457 resolve(source);
4442 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]); 4458 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
4443 verify([source]); 4459 verify([source]);
4444 } 4460 }
4445 4461
4446 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { 4462 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() {
4463 // A typedef is allowed to indirectly reference itself via a class.
4447 Source source = addSource(r''' 4464 Source source = addSource(r'''
4448 typedef C A(); 4465 typedef C A();
4449 typedef A B(); 4466 typedef A B();
4450 class C { 4467 class C {
4451 B a; 4468 B a;
4452 }'''); 4469 }''');
4453 resolve(source); 4470 resolve(source);
4454 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]); 4471 assertNoErrors(source);
4455 verify([source]); 4472 verify([source]);
4456 } 4473 }
4457 4474
4458 void test_typeAliasCannotReferenceItself_returnType() { 4475 void test_typeAliasCannotReferenceItself_returnType() {
4459 Source source = addSource("typedef A A();"); 4476 Source source = addSource("typedef A A();");
4460 resolve(source); 4477 resolve(source);
4461 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]); 4478 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
4462 verify([source]); 4479 verify([source]);
4463 } 4480 }
4464 4481
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
4760 void _check_wrongNumberOfParametersForOperator1(String name) { 4777 void _check_wrongNumberOfParametersForOperator1(String name) {
4761 _check_wrongNumberOfParametersForOperator(name, ""); 4778 _check_wrongNumberOfParametersForOperator(name, "");
4762 _check_wrongNumberOfParametersForOperator(name, "a, b"); 4779 _check_wrongNumberOfParametersForOperator(name, "a, b");
4763 } 4780 }
4764 } 4781 }
4765 4782
4766 main() { 4783 main() {
4767 _ut.groupSep = ' | '; 4784 _ut.groupSep = ' | ';
4768 runReflectiveTests(CompileTimeErrorCodeTest); 4785 runReflectiveTests(CompileTimeErrorCodeTest);
4769 } 4786 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698