| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
| 7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import 'compiler_helper.dart'; | 8 import 'compiler_helper.dart'; |
| 9 | 9 |
| 10 Future dummyImplTest() async { | 10 Future dummyImplTest() async { |
| 11 String source = """ | 11 String source = """ |
| 12 class A { | 12 class A { |
| 13 foo() => 3; | 13 foo() => 3; |
| 14 noSuchMethod(x) => super.noSuchMethod(x); | 14 noSuchMethod(x) => super.noSuchMethod(x); |
| 15 } | 15 } |
| 16 main() { | 16 main() { |
| 17 print(new A().foo()); | 17 print(new A().foo()); |
| 18 } | 18 } |
| 19 """; | 19 """; |
| 20 Uri uri = new Uri(scheme: 'source'); | 20 Uri uri = new Uri(scheme: 'source'); |
| 21 var compiler = compilerFor(source, uri); | 21 var compiler = compilerFor(source, uri); |
| 22 await compiler.run(uri); | 22 await compiler.run(uri); |
| 23 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 23 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 24 ClassElement clsA = findElement(compiler, 'A'); | 24 ClassElement clsA = findElement(compiler, 'A'); |
| 25 Expect.isTrue( | 25 Expect.isTrue(compiler.backend.noSuchMethodRegistry.defaultImpls |
| 26 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 26 .contains(clsA.lookupMember('noSuchMethod'))); |
| 27 clsA.lookupMember('noSuchMethod'))); | |
| 28 } | 27 } |
| 29 | 28 |
| 30 Future dummyImplTest2() async { | 29 Future dummyImplTest2() async { |
| 31 String source = """ | 30 String source = """ |
| 32 class A extends B { | 31 class A extends B { |
| 33 foo() => 3; | 32 foo() => 3; |
| 34 noSuchMethod(x) => super.noSuchMethod(x); | 33 noSuchMethod(x) => super.noSuchMethod(x); |
| 35 } | 34 } |
| 36 class B {} | 35 class B {} |
| 37 main() { | 36 main() { |
| 38 print(new A().foo()); | 37 print(new A().foo()); |
| 39 } | 38 } |
| 40 """; | 39 """; |
| 41 Uri uri = new Uri(scheme: 'source'); | 40 Uri uri = new Uri(scheme: 'source'); |
| 42 var compiler = compilerFor(source, uri); | 41 var compiler = compilerFor(source, uri); |
| 43 await compiler.run(uri); | 42 await compiler.run(uri); |
| 44 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 43 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 45 ClassElement clsA = findElement(compiler, 'A'); | 44 ClassElement clsA = findElement(compiler, 'A'); |
| 46 Expect.isTrue( | 45 Expect.isTrue(compiler.backend.noSuchMethodRegistry.defaultImpls |
| 47 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 46 .contains(clsA.lookupMember('noSuchMethod'))); |
| 48 clsA.lookupMember('noSuchMethod'))); | |
| 49 } | 47 } |
| 50 | 48 |
| 51 Future dummyImplTest3() async { | 49 Future dummyImplTest3() async { |
| 52 String source = """ | 50 String source = """ |
| 53 class A extends B { | 51 class A extends B { |
| 54 foo() => 3; | 52 foo() => 3; |
| 55 noSuchMethod(x) { | 53 noSuchMethod(x) { |
| 56 return super.noSuchMethod(x); | 54 return super.noSuchMethod(x); |
| 57 } | 55 } |
| 58 } | 56 } |
| 59 class B {} | 57 class B {} |
| 60 main() { | 58 main() { |
| 61 print(new A().foo()); | 59 print(new A().foo()); |
| 62 } | 60 } |
| 63 """; | 61 """; |
| 64 Uri uri = new Uri(scheme: 'source'); | 62 Uri uri = new Uri(scheme: 'source'); |
| 65 var compiler = compilerFor(source, uri); | 63 var compiler = compilerFor(source, uri); |
| 66 await compiler.run(uri); | 64 await compiler.run(uri); |
| 67 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 65 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 68 ClassElement clsA = findElement(compiler, 'A'); | 66 ClassElement clsA = findElement(compiler, 'A'); |
| 69 Expect.isTrue( | 67 Expect.isTrue(compiler.backend.noSuchMethodRegistry.defaultImpls |
| 70 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 68 .contains(clsA.lookupMember('noSuchMethod'))); |
| 71 clsA.lookupMember('noSuchMethod'))); | |
| 72 } | 69 } |
| 73 | 70 |
| 74 Future dummyImplTest4() async { | 71 Future dummyImplTest4() async { |
| 75 String source = """ | 72 String source = """ |
| 76 class A extends B { | 73 class A extends B { |
| 77 foo() => 3; | 74 foo() => 3; |
| 78 noSuchMethod(x) => super.noSuchMethod(x); | 75 noSuchMethod(x) => super.noSuchMethod(x); |
| 79 } | 76 } |
| 80 class B { | 77 class B { |
| 81 noSuchMethod(x) => super.noSuchMethod(x); | 78 noSuchMethod(x) => super.noSuchMethod(x); |
| 82 } | 79 } |
| 83 main() { | 80 main() { |
| 84 print(new A().foo()); | 81 print(new A().foo()); |
| 85 } | 82 } |
| 86 """; | 83 """; |
| 87 Uri uri = new Uri(scheme: 'source'); | 84 Uri uri = new Uri(scheme: 'source'); |
| 88 var compiler = compilerFor(source, uri); | 85 var compiler = compilerFor(source, uri); |
| 89 await compiler.run(uri); | 86 await compiler.run(uri); |
| 90 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 87 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 91 ClassElement clsA = findElement(compiler, 'A'); | 88 ClassElement clsA = findElement(compiler, 'A'); |
| 92 Expect.isTrue( | 89 Expect.isTrue(compiler.backend.noSuchMethodRegistry.defaultImpls |
| 93 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 90 .contains(clsA.lookupMember('noSuchMethod'))); |
| 94 clsA.lookupMember('noSuchMethod'))); | |
| 95 ClassElement clsB = findElement(compiler, 'B'); | 91 ClassElement clsB = findElement(compiler, 'B'); |
| 96 Expect.isTrue( | 92 Expect.isTrue(compiler.backend.noSuchMethodRegistry.defaultImpls |
| 97 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 93 .contains(clsB.lookupMember('noSuchMethod'))); |
| 98 clsB.lookupMember('noSuchMethod'))); | |
| 99 } | 94 } |
| 100 | 95 |
| 101 Future dummyImplTest5() async { | 96 Future dummyImplTest5() async { |
| 102 String source = """ | 97 String source = """ |
| 103 class A extends B { | 98 class A extends B { |
| 104 foo() => 3; | 99 foo() => 3; |
| 105 noSuchMethod(x) => super.noSuchMethod(x); | 100 noSuchMethod(x) => super.noSuchMethod(x); |
| 106 } | 101 } |
| 107 class B { | 102 class B { |
| 108 noSuchMethod(x) => throw 'foo'; | 103 noSuchMethod(x) => throw 'foo'; |
| 109 } | 104 } |
| 110 main() { | 105 main() { |
| 111 print(new A().foo()); | 106 print(new A().foo()); |
| 112 } | 107 } |
| 113 """; | 108 """; |
| 114 Uri uri = new Uri(scheme: 'source'); | 109 Uri uri = new Uri(scheme: 'source'); |
| 115 var compiler = compilerFor(source, uri); | 110 var compiler = compilerFor(source, uri); |
| 116 await compiler.run(uri); | 111 await compiler.run(uri); |
| 117 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 112 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 118 ClassElement clsA = findElement(compiler, 'A'); | 113 ClassElement clsA = findElement(compiler, 'A'); |
| 119 Expect.isTrue( | 114 Expect.isTrue(compiler.backend.noSuchMethodRegistry.throwingImpls |
| 120 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( | 115 .contains(clsA.lookupMember('noSuchMethod'))); |
| 121 clsA.lookupMember('noSuchMethod'))); | |
| 122 ClassElement clsB = findElement(compiler, 'B'); | 116 ClassElement clsB = findElement(compiler, 'B'); |
| 123 Expect.isTrue( | 117 Expect.isTrue(compiler.backend.noSuchMethodRegistry.throwingImpls |
| 124 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( | 118 .contains(clsB.lookupMember('noSuchMethod'))); |
| 125 clsB.lookupMember('noSuchMethod'))); | |
| 126 } | 119 } |
| 127 | 120 |
| 128 Future dummyImplTest6() async { | 121 Future dummyImplTest6() async { |
| 129 String source = """ | 122 String source = """ |
| 130 class A { | 123 class A { |
| 131 noSuchMethod(x) => 3; | 124 noSuchMethod(x) => 3; |
| 132 } | 125 } |
| 133 main() { | 126 main() { |
| 134 print(new A().foo()); | 127 print(new A().foo()); |
| 135 } | 128 } |
| 136 """; | 129 """; |
| 137 Uri uri = new Uri(scheme: 'source'); | 130 Uri uri = new Uri(scheme: 'source'); |
| 138 var compiler = compilerFor(source, uri); | 131 var compiler = compilerFor(source, uri); |
| 139 await compiler.run(uri); | 132 await compiler.run(uri); |
| 140 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 133 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 141 ClassElement clsA = findElement(compiler, 'A'); | 134 ClassElement clsA = findElement(compiler, 'A'); |
| 142 Expect.isTrue( | 135 Expect.isTrue(compiler.backend.noSuchMethodRegistry.otherImpls |
| 143 compiler.backend.noSuchMethodRegistry.otherImpls.contains( | 136 .contains(clsA.lookupMember('noSuchMethod'))); |
| 144 clsA.lookupMember('noSuchMethod'))); | |
| 145 } | 137 } |
| 146 | 138 |
| 147 Future dummyImplTest7() async { | 139 Future dummyImplTest7() async { |
| 148 String source = """ | 140 String source = """ |
| 149 class A { | 141 class A { |
| 150 noSuchMethod(x, [y]) => super.noSuchMethod(x); | 142 noSuchMethod(x, [y]) => super.noSuchMethod(x); |
| 151 } | 143 } |
| 152 main() { | 144 main() { |
| 153 print(new A().foo()); | 145 print(new A().foo()); |
| 154 } | 146 } |
| 155 """; | 147 """; |
| 156 Uri uri = new Uri(scheme: 'source'); | 148 Uri uri = new Uri(scheme: 'source'); |
| 157 var compiler = compilerFor(source, uri); | 149 var compiler = compilerFor(source, uri); |
| 158 await compiler.run(uri); | 150 await compiler.run(uri); |
| 159 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 151 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 160 ClassElement clsA = findElement(compiler, 'A'); | 152 ClassElement clsA = findElement(compiler, 'A'); |
| 161 Expect.isTrue( | 153 Expect.isTrue(compiler.backend.noSuchMethodRegistry.defaultImpls |
| 162 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 154 .contains(clsA.lookupMember('noSuchMethod'))); |
| 163 clsA.lookupMember('noSuchMethod'))); | |
| 164 } | 155 } |
| 165 | 156 |
| 166 Future dummyImplTest8() async { | 157 Future dummyImplTest8() async { |
| 167 String source = """ | 158 String source = """ |
| 168 class A { | 159 class A { |
| 169 noSuchMethod(x, [y]) => super.noSuchMethod(x, y); | 160 noSuchMethod(x, [y]) => super.noSuchMethod(x, y); |
| 170 } | 161 } |
| 171 main() { | 162 main() { |
| 172 print(new A().foo()); | 163 print(new A().foo()); |
| 173 } | 164 } |
| 174 """; | 165 """; |
| 175 Uri uri = new Uri(scheme: 'source'); | 166 Uri uri = new Uri(scheme: 'source'); |
| 176 var compiler = compilerFor(source, uri); | 167 var compiler = compilerFor(source, uri); |
| 177 await compiler.run(uri); | 168 await compiler.run(uri); |
| 178 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 169 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 179 ClassElement clsA = findElement(compiler, 'A'); | 170 ClassElement clsA = findElement(compiler, 'A'); |
| 180 Expect.isTrue( | 171 Expect.isTrue(compiler.backend.noSuchMethodRegistry.otherImpls |
| 181 compiler.backend.noSuchMethodRegistry.otherImpls.contains( | 172 .contains(clsA.lookupMember('noSuchMethod'))); |
| 182 clsA.lookupMember('noSuchMethod'))); | |
| 183 } | 173 } |
| 184 | 174 |
| 185 Future dummyImplTest9() async { | 175 Future dummyImplTest9() async { |
| 186 String source = """ | 176 String source = """ |
| 187 class A { | 177 class A { |
| 188 noSuchMethod(x, y) => super.noSuchMethod(x); | 178 noSuchMethod(x, y) => super.noSuchMethod(x); |
| 189 } | 179 } |
| 190 main() { | 180 main() { |
| 191 print(new A().foo()); | 181 print(new A().foo()); |
| 192 } | 182 } |
| 193 """; | 183 """; |
| 194 Uri uri = new Uri(scheme: 'source'); | 184 Uri uri = new Uri(scheme: 'source'); |
| 195 var compiler = compilerFor(source, uri); | 185 var compiler = compilerFor(source, uri); |
| 196 await compiler.run(uri); | 186 await compiler.run(uri); |
| 197 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 187 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 198 ClassElement clsA = findElement(compiler, 'A'); | 188 ClassElement clsA = findElement(compiler, 'A'); |
| 199 Expect.isTrue( | 189 Expect.isTrue(compiler.backend.noSuchMethodRegistry.notApplicableImpls |
| 200 compiler.backend.noSuchMethodRegistry.notApplicableImpls.contains( | 190 .contains(clsA.lookupMember('noSuchMethod'))); |
| 201 clsA.lookupMember('noSuchMethod'))); | |
| 202 } | 191 } |
| 203 | 192 |
| 204 Future dummyImplTest10() async { | 193 Future dummyImplTest10() async { |
| 205 String source = """ | 194 String source = """ |
| 206 class A { | 195 class A { |
| 207 noSuchMethod(Invocation x) { | 196 noSuchMethod(Invocation x) { |
| 208 throw new UnsupportedException(); | 197 throw new UnsupportedException(); |
| 209 } | 198 } |
| 210 } | 199 } |
| 211 main() { | 200 main() { |
| 212 print(new A().foo()); | 201 print(new A().foo()); |
| 213 } | 202 } |
| 214 """; | 203 """; |
| 215 Uri uri = new Uri(scheme: 'source'); | 204 Uri uri = new Uri(scheme: 'source'); |
| 216 var compiler = compilerFor(source, uri); | 205 var compiler = compilerFor(source, uri); |
| 217 await compiler.run(uri); | 206 await compiler.run(uri); |
| 218 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 207 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 219 ClassElement clsA = findElement(compiler, 'A'); | 208 ClassElement clsA = findElement(compiler, 'A'); |
| 220 Expect.isTrue( | 209 Expect.isTrue(compiler.backend.noSuchMethodRegistry.throwingImpls |
| 221 compiler.backend.noSuchMethodRegistry.throwingImpls.contains( | 210 .contains(clsA.lookupMember('noSuchMethod'))); |
| 222 clsA.lookupMember('noSuchMethod'))); | |
| 223 } | 211 } |
| 224 | 212 |
| 225 Future dummyImplTest11() async { | 213 Future dummyImplTest11() async { |
| 226 String source = """ | 214 String source = """ |
| 227 class A { | 215 class A { |
| 228 noSuchMethod(Invocation x) { | 216 noSuchMethod(Invocation x) { |
| 229 print('foo'); | 217 print('foo'); |
| 230 throw 'foo'; | 218 throw 'foo'; |
| 231 } | 219 } |
| 232 } | 220 } |
| 233 main() { | 221 main() { |
| 234 print(new A().foo()); | 222 print(new A().foo()); |
| 235 } | 223 } |
| 236 """; | 224 """; |
| 237 Uri uri = new Uri(scheme: 'source'); | 225 Uri uri = new Uri(scheme: 'source'); |
| 238 var compiler = compilerFor(source, uri); | 226 var compiler = compilerFor(source, uri); |
| 239 await compiler.run(uri); | 227 await compiler.run(uri); |
| 240 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 228 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 241 ClassElement clsA = findElement(compiler, 'A'); | 229 ClassElement clsA = findElement(compiler, 'A'); |
| 242 Expect.isTrue( | 230 Expect.isTrue(compiler.backend.noSuchMethodRegistry.otherImpls |
| 243 compiler.backend.noSuchMethodRegistry.otherImpls.contains( | 231 .contains(clsA.lookupMember('noSuchMethod'))); |
| 244 clsA.lookupMember('noSuchMethod'))); | 232 Expect.isTrue(compiler.backend.noSuchMethodRegistry.complexNoReturnImpls |
| 245 Expect.isTrue( | 233 .contains(clsA.lookupMember('noSuchMethod'))); |
| 246 compiler.backend.noSuchMethodRegistry.complexNoReturnImpls.contains( | |
| 247 clsA.lookupMember('noSuchMethod'))); | |
| 248 } | 234 } |
| 249 | 235 |
| 250 Future dummyImplTest12() async { | 236 Future dummyImplTest12() async { |
| 251 String source = """ | 237 String source = """ |
| 252 class A { | 238 class A { |
| 253 noSuchMethod(Invocation x) { | 239 noSuchMethod(Invocation x) { |
| 254 return toString(); | 240 return toString(); |
| 255 } | 241 } |
| 256 } | 242 } |
| 257 main() { | 243 main() { |
| 258 print(new A().foo()); | 244 print(new A().foo()); |
| 259 } | 245 } |
| 260 """; | 246 """; |
| 261 Uri uri = new Uri(scheme: 'source'); | 247 Uri uri = new Uri(scheme: 'source'); |
| 262 var compiler = compilerFor(source, uri); | 248 var compiler = compilerFor(source, uri); |
| 263 await compiler.run(uri); | 249 await compiler.run(uri); |
| 264 Expect.isTrue(compiler.backend.enabledNoSuchMethod); | 250 Expect.isTrue(compiler.backend.enabledNoSuchMethod); |
| 265 ClassElement clsA = findElement(compiler, 'A'); | 251 ClassElement clsA = findElement(compiler, 'A'); |
| 266 Expect.isTrue( | 252 Expect.isTrue(compiler.backend.noSuchMethodRegistry.otherImpls |
| 267 compiler.backend.noSuchMethodRegistry.otherImpls.contains( | 253 .contains(clsA.lookupMember('noSuchMethod'))); |
| 268 clsA.lookupMember('noSuchMethod'))); | 254 Expect.isTrue(compiler.backend.noSuchMethodRegistry.complexReturningImpls |
| 269 Expect.isTrue( | 255 .contains(clsA.lookupMember('noSuchMethod'))); |
| 270 compiler.backend.noSuchMethodRegistry.complexReturningImpls.contains( | |
| 271 clsA.lookupMember('noSuchMethod'))); | |
| 272 } | 256 } |
| 273 | 257 |
| 274 Future dummyImplTest13() async { | 258 Future dummyImplTest13() async { |
| 275 String source = """ | 259 String source = """ |
| 276 class A { | 260 class A { |
| 277 noSuchMethod(x) => super.noSuchMethod(x) as dynamic; | 261 noSuchMethod(x) => super.noSuchMethod(x) as dynamic; |
| 278 } | 262 } |
| 279 main() { | 263 main() { |
| 280 print(new A().foo()); | 264 print(new A().foo()); |
| 281 } | 265 } |
| 282 """; | 266 """; |
| 283 Uri uri = new Uri(scheme: 'source'); | 267 Uri uri = new Uri(scheme: 'source'); |
| 284 var compiler = compilerFor(source, uri); | 268 var compiler = compilerFor(source, uri); |
| 285 await compiler.run(uri); | 269 await compiler.run(uri); |
| 286 Expect.isFalse(compiler.backend.enabledNoSuchMethod); | 270 Expect.isFalse(compiler.backend.enabledNoSuchMethod); |
| 287 ClassElement clsA = findElement(compiler, 'A'); | 271 ClassElement clsA = findElement(compiler, 'A'); |
| 288 Expect.isTrue( | 272 Expect.isTrue(compiler.backend.noSuchMethodRegistry.defaultImpls |
| 289 compiler.backend.noSuchMethodRegistry.defaultImpls.contains( | 273 .contains(clsA.lookupMember('noSuchMethod'))); |
| 290 clsA.lookupMember('noSuchMethod'))); | |
| 291 } | 274 } |
| 292 | 275 |
| 293 main() { | 276 main() { |
| 294 asyncTest(() async { | 277 asyncTest(() async { |
| 295 await dummyImplTest(); | 278 await dummyImplTest(); |
| 296 await dummyImplTest2(); | 279 await dummyImplTest2(); |
| 297 await dummyImplTest3(); | 280 await dummyImplTest3(); |
| 298 await dummyImplTest4(); | 281 await dummyImplTest4(); |
| 299 await dummyImplTest5(); | 282 await dummyImplTest5(); |
| 300 await dummyImplTest6(); | 283 await dummyImplTest6(); |
| 301 await dummyImplTest7(); | 284 await dummyImplTest7(); |
| 302 await dummyImplTest8(); | 285 await dummyImplTest8(); |
| 303 await dummyImplTest9(); | 286 await dummyImplTest9(); |
| 304 await dummyImplTest10(); | 287 await dummyImplTest10(); |
| 305 await dummyImplTest11(); | 288 await dummyImplTest11(); |
| 306 await dummyImplTest12(); | 289 await dummyImplTest12(); |
| 307 await dummyImplTest13(); | 290 await dummyImplTest13(); |
| 308 }); | 291 }); |
| 309 } | 292 } |
| OLD | NEW |