| 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 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import | 6 import |
| 7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' | 7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' |
| 8 show TypeMask; | 8 show TypeMask; |
| 9 | 9 |
| 10 import 'compiler_helper.dart'; | 10 import 'compiler_helper.dart'; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 returnIntAsNum() { | 229 returnIntAsNum() { |
| 230 return 0 as num; | 230 return 0 as num; |
| 231 } | 231 } |
| 232 | 232 |
| 233 typedef int Foo(); | 233 typedef int Foo(); |
| 234 | 234 |
| 235 returnAsTypedef() { | 235 returnAsTypedef() { |
| 236 return topLevelGetter() as Foo; | 236 return topLevelGetter() as Foo; |
| 237 } | 237 } |
| 238 | 238 |
| 239 testSwitch1() { |
| 240 var a = null; |
| 241 switch (topLevelGetter) { |
| 242 case 100: a = 42.5; break; |
| 243 case 200: a = 42; break; |
| 244 } |
| 245 return a; |
| 246 } |
| 247 |
| 248 testSwitch2() { |
| 249 var a = null; |
| 250 switch (topLevelGetter) { |
| 251 case 100: a = 42; break; |
| 252 case 200: a = 42; break; |
| 253 default: |
| 254 a = 43; |
| 255 } |
| 256 return a; |
| 257 } |
| 258 |
| 259 testSwitch3() { |
| 260 var a = 42; |
| 261 var b; |
| 262 switch (topLevelGetter) { |
| 263 L1: case 1: b = a + 42; break; |
| 264 case 2: a = 'foo'; continue L1; |
| 265 } |
| 266 return b; |
| 267 } |
| 268 |
| 239 get topLevelGetter => 42; | 269 get topLevelGetter => 42; |
| 240 returnDynamic() => topLevelGetter(42); | 270 returnDynamic() => topLevelGetter(42); |
| 241 | 271 |
| 242 class A { | 272 class A { |
| 243 factory A() = A.generative; | 273 factory A() = A.generative; |
| 244 A.generative(); | 274 A.generative(); |
| 245 operator==(other) => 42; | 275 operator==(other) => 42; |
| 246 | 276 |
| 247 get myField => 42; | 277 get myField => 42; |
| 248 set myField(a) {} | 278 set myField(a) {} |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 testIsCheck13(topLevelGetter()); | 330 testIsCheck13(topLevelGetter()); |
| 301 testIsCheck14(topLevelGetter()); | 331 testIsCheck14(topLevelGetter()); |
| 302 testIsCheck15(topLevelGetter()); | 332 testIsCheck15(topLevelGetter()); |
| 303 testIsCheck16(topLevelGetter()); | 333 testIsCheck16(topLevelGetter()); |
| 304 testIsCheck17(topLevelGetter()); | 334 testIsCheck17(topLevelGetter()); |
| 305 testIsCheck18(topLevelGetter()); | 335 testIsCheck18(topLevelGetter()); |
| 306 testIsCheck19(topLevelGetter()); | 336 testIsCheck19(topLevelGetter()); |
| 307 returnAsString(); | 337 returnAsString(); |
| 308 returnIntAsNum(); | 338 returnIntAsNum(); |
| 309 returnAsTypedef(); | 339 returnAsTypedef(); |
| 340 testSwitch1(); |
| 341 testSwitch2(); |
| 342 testSwitch3(); |
| 310 new A() == null; | 343 new A() == null; |
| 311 new A()..returnInt1() | 344 new A()..returnInt1() |
| 312 ..returnInt2() | 345 ..returnInt2() |
| 313 ..returnInt3() | 346 ..returnInt3() |
| 314 ..returnInt4() | 347 ..returnInt4() |
| 315 ..returnInt5() | 348 ..returnInt5() |
| 316 ..returnInt6(); | 349 ..returnInt6(); |
| 317 | 350 |
| 318 new B()..returnInt1() | 351 new B()..returnInt1() |
| 319 ..returnInt2() | 352 ..returnInt2() |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 checkReturn('testIsCheck14', typesInferrer.dynamicType); | 405 checkReturn('testIsCheck14', typesInferrer.dynamicType); |
| 373 checkReturn('testIsCheck15', intType); | 406 checkReturn('testIsCheck15', intType); |
| 374 checkReturn('testIsCheck16', typesInferrer.dynamicType); | 407 checkReturn('testIsCheck16', typesInferrer.dynamicType); |
| 375 checkReturn('testIsCheck17', intType); | 408 checkReturn('testIsCheck17', intType); |
| 376 checkReturn('testIsCheck18', typesInferrer.dynamicType); | 409 checkReturn('testIsCheck18', typesInferrer.dynamicType); |
| 377 checkReturn('testIsCheck19', typesInferrer.dynamicType); | 410 checkReturn('testIsCheck19', typesInferrer.dynamicType); |
| 378 checkReturn('returnAsString', | 411 checkReturn('returnAsString', |
| 379 new TypeMask.subtype(compiler.stringClass.computeType(compiler))); | 412 new TypeMask.subtype(compiler.stringClass.computeType(compiler))); |
| 380 checkReturn('returnIntAsNum', typesInferrer.intType); | 413 checkReturn('returnIntAsNum', typesInferrer.intType); |
| 381 checkReturn('returnAsTypedef', typesInferrer.functionType.nullable()); | 414 checkReturn('returnAsTypedef', typesInferrer.functionType.nullable()); |
| 415 checkReturn('testSwitch1', |
| 416 typesInferrer.intType.union(typesInferrer.doubleType, compiler).nullable()); |
| 417 checkReturn('testSwitch2', typesInferrer.intType); |
| 418 checkReturn('testSwitch3', interceptorType.nullable()); |
| 382 | 419 |
| 383 checkReturnInClass(String className, String methodName, type) { | 420 checkReturnInClass(String className, String methodName, type) { |
| 384 var cls = findElement(compiler, className); | 421 var cls = findElement(compiler, className); |
| 385 var element = cls.lookupLocalMember(buildSourceString(methodName)); | 422 var element = cls.lookupLocalMember(buildSourceString(methodName)); |
| 386 Expect.equals(type, typesInferrer.internal.returnTypeOf[element]); | 423 Expect.equals(type, typesInferrer.internal.returnTypeOf[element]); |
| 387 } | 424 } |
| 388 | 425 |
| 389 checkReturnInClass('A', 'returnInt1', typesInferrer.intType); | 426 checkReturnInClass('A', 'returnInt1', typesInferrer.intType); |
| 390 checkReturnInClass('A', 'returnInt2', typesInferrer.intType); | 427 checkReturnInClass('A', 'returnInt2', typesInferrer.intType); |
| 391 checkReturnInClass('A', 'returnInt3', typesInferrer.intType); | 428 checkReturnInClass('A', 'returnInt3', typesInferrer.intType); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 404 checkReturnInClass('B', 'returnInt8', typesInferrer.intType); | 441 checkReturnInClass('B', 'returnInt8', typesInferrer.intType); |
| 405 | 442 |
| 406 checkFactoryConstructor(String className) { | 443 checkFactoryConstructor(String className) { |
| 407 var cls = findElement(compiler, className); | 444 var cls = findElement(compiler, className); |
| 408 var element = cls.localLookup(buildSourceString(className)); | 445 var element = cls.localLookup(buildSourceString(className)); |
| 409 Expect.equals(new TypeMask.nonNullExact(cls.rawType), | 446 Expect.equals(new TypeMask.nonNullExact(cls.rawType), |
| 410 typesInferrer.internal.returnTypeOf[element]); | 447 typesInferrer.internal.returnTypeOf[element]); |
| 411 } | 448 } |
| 412 checkFactoryConstructor('A'); | 449 checkFactoryConstructor('A'); |
| 413 } | 450 } |
| OLD | NEW |