| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 'package:compiler/src/compiler.dart'; | 8 import 'package:compiler/src/compiler.dart'; |
| 9 import 'package:compiler/src/diagnostics/messages.dart' show MessageKind; | 9 import 'package:compiler/src/diagnostics/messages.dart' show MessageKind; |
| 10 import 'package:compiler/src/elements/elements.dart'; | 10 import 'package:compiler/src/elements/elements.dart'; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 expectHasBody(compiler, element); | 114 expectHasBody(compiler, element); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 Expect.isFalse(element.isPatched && element.isPatch); | 117 Expect.isFalse(element.isPatched && element.isPatch); |
| 118 return element; | 118 return element; |
| 119 } | 119 } |
| 120 | 120 |
| 121 Future testPatchFunction() async { | 121 Future testPatchFunction() async { |
| 122 var compiler = await applyPatch( | 122 var compiler = await applyPatch( |
| 123 "external test();", "@patch test() { return 'string'; } "); | 123 "external test();", "@patch test() { return 'string'; } "); |
| 124 ensure(compiler, "test", compiler.commonElements.coreLibrary.find, | 124 ensure(compiler, "test", compiler.resolution.commonElements.coreLibrary.find, |
| 125 expectIsPatched: true, checkHasBody: true); | 125 expectIsPatched: true, checkHasBody: true); |
| 126 ensure(compiler, "test", compiler.commonElements.coreLibrary.patch.find, | 126 ensure(compiler, "test", |
| 127 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 127 expectIsPatch: true, checkHasBody: true); | 128 expectIsPatch: true, checkHasBody: true); |
| 128 | 129 |
| 129 DiagnosticCollector collector = compiler.diagnosticCollector; | 130 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 130 Expect.isTrue( | 131 Expect.isTrue( |
| 131 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 132 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 132 Expect.isTrue( | 133 Expect.isTrue( |
| 133 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); | 134 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); |
| 134 } | 135 } |
| 135 | 136 |
| 136 Future testPatchFunctionMetadata() async { | 137 Future testPatchFunctionMetadata() async { |
| 137 var compiler = await applyPatch( | 138 var compiler = await applyPatch( |
| 138 """ | 139 """ |
| 139 const a = 0; | 140 const a = 0; |
| 140 @a external test(); | 141 @a external test(); |
| 141 """, | 142 """, |
| 142 """ | 143 """ |
| 143 const _b = 1; | 144 const _b = 1; |
| 144 @patch @_b test() {} | 145 @patch @_b test() {} |
| 145 """); | 146 """); |
| 146 Element origin = ensure( | 147 Element origin = ensure( |
| 147 compiler, "test", compiler.commonElements.coreLibrary.find, | 148 compiler, "test", compiler.resolution.commonElements.coreLibrary.find, |
| 148 expectIsPatched: true, checkHasBody: true); | 149 expectIsPatched: true, checkHasBody: true); |
| 149 Element patch = ensure( | 150 Element patch = ensure(compiler, "test", |
| 150 compiler, "test", compiler.commonElements.coreLibrary.patch.find, | 151 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 151 expectIsPatch: true, checkHasBody: true); | 152 expectIsPatch: true, checkHasBody: true); |
| 152 | 153 |
| 153 DiagnosticCollector collector = compiler.diagnosticCollector; | 154 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 154 Expect.isTrue( | 155 Expect.isTrue( |
| 155 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 156 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 156 Expect.isTrue( | 157 Expect.isTrue( |
| 157 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); | 158 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); |
| 158 | 159 |
| 159 Expect.equals(1, origin.metadata.length, | 160 Expect.equals(1, origin.metadata.length, |
| 160 "Unexpected origin metadata: ${origin.metadata}."); | 161 "Unexpected origin metadata: ${origin.metadata}."); |
| 161 Expect.equals(3, patch.metadata.length, | 162 Expect.equals(3, patch.metadata.length, |
| 162 "Unexpected patch metadata: ${patch.metadata}."); | 163 "Unexpected patch metadata: ${patch.metadata}."); |
| 163 } | 164 } |
| 164 | 165 |
| 165 Future testPatchFunctionGeneric() async { | 166 Future testPatchFunctionGeneric() async { |
| 166 var compiler = await applyPatch( | 167 var compiler = await applyPatch( |
| 167 "external T test<T>();", "@patch T test<T>() { return null; } "); | 168 "external T test<T>();", "@patch T test<T>() { return null; } "); |
| 168 Element origin = ensure( | 169 Element origin = ensure( |
| 169 compiler, "test", compiler.commonElements.coreLibrary.find, | 170 compiler, "test", compiler.resolution.commonElements.coreLibrary.find, |
| 170 expectIsPatched: true, checkHasBody: true); | 171 expectIsPatched: true, checkHasBody: true); |
| 171 ensure(compiler, "test", compiler.commonElements.coreLibrary.patch.find, | 172 ensure(compiler, "test", |
| 173 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 172 expectIsPatch: true, checkHasBody: true); | 174 expectIsPatch: true, checkHasBody: true); |
| 173 compiler.resolver.resolve(origin); | 175 compiler.resolver.resolve(origin); |
| 174 | 176 |
| 175 DiagnosticCollector collector = compiler.diagnosticCollector; | 177 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 176 Expect.isTrue( | 178 Expect.isTrue( |
| 177 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 179 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 178 Expect.isTrue( | 180 Expect.isTrue( |
| 179 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); | 181 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); |
| 180 } | 182 } |
| 181 | 183 |
| 182 Future testPatchFunctionGenericExtraTypeVariable() async { | 184 Future testPatchFunctionGenericExtraTypeVariable() async { |
| 183 var compiler = await applyPatch( | 185 var compiler = await applyPatch( |
| 184 "external T test<T>();", "@patch T test<T, S>() { return null; } "); | 186 "external T test<T>();", "@patch T test<T, S>() { return null; } "); |
| 185 Element origin = ensure( | 187 Element origin = ensure( |
| 186 compiler, "test", compiler.commonElements.coreLibrary.find, | 188 compiler, "test", compiler.resolution.commonElements.coreLibrary.find, |
| 187 expectIsPatched: true, checkHasBody: true); | 189 expectIsPatched: true, checkHasBody: true); |
| 188 ensure(compiler, "test", compiler.commonElements.coreLibrary.patch.find, | 190 ensure(compiler, "test", |
| 191 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 189 expectIsPatch: true, checkHasBody: true); | 192 expectIsPatch: true, checkHasBody: true); |
| 190 compiler.resolver.resolve(origin); | 193 compiler.resolver.resolve(origin); |
| 191 | 194 |
| 192 DiagnosticCollector collector = compiler.diagnosticCollector; | 195 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 193 Expect.isTrue( | 196 Expect.isTrue( |
| 194 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 197 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 195 Expect.equals(1, collector.errors.length); | 198 Expect.equals(1, collector.errors.length); |
| 196 Expect.isTrue(collector.errors.first.message.kind == | 199 Expect.isTrue(collector.errors.first.message.kind == |
| 197 MessageKind.PATCH_TYPE_VARIABLES_MISMATCH); | 200 MessageKind.PATCH_TYPE_VARIABLES_MISMATCH); |
| 198 } | 201 } |
| 199 | 202 |
| 200 Future testPatchFunctionGenericDifferentNames() async { | 203 Future testPatchFunctionGenericDifferentNames() async { |
| 201 var compiler = await applyPatch( | 204 var compiler = await applyPatch( |
| 202 "external T test<T, S>();", "@patch T test<S, T>() { return null; } "); | 205 "external T test<T, S>();", "@patch T test<S, T>() { return null; } "); |
| 203 Element origin = ensure( | 206 Element origin = ensure( |
| 204 compiler, "test", compiler.commonElements.coreLibrary.find, | 207 compiler, "test", compiler.resolution.commonElements.coreLibrary.find, |
| 205 expectIsPatched: true, checkHasBody: true); | 208 expectIsPatched: true, checkHasBody: true); |
| 206 ensure(compiler, "test", compiler.commonElements.coreLibrary.patch.find, | 209 ensure(compiler, "test", |
| 210 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 207 expectIsPatch: true, checkHasBody: true); | 211 expectIsPatch: true, checkHasBody: true); |
| 208 compiler.resolver.resolve(origin); | 212 compiler.resolver.resolve(origin); |
| 209 | 213 |
| 210 DiagnosticCollector collector = compiler.diagnosticCollector; | 214 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 211 Expect.isTrue( | 215 Expect.isTrue( |
| 212 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 216 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 213 Expect.equals(1, collector.errors.length); | 217 Expect.equals(1, collector.errors.length); |
| 214 Expect.isTrue(collector.errors.first.message.kind == | 218 Expect.isTrue(collector.errors.first.message.kind == |
| 215 MessageKind.PATCH_TYPE_VARIABLES_MISMATCH); | 219 MessageKind.PATCH_TYPE_VARIABLES_MISMATCH); |
| 216 } | 220 } |
| 217 | 221 |
| 218 Future testPatchConstructor() async { | 222 Future testPatchConstructor() async { |
| 219 var compiler = await applyPatch( | 223 var compiler = await applyPatch( |
| 220 """ | 224 """ |
| 221 class Class { | 225 class Class { |
| 222 external Class(); | 226 external Class(); |
| 223 } | 227 } |
| 224 """, | 228 """, |
| 225 """ | 229 """ |
| 226 @patch class Class { | 230 @patch class Class { |
| 227 @patch Class(); | 231 @patch Class(); |
| 228 } | 232 } |
| 229 """); | 233 """); |
| 230 var classOrigin = ensure( | 234 var classOrigin = ensure( |
| 231 compiler, "Class", compiler.commonElements.coreLibrary.find, | 235 compiler, "Class", compiler.resolution.commonElements.coreLibrary.find, |
| 232 expectIsPatched: true); | 236 expectIsPatched: true); |
| 233 classOrigin.ensureResolved(compiler.resolution); | 237 classOrigin.ensureResolved(compiler.resolution); |
| 234 var classPatch = ensure( | 238 var classPatch = ensure(compiler, "Class", |
| 235 compiler, "Class", compiler.commonElements.coreLibrary.patch.find, | 239 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 236 expectIsPatch: true); | 240 expectIsPatch: true); |
| 237 | 241 |
| 238 Expect.equals(classPatch, classOrigin.patch); | 242 Expect.equals(classPatch, classOrigin.patch); |
| 239 Expect.equals(classOrigin, classPatch.origin); | 243 Expect.equals(classOrigin, classPatch.origin); |
| 240 | 244 |
| 241 var constructorOrigin = ensure( | 245 var constructorOrigin = ensure( |
| 242 compiler, "", (name) => classOrigin.localLookup(name), | 246 compiler, "", (name) => classOrigin.localLookup(name), |
| 243 expectIsPatched: true); | 247 expectIsPatched: true); |
| 244 var constructorPatch = ensure( | 248 var constructorPatch = ensure( |
| 245 compiler, "", (name) => classPatch.localLookup(name), | 249 compiler, "", (name) => classPatch.localLookup(name), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 263 | 267 |
| 264 external Class._(x, y); | 268 external Class._(x, y); |
| 265 } | 269 } |
| 266 """, | 270 """, |
| 267 r""" | 271 r""" |
| 268 @patch class Class { | 272 @patch class Class { |
| 269 @patch Class._(x, y) { print('$x,$y'); } | 273 @patch Class._(x, y) { print('$x,$y'); } |
| 270 } | 274 } |
| 271 """); | 275 """); |
| 272 var classOrigin = ensure( | 276 var classOrigin = ensure( |
| 273 compiler, "Class", compiler.commonElements.coreLibrary.find, | 277 compiler, "Class", compiler.resolution.commonElements.coreLibrary.find, |
| 274 expectIsPatched: true); | 278 expectIsPatched: true); |
| 275 classOrigin.ensureResolved(compiler.resolution); | 279 classOrigin.ensureResolved(compiler.resolution); |
| 276 | 280 |
| 277 var classPatch = ensure( | 281 var classPatch = ensure(compiler, "Class", |
| 278 compiler, "Class", compiler.commonElements.coreLibrary.patch.find, | 282 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 279 expectIsPatch: true); | 283 expectIsPatch: true); |
| 280 | 284 |
| 281 Expect.equals(classOrigin, classPatch.origin); | 285 Expect.equals(classOrigin, classPatch.origin); |
| 282 Expect.equals(classPatch, classOrigin.patch); | 286 Expect.equals(classPatch, classOrigin.patch); |
| 283 | 287 |
| 284 var constructorRedirecting = | 288 var constructorRedirecting = |
| 285 ensure(compiler, "", (name) => classOrigin.localLookup(name)); | 289 ensure(compiler, "", (name) => classOrigin.localLookup(name)); |
| 286 var constructorOrigin = ensure( | 290 var constructorOrigin = ensure( |
| 287 compiler, "_", (name) => classOrigin.localLookup(name), | 291 compiler, "_", (name) => classOrigin.localLookup(name), |
| 288 expectIsPatched: true); | 292 expectIsPatched: true); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 307 class Class { | 311 class Class { |
| 308 external String toString(); | 312 external String toString(); |
| 309 } | 313 } |
| 310 """, | 314 """, |
| 311 """ | 315 """ |
| 312 @patch class Class { | 316 @patch class Class { |
| 313 @patch String toString() => 'string'; | 317 @patch String toString() => 'string'; |
| 314 } | 318 } |
| 315 """); | 319 """); |
| 316 var container = ensure( | 320 var container = ensure( |
| 317 compiler, "Class", compiler.commonElements.coreLibrary.find, | 321 compiler, "Class", compiler.resolution.commonElements.coreLibrary.find, |
| 318 expectIsPatched: true); | 322 expectIsPatched: true); |
| 319 container.parseNode(compiler.parsingContext); | 323 container.parseNode(compiler.parsingContext); |
| 320 ensure(compiler, "Class", compiler.commonElements.coreLibrary.patch.find, | 324 ensure(compiler, "Class", |
| 325 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 321 expectIsPatch: true); | 326 expectIsPatch: true); |
| 322 | 327 |
| 323 ensure(compiler, "toString", container.lookupLocalMember, | 328 ensure(compiler, "toString", container.lookupLocalMember, |
| 324 expectIsPatched: true, checkHasBody: true); | 329 expectIsPatched: true, checkHasBody: true); |
| 325 ensure(compiler, "toString", container.patch.lookupLocalMember, | 330 ensure(compiler, "toString", container.patch.lookupLocalMember, |
| 326 expectIsPatch: true, checkHasBody: true); | 331 expectIsPatch: true, checkHasBody: true); |
| 327 | 332 |
| 328 DiagnosticCollector collector = compiler.diagnosticCollector; | 333 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 329 Expect.isTrue( | 334 Expect.isTrue( |
| 330 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 335 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 331 Expect.isTrue( | 336 Expect.isTrue( |
| 332 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); | 337 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); |
| 333 } | 338 } |
| 334 | 339 |
| 335 Future testPatchGetter() async { | 340 Future testPatchGetter() async { |
| 336 var compiler = await applyPatch( | 341 var compiler = await applyPatch( |
| 337 """ | 342 """ |
| 338 class Class { | 343 class Class { |
| 339 external int get field; | 344 external int get field; |
| 340 } | 345 } |
| 341 """, | 346 """, |
| 342 """ | 347 """ |
| 343 @patch class Class { | 348 @patch class Class { |
| 344 @patch int get field => 5; | 349 @patch int get field => 5; |
| 345 } | 350 } |
| 346 """); | 351 """); |
| 347 var container = ensure( | 352 var container = ensure( |
| 348 compiler, "Class", compiler.commonElements.coreLibrary.find, | 353 compiler, "Class", compiler.resolution.commonElements.coreLibrary.find, |
| 349 expectIsPatched: true); | 354 expectIsPatched: true); |
| 350 container.parseNode(compiler.parsingContext); | 355 container.parseNode(compiler.parsingContext); |
| 351 ensure(compiler, "field", container.lookupLocalMember, | 356 ensure(compiler, "field", container.lookupLocalMember, |
| 352 expectIsGetter: true, expectIsPatched: true, checkHasBody: true); | 357 expectIsGetter: true, expectIsPatched: true, checkHasBody: true); |
| 353 ensure(compiler, "field", container.patch.lookupLocalMember, | 358 ensure(compiler, "field", container.patch.lookupLocalMember, |
| 354 expectIsGetter: true, expectIsPatch: true, checkHasBody: true); | 359 expectIsGetter: true, expectIsPatch: true, checkHasBody: true); |
| 355 | 360 |
| 356 DiagnosticCollector collector = compiler.diagnosticCollector; | 361 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 357 Expect.isTrue( | 362 Expect.isTrue( |
| 358 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 363 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 359 Expect.isTrue( | 364 Expect.isTrue( |
| 360 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); | 365 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); |
| 361 } | 366 } |
| 362 | 367 |
| 363 Future testRegularMember() async { | 368 Future testRegularMember() async { |
| 364 var compiler = await applyPatch( | 369 var compiler = await applyPatch( |
| 365 """ | 370 """ |
| 366 class Class { | 371 class Class { |
| 367 void regular() {} | 372 void regular() {} |
| 368 } | 373 } |
| 369 """, | 374 """, |
| 370 """ | 375 """ |
| 371 @patch class Class { | 376 @patch class Class { |
| 372 } | 377 } |
| 373 """); | 378 """); |
| 374 var container = ensure( | 379 var container = ensure( |
| 375 compiler, "Class", compiler.commonElements.coreLibrary.find, | 380 compiler, "Class", compiler.resolution.commonElements.coreLibrary.find, |
| 376 expectIsPatched: true); | 381 expectIsPatched: true); |
| 377 container.parseNode(compiler.parsingContext); | 382 container.parseNode(compiler.parsingContext); |
| 378 ensure(compiler, "Class", compiler.commonElements.coreLibrary.patch.find, | 383 ensure(compiler, "Class", |
| 384 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 379 expectIsPatch: true); | 385 expectIsPatch: true); |
| 380 | 386 |
| 381 ensure(compiler, "regular", container.lookupLocalMember, | 387 ensure(compiler, "regular", container.lookupLocalMember, |
| 382 checkHasBody: true, expectIsRegular: true); | 388 checkHasBody: true, expectIsRegular: true); |
| 383 ensure(compiler, "regular", container.patch.lookupLocalMember, | 389 ensure(compiler, "regular", container.patch.lookupLocalMember, |
| 384 checkHasBody: true, expectIsRegular: true); | 390 checkHasBody: true, expectIsRegular: true); |
| 385 | 391 |
| 386 DiagnosticCollector collector = compiler.diagnosticCollector; | 392 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 387 Expect.isTrue( | 393 Expect.isTrue( |
| 388 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 394 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 389 Expect.isTrue( | 395 Expect.isTrue( |
| 390 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); | 396 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); |
| 391 } | 397 } |
| 392 | 398 |
| 393 Future testInjectedMember() async { | 399 Future testInjectedMember() async { |
| 394 var compiler = await applyPatch( | 400 var compiler = await applyPatch( |
| 395 """ | 401 """ |
| 396 class Class { | 402 class Class { |
| 397 } | 403 } |
| 398 """, | 404 """, |
| 399 """ | 405 """ |
| 400 @patch class Class { | 406 @patch class Class { |
| 401 void _injected() {} | 407 void _injected() {} |
| 402 } | 408 } |
| 403 """); | 409 """); |
| 404 var container = ensure( | 410 var container = ensure( |
| 405 compiler, "Class", compiler.commonElements.coreLibrary.find, | 411 compiler, "Class", compiler.resolution.commonElements.coreLibrary.find, |
| 406 expectIsPatched: true); | 412 expectIsPatched: true); |
| 407 container.parseNode(compiler.parsingContext); | 413 container.parseNode(compiler.parsingContext); |
| 408 ensure(compiler, "Class", compiler.commonElements.coreLibrary.patch.find, | 414 ensure(compiler, "Class", |
| 415 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 409 expectIsPatch: true); | 416 expectIsPatch: true); |
| 410 | 417 |
| 411 ensure(compiler, "_injected", container.lookupLocalMember, | 418 ensure(compiler, "_injected", container.lookupLocalMember, |
| 412 expectIsFound: false); | 419 expectIsFound: false); |
| 413 ensure(compiler, "_injected", container.patch.lookupLocalMember, | 420 ensure(compiler, "_injected", container.patch.lookupLocalMember, |
| 414 checkHasBody: true, expectIsRegular: true); | 421 checkHasBody: true, expectIsRegular: true); |
| 415 | 422 |
| 416 DiagnosticCollector collector = compiler.diagnosticCollector; | 423 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 417 Expect.isTrue( | 424 Expect.isTrue( |
| 418 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 425 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 419 Expect.isTrue( | 426 Expect.isTrue( |
| 420 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); | 427 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); |
| 421 } | 428 } |
| 422 | 429 |
| 423 Future testInjectedPublicMember() async { | 430 Future testInjectedPublicMember() async { |
| 424 var compiler = await applyPatch( | 431 var compiler = await applyPatch( |
| 425 """ | 432 """ |
| 426 class Class { | 433 class Class { |
| 427 } | 434 } |
| 428 """, | 435 """, |
| 429 """ | 436 """ |
| 430 @patch class Class { | 437 @patch class Class { |
| 431 void injected() {} | 438 void injected() {} |
| 432 } | 439 } |
| 433 """); | 440 """); |
| 434 var container = ensure( | 441 var container = ensure( |
| 435 compiler, "Class", compiler.commonElements.coreLibrary.find, | 442 compiler, "Class", compiler.resolution.commonElements.coreLibrary.find, |
| 436 expectIsPatched: true); | 443 expectIsPatched: true); |
| 437 container.parseNode(compiler.parsingContext); | 444 container.parseNode(compiler.parsingContext); |
| 438 ensure(compiler, "Class", compiler.commonElements.coreLibrary.patch.find, | 445 ensure(compiler, "Class", |
| 446 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 439 expectIsPatch: true); | 447 expectIsPatch: true); |
| 440 | 448 |
| 441 ensure(compiler, "injected", container.lookupLocalMember, | 449 ensure(compiler, "injected", container.lookupLocalMember, |
| 442 expectIsFound: false); | 450 expectIsFound: false); |
| 443 ensure(compiler, "injected", container.patch.lookupLocalMember, | 451 ensure(compiler, "injected", container.patch.lookupLocalMember, |
| 444 checkHasBody: true, expectIsRegular: true); | 452 checkHasBody: true, expectIsRegular: true); |
| 445 | 453 |
| 446 DiagnosticCollector collector = compiler.diagnosticCollector; | 454 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 447 Expect.isTrue( | 455 Expect.isTrue( |
| 448 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 456 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 449 Expect.equals( | 457 Expect.equals( |
| 450 1, collector.errors.length, "Unexpected errors: ${collector.errors}"); | 458 1, collector.errors.length, "Unexpected errors: ${collector.errors}"); |
| 451 Expect.isTrue(collector.errors.first.message.kind == | 459 Expect.isTrue(collector.errors.first.message.kind == |
| 452 MessageKind.INJECTED_PUBLIC_MEMBER); | 460 MessageKind.INJECTED_PUBLIC_MEMBER); |
| 453 } | 461 } |
| 454 | 462 |
| 455 Future testInjectedFunction() async { | 463 Future testInjectedFunction() async { |
| 456 var compiler = await applyPatch("", "int _function() => 5;"); | 464 var compiler = await applyPatch("", "int _function() => 5;"); |
| 457 ensure(compiler, "_function", compiler.commonElements.coreLibrary.find, | 465 ensure(compiler, "_function", |
| 466 compiler.resolution.commonElements.coreLibrary.find, |
| 458 expectIsFound: false); | 467 expectIsFound: false); |
| 459 ensure(compiler, "_function", compiler.commonElements.coreLibrary.patch.find, | 468 ensure(compiler, "_function", |
| 469 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 460 checkHasBody: true, expectIsRegular: true); | 470 checkHasBody: true, expectIsRegular: true); |
| 461 | 471 |
| 462 DiagnosticCollector collector = compiler.diagnosticCollector; | 472 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 463 Expect.isTrue( | 473 Expect.isTrue( |
| 464 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 474 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 465 Expect.isTrue( | 475 Expect.isTrue( |
| 466 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); | 476 collector.errors.isEmpty, "Unexpected errors: ${collector.errors}"); |
| 467 } | 477 } |
| 468 | 478 |
| 469 Future testInjectedPublicFunction() async { | 479 Future testInjectedPublicFunction() async { |
| 470 var compiler = await applyPatch("", "int function() => 5;"); | 480 var compiler = await applyPatch("", "int function() => 5;"); |
| 471 ensure(compiler, "function", compiler.commonElements.coreLibrary.find, | 481 ensure( |
| 482 compiler, "function", compiler.resolution.commonElements.coreLibrary.find, |
| 472 expectIsFound: false); | 483 expectIsFound: false); |
| 473 ensure(compiler, "function", compiler.commonElements.coreLibrary.patch.find, | 484 ensure(compiler, "function", |
| 485 compiler.resolution.commonElements.coreLibrary.patch.find, |
| 474 checkHasBody: true, expectIsRegular: true); | 486 checkHasBody: true, expectIsRegular: true); |
| 475 | 487 |
| 476 DiagnosticCollector collector = compiler.diagnosticCollector; | 488 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 477 Expect.isTrue( | 489 Expect.isTrue( |
| 478 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 490 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 479 Expect.equals( | 491 Expect.equals( |
| 480 1, collector.errors.length, "Unexpected errors: ${collector.errors}"); | 492 1, collector.errors.length, "Unexpected errors: ${collector.errors}"); |
| 481 Expect.isTrue(collector.errors.first.message.kind == | 493 Expect.isTrue(collector.errors.first.message.kind == |
| 482 MessageKind.INJECTED_PUBLIC_MEMBER); | 494 MessageKind.INJECTED_PUBLIC_MEMBER); |
| 483 } | 495 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 508 @patch void method5() {} | 520 @patch void method5() {} |
| 509 @patch void method6([String str]) {} | 521 @patch void method6([String str]) {} |
| 510 @patch void method7([String s2]) {} | 522 @patch void method7([String s2]) {} |
| 511 @patch void method8({String s2}) {} | 523 @patch void method8({String s2}) {} |
| 512 @patch void method9(int str) {} | 524 @patch void method9(int str) {} |
| 513 @patch void method10([int str]) {} | 525 @patch void method10([int str]) {} |
| 514 @patch void method11({int str}) {} | 526 @patch void method11({int str}) {} |
| 515 } | 527 } |
| 516 """); | 528 """); |
| 517 var container = ensure( | 529 var container = ensure( |
| 518 compiler, "Class", compiler.commonElements.coreLibrary.find, | 530 compiler, "Class", compiler.resolution.commonElements.coreLibrary.find, |
| 519 expectIsPatched: true); | 531 expectIsPatched: true); |
| 520 container.ensureResolved(compiler.resolution); | 532 container.ensureResolved(compiler.resolution); |
| 521 container.parseNode(compiler.parsingContext); | 533 container.parseNode(compiler.parsingContext); |
| 522 DiagnosticCollector collector = compiler.diagnosticCollector; | 534 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 523 | 535 |
| 524 void expect(String methodName, List infos, List errors) { | 536 void expect(String methodName, List infos, List errors) { |
| 525 collector.clear(); | 537 collector.clear(); |
| 526 compiler.resolver.resolveMethodElement(ensure( | 538 compiler.resolver.resolveMethodElement(ensure( |
| 527 compiler, methodName, container.lookupLocalMember, | 539 compiler, methodName, container.lookupLocalMember, |
| 528 expectIsPatched: true, checkHasBody: true)); | 540 expectIsPatched: true, checkHasBody: true)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 559 } | 571 } |
| 560 | 572 |
| 561 Future testExternalWithoutImplementationTopLevel() async { | 573 Future testExternalWithoutImplementationTopLevel() async { |
| 562 var compiler = await applyPatch( | 574 var compiler = await applyPatch( |
| 563 """ | 575 """ |
| 564 external void foo(); | 576 external void foo(); |
| 565 """, | 577 """, |
| 566 """ | 578 """ |
| 567 // @patch void foo() {} | 579 // @patch void foo() {} |
| 568 """); | 580 """); |
| 569 var function = | 581 var function = ensure( |
| 570 ensure(compiler, "foo", compiler.commonElements.coreLibrary.find); | 582 compiler, "foo", compiler.resolution.commonElements.coreLibrary.find); |
| 571 compiler.resolver.resolve(function); | 583 compiler.resolver.resolve(function); |
| 572 DiagnosticCollector collector = compiler.diagnosticCollector; | 584 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 573 Expect.isTrue( | 585 Expect.isTrue( |
| 574 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 586 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 575 print('testExternalWithoutImplementationTopLevel:${collector.errors}'); | 587 print('testExternalWithoutImplementationTopLevel:${collector.errors}'); |
| 576 Expect.equals(1, collector.errors.length); | 588 Expect.equals(1, collector.errors.length); |
| 577 Expect.isTrue(collector.errors.first.message.kind == | 589 Expect.isTrue(collector.errors.first.message.kind == |
| 578 MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); | 590 MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); |
| 579 Expect.stringEquals('External method without an implementation.', | 591 Expect.stringEquals('External method without an implementation.', |
| 580 collector.errors.first.message.toString()); | 592 collector.errors.first.message.toString()); |
| 581 } | 593 } |
| 582 | 594 |
| 583 Future testExternalWithoutImplementationMember() async { | 595 Future testExternalWithoutImplementationMember() async { |
| 584 var compiler = await applyPatch( | 596 var compiler = await applyPatch( |
| 585 """ | 597 """ |
| 586 class Class { | 598 class Class { |
| 587 external void foo(); | 599 external void foo(); |
| 588 } | 600 } |
| 589 """, | 601 """, |
| 590 """ | 602 """ |
| 591 @patch class Class { | 603 @patch class Class { |
| 592 // @patch void foo() {} | 604 // @patch void foo() {} |
| 593 } | 605 } |
| 594 """); | 606 """); |
| 595 var container = ensure( | 607 var container = ensure( |
| 596 compiler, "Class", compiler.commonElements.coreLibrary.find, | 608 compiler, "Class", compiler.resolution.commonElements.coreLibrary.find, |
| 597 expectIsPatched: true); | 609 expectIsPatched: true); |
| 598 container.parseNode(compiler.parsingContext); | 610 container.parseNode(compiler.parsingContext); |
| 599 DiagnosticCollector collector = compiler.diagnosticCollector; | 611 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 600 collector.clear(); | 612 collector.clear(); |
| 601 compiler.resolver.resolveMethodElement( | 613 compiler.resolver.resolveMethodElement( |
| 602 ensure(compiler, "foo", container.lookupLocalMember)); | 614 ensure(compiler, "foo", container.lookupLocalMember)); |
| 603 Expect.isTrue( | 615 Expect.isTrue( |
| 604 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 616 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 605 print('testExternalWithoutImplementationMember:${collector.errors}'); | 617 print('testExternalWithoutImplementationMember:${collector.errors}'); |
| 606 Expect.equals(1, collector.errors.length); | 618 Expect.equals(1, collector.errors.length); |
| 607 Expect.isTrue(collector.errors.first.message.kind == | 619 Expect.isTrue(collector.errors.first.message.kind == |
| 608 MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); | 620 MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); |
| 609 Expect.stringEquals('External method without an implementation.', | 621 Expect.stringEquals('External method without an implementation.', |
| 610 collector.errors.first.message.toString()); | 622 collector.errors.first.message.toString()); |
| 611 } | 623 } |
| 612 | 624 |
| 613 Future testIsSubclass() async { | 625 Future testIsSubclass() async { |
| 614 var compiler = await applyPatch( | 626 var compiler = await applyPatch( |
| 615 """ | 627 """ |
| 616 class A {} | 628 class A {} |
| 617 """, | 629 """, |
| 618 """ | 630 """ |
| 619 @patch class A {} | 631 @patch class A {} |
| 620 """); | 632 """); |
| 621 ClassElement cls = ensure( | 633 ClassElement cls = ensure( |
| 622 compiler, "A", compiler.commonElements.coreLibrary.find, | 634 compiler, "A", compiler.resolution.commonElements.coreLibrary.find, |
| 623 expectIsPatched: true); | 635 expectIsPatched: true); |
| 624 ClassElement patch = cls.patch; | 636 ClassElement patch = cls.patch; |
| 625 Expect.isTrue(cls != patch); | 637 Expect.isTrue(cls != patch); |
| 626 Expect.isTrue(cls.isSubclassOf(patch)); | 638 Expect.isTrue(cls.isSubclassOf(patch)); |
| 627 Expect.isTrue(patch.isSubclassOf(cls)); | 639 Expect.isTrue(patch.isSubclassOf(cls)); |
| 628 } | 640 } |
| 629 | 641 |
| 630 Future testPatchNonExistingTopLevel() async { | 642 Future testPatchNonExistingTopLevel() async { |
| 631 var compiler = await applyPatch( | 643 var compiler = await applyPatch( |
| 632 """ | 644 """ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 648 var compiler = await applyPatch( | 660 var compiler = await applyPatch( |
| 649 """ | 661 """ |
| 650 class Class {} | 662 class Class {} |
| 651 """, | 663 """, |
| 652 """ | 664 """ |
| 653 @patch class Class { | 665 @patch class Class { |
| 654 @patch void foo() {} | 666 @patch void foo() {} |
| 655 } | 667 } |
| 656 """); | 668 """); |
| 657 var container = ensure( | 669 var container = ensure( |
| 658 compiler, "Class", compiler.commonElements.coreLibrary.find, | 670 compiler, "Class", compiler.resolution.commonElements.coreLibrary.find, |
| 659 expectIsPatched: true); | 671 expectIsPatched: true); |
| 660 container.parseNode(compiler.parsingContext); | 672 container.parseNode(compiler.parsingContext); |
| 661 DiagnosticCollector collector = compiler.diagnosticCollector; | 673 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 662 | 674 |
| 663 Expect.isTrue( | 675 Expect.isTrue( |
| 664 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 676 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 665 print('testPatchNonExistingMember:${collector.errors}'); | 677 print('testPatchNonExistingMember:${collector.errors}'); |
| 666 Expect.equals(1, collector.errors.length); | 678 Expect.equals(1, collector.errors.length); |
| 667 Expect.isTrue( | 679 Expect.isTrue( |
| 668 collector.errors.first.message.kind == MessageKind.PATCH_NON_EXISTING); | 680 collector.errors.first.message.kind == MessageKind.PATCH_NON_EXISTING); |
| 669 } | 681 } |
| 670 | 682 |
| 671 Future testPatchNonPatchablePatch() async { | 683 Future testPatchNonPatchablePatch() async { |
| 672 var compiler = await applyPatch( | 684 var compiler = await applyPatch( |
| 673 """ | 685 """ |
| 674 external get foo; | 686 external get foo; |
| 675 """, | 687 """, |
| 676 """ | 688 """ |
| 677 @patch var foo; | 689 @patch var foo; |
| 678 """); | 690 """); |
| 679 ensure(compiler, "foo", compiler.commonElements.coreLibrary.find); | 691 ensure(compiler, "foo", compiler.resolution.commonElements.coreLibrary.find); |
| 680 | 692 |
| 681 DiagnosticCollector collector = compiler.diagnosticCollector; | 693 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 682 Expect.isTrue( | 694 Expect.isTrue( |
| 683 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 695 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 684 print('testPatchNonPatchablePatch:${collector.errors}'); | 696 print('testPatchNonPatchablePatch:${collector.errors}'); |
| 685 Expect.equals(1, collector.errors.length); | 697 Expect.equals(1, collector.errors.length); |
| 686 Expect.isTrue( | 698 Expect.isTrue( |
| 687 collector.errors.first.message.kind == MessageKind.PATCH_NONPATCHABLE); | 699 collector.errors.first.message.kind == MessageKind.PATCH_NONPATCHABLE); |
| 688 } | 700 } |
| 689 | 701 |
| 690 Future testPatchNonPatchableOrigin() async { | 702 Future testPatchNonPatchableOrigin() async { |
| 691 var compiler = await applyPatch( | 703 var compiler = await applyPatch( |
| 692 """ | 704 """ |
| 693 external var foo; | 705 external var foo; |
| 694 """, | 706 """, |
| 695 """ | 707 """ |
| 696 @patch get foo => 0; | 708 @patch get foo => 0; |
| 697 """); | 709 """); |
| 698 ensure(compiler, "foo", compiler.commonElements.coreLibrary.find); | 710 ensure(compiler, "foo", compiler.resolution.commonElements.coreLibrary.find); |
| 699 | 711 |
| 700 DiagnosticCollector collector = compiler.diagnosticCollector; | 712 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 701 Expect.isTrue( | 713 Expect.isTrue( |
| 702 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); | 714 collector.warnings.isEmpty, "Unexpected warnings: ${collector.warnings}"); |
| 703 print('testPatchNonPatchableOrigin:${collector.errors}'); | 715 print('testPatchNonPatchableOrigin:${collector.errors}'); |
| 704 Expect.equals(2, collector.errors.length); | 716 Expect.equals(2, collector.errors.length); |
| 705 Expect.equals( | 717 Expect.equals( |
| 706 MessageKind.EXTRANEOUS_MODIFIER, collector.errors.first.message.kind); | 718 MessageKind.EXTRANEOUS_MODIFIER, collector.errors.first.message.kind); |
| 707 Expect.equals( | 719 Expect.equals( |
| 708 // TODO(ahe): Eventually, this error should be removed as it will be | 720 // TODO(ahe): Eventually, this error should be removed as it will be |
| (...skipping 28 matching lines...) Expand all Loading... |
| 737 class Class { | 749 class Class { |
| 738 void foo() {} | 750 void foo() {} |
| 739 } | 751 } |
| 740 """, | 752 """, |
| 741 """ | 753 """ |
| 742 @patch class Class { | 754 @patch class Class { |
| 743 @patch void foo() {} | 755 @patch void foo() {} |
| 744 } | 756 } |
| 745 """); | 757 """); |
| 746 var container = ensure( | 758 var container = ensure( |
| 747 compiler, "Class", compiler.commonElements.coreLibrary.find, | 759 compiler, "Class", compiler.resolution.commonElements.coreLibrary.find, |
| 748 expectIsPatched: true); | 760 expectIsPatched: true); |
| 749 container.parseNode(compiler.parsingContext); | 761 container.parseNode(compiler.parsingContext); |
| 750 | 762 |
| 751 DiagnosticCollector collector = compiler.diagnosticCollector; | 763 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 752 print('testPatchNonExternalMember.errors:${collector.errors}'); | 764 print('testPatchNonExternalMember.errors:${collector.errors}'); |
| 753 print('testPatchNonExternalMember.warnings:${collector.warnings}'); | 765 print('testPatchNonExternalMember.warnings:${collector.warnings}'); |
| 754 Expect.equals(1, collector.errors.length); | 766 Expect.equals(1, collector.errors.length); |
| 755 Expect.isTrue( | 767 Expect.isTrue( |
| 756 collector.errors.first.message.kind == MessageKind.PATCH_NON_EXTERNAL); | 768 collector.errors.first.message.kind == MessageKind.PATCH_NON_EXTERNAL); |
| 757 Expect.equals(0, collector.warnings.length); | 769 Expect.equals(0, collector.warnings.length); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 new A(); // ensure A and B are instantiated | 912 new A(); // ensure A and B are instantiated |
| 901 new B(); | 913 new B(); |
| 902 } | 914 } |
| 903 """, | 915 """, |
| 904 runCompiler: true, | 916 runCompiler: true, |
| 905 analyzeOnly: true); | 917 analyzeOnly: true); |
| 906 compiler.closeResolution(); | 918 compiler.closeResolution(); |
| 907 ClosedWorld world = compiler.resolutionWorldBuilder.closedWorldForTesting; | 919 ClosedWorld world = compiler.resolutionWorldBuilder.closedWorldForTesting; |
| 908 | 920 |
| 909 ClassElement cls = ensure( | 921 ClassElement cls = ensure( |
| 910 compiler, "A", compiler.commonElements.coreLibrary.find, | 922 compiler, "A", compiler.resolution.commonElements.coreLibrary.find, |
| 911 expectIsPatched: true); | 923 expectIsPatched: true); |
| 912 cls.ensureResolved(compiler.resolution); | 924 cls.ensureResolved(compiler.resolution); |
| 913 | 925 |
| 914 ensure(compiler, "method", cls.patch.lookupLocalMember, | 926 ensure(compiler, "method", cls.patch.lookupLocalMember, |
| 915 checkHasBody: true, expectIsRegular: true); | 927 checkHasBody: true, expectIsRegular: true); |
| 916 | 928 |
| 917 ensure(compiler, "clear", cls.lookupLocalMember, | 929 ensure(compiler, "clear", cls.lookupLocalMember, |
| 918 checkHasBody: true, expectIsPatched: true); | 930 checkHasBody: true, expectIsPatched: true); |
| 919 | 931 |
| 920 compiler.phase = Compiler.PHASE_DONE_RESOLVING; | 932 compiler.phase = Compiler.PHASE_DONE_RESOLVING; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 934 selector = | 946 selector = |
| 935 new Selector.call(const PublicName('clear'), CallStructure.NO_ARGS); | 947 new Selector.call(const PublicName('clear'), CallStructure.NO_ARGS); |
| 936 typeMask = new TypeMask.exact(cls, world); | 948 typeMask = new TypeMask.exact(cls, world); |
| 937 method = cls.lookupLocalMember('clear'); | 949 method = cls.lookupLocalMember('clear'); |
| 938 method.computeType(compiler.resolution); | 950 method.computeType(compiler.resolution); |
| 939 Expect.isTrue(selector.applies(method)); | 951 Expect.isTrue(selector.applies(method)); |
| 940 Expect.isTrue(typeMask.canHit(method, selector, world)); | 952 Expect.isTrue(typeMask.canHit(method, selector, world)); |
| 941 | 953 |
| 942 // Check that the declaration method in the declaration class is a target | 954 // Check that the declaration method in the declaration class is a target |
| 943 // for a typed selector on a subclass. | 955 // for a typed selector on a subclass. |
| 944 cls = ensure(compiler, "B", compiler.commonElements.coreLibrary.find); | 956 cls = ensure( |
| 957 compiler, "B", compiler.resolution.commonElements.coreLibrary.find); |
| 945 cls.ensureResolved(compiler.resolution); | 958 cls.ensureResolved(compiler.resolution); |
| 946 typeMask = new TypeMask.exact(cls, world); | 959 typeMask = new TypeMask.exact(cls, world); |
| 947 Expect.isTrue(selector.applies(method)); | 960 Expect.isTrue(selector.applies(method)); |
| 948 Expect.isTrue(typeMask.canHit(method, selector, world)); | 961 Expect.isTrue(typeMask.canHit(method, selector, world)); |
| 949 } | 962 } |
| 950 | 963 |
| 951 Future testAnalyzeAllInjectedMembers() async { | 964 Future testAnalyzeAllInjectedMembers() async { |
| 952 Future expect(String patchText, [expectedWarnings]) async { | 965 Future expect(String patchText, [expectedWarnings]) async { |
| 953 if (expectedWarnings == null) expectedWarnings = []; | 966 if (expectedWarnings == null) expectedWarnings = []; |
| 954 if (expectedWarnings is! List) { | 967 if (expectedWarnings is! List) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 @patch | 1025 @patch |
| 1013 factory B.patchInjected() = _C.injected; | 1026 factory B.patchInjected() = _C.injected; |
| 1014 } | 1027 } |
| 1015 class _C extends B { | 1028 class _C extends B { |
| 1016 _C.injected() : super.patchTarget(); | 1029 _C.injected() : super.patchTarget(); |
| 1017 } | 1030 } |
| 1018 """; | 1031 """; |
| 1019 | 1032 |
| 1020 var compiler = await applyPatch(origin, patch, | 1033 var compiler = await applyPatch(origin, patch, |
| 1021 analyzeAll: true, analyzeOnly: true, runCompiler: true); | 1034 analyzeAll: true, analyzeOnly: true, runCompiler: true); |
| 1022 ClassElement clsA = compiler.commonElements.coreLibrary.find("A"); | 1035 ClassElement clsA = compiler.resolution.commonElements.coreLibrary.find("A"); |
| 1023 ClassElement clsB = compiler.commonElements.coreLibrary.find("B"); | 1036 ClassElement clsB = compiler.resolution.commonElements.coreLibrary.find("B"); |
| 1024 | 1037 |
| 1025 ConstructorElement forward = clsA.lookupConstructor("forward"); | 1038 ConstructorElement forward = clsA.lookupConstructor("forward"); |
| 1026 ConstructorElement target = forward.effectiveTarget; | 1039 ConstructorElement target = forward.effectiveTarget; |
| 1027 Expect.isTrue(target.isPatched, "Unexpected target $target for $forward"); | 1040 Expect.isTrue(target.isPatched, "Unexpected target $target for $forward"); |
| 1028 Expect.isFalse(target.isPatch, "Unexpected target $target for $forward"); | 1041 Expect.isFalse(target.isPatch, "Unexpected target $target for $forward"); |
| 1029 Expect.equals("patchTarget", target.name); | 1042 Expect.equals("patchTarget", target.name); |
| 1030 | 1043 |
| 1031 ConstructorElement forwardOne = clsA.lookupConstructor("forwardOne"); | 1044 ConstructorElement forwardOne = clsA.lookupConstructor("forwardOne"); |
| 1032 target = forwardOne.effectiveTarget; | 1045 target = forwardOne.effectiveTarget; |
| 1033 Expect.isFalse(forwardOne.isMalformed); | 1046 Expect.isFalse(forwardOne.isMalformed); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 await testPatchNonFunction(); | 1114 await testPatchNonFunction(); |
| 1102 | 1115 |
| 1103 await testPatchAndSelector(); | 1116 await testPatchAndSelector(); |
| 1104 | 1117 |
| 1105 await testEffectiveTarget(); | 1118 await testEffectiveTarget(); |
| 1106 | 1119 |
| 1107 await testAnalyzeAllInjectedMembers(); | 1120 await testAnalyzeAllInjectedMembers(); |
| 1108 await testTypecheckPatchedMembers(); | 1121 await testTypecheckPatchedMembers(); |
| 1109 }); | 1122 }); |
| 1110 } | 1123 } |
| OLD | NEW |