| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.dart"; |
| 7 import 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 | 9 |
| 10 Future compile(String source) { | 10 Future compile(String source) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 new A(); | 157 new A(); |
| 158 new A<num>(); | 158 new A<num>(); |
| 159 new A<dynamic>(); | 159 new A<dynamic>(); |
| 160 new A<int>(); | 160 new A<int>(); |
| 161 new A<double>(); | 161 new A<double>(); |
| 162 } | 162 } |
| 163 """); | 163 """); |
| 164 } | 164 } |
| 165 | 165 |
| 166 Future test6() { | 166 Future test6() { |
| 167 return test( | 167 return test(r""" |
| 168 r""" | |
| 169 class A<T extends num> {} | 168 class A<T extends num> {} |
| 170 | 169 |
| 171 void main() { | 170 void main() { |
| 172 new A<String>(); | 171 new A<String>(); |
| 173 } | 172 } |
| 174 """, | 173 """, warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND); |
| 175 warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND); | |
| 176 } | 174 } |
| 177 | 175 |
| 178 Future test7() { | 176 Future test7() { |
| 179 return test( | 177 return test(r""" |
| 180 r""" | |
| 181 class A<T extends num> {} | 178 class A<T extends num> {} |
| 182 class B<T> extends A<T> {} // Warning produced here. | 179 class B<T> extends A<T> {} // Warning produced here. |
| 183 | 180 |
| 184 void main() { | 181 void main() { |
| 185 new B(); // No warning produced here. | 182 new B(); // No warning produced here. |
| 186 new B<String>(); // No warning produced here. | 183 new B<String>(); // No warning produced here. |
| 187 } | 184 } |
| 188 """, | 185 """, warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND); |
| 189 warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND); | |
| 190 } | 186 } |
| 191 | 187 |
| 192 Future test8() { | 188 Future test8() { |
| 193 return test(r""" | 189 return test(r""" |
| 194 class B<T extends B<T>> {} | 190 class B<T extends B<T>> {} |
| 195 class C<T extends B<T>> extends B<T> {} | 191 class C<T extends B<T>> extends B<T> {} |
| 196 class D<T extends C<T>> extends C<T> {} | 192 class D<T extends C<T>> extends C<T> {} |
| 197 class E<T extends E<T>> extends D<T> {} | 193 class E<T extends E<T>> extends D<T> {} |
| 198 class F extends E<F> {} | 194 class F extends E<F> {} |
| 199 | 195 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 210 new D<C<F>>(); | 206 new D<C<F>>(); |
| 211 new E(); | 207 new E(); |
| 212 new E<dynamic>(); | 208 new E<dynamic>(); |
| 213 new E<E<F>>(); | 209 new E<E<F>>(); |
| 214 new F(); | 210 new F(); |
| 215 } | 211 } |
| 216 """); | 212 """); |
| 217 } | 213 } |
| 218 | 214 |
| 219 Future test9() { | 215 Future test9() { |
| 220 return test( | 216 return test(r""" |
| 221 r""" | |
| 222 class B<T extends B<T>> {} | 217 class B<T extends B<T>> {} |
| 223 class C<T extends B<T>> extends B<T> {} | 218 class C<T extends B<T>> extends B<T> {} |
| 224 class D<T extends C<T>> extends C<T> {} | 219 class D<T extends C<T>> extends C<T> {} |
| 225 class E<T extends E<T>> extends D<T> {} | 220 class E<T extends E<T>> extends D<T> {} |
| 226 class F extends E<F> {} | 221 class F extends E<F> {} |
| 227 | 222 |
| 228 void main() { | 223 void main() { |
| 229 new D<B<F>>(); // Warning: B<F> is not a subtype of C<T>. | 224 new D<B<F>>(); // Warning: B<F> is not a subtype of C<T>. |
| 230 new E<D<F>>(); // Warning: E<F> is not a subtype of E<T>. | 225 new E<D<F>>(); // Warning: E<F> is not a subtype of E<T>. |
| 231 } | 226 } |
| 232 """, | 227 """, warnings: [ |
| 233 warnings: [ | 228 MessageKind.INVALID_TYPE_VARIABLE_BOUND, |
| 234 MessageKind.INVALID_TYPE_VARIABLE_BOUND, | 229 MessageKind.INVALID_TYPE_VARIABLE_BOUND |
| 235 MessageKind.INVALID_TYPE_VARIABLE_BOUND | 230 ]); |
| 236 ]); | |
| 237 } | 231 } |
| 238 | 232 |
| 239 Future test10() { | 233 Future test10() { |
| 240 return test(r""" | 234 return test(r""" |
| 241 class A { | 235 class A { |
| 242 const A(); | 236 const A(); |
| 243 } | 237 } |
| 244 class Test<T extends A> { | 238 class Test<T extends A> { |
| 245 final T x = const A(); | 239 final T x = const A(); |
| 246 const Test(); | 240 const Test(); |
| 247 } | 241 } |
| 248 main() { | 242 main() { |
| 249 print(const Test<A>()); | 243 print(const Test<A>()); |
| 250 } | 244 } |
| 251 """); | 245 """); |
| 252 } | 246 } |
| 253 | 247 |
| 254 // TODO(het): The error is reported twice because both the Dart and JS constant | 248 // TODO(het): The error is reported twice because both the Dart and JS constant |
| 255 // compilers are run on the const constructor, investigate why. | 249 // compilers are run on the const constructor, investigate why. |
| 256 Future test11() { | 250 Future test11() { |
| 257 return test( | 251 return test(r""" |
| 258 r""" | |
| 259 class A { | 252 class A { |
| 260 const A(); | 253 const A(); |
| 261 } | 254 } |
| 262 class B extends A { | 255 class B extends A { |
| 263 const B(); | 256 const B(); |
| 264 } | 257 } |
| 265 class Test<T extends A> { | 258 class Test<T extends A> { |
| 266 final T x = const A(); | 259 final T x = const A(); |
| 267 const Test(); | 260 const Test(); |
| 268 } | 261 } |
| 269 main() { | 262 main() { |
| 270 print(const Test<B>()); | 263 print(const Test<B>()); |
| 271 } | 264 } |
| 272 """, | 265 """, errors: [MessageKind.NOT_ASSIGNABLE, MessageKind.NOT_ASSIGNABLE]); |
| 273 errors: [MessageKind.NOT_ASSIGNABLE, MessageKind.NOT_ASSIGNABLE]); | |
| 274 } | 266 } |
| 275 | 267 |
| 276 main() { | 268 main() { |
| 277 asyncTest(() async { | 269 asyncTest(() async { |
| 278 await test1(); | 270 await test1(); |
| 279 await test2(); | 271 await test2(); |
| 280 await test3(); | 272 await test3(); |
| 281 await test4(); | 273 await test4(); |
| 282 await test5(); | 274 await test5(); |
| 283 await test6(); | 275 await test6(); |
| 284 await test7(); | 276 await test7(); |
| 285 await test8(); | 277 await test8(); |
| 286 await test9(); | 278 await test9(); |
| 287 await test10(); | 279 await test10(); |
| 288 await test11(); | 280 await test11(); |
| 289 }); | 281 }); |
| 290 } | 282 } |
| OLD | NEW |