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

Side by Side Diff: pkg/analyzer/test/src/task/strong/checker_test.dart

Issue 2986063002: Avoid issuing incorrect errors when super mixins are enabled (Closed)
Patch Set: Coment Created 3 years, 4 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.src.task.strong.checker_test; 5 library analyzer.test.src.task.strong.checker_test;
6 6
7 import 'package:test_reflective_loader/test_reflective_loader.dart'; 7 import 'package:test_reflective_loader/test_reflective_loader.dart';
8 8
9 import 'strong_test_helper.dart'; 9 import 'strong_test_helper.dart';
10 10
(...skipping 2621 matching lines...) Expand 10 before | Expand all | Expand 10 after
2632 } 2632 }
2633 2633
2634 abstract class M2 = Object with M; 2634 abstract class M2 = Object with M;
2635 2635
2636 class C2 extends Object with M2 { 2636 class C2 extends Object with M2 {
2637 /*error:INVALID_METHOD_OVERRIDE*/String x; 2637 /*error:INVALID_METHOD_OVERRIDE*/String x;
2638 } 2638 }
2639 '''); 2639 ''');
2640 } 2640 }
2641 2641
2642 test_interfacesFromMixinsOnlyConsiderMostDerivedMember() {
2643 // Regression test for dart2js interface pattern in strong mode.
2644 return checkFile(r'''
2645 abstract class I1 { num get x; }
2646 abstract class I2 extends I1 { int get x; }
2647
2648 class M1 { num get x => 0; }
2649 class M2 { int get x => 0; }
2650
2651 class Base extends Object with M1 implements I1 {}
2652 class Child extends Base with M2 implements I2 {}
2653
2654 class C extends Object with M1, M2 implements I1, I2 {}
2655 ''');
2656 }
2657
2642 test_interfacesFromMixinsUsedTwiceAreChecked() { 2658 test_interfacesFromMixinsUsedTwiceAreChecked() {
2643 // Regression test for https://github.com/dart-lang/sdk/issues/29782 2659 // Regression test for https://github.com/dart-lang/sdk/issues/29782
2644 return checkFile(r''' 2660 return checkFile(r'''
2645 abstract class I<E> { 2661 abstract class I<E> {
2646 set x(E v); 2662 set x(E v);
2647 } 2663 }
2648 abstract class M<E> implements I<E> {} 2664 abstract class M<E> implements I<E> {}
2649 2665
2650 class C extends Object with M<int> { 2666 class C extends Object with M<int> {
2651 /*error:INVALID_METHOD_OVERRIDE*/String x; 2667 /*error:INVALID_METHOD_OVERRIDE*/String x;
2652 } 2668 }
2653 2669
2654 abstract class D extends Object with M<num> {} 2670 abstract class D extends Object with M<num> {}
2655 class E extends D with M<int> { 2671 class E extends D with M<int> {
2656 /*error:INVALID_METHOD_OVERRIDE*/int x; 2672 /*error:INVALID_METHOD_OVERRIDE*/int x;
2657 } 2673 }
2658 class F extends D with M<int> { 2674 class F extends D with M<int> {
2659 num x; 2675 num x;
2660 } 2676 }
2661 '''); 2677 ''');
2662 } 2678 }
2663 2679
2664 test_interfacesFromMixinsOnlyConsiderMostDerivedMember() {
2665 // Regression test for dart2js interface pattern in strong mode.
2666 return checkFile(r'''
2667 abstract class I1 { num get x; }
2668 abstract class I2 extends I1 { int get x; }
2669
2670 class M1 { num get x => 0; }
2671 class M2 { int get x => 0; }
2672
2673 class Base extends Object with M1 implements I1 {}
2674 class Child extends Base with M2 implements I2 {}
2675
2676 class C extends Object with M1, M2 implements I1, I2 {}
2677 ''');
2678 }
2679
2680 test_invalidOverrides_baseClassOverrideToChildInterface() async { 2680 test_invalidOverrides_baseClassOverrideToChildInterface() async {
2681 await checkFile(''' 2681 await checkFile('''
2682 class A {} 2682 class A {}
2683 class B {} 2683 class B {}
2684 2684
2685 abstract class I { 2685 abstract class I {
2686 m(A a); 2686 m(A a);
2687 } 2687 }
2688 2688
2689 class Base { 2689 class Base {
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
3163 await checkFile(r''' 3163 await checkFile(r'''
3164 class A { 3164 class A {
3165 void foo(dynamic x) {} 3165 void foo(dynamic x) {}
3166 void test(void f(int x)) { 3166 void test(void f(int x)) {
3167 test(foo); 3167 test(foo);
3168 } 3168 }
3169 } 3169 }
3170 '''); 3170 ''');
3171 } 3171 }
3172 3172
3173 test_mixinApplicationIsConcrete() async {
Jennifer Messerly 2017/07/27 21:07:58 style thing: existing tests in this file often use
Leaf 2017/07/27 21:38:09 Done.
3174 addFile(r'''
3175 class A {
3176 int get foo => 3;
3177 }
3178
3179 class B {
3180 num get foo => 3.0;
3181 }
3182
3183 class C = Object with B;
3184
3185 class D extends Object with /*error:INVALID_METHOD_OVERRIDE_FROM_MIXIN*/C implem ents A {}
3186 ''');
3187 await check();
3188 }
3189
3173 test_mixinOverrideOfGrandInterface_interfaceOfAbstractSuperclass() async { 3190 test_mixinOverrideOfGrandInterface_interfaceOfAbstractSuperclass() async {
3174 await checkFile(''' 3191 await checkFile('''
3175 class A {} 3192 class A {}
3176 class B {} 3193 class B {}
3177 3194
3178 abstract class I1 { 3195 abstract class I1 {
3179 m(A a); 3196 m(A a);
3180 } 3197 }
3181 abstract class Base implements I1 {} 3198 abstract class Base implements I1 {}
3182 3199
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
3906 3923
3907 test_superConstructor() async { 3924 test_superConstructor() async {
3908 await checkFile(''' 3925 await checkFile('''
3909 class A { A(A x) {} } 3926 class A { A(A x) {} }
3910 class B extends A { 3927 class B extends A {
3911 B() : super(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); 3928 B() : super(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
3912 } 3929 }
3913 '''); 3930 ''');
3914 } 3931 }
3915 3932
3933 @failingTest
3934 test_superMixin_invalidApplication() async {
Jennifer Messerly 2017/07/27 21:07:58 (same comment from above would apply to these test
Leaf 2017/07/27 21:38:09 Done.
3935 //Failing: https://github.com/dart-lang/sdk/issues/30283
Jennifer Messerly 2017/07/27 21:07:58 trivia nit: space after "//"
Leaf 2017/07/27 21:38:09 Done.
3936 addFile(r'''
3937 class A {
3938 int get foo => 3;
3939 }
3940
3941 // This expects a super class which satisfies the contract of A
3942 class B extends A {}
3943
3944 class C {
3945 num get foo => null;
3946 }
3947
3948 // This mixin application doesn't provide a valid superclass for B
3949 class D extends C with /*error:INCONSISTENT_METHOD_INHERITANCE*/B {}
3950 }
3951 ''');
3952 await check(superMixins: true);
3953 }
3954
3955 test_superMixinsMakeSuperclassMethodsAbstract() async {
3956 addFile(r'''
3957 abstract class A {}
3958
3959 abstract class B extends A {}
3960
3961 abstract class ProvidesConcreteAGetter {
3962 A get constraints => null;
3963 }
3964
3965 abstract class ProvidesConcreteBGetter extends ProvidesConcreteAGetter {
3966 @override
3967 B get constraints => null;
3968 }
3969
3970 abstract class ProvidesAbstractBGetter implements ProvidesConcreteBGetter {}
3971
3972 abstract class ProvidesAbstractAGetterMixin extends ProvidesConcreteAGetter {}
3973
3974 abstract class HasConcreteBGetterButMixesinAbstractAGetter
3975 extends ProvidesConcreteBGetter
3976 with ProvidesAbstractAGetterMixin, ProvidesAbstractBGetter {}
3977 ''');
3978 await check(superMixins: true);
3979 }
3980
3916 test_tearOffTreatedConsistentlyAsStrictArrow() async { 3981 test_tearOffTreatedConsistentlyAsStrictArrow() async {
3917 await checkFile(r''' 3982 await checkFile(r'''
3918 void foo(void f(String x)) {} 3983 void foo(void f(String x)) {}
3919 3984
3920 class A { 3985 class A {
3921 Null bar1(dynamic x) => null; 3986 Null bar1(dynamic x) => null;
3922 void bar2(dynamic x) => null; 3987 void bar2(dynamic x) => null;
3923 Null bar3(String x) => null; 3988 Null bar3(String x) => null;
3924 void test() { 3989 void test() {
3925 foo(bar1); 3990 foo(bar1);
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
4396 class CheckerTest_Driver extends CheckerTest { 4461 class CheckerTest_Driver extends CheckerTest {
4397 @override 4462 @override
4398 bool get enableNewAnalysisDriver => true; 4463 bool get enableNewAnalysisDriver => true;
4399 4464
4400 @failingTest 4465 @failingTest
4401 @override 4466 @override
4402 test_covariantOverride_fields() async { 4467 test_covariantOverride_fields() async {
4403 await super.test_covariantOverride_fields(); 4468 await super.test_covariantOverride_fields();
4404 } 4469 }
4405 } 4470 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698