|
| 1 | +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 | + |
| 5 | +// This test contains a test case for each condition that can lead to the front |
| 6 | +// end's `ArgumentTypeNotAssignableNullability` error, for which we wish to |
| 7 | +// report "why not promoted" context information. |
| 8 | + |
| 9 | +class C1 { |
| 10 | + int? bad; |
| 11 | + f(int i) {} |
| 12 | +} |
| 13 | + |
| 14 | +required_unnamed(C1 c) { |
| 15 | + if (c.bad == null) return; |
| 16 | + c.f( |
| 17 | + /*analyzer.notPromoted(propertyNotPromoted(target: member:C1.bad, type: int?))*/ c |
| 18 | + . /*cfe.notPromoted(propertyNotPromoted(target: member:C1.bad, type: int?))*/ bad); |
| 19 | +} |
| 20 | + |
| 21 | +class C2 { |
| 22 | + int? bad; |
| 23 | + f([int i = 0]) {} |
| 24 | +} |
| 25 | + |
| 26 | +optional_unnamed(C2 c) { |
| 27 | + if (c.bad == null) return; |
| 28 | + c.f( |
| 29 | + /*analyzer.notPromoted(propertyNotPromoted(target: member:C2.bad, type: int?))*/ c |
| 30 | + . /*cfe.notPromoted(propertyNotPromoted(target: member:C2.bad, type: int?))*/ bad); |
| 31 | +} |
| 32 | + |
| 33 | +class C3 { |
| 34 | + int? bad; |
| 35 | + f({required int i}) {} |
| 36 | +} |
| 37 | + |
| 38 | +required_named(C3 c) { |
| 39 | + if (c.bad == null) return; |
| 40 | + c.f( |
| 41 | + /*analyzer.notPromoted(propertyNotPromoted(target: member:C3.bad, type: int?))*/ i: |
| 42 | + c. /*cfe.notPromoted(propertyNotPromoted(target: member:C3.bad, type: int?))*/ bad); |
| 43 | +} |
| 44 | + |
| 45 | +class C4 { |
| 46 | + int? bad; |
| 47 | + f({int i = 0}) {} |
| 48 | +} |
| 49 | + |
| 50 | +optional_named(C4 c) { |
| 51 | + if (c.bad == null) return; |
| 52 | + c.f( |
| 53 | + /*analyzer.notPromoted(propertyNotPromoted(target: member:C4.bad, type: int?))*/ i: |
| 54 | + c. /*cfe.notPromoted(propertyNotPromoted(target: member:C4.bad, type: int?))*/ bad); |
| 55 | +} |
| 56 | + |
| 57 | +class C5 { |
| 58 | + List<int>? bad; |
| 59 | + f<T>(List<T> x) {} |
| 60 | +} |
| 61 | + |
| 62 | +type_inferred(C5 c) { |
| 63 | + if (c.bad == null) return; |
| 64 | + c.f( |
| 65 | + /*analyzer.notPromoted(propertyNotPromoted(target: member:C5.bad, type: List<int>?))*/ c |
| 66 | + . /*cfe.notPromoted(propertyNotPromoted(target: member:C5.bad, type: List<int>?))*/ bad); |
| 67 | +} |
| 68 | + |
| 69 | +class C6 { |
| 70 | + int? bad; |
| 71 | + C6(int i); |
| 72 | +} |
| 73 | + |
| 74 | +C6 constructor_with_implicit_new(C6 c) { |
| 75 | + if (c.bad == null) return; |
| 76 | + return C6( |
| 77 | + /*analyzer.notPromoted(propertyNotPromoted(target: member:C6.bad, type: int?))*/ c |
| 78 | + . /*cfe.notPromoted(propertyNotPromoted(target: member:C6.bad, type: int?))*/ bad); |
| 79 | +} |
| 80 | + |
| 81 | +class C7 { |
| 82 | + int? bad; |
| 83 | + C7(int i); |
| 84 | +} |
| 85 | + |
| 86 | +C7 constructor_with_explicit_new(C7 c) { |
| 87 | + if (c.bad == null) return; |
| 88 | + return new C7( |
| 89 | + /*analyzer.notPromoted(propertyNotPromoted(target: member:C7.bad, type: int?))*/ c |
| 90 | + . /*cfe.notPromoted(propertyNotPromoted(target: member:C7.bad, type: int?))*/ bad); |
| 91 | +} |
0 commit comments