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

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

Issue 2837173002: fix #29426, class type alias was missing checks (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
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 analyzer.test.generated.compile_time_error_code_test; 5 library analyzer.test.generated.compile_time_error_code_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/error/error.dart'; 9 import 'package:analyzer/error/error.dart';
10 import 'package:analyzer/src/error/codes.dart'; 10 import 'package:analyzer/src/error/codes.dart';
(...skipping 2764 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 verify([source]); 2775 verify([source]);
2776 } 2776 }
2777 2777
2778 test_implementsSuperClass_Object() async { 2778 test_implementsSuperClass_Object() async {
2779 Source source = addSource("class A implements Object {}"); 2779 Source source = addSource("class A implements Object {}");
2780 await computeAnalysisResult(source); 2780 await computeAnalysisResult(source);
2781 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]); 2781 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]);
2782 verify([source]); 2782 verify([source]);
2783 } 2783 }
2784 2784
2785 test_implementsSuperClass_typeAlias() async {
2786 Source source = addSource(r'''
2787 class A {}
2788 class M {}
2789 class B = A with M implements A;''');
2790 await computeAnalysisResult(source);
2791 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]);
2792 verify([source]);
2793 }
2794
2795 test_implementsSuperClass_Object_typeAlias() async {
2796 Source source = addSource(r'''
2797 class M {}
2798 class A = Object with M implements Object;
2799 ''');
2800 await computeAnalysisResult(source);
2801 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]);
2802 verify([source]);
2803 }
2804
2785 test_implicitThisReferenceInInitializer_field() async { 2805 test_implicitThisReferenceInInitializer_field() async {
2786 Source source = addSource(r''' 2806 Source source = addSource(r'''
2787 class A { 2807 class A {
2788 var v; 2808 var v;
2789 A() : v = f; 2809 A() : v = f;
2790 var f; 2810 var f;
2791 }'''); 2811 }''');
2792 await computeAnalysisResult(source); 2812 await computeAnalysisResult(source);
2793 assertErrors( 2813 assertErrors(
2794 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); 2814 source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
(...skipping 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after
5330 f() { 5350 f() {
5331 p?.g(); 5351 p?.g();
5332 } 5352 }
5333 '''); 5353 ''');
5334 await computeAnalysisResult(source); 5354 await computeAnalysisResult(source);
5335 assertErrors( 5355 assertErrors(
5336 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]); 5356 source, [CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT]);
5337 verify([source]); 5357 verify([source]);
5338 } 5358 }
5339 5359
5340 test_privateCollisionInMixinApplication_mixinAndMixin() async { 5360 test_privateCollisionInMixinApplication_mixinAndMixin() {
5341 resetWith(options: new AnalysisOptionsImpl()..strongMode = true); 5361 return _privateCollisionInMixinApplicationTest('''
5342 addNamedSource(
5343 '/lib1.dart',
5344 '''
5345 class A {
5346 int _x;
5347 }
5348
5349 class B {
5350 int _x;
5351 }
5352 ''');
5353 Source source = addSource('''
5354 import 'lib1.dart'; 5362 import 'lib1.dart';
5355 class C extends Object with A, B {} 5363 class C extends Object with A, B {}
5356 '''); 5364 ''');
5357 await computeAnalysisResult(source);
5358 assertErrors(
5359 source, [CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION]);
5360 verify([source]);
5361 } 5365 }
5362 5366
5363 test_privateCollisionInMixinApplication_mixinAndMixin_indirect() async { 5367 test_privateCollisionInMixinApplication_mixinAndMixin_indirect() {
5364 resetWith(options: new AnalysisOptionsImpl()..strongMode = true); 5368 return _privateCollisionInMixinApplicationTest('''
5365 addNamedSource(
5366 '/lib1.dart',
5367 '''
5368 class A {
5369 int _x;
5370 }
5371
5372 class B {
5373 int _x;
5374 }
5375 ''');
5376 Source source = addSource('''
5377 import 'lib1.dart'; 5369 import 'lib1.dart';
5378 class C extends Object with A {} 5370 class C extends Object with A {}
5379 class D extends C with B {} 5371 class D extends C with B {}
5380 '''); 5372 ''');
5381 await computeAnalysisResult(source);
5382 assertErrors(
5383 source, [CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION]);
5384 verify([source]);
5385 } 5373 }
5386 5374
5387 test_privateCollisionInMixinApplication_superclassAndMixin() async { 5375 test_privateCollisionInMixinApplication_superclassAndMixin() {
5388 resetWith(options: new AnalysisOptionsImpl()..strongMode = true); 5376 return _privateCollisionInMixinApplicationTest('''
5389 addNamedSource(
5390 '/lib1.dart',
5391 '''
5392 class A {
5393 int _x;
5394 }
5395
5396 class B {
5397 int _x;
5398 }
5399 ''');
5400 Source source = addSource('''
5401 import 'lib1.dart'; 5377 import 'lib1.dart';
5402 class C extends A with B {} 5378 class C extends A with B {}
5403 '''); 5379 ''');
5404 await computeAnalysisResult(source);
5405 assertErrors(
5406 source, [CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION]);
5407 verify([source]);
5408 } 5380 }
5409 5381
5410 test_privateCollisionInMixinApplication_superclassAndMixin_same() async { 5382 test_privateCollisionInMixinApplication_superclassAndMixin_same() {
5411 resetWith(options: new AnalysisOptionsImpl()..strongMode = true); 5383 return _privateCollisionInMixinApplicationTest('''
5412 addNamedSource(
5413 '/lib1.dart',
5414 '''
5415 class A {
5416 int _x;
5417 }
5418
5419 class B {
5420 int _x;
5421 }
5422 ''');
5423 Source source = addSource('''
5424 import 'lib1.dart'; 5384 import 'lib1.dart';
5425 class C extends A with A {} 5385 class C extends A with A {}
5426 '''); 5386 ''');
5427 await computeAnalysisResult(source); 5387 }
5428 assertErrors( 5388
5429 source, [CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION]); 5389 test_privateCollisionInClassTypeAlias_mixinAndMixin() {
5430 verify([source]); 5390 return _privateCollisionInMixinApplicationTest('''
5391 import 'lib1.dart';
5392 class C = Object with A, B;
5393 ''');
5394 }
5395
5396 test_privateCollisionInClassTypeAlias_mixinAndMixin_indirect() {
5397 return _privateCollisionInMixinApplicationTest('''
5398 import 'lib1.dart';
5399 class C = Object with A;
5400 class D = C with B;
5401 ''');
5402 }
5403
5404 test_privateCollisionInClassTypeAlias_superclassAndMixin() {
5405 return _privateCollisionInMixinApplicationTest('''
5406 import 'lib1.dart';
5407 class C = A with B;
5408 ''');
5409 }
5410
5411 test_privateCollisionInClassTypeAlias_superclassAndMixin_same() {
5412 return _privateCollisionInMixinApplicationTest('''
5413 import 'lib1.dart';
5414 class C = A with A;
5415 ''');
5431 } 5416 }
5432 5417
5433 test_privateOptionalParameter() async { 5418 test_privateOptionalParameter() async {
5434 Source source = addSource("f({var _p}) {}"); 5419 Source source = addSource("f({var _p}) {}");
5435 await computeAnalysisResult(source); 5420 await computeAnalysisResult(source);
5436 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); 5421 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
5437 verify([source]); 5422 verify([source]);
5438 } 5423 }
5439 5424
5440 test_privateOptionalParameter_fieldFormal() async { 5425 test_privateOptionalParameter_fieldFormal() async {
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
6655 assertErrors( 6640 assertErrors(
6656 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); 6641 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]);
6657 verify([source]); 6642 verify([source]);
6658 reset(); 6643 reset();
6659 } 6644 }
6660 6645
6661 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { 6646 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async {
6662 await _check_wrongNumberOfParametersForOperator(name, ""); 6647 await _check_wrongNumberOfParametersForOperator(name, "");
6663 await _check_wrongNumberOfParametersForOperator(name, "a, b"); 6648 await _check_wrongNumberOfParametersForOperator(name, "a, b");
6664 } 6649 }
6650
6651 Future<Null> _privateCollisionInMixinApplicationTest(String testCode) async {
6652 resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
6653 addNamedSource(
6654 '/lib1.dart',
6655 '''
6656 class A {
6657 int _x;
6665 } 6658 }
6659
6660 class B {
6661 int _x;
6662 }
6663 ''');
6664 Source source = addSource(testCode);
6665 await computeAnalysisResult(source);
6666 assertErrors(
6667 source, [CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION]);
6668 verify([source]);
6669 }
6670 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698