| 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 'compiler_helper.dart'; | 5 import 'compiler_helper.dart'; |
| 6 import 'parser_helper.dart'; | 6 import 'parser_helper.dart'; |
| 7 | 7 |
| 8 const String TEST = """ | 8 const String TEST = """ |
| 9 | 9 |
| 10 class A { | 10 class A { |
| 11 get foo => 'string'; | 11 get foo => 'string'; |
| 12 set foo(value) {} | 12 set foo(value) {} |
| 13 operator[](index) => 'string'; | 13 operator[](index) => 'string'; |
| 14 operator[]=(index, value) {} | 14 operator[]=(index, value) {} |
| 15 | 15 |
| 16 returnString1() => foo--; | 16 returnDynamic1() => foo--; |
| 17 returnNum1() => --foo; | 17 returnNum1() => --foo; |
| 18 returnNum2() => foo -= 42; | 18 returnNum2() => foo -= 42; |
| 19 | 19 |
| 20 returnDynamic1() => this[index]--; | 20 returnDynamic2() => this[index]--; |
| 21 returnNum3() => --this[index]; | 21 returnNum3() => --this[index]; |
| 22 returnNum4() => this[index] -= 42; | 22 returnNum4() => this[index] -= 42; |
| 23 | 23 |
| 24 returnDynamic2() => this.bar--; | 24 returnDynamic3() => this.bar--; |
| 25 returnNum5() => --this.bar; | 25 returnNum5() => --this.bar; |
| 26 returnNum6() => this.bar -= 42; | 26 returnNum6() => this.bar -= 42; |
| 27 } | 27 } |
| 28 | 28 |
| 29 class B extends A { | 29 class B extends A { |
| 30 get foo() => 42; |
| 31 operator[](index) => 42; |
| 32 |
| 30 returnString1() => super.foo--; | 33 returnString1() => super.foo--; |
| 31 returnNum1() => --super.foo; | 34 returnDynamic1() => --super.foo; |
| 32 returnNum2() => super.foo -= 42; | 35 returnDynamic2() => super.foo -= 42; |
| 33 | 36 |
| 34 returnDynamic1() => super[index]--; | 37 returnString2() => super[index]--; |
| 35 returnNum3() => --super[index]; | 38 returnDynamic3() => --super[index]; |
| 36 returnNum4() => super[index] -= 42; | 39 returnDynamic4() => super[index] -= 42; |
| 37 } | 40 } |
| 38 | 41 |
| 39 main() { | 42 main() { |
| 40 new A()..returnNum1() | 43 new A()..returnNum1() |
| 41 ..returnNum2() | 44 ..returnNum2() |
| 42 ..returnNum3() | 45 ..returnNum3() |
| 43 ..returnNum4() | 46 ..returnNum4() |
| 44 ..returnNum5() | 47 ..returnNum5() |
| 45 ..returnNum6() | 48 ..returnNum6() |
| 46 ..returnString1() | |
| 47 ..returnDynamic1() | 49 ..returnDynamic1() |
| 48 ..returnDynamic2(); | 50 ..returnDynamic2() |
| 51 ..returnDynamic3(); |
| 49 | 52 |
| 50 new B()..returnNum1() | 53 new B()..returnString1() |
| 51 ..returnNum2() | 54 ..returnString2() |
| 52 ..returnNum3() | 55 ..returnDynamic1() |
| 53 ..returnNum4() | 56 ..returnDynamic2() |
| 54 ..returnString1() | 57 ..returnDynamic3() |
| 55 ..returnDynamic1(); | 58 ..returnDynamic4(); |
| 56 } | 59 } |
| 57 """; | 60 """; |
| 58 | 61 |
| 59 void main() { | 62 void main() { |
| 60 Uri uri = new Uri.fromComponents(scheme: 'source'); | 63 Uri uri = new Uri.fromComponents(scheme: 'source'); |
| 61 var compiler = compilerFor(TEST, uri); | 64 var compiler = compilerFor(TEST, uri); |
| 62 compiler.runCompiler(uri); | 65 compiler.runCompiler(uri); |
| 63 var typesInferrer = compiler.typesTask.typesInferrer; | 66 var typesInferrer = compiler.typesTask.typesInferrer; |
| 64 | 67 |
| 65 checkReturnInClass(String className, String methodName, type) { | 68 checkReturnInClass(String className, String methodName, type) { |
| 66 var cls = findElement(compiler, className); | 69 var cls = findElement(compiler, className); |
| 67 var element = cls.lookupLocalMember(buildSourceString(methodName)); | 70 var element = cls.lookupLocalMember(buildSourceString(methodName)); |
| 68 Expect.equals(type, typesInferrer.returnTypeOf[element]); | 71 Expect.equals(type, typesInferrer.returnTypeOf[element]); |
| 69 } | 72 } |
| 70 | 73 |
| 71 checkReturnInClass('A', 'returnNum1', typesInferrer.numType); | 74 checkReturnInClass('A', 'returnNum1', typesInferrer.numType); |
| 72 checkReturnInClass('A', 'returnNum2', typesInferrer.numType); | 75 checkReturnInClass('A', 'returnNum2', typesInferrer.numType); |
| 73 checkReturnInClass('A', 'returnNum3', typesInferrer.numType); | 76 checkReturnInClass('A', 'returnNum3', typesInferrer.numType); |
| 74 checkReturnInClass('A', 'returnNum4', typesInferrer.numType); | 77 checkReturnInClass('A', 'returnNum4', typesInferrer.numType); |
| 75 checkReturnInClass('A', 'returnNum5', typesInferrer.numType); | 78 checkReturnInClass('A', 'returnNum5', typesInferrer.numType); |
| 76 checkReturnInClass('A', 'returnNum6', typesInferrer.numType); | 79 checkReturnInClass('A', 'returnNum6', typesInferrer.numType); |
| 77 checkReturnInClass('A', 'returnDynamic1', typesInferrer.dynamicType); | 80 checkReturnInClass('A', 'returnDynamic1', typesInferrer.dynamicType); |
| 78 checkReturnInClass('A', 'returnDynamic2', typesInferrer.dynamicType); | 81 checkReturnInClass('A', 'returnDynamic2', typesInferrer.dynamicType); |
| 79 checkReturnInClass('A', 'returnString1', typesInferrer.stringType); | 82 checkReturnInClass('A', 'returnDynamic3', typesInferrer.dynamicType); |
| 80 | 83 |
| 81 checkReturnInClass('B', 'returnNum1', typesInferrer.numType); | |
| 82 checkReturnInClass('B', 'returnNum2', typesInferrer.numType); | |
| 83 checkReturnInClass('B', 'returnNum3', typesInferrer.numType); | |
| 84 checkReturnInClass('B', 'returnNum4', typesInferrer.numType); | |
| 85 checkReturnInClass('B', 'returnString1', typesInferrer.stringType); | 84 checkReturnInClass('B', 'returnString1', typesInferrer.stringType); |
| 85 checkReturnInClass('B', 'returnString2', typesInferrer.stringType); |
| 86 checkReturnInClass('B', 'returnDynamic1', typesInferrer.dynamicType); | 86 checkReturnInClass('B', 'returnDynamic1', typesInferrer.dynamicType); |
| 87 checkReturnInClass('B', 'returnDynamic2', typesInferrer.dynamicType); |
| 88 checkReturnInClass('B', 'returnDynamic3', typesInferrer.dynamicType); |
| 89 checkReturnInClass('B', 'returnDynamic4', typesInferrer.dynamicType); |
| 87 } | 90 } |
| OLD | NEW |