Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
|
eernst
2017/09/04 17:04:56
Lost coverage: don't delete this 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 // Test type promotion of parameters. | |
| 6 | |
| 7 class A { | |
| 8 var a = "a"; | |
| 9 } | |
| 10 | |
| 11 class B extends A { | |
| 12 var b = "b"; | |
| 13 } | |
| 14 | |
| 15 class C extends B { | |
| 16 var c = "c"; | |
| 17 } | |
| 18 | |
| 19 class D extends A { | |
| 20 var d = "d"; | |
| 21 } | |
| 22 | |
| 23 class E implements C, D { | |
| 24 var a = ""; | |
| 25 var b = ""; | |
| 26 var c = ""; | |
| 27 var d = ""; | |
| 28 } | |
| 29 | |
| 30 void main() { | |
| 31 test(new E()); | |
| 32 } | |
| 33 | |
| 34 void test(A a) { | |
| 35 print(a.a); | |
| 36 print(a.b); //# 01: static type warning | |
| 37 print(a.c); //# 02: static type warning | |
| 38 print(a.d); //# 03: static type warning | |
| 39 | |
| 40 if (a is B) { | |
| 41 print(a.a); | |
| 42 print(a.b); | |
| 43 print(a.c); //# 04: static type warning | |
| 44 print(a.d); //# 05: static type warning | |
| 45 | |
| 46 if (a is C) { | |
| 47 print(a.a); | |
| 48 print(a.b); | |
| 49 print(a.c); | |
| 50 print(a.d); //# 06: static type warning | |
| 51 } | |
| 52 | |
| 53 print(a.a); | |
| 54 print(a.b); | |
| 55 print(a.c); //# 07: static type warning | |
| 56 print(a.d); //# 08: static type warning | |
| 57 } | |
| 58 if (a is C) { | |
| 59 print(a.a); | |
| 60 print(a.b); | |
| 61 print(a.c); | |
| 62 print(a.d); //# 09: static type warning | |
| 63 | |
| 64 if (a is B) { | |
| 65 print(a.a); | |
| 66 print(a.b); | |
| 67 print(a.c); | |
| 68 print(a.d); //# 10: static type warning | |
| 69 } | |
| 70 if (a is D) { | |
| 71 print(a.a); | |
| 72 print(a.b); | |
| 73 print(a.c); | |
| 74 print(a.d); //# 11: static type warning | |
| 75 } | |
| 76 | |
| 77 print(a.a); | |
| 78 print(a.b); | |
| 79 print(a.c); | |
| 80 print(a.d); //# 12: static type warning | |
| 81 } | |
| 82 | |
| 83 print(a.a); | |
| 84 print(a.b); //# 13: static type warning | |
| 85 print(a.c); //# 14: static type warning | |
| 86 print(a.d); //# 15: static type warning | |
| 87 | |
| 88 if (a is D) { | |
| 89 print(a.a); | |
| 90 print(a.b); //# 16: static type warning | |
| 91 print(a.c); //# 17: static type warning | |
| 92 print(a.d); | |
| 93 } | |
| 94 | |
| 95 print(a.a); | |
| 96 print(a.b); //# 18: static type warning | |
| 97 print(a.c); //# 19: static type warning | |
| 98 print(a.d); //# 20: static type warning | |
| 99 | |
| 100 var o1 = a is B | |
| 101 ? '${a.a}' | |
| 102 '${a.b}' | |
| 103 '${a.c}' //# 21: static type warning | |
| 104 '${a.d}' //# 22: static type warning | |
| 105 : '${a.a}' | |
| 106 '${a.b}' //# 23: static type warning | |
| 107 '${a.c}' //# 24: static type warning | |
| 108 '${a.d}' //# 25: static type warning | |
| 109 ; | |
| 110 | |
| 111 var o2 = a is C | |
| 112 ? '${a.a}' | |
| 113 '${a.b}' | |
| 114 '${a.c}' | |
| 115 '${a.d}' //# 26: static type warning | |
| 116 : '${a.a}' | |
| 117 '${a.b}' //# 27: static type warning | |
| 118 '${a.c}' //# 28: static type warning | |
| 119 '${a.d}' //# 29: static type warning | |
| 120 ; | |
| 121 | |
| 122 var o3 = a is D | |
| 123 ? '${a.a}' | |
| 124 '${a.b}' //# 30: static type warning | |
| 125 '${a.c}' //# 31: static type warning | |
| 126 '${a.d}' | |
| 127 : '${a.a}' | |
| 128 '${a.b}' //# 32: static type warning | |
| 129 '${a.c}' //# 33: static type warning | |
| 130 '${a.d}' //# 34: static type warning | |
| 131 ; | |
| 132 | |
| 133 if (a is B && a is B) { | |
| 134 print(a.a); | |
| 135 print(a.b); | |
| 136 print(a.c); //# 35: static type warning | |
| 137 print(a.d); //# 36: static type warning | |
| 138 } | |
| 139 if (a is B && a is C) { | |
| 140 print(a.a); | |
| 141 print(a.b); | |
| 142 print(a.c); | |
| 143 print(a.d); //# 37: static type warning | |
| 144 } | |
| 145 if (a is C && a is B) { | |
| 146 print(a.a); | |
| 147 print(a.b); | |
| 148 print(a.c); | |
| 149 print(a.d); //# 38: static type warning | |
| 150 } | |
| 151 if (a is C && a is D) { | |
| 152 print(a.a); | |
| 153 print(a.b); | |
| 154 print(a.c); | |
| 155 print(a.d); //# 39: static type warning | |
| 156 } | |
| 157 if (a is D && a is C) { | |
| 158 print(a.a); | |
| 159 print(a.b); //# 40: static type warning | |
| 160 print(a.c); //# 41: static type warning | |
| 161 print(a.d); | |
| 162 } | |
| 163 if (a is D && | |
| 164 a.a == "" | |
| 165 && a.b == "" // //# 42: static type warning | |
| 166 && a.c == "" // //# 43: static type warning | |
| 167 && | |
| 168 a.d == "") { | |
| 169 print(a.a); | |
| 170 print(a.b); //# 44: static type warning | |
| 171 print(a.c); //# 45: static type warning | |
| 172 print(a.d); | |
| 173 } | |
| 174 if (a.a == "" | |
| 175 && a.b == "" //# 46: static type warning | |
| 176 && a.c == "" //# 47: static type warning | |
| 177 && a.d == "" //# 48: static type warning | |
| 178 && | |
| 179 a is B && | |
| 180 a.a == "" && | |
| 181 a.b == "" | |
| 182 && a.c == "" //# 49: static type warning | |
| 183 && a.d == "" //# 50: static type warning | |
| 184 && | |
| 185 a is C && | |
| 186 a.a == "" && | |
| 187 a.b == "" && | |
| 188 a.c == "" | |
| 189 && a.d == "" //# 51: static type warning | |
| 190 ) { | |
| 191 print(a.a); | |
| 192 print(a.b); | |
| 193 print(a.c); | |
| 194 print(a.d); //# 52: static type warning | |
| 195 } | |
| 196 if ((a is B)) { | |
| 197 print(a.a); | |
| 198 print(a.b); | |
| 199 print(a.c); //# 54: static type warning | |
| 200 print(a.d); //# 55: static type warning | |
| 201 } | |
| 202 if ((a is B && (a) is C) && a is B) { | |
| 203 print(a.a); | |
| 204 print(a.b); | |
| 205 print(a.c); | |
| 206 print(a.d); //# 56: static type warning | |
| 207 } | |
| 208 } | |
| OLD | NEW |