OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library engine.resolver_test; | 5 library engine.resolver_test; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
(...skipping 8058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8069 void main() { | 8069 void main() { |
8070 new C().x += 1; | 8070 new C().x += 1; |
8071 } | 8071 } |
8072 '''); | 8072 '''); |
8073 LibraryElement library = resolve(source); | 8073 LibraryElement library = resolve(source); |
8074 assertNoErrors(source); | 8074 assertNoErrors(source); |
8075 verify([source]); | 8075 verify([source]); |
8076 // Verify that both the getter and setter for "x" in "new C().x" refer to | 8076 // Verify that both the getter and setter for "x" in "new C().x" refer to |
8077 // the accessors defined in M2. | 8077 // the accessors defined in M2. |
8078 FunctionDeclaration main = | 8078 FunctionDeclaration main = |
8079 library.definingCompilationUnit.functions[0].node; | 8079 library.definingCompilationUnit.functions[0].computeNode(); |
8080 BlockFunctionBody body = main.functionExpression.body; | 8080 BlockFunctionBody body = main.functionExpression.body; |
8081 ExpressionStatement stmt = body.block.statements[0]; | 8081 ExpressionStatement stmt = body.block.statements[0]; |
8082 AssignmentExpression assignment = stmt.expression; | 8082 AssignmentExpression assignment = stmt.expression; |
8083 PropertyAccess propertyAccess = assignment.leftHandSide; | 8083 PropertyAccess propertyAccess = assignment.leftHandSide; |
8084 expect( | 8084 expect( |
8085 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2'); | 8085 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2'); |
8086 expect( | 8086 expect( |
8087 propertyAccess.propertyName.auxiliaryElements.staticElement.enclosingEle
ment.name, | 8087 propertyAccess.propertyName.auxiliaryElements.staticElement.enclosingEle
ment.name, |
8088 'M2'); | 8088 'M2'); |
8089 } | 8089 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8210 } | 8210 } |
8211 class A { | 8211 class A { |
8212 set sss(x) {} | 8212 set sss(x) {} |
8213 }'''); | 8213 }'''); |
8214 LibraryElement library = resolve(source); | 8214 LibraryElement library = resolve(source); |
8215 CompilationUnitElement unit = library.definingCompilationUnit; | 8215 CompilationUnitElement unit = library.definingCompilationUnit; |
8216 // find "a.sss = 0" | 8216 // find "a.sss = 0" |
8217 AssignmentExpression assignment; | 8217 AssignmentExpression assignment; |
8218 { | 8218 { |
8219 FunctionElement mainElement = unit.functions[0]; | 8219 FunctionElement mainElement = unit.functions[0]; |
8220 FunctionBody mainBody = mainElement.node.functionExpression.body; | 8220 FunctionBody mainBody = mainElement.computeNode().functionExpression.body; |
8221 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; | 8221 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; |
8222 ExpressionStatement expressionStatement = | 8222 ExpressionStatement expressionStatement = |
8223 statement as ExpressionStatement; | 8223 statement as ExpressionStatement; |
8224 assignment = expressionStatement.expression as AssignmentExpression; | 8224 assignment = expressionStatement.expression as AssignmentExpression; |
8225 } | 8225 } |
8226 // get parameter | 8226 // get parameter |
8227 Expression rhs = assignment.rightHandSide; | 8227 Expression rhs = assignment.rightHandSide; |
8228 expect(rhs.staticParameterElement, isNull); | 8228 expect(rhs.staticParameterElement, isNull); |
8229 ParameterElement parameter = rhs.propagatedParameterElement; | 8229 ParameterElement parameter = rhs.propagatedParameterElement; |
8230 expect(parameter, isNotNull); | 8230 expect(parameter, isNotNull); |
(...skipping 15 matching lines...) Expand all Loading... |
8246 } | 8246 } |
8247 class B { | 8247 class B { |
8248 set sss(x) {} | 8248 set sss(x) {} |
8249 }'''); | 8249 }'''); |
8250 LibraryElement library = resolve(source); | 8250 LibraryElement library = resolve(source); |
8251 CompilationUnitElement unit = library.definingCompilationUnit; | 8251 CompilationUnitElement unit = library.definingCompilationUnit; |
8252 // find "a.b.sss = 0" | 8252 // find "a.b.sss = 0" |
8253 AssignmentExpression assignment; | 8253 AssignmentExpression assignment; |
8254 { | 8254 { |
8255 FunctionElement mainElement = unit.functions[0]; | 8255 FunctionElement mainElement = unit.functions[0]; |
8256 FunctionBody mainBody = mainElement.node.functionExpression.body; | 8256 FunctionBody mainBody = mainElement.computeNode().functionExpression.body; |
8257 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; | 8257 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; |
8258 ExpressionStatement expressionStatement = | 8258 ExpressionStatement expressionStatement = |
8259 statement as ExpressionStatement; | 8259 statement as ExpressionStatement; |
8260 assignment = expressionStatement.expression as AssignmentExpression; | 8260 assignment = expressionStatement.expression as AssignmentExpression; |
8261 } | 8261 } |
8262 // get parameter | 8262 // get parameter |
8263 Expression rhs = assignment.rightHandSide; | 8263 Expression rhs = assignment.rightHandSide; |
8264 expect(rhs.staticParameterElement, isNull); | 8264 expect(rhs.staticParameterElement, isNull); |
8265 ParameterElement parameter = rhs.propagatedParameterElement; | 8265 ParameterElement parameter = rhs.propagatedParameterElement; |
8266 expect(parameter, isNotNull); | 8266 expect(parameter, isNotNull); |
(...skipping 12 matching lines...) Expand all Loading... |
8279 } | 8279 } |
8280 class A { | 8280 class A { |
8281 set sss(x) {} | 8281 set sss(x) {} |
8282 }'''); | 8282 }'''); |
8283 LibraryElement library = resolve(source); | 8283 LibraryElement library = resolve(source); |
8284 CompilationUnitElement unit = library.definingCompilationUnit; | 8284 CompilationUnitElement unit = library.definingCompilationUnit; |
8285 // find "a.sss = 0" | 8285 // find "a.sss = 0" |
8286 AssignmentExpression assignment; | 8286 AssignmentExpression assignment; |
8287 { | 8287 { |
8288 FunctionElement mainElement = unit.functions[0]; | 8288 FunctionElement mainElement = unit.functions[0]; |
8289 FunctionBody mainBody = mainElement.node.functionExpression.body; | 8289 FunctionBody mainBody = mainElement.computeNode().functionExpression.body; |
8290 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; | 8290 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; |
8291 ExpressionStatement expressionStatement = | 8291 ExpressionStatement expressionStatement = |
8292 statement as ExpressionStatement; | 8292 statement as ExpressionStatement; |
8293 assignment = expressionStatement.expression as AssignmentExpression; | 8293 assignment = expressionStatement.expression as AssignmentExpression; |
8294 } | 8294 } |
8295 // get parameter | 8295 // get parameter |
8296 Expression rhs = assignment.rightHandSide; | 8296 Expression rhs = assignment.rightHandSide; |
8297 ParameterElement parameter = rhs.staticParameterElement; | 8297 ParameterElement parameter = rhs.staticParameterElement; |
8298 expect(parameter, isNotNull); | 8298 expect(parameter, isNotNull); |
8299 expect(parameter.displayName, "x"); | 8299 expect(parameter.displayName, "x"); |
(...skipping 14 matching lines...) Expand all Loading... |
8314 } | 8314 } |
8315 class B { | 8315 class B { |
8316 set sss(x) {} | 8316 set sss(x) {} |
8317 }'''); | 8317 }'''); |
8318 LibraryElement library = resolve(source); | 8318 LibraryElement library = resolve(source); |
8319 CompilationUnitElement unit = library.definingCompilationUnit; | 8319 CompilationUnitElement unit = library.definingCompilationUnit; |
8320 // find "a.b.sss = 0" | 8320 // find "a.b.sss = 0" |
8321 AssignmentExpression assignment; | 8321 AssignmentExpression assignment; |
8322 { | 8322 { |
8323 FunctionElement mainElement = unit.functions[0]; | 8323 FunctionElement mainElement = unit.functions[0]; |
8324 FunctionBody mainBody = mainElement.node.functionExpression.body; | 8324 FunctionBody mainBody = mainElement.computeNode().functionExpression.body; |
8325 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; | 8325 Statement statement = (mainBody as BlockFunctionBody).block.statements[1]; |
8326 ExpressionStatement expressionStatement = | 8326 ExpressionStatement expressionStatement = |
8327 statement as ExpressionStatement; | 8327 statement as ExpressionStatement; |
8328 assignment = expressionStatement.expression as AssignmentExpression; | 8328 assignment = expressionStatement.expression as AssignmentExpression; |
8329 } | 8329 } |
8330 // get parameter | 8330 // get parameter |
8331 Expression rhs = assignment.rightHandSide; | 8331 Expression rhs = assignment.rightHandSide; |
8332 ParameterElement parameter = rhs.staticParameterElement; | 8332 ParameterElement parameter = rhs.staticParameterElement; |
8333 expect(parameter, isNotNull); | 8333 expect(parameter, isNotNull); |
8334 expect(parameter.displayName, "x"); | 8334 expect(parameter.displayName, "x"); |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8790 x += 1; | 8790 x += 1; |
8791 } | 8791 } |
8792 } | 8792 } |
8793 '''); | 8793 '''); |
8794 LibraryElement library = resolve(source); | 8794 LibraryElement library = resolve(source); |
8795 assertNoErrors(source); | 8795 assertNoErrors(source); |
8796 verify([source]); | 8796 verify([source]); |
8797 // Verify that both the getter and setter for "x" in C.f() refer to the | 8797 // Verify that both the getter and setter for "x" in C.f() refer to the |
8798 // accessors defined in M2. | 8798 // accessors defined in M2. |
8799 ClassElement classC = library.definingCompilationUnit.types[3]; | 8799 ClassElement classC = library.definingCompilationUnit.types[3]; |
8800 MethodDeclaration f = classC.getMethod('f').node; | 8800 MethodDeclaration f = classC.getMethod('f').computeNode(); |
8801 BlockFunctionBody body = f.body; | 8801 BlockFunctionBody body = f.body; |
8802 ExpressionStatement stmt = body.block.statements[0]; | 8802 ExpressionStatement stmt = body.block.statements[0]; |
8803 AssignmentExpression assignment = stmt.expression; | 8803 AssignmentExpression assignment = stmt.expression; |
8804 SimpleIdentifier leftHandSide = assignment.leftHandSide; | 8804 SimpleIdentifier leftHandSide = assignment.leftHandSide; |
8805 expect(leftHandSide.staticElement.enclosingElement.name, 'M2'); | 8805 expect(leftHandSide.staticElement.enclosingElement.name, 'M2'); |
8806 expect(leftHandSide.auxiliaryElements.staticElement.enclosingElement.name, | 8806 expect(leftHandSide.auxiliaryElements.staticElement.enclosingElement.name, |
8807 'M2'); | 8807 'M2'); |
8808 } | 8808 } |
8809 | 8809 |
8810 void test_getter_fromMixins_bare_identifier() { | 8810 void test_getter_fromMixins_bare_identifier() { |
(...skipping 10 matching lines...) Expand all Loading... |
8821 return x; | 8821 return x; |
8822 } | 8822 } |
8823 } | 8823 } |
8824 '''); | 8824 '''); |
8825 LibraryElement library = resolve(source); | 8825 LibraryElement library = resolve(source); |
8826 assertNoErrors(source); | 8826 assertNoErrors(source); |
8827 verify([source]); | 8827 verify([source]); |
8828 // Verify that the getter for "x" in C.f() refers to the getter defined in | 8828 // Verify that the getter for "x" in C.f() refers to the getter defined in |
8829 // M2. | 8829 // M2. |
8830 ClassElement classC = library.definingCompilationUnit.types[3]; | 8830 ClassElement classC = library.definingCompilationUnit.types[3]; |
8831 MethodDeclaration f = classC.getMethod('f').node; | 8831 MethodDeclaration f = classC.getMethod('f').computeNode(); |
8832 BlockFunctionBody body = f.body; | 8832 BlockFunctionBody body = f.body; |
8833 ReturnStatement stmt = body.block.statements[0]; | 8833 ReturnStatement stmt = body.block.statements[0]; |
8834 SimpleIdentifier x = stmt.expression; | 8834 SimpleIdentifier x = stmt.expression; |
8835 expect(x.staticElement.enclosingElement.name, 'M2'); | 8835 expect(x.staticElement.enclosingElement.name, 'M2'); |
8836 } | 8836 } |
8837 | 8837 |
8838 void test_getter_fromMixins_property_access() { | 8838 void test_getter_fromMixins_property_access() { |
8839 Source source = addSource(''' | 8839 Source source = addSource(''' |
8840 class B {} | 8840 class B {} |
8841 class M1 { | 8841 class M1 { |
8842 get x => null; | 8842 get x => null; |
8843 } | 8843 } |
8844 class M2 { | 8844 class M2 { |
8845 get x => null; | 8845 get x => null; |
8846 } | 8846 } |
8847 class C extends B with M1, M2 {} | 8847 class C extends B with M1, M2 {} |
8848 void main() { | 8848 void main() { |
8849 var y = new C().x; | 8849 var y = new C().x; |
8850 } | 8850 } |
8851 '''); | 8851 '''); |
8852 LibraryElement library = resolve(source); | 8852 LibraryElement library = resolve(source); |
8853 assertNoErrors(source); | 8853 assertNoErrors(source); |
8854 verify([source]); | 8854 verify([source]); |
8855 // Verify that the getter for "x" in "new C().x" refers to the getter | 8855 // Verify that the getter for "x" in "new C().x" refers to the getter |
8856 // defined in M2. | 8856 // defined in M2. |
8857 FunctionDeclaration main = | 8857 FunctionDeclaration main = |
8858 library.definingCompilationUnit.functions[0].node; | 8858 library.definingCompilationUnit.functions[0].computeNode(); |
8859 BlockFunctionBody body = main.functionExpression.body; | 8859 BlockFunctionBody body = main.functionExpression.body; |
8860 VariableDeclarationStatement stmt = body.block.statements[0]; | 8860 VariableDeclarationStatement stmt = body.block.statements[0]; |
8861 PropertyAccess propertyAccess = stmt.variables.variables[0].initializer; | 8861 PropertyAccess propertyAccess = stmt.variables.variables[0].initializer; |
8862 expect( | 8862 expect( |
8863 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2'); | 8863 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2'); |
8864 } | 8864 } |
8865 | 8865 |
8866 void test_getterAndSetterWithDifferentTypes() { | 8866 void test_getterAndSetterWithDifferentTypes() { |
8867 Source source = addSource(r''' | 8867 Source source = addSource(r''' |
8868 class A { | 8868 class A { |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9360 class C extends B with M1, M2 {} | 9360 class C extends B with M1, M2 {} |
9361 void main() { | 9361 void main() { |
9362 new C().f(); | 9362 new C().f(); |
9363 } | 9363 } |
9364 '''); | 9364 '''); |
9365 LibraryElement library = resolve(source); | 9365 LibraryElement library = resolve(source); |
9366 assertNoErrors(source); | 9366 assertNoErrors(source); |
9367 verify([source]); | 9367 verify([source]); |
9368 // Verify that the "f" in "new C().f()" refers to the "f" defined in M2. | 9368 // Verify that the "f" in "new C().f()" refers to the "f" defined in M2. |
9369 FunctionDeclaration main = | 9369 FunctionDeclaration main = |
9370 library.definingCompilationUnit.functions[0].node; | 9370 library.definingCompilationUnit.functions[0].computeNode(); |
9371 BlockFunctionBody body = main.functionExpression.body; | 9371 BlockFunctionBody body = main.functionExpression.body; |
9372 ExpressionStatement stmt = body.block.statements[0]; | 9372 ExpressionStatement stmt = body.block.statements[0]; |
9373 MethodInvocation expr = stmt.expression; | 9373 MethodInvocation expr = stmt.expression; |
9374 expect(expr.methodName.staticElement.enclosingElement.name, 'M2'); | 9374 expect(expr.methodName.staticElement.enclosingElement.name, 'M2'); |
9375 } | 9375 } |
9376 | 9376 |
9377 void test_method_fromMixins_bare_identifier() { | 9377 void test_method_fromMixins_bare_identifier() { |
9378 Source source = addSource(''' | 9378 Source source = addSource(''' |
9379 class B {} | 9379 class B {} |
9380 class M1 { | 9380 class M1 { |
9381 void f() {} | 9381 void f() {} |
9382 } | 9382 } |
9383 class M2 { | 9383 class M2 { |
9384 void f() {} | 9384 void f() {} |
9385 } | 9385 } |
9386 class C extends B with M1, M2 { | 9386 class C extends B with M1, M2 { |
9387 void g() { | 9387 void g() { |
9388 f(); | 9388 f(); |
9389 } | 9389 } |
9390 } | 9390 } |
9391 '''); | 9391 '''); |
9392 LibraryElement library = resolve(source); | 9392 LibraryElement library = resolve(source); |
9393 assertNoErrors(source); | 9393 assertNoErrors(source); |
9394 verify([source]); | 9394 verify([source]); |
9395 // Verify that the call to f() in C.g() refers to the method defined in M2. | 9395 // Verify that the call to f() in C.g() refers to the method defined in M2. |
9396 ClassElement classC = library.definingCompilationUnit.types[3]; | 9396 ClassElement classC = library.definingCompilationUnit.types[3]; |
9397 MethodDeclaration g = classC.getMethod('g').node; | 9397 MethodDeclaration g = classC.getMethod('g').computeNode(); |
9398 BlockFunctionBody body = g.body; | 9398 BlockFunctionBody body = g.body; |
9399 ExpressionStatement stmt = body.block.statements[0]; | 9399 ExpressionStatement stmt = body.block.statements[0]; |
9400 MethodInvocation invocation = stmt.expression; | 9400 MethodInvocation invocation = stmt.expression; |
9401 SimpleIdentifier methodName = invocation.methodName; | 9401 SimpleIdentifier methodName = invocation.methodName; |
9402 expect(methodName.staticElement.enclosingElement.name, 'M2'); | 9402 expect(methodName.staticElement.enclosingElement.name, 'M2'); |
9403 } | 9403 } |
9404 | 9404 |
9405 void test_method_fromMixins_invked_from_outside_class() { | 9405 void test_method_fromMixins_invked_from_outside_class() { |
9406 Source source = addSource(''' | 9406 Source source = addSource(''' |
9407 class B {} | 9407 class B {} |
9408 class M1 { | 9408 class M1 { |
9409 void f() {} | 9409 void f() {} |
9410 } | 9410 } |
9411 class M2 { | 9411 class M2 { |
9412 void f() {} | 9412 void f() {} |
9413 } | 9413 } |
9414 class C extends B with M1, M2 {} | 9414 class C extends B with M1, M2 {} |
9415 void main() { | 9415 void main() { |
9416 new C().f(); | 9416 new C().f(); |
9417 } | 9417 } |
9418 '''); | 9418 '''); |
9419 LibraryElement library = resolve(source); | 9419 LibraryElement library = resolve(source); |
9420 assertNoErrors(source); | 9420 assertNoErrors(source); |
9421 verify([source]); | 9421 verify([source]); |
9422 // Verify that the call to f() in "new C().f()" refers to the method | 9422 // Verify that the call to f() in "new C().f()" refers to the method |
9423 // defined in M2. | 9423 // defined in M2. |
9424 FunctionDeclaration main = | 9424 FunctionDeclaration main = |
9425 library.definingCompilationUnit.functions[0].node; | 9425 library.definingCompilationUnit.functions[0].computeNode(); |
9426 BlockFunctionBody body = main.functionExpression.body; | 9426 BlockFunctionBody body = main.functionExpression.body; |
9427 ExpressionStatement stmt = body.block.statements[0]; | 9427 ExpressionStatement stmt = body.block.statements[0]; |
9428 MethodInvocation invocation = stmt.expression; | 9428 MethodInvocation invocation = stmt.expression; |
9429 expect(invocation.methodName.staticElement.enclosingElement.name, 'M2'); | 9429 expect(invocation.methodName.staticElement.enclosingElement.name, 'M2'); |
9430 } | 9430 } |
9431 | 9431 |
9432 void test_method_fromSuperclassMixin() { | 9432 void test_method_fromSuperclassMixin() { |
9433 Source source = addSource(r''' | 9433 Source source = addSource(r''' |
9434 class A { | 9434 class A { |
9435 void m1() {} | 9435 void m1() {} |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9504 x = 1; | 9504 x = 1; |
9505 } | 9505 } |
9506 } | 9506 } |
9507 '''); | 9507 '''); |
9508 LibraryElement library = resolve(source); | 9508 LibraryElement library = resolve(source); |
9509 assertNoErrors(source); | 9509 assertNoErrors(source); |
9510 verify([source]); | 9510 verify([source]); |
9511 // Verify that the setter for "x" in C.f() refers to the setter defined in | 9511 // Verify that the setter for "x" in C.f() refers to the setter defined in |
9512 // M2. | 9512 // M2. |
9513 ClassElement classC = library.definingCompilationUnit.types[3]; | 9513 ClassElement classC = library.definingCompilationUnit.types[3]; |
9514 MethodDeclaration f = classC.getMethod('f').node; | 9514 MethodDeclaration f = classC.getMethod('f').computeNode(); |
9515 BlockFunctionBody body = f.body; | 9515 BlockFunctionBody body = f.body; |
9516 ExpressionStatement stmt = body.block.statements[0]; | 9516 ExpressionStatement stmt = body.block.statements[0]; |
9517 AssignmentExpression assignment = stmt.expression; | 9517 AssignmentExpression assignment = stmt.expression; |
9518 SimpleIdentifier leftHandSide = assignment.leftHandSide; | 9518 SimpleIdentifier leftHandSide = assignment.leftHandSide; |
9519 expect(leftHandSide.staticElement.enclosingElement.name, 'M2'); | 9519 expect(leftHandSide.staticElement.enclosingElement.name, 'M2'); |
9520 } | 9520 } |
9521 | 9521 |
9522 void test_setter_fromMixins_property_access() { | 9522 void test_setter_fromMixins_property_access() { |
9523 Source source = addSource(''' | 9523 Source source = addSource(''' |
9524 class B {} | 9524 class B {} |
9525 class M1 { | 9525 class M1 { |
9526 set x(value) {} | 9526 set x(value) {} |
9527 } | 9527 } |
9528 class M2 { | 9528 class M2 { |
9529 set x(value) {} | 9529 set x(value) {} |
9530 } | 9530 } |
9531 class C extends B with M1, M2 {} | 9531 class C extends B with M1, M2 {} |
9532 void main() { | 9532 void main() { |
9533 new C().x = 1; | 9533 new C().x = 1; |
9534 } | 9534 } |
9535 '''); | 9535 '''); |
9536 LibraryElement library = resolve(source); | 9536 LibraryElement library = resolve(source); |
9537 assertNoErrors(source); | 9537 assertNoErrors(source); |
9538 verify([source]); | 9538 verify([source]); |
9539 // Verify that the setter for "x" in "new C().x" refers to the setter | 9539 // Verify that the setter for "x" in "new C().x" refers to the setter |
9540 // defined in M2. | 9540 // defined in M2. |
9541 FunctionDeclaration main = | 9541 FunctionDeclaration main = |
9542 library.definingCompilationUnit.functions[0].node; | 9542 library.definingCompilationUnit.functions[0].computeNode(); |
9543 BlockFunctionBody body = main.functionExpression.body; | 9543 BlockFunctionBody body = main.functionExpression.body; |
9544 ExpressionStatement stmt = body.block.statements[0]; | 9544 ExpressionStatement stmt = body.block.statements[0]; |
9545 AssignmentExpression assignment = stmt.expression; | 9545 AssignmentExpression assignment = stmt.expression; |
9546 PropertyAccess propertyAccess = assignment.leftHandSide; | 9546 PropertyAccess propertyAccess = assignment.leftHandSide; |
9547 expect( | 9547 expect( |
9548 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2'); | 9548 propertyAccess.propertyName.staticElement.enclosingElement.name, 'M2'); |
9549 } | 9549 } |
9550 | 9550 |
9551 void test_setter_inherited() { | 9551 void test_setter_inherited() { |
9552 Source source = addSource(r''' | 9552 Source source = addSource(r''' |
(...skipping 4244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13797 // check propagated type | 13797 // check propagated type |
13798 FunctionType propagatedType = node.propagatedType as FunctionType; | 13798 FunctionType propagatedType = node.propagatedType as FunctionType; |
13799 expect(propagatedType.returnType, test.typeProvider.stringType); | 13799 expect(propagatedType.returnType, test.typeProvider.stringType); |
13800 } on AnalysisException catch (e, stackTrace) { | 13800 } on AnalysisException catch (e, stackTrace) { |
13801 thrownException[0] = new CaughtException(e, stackTrace); | 13801 thrownException[0] = new CaughtException(e, stackTrace); |
13802 } | 13802 } |
13803 } | 13803 } |
13804 return null; | 13804 return null; |
13805 } | 13805 } |
13806 } | 13806 } |
OLD | NEW |