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

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

Issue 2675963004: fix #28630, instance method tear-offs are treated as strict arrows (Closed)
Patch Set: fix Created 3 years, 10 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 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 C c = new C(); 1667 C c = new C();
1668 { 1668 {
1669 Function2<B, A> f; 1669 Function2<B, A> f;
1670 f = c.top; 1670 f = c.top;
1671 f = c.left; 1671 f = c.left;
1672 f = c.right; 1672 f = c.right;
1673 f = c.bot; 1673 f = c.bot;
1674 } 1674 }
1675 { 1675 {
1676 Function2<B, B> f; 1676 Function2<B, B> f;
1677 f = /*warning:DOWN_CAST_COMPOSITE*/c.top; 1677 f = /*error:INVALID_CAST_METHOD*/c.top;
Leaf 2017/02/03 20:28:41 This isn't right. This error is only for casts
Jennifer Messerly 2017/02/03 21:02:50 yeah, that's why I'd split out like that initially
1678 f = c.left; 1678 f = c.left;
1679 f = /*error:INVALID_ASSIGNMENT*/c.right; 1679 f = /*error:INVALID_ASSIGNMENT*/c.right;
1680 f = c.bot; 1680 f = c.bot;
1681 } 1681 }
1682 { 1682 {
1683 Function2<A, A> f; 1683 Function2<A, A> f;
1684 f = /*warning:DOWN_CAST_COMPOSITE*/c.top; 1684 f = /*error:INVALID_CAST_METHOD*/c.top;
1685 f = /*error:INVALID_ASSIGNMENT*/c.left; 1685 f = /*error:INVALID_ASSIGNMENT*/c.left;
1686 f = c.right; 1686 f = c.right;
1687 f = c.bot; 1687 f = c.bot;
1688 } 1688 }
1689 { 1689 {
1690 Function2<A, B> f; 1690 Function2<A, B> f;
1691 f = /*warning:DOWN_CAST_COMPOSITE*/c.top; 1691 f = /*error:INVALID_CAST_METHOD*/c.top;
1692 f = /*warning:DOWN_CAST_COMPOSITE*/c.left; 1692 f = /*error:INVALID_CAST_METHOD*/c.left;
1693 f = /*warning:DOWN_CAST_COMPOSITE*/c.right; 1693 f = /*error:INVALID_CAST_METHOD*/c.right;
1694 f = c.bot; 1694 f = c.bot;
1695 } 1695 }
1696 } 1696 }
1697 '''); 1697 ''');
1698 } 1698 }
1699 1699
1700 void test_functionTypingAndSubtyping_intAndObject() { 1700 void test_functionTypingAndSubtyping_intAndObject() {
1701 checkFile(''' 1701 checkFile('''
1702 typedef Object Top(int x); // Top of the lattice 1702 typedef Object Top(int x); // Top of the lattice
1703 typedef int Left(int x); // Left branch 1703 typedef int Left(int x); // Left branch
(...skipping 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after
3671 3671
3672 void test_superConstructor() { 3672 void test_superConstructor() {
3673 checkFile(''' 3673 checkFile('''
3674 class A { A(A x) {} } 3674 class A { A(A x) {} }
3675 class B extends A { 3675 class B extends A {
3676 B() : super(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3); 3676 B() : super(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/3);
3677 } 3677 }
3678 '''); 3678 ''');
3679 } 3679 }
3680 3680
3681 void test_tearOffTreatedConsistentlyAsStrictArrow() {
3682 checkFile(r'''
3683 void foo(void f(String x)) {}
3684
3685 class A {
3686 Null bar1(dynamic x) => null;
3687 void bar2(dynamic x) => null;
3688 Null bar3(String x) => null;
3689 void test() {
3690 foo(bar1);
3691 foo(bar2);
3692 foo(bar3);
3693 }
3694 }
3695
3696
3697 Null baz1(dynamic x) => null;
3698 void baz2(dynamic x) => null;
3699 Null baz3(String x) => null;
3700 void test() {
3701 foo(baz1);
3702 foo(baz2);
3703 foo(baz3);
3704 }
3705 ''');
3706 }
3707
3681 void test_ternaryOperator() { 3708 void test_ternaryOperator() {
3682 checkFile(''' 3709 checkFile('''
3683 abstract class Comparable<T> { 3710 abstract class Comparable<T> {
3684 int compareTo(T other); 3711 int compareTo(T other);
3685 static int compare(Comparable a, Comparable b) => a.compareTo(b); 3712 static int compare(Comparable a, Comparable b) => a.compareTo(b);
3686 } 3713 }
3687 typedef int Comparator<T>(T a, T b); 3714 typedef int Comparator<T>(T a, T b);
3688 3715
3689 typedef bool _Predicate<T>(T value); 3716 typedef bool _Predicate<T>(T value);
3690 3717
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
4088 // Regression test for https://github.com/dart-lang/sdk/issues/25069 4115 // Regression test for https://github.com/dart-lang/sdk/issues/25069
4089 checkFile(''' 4116 checkFile('''
4090 typedef int Foo(); 4117 typedef int Foo();
4091 void foo() {} 4118 void foo() {}
4092 void main () { 4119 void main () {
4093 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); 4120 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo();
4094 } 4121 }
4095 '''); 4122 ''');
4096 } 4123 }
4097 } 4124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698