| 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 library analyzer.test.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/error/listener.dart'; | 9 import 'package:analyzer/error/listener.dart'; |
| 10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| (...skipping 6918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6929 class C { | 6929 class C { |
| 6930 List<int> items; | 6930 List<int> items; |
| 6931 } | 6931 } |
| 6932 final C c = new C(); | 6932 final C c = new C(); |
| 6933 final v = c.items..[1] = 2; | 6933 final v = c.items..[1] = 2; |
| 6934 '''); | 6934 '''); |
| 6935 assertUnlinkedConst(variable.initializer.bodyExpr, | 6935 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 6936 isValidConst: false, | 6936 isValidConst: false, |
| 6937 operators: [ | 6937 operators: [ |
| 6938 UnlinkedExprOperation.pushReference, | 6938 UnlinkedExprOperation.pushReference, |
| 6939 // ..[1] = 2 | |
| 6940 UnlinkedExprOperation.cascadeSectionBegin, | |
| 6941 UnlinkedExprOperation.pushInt, | |
| 6942 UnlinkedExprOperation.pushInt, | |
| 6943 UnlinkedExprOperation.assignToIndex, | |
| 6944 // c | |
| 6945 UnlinkedExprOperation.cascadeSectionEnd, | |
| 6946 ], | 6939 ], |
| 6947 assignmentOperators: [ | 6940 assignmentOperators: [], |
| 6948 UnlinkedExprAssignOperator.assign, | 6941 ints: [], |
| 6949 ], | |
| 6950 ints: [ | |
| 6951 2, | |
| 6952 1 | |
| 6953 ], | |
| 6954 strings: [], | 6942 strings: [], |
| 6955 referenceValidators: [ | 6943 referenceValidators: [ |
| 6956 (EntityRef r) => checkTypeRef(r, null, 'items', | 6944 (EntityRef r) => checkTypeRef(r, null, 'items', |
| 6957 expectedKind: ReferenceKind.unresolved, | 6945 expectedKind: ReferenceKind.unresolved, |
| 6958 prefixExpectations: [ | 6946 prefixExpectations: [ |
| 6959 new _PrefixExpectation( | 6947 new _PrefixExpectation( |
| 6960 ReferenceKind.topLevelPropertyAccessor, 'c'), | 6948 ReferenceKind.topLevelPropertyAccessor, 'c'), |
| 6961 ]) | 6949 ]) |
| 6962 ]); | 6950 ]); |
| 6963 } | 6951 } |
| 6964 | 6952 |
| 6965 test_expr_cascadeSection_assignToProperty() { | 6953 test_expr_cascadeSection_assignToProperty() { |
| 6966 if (skipNonConstInitializers) { | 6954 if (skipNonConstInitializers) { |
| 6967 return; | 6955 return; |
| 6968 } | 6956 } |
| 6969 UnlinkedVariable variable = serializeVariableText(''' | 6957 UnlinkedVariable variable = serializeVariableText(''' |
| 6970 class C { | 6958 class C { |
| 6971 int f1 = 0; | 6959 int f1 = 0; |
| 6972 int f2 = 0; | 6960 int f2 = 0; |
| 6973 } | 6961 } |
| 6974 final v = new C()..f1 = 1..f2 += 2; | 6962 final v = new C()..f1 = 1..f2 += 2; |
| 6975 '''); | 6963 '''); |
| 6976 assertUnlinkedConst(variable.initializer.bodyExpr, | 6964 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 6977 isValidConst: false, | 6965 isValidConst: false, |
| 6978 operators: [ | 6966 operators: [ |
| 6979 // new C() | |
| 6980 UnlinkedExprOperation.invokeConstructor, | 6967 UnlinkedExprOperation.invokeConstructor, |
| 6981 // ..f1 = 1 | |
| 6982 UnlinkedExprOperation.cascadeSectionBegin, | |
| 6983 UnlinkedExprOperation.pushInt, | |
| 6984 UnlinkedExprOperation.assignToProperty, | |
| 6985 // C | |
| 6986 UnlinkedExprOperation.cascadeSectionEnd, | |
| 6987 // ..f2 += 2 | |
| 6988 UnlinkedExprOperation.cascadeSectionBegin, | |
| 6989 UnlinkedExprOperation.pushInt, | |
| 6990 UnlinkedExprOperation.assignToProperty, | |
| 6991 // C | |
| 6992 UnlinkedExprOperation.cascadeSectionEnd, | |
| 6993 ], | 6968 ], |
| 6994 assignmentOperators: [ | 6969 assignmentOperators: [], |
| 6995 UnlinkedExprAssignOperator.assign, | 6970 ints: [ |
| 6996 UnlinkedExprAssignOperator.plus, | 6971 0, |
| 6972 0 |
| 6997 ], | 6973 ], |
| 6998 ints: [ | 6974 strings: [], |
| 6999 0, 0, // new C() | |
| 7000 1, // f1 = 1 | |
| 7001 2, // f2 += 2 | |
| 7002 ], | |
| 7003 strings: [ | |
| 7004 'f1', | |
| 7005 'f2', | |
| 7006 ], | |
| 7007 referenceValidators: [ | 6975 referenceValidators: [ |
| 7008 (EntityRef r) => checkTypeRef(r, null, 'C', | 6976 (EntityRef r) => checkTypeRef(r, null, 'C', |
| 7009 expectedKind: ReferenceKind.classOrEnum) | 6977 expectedKind: ReferenceKind.classOrEnum) |
| 7010 ]); | 6978 ]); |
| 7011 } | 6979 } |
| 7012 | 6980 |
| 7013 test_expr_cascadeSection_embedded() { | 6981 test_expr_cascadeSection_embedded() { |
| 7014 if (skipNonConstInitializers) { | 6982 if (skipNonConstInitializers) { |
| 7015 return; | 6983 return; |
| 7016 } | 6984 } |
| 7017 UnlinkedVariable variable = serializeVariableText(''' | 6985 UnlinkedVariable variable = serializeVariableText(''' |
| 7018 class A { | 6986 class A { |
| 7019 int fa1; | 6987 int fa1; |
| 7020 B b; | 6988 B b; |
| 7021 int fa2; | 6989 int fa2; |
| 7022 } | 6990 } |
| 7023 class B { | 6991 class B { |
| 7024 int fb; | 6992 int fb; |
| 7025 } | 6993 } |
| 7026 final v = new A() | 6994 final v = new A() |
| 7027 ..fa1 = 1 | 6995 ..fa1 = 1 |
| 7028 ..b = (new B()..fb = 2) | 6996 ..b = (new B()..fb = 2) |
| 7029 ..fa2 = 3; | 6997 ..fa2 = 3; |
| 7030 '''); | 6998 '''); |
| 7031 assertUnlinkedConst(variable.initializer.bodyExpr, | 6999 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 7032 isValidConst: false, | 7000 isValidConst: false, |
| 7033 operators: [ | 7001 operators: [ |
| 7034 // new A() | |
| 7035 UnlinkedExprOperation.invokeConstructor, | 7002 UnlinkedExprOperation.invokeConstructor, |
| 7036 // ..fa1 = 1 | |
| 7037 UnlinkedExprOperation.cascadeSectionBegin, | |
| 7038 UnlinkedExprOperation.pushInt, | |
| 7039 UnlinkedExprOperation.assignToProperty, | |
| 7040 UnlinkedExprOperation.cascadeSectionEnd, | |
| 7041 // ..b | |
| 7042 UnlinkedExprOperation.cascadeSectionBegin, | |
| 7043 // new B() | |
| 7044 UnlinkedExprOperation.invokeConstructor, | |
| 7045 // ..fb = 2 | |
| 7046 UnlinkedExprOperation.cascadeSectionBegin, | |
| 7047 UnlinkedExprOperation.pushInt, | |
| 7048 UnlinkedExprOperation.assignToProperty, | |
| 7049 UnlinkedExprOperation.cascadeSectionEnd, | |
| 7050 // ..b = <pop value> | |
| 7051 UnlinkedExprOperation.assignToProperty, | |
| 7052 UnlinkedExprOperation.cascadeSectionEnd, | |
| 7053 // ..fa2 = 3 | |
| 7054 UnlinkedExprOperation.cascadeSectionBegin, | |
| 7055 UnlinkedExprOperation.pushInt, | |
| 7056 UnlinkedExprOperation.assignToProperty, | |
| 7057 UnlinkedExprOperation.cascadeSectionEnd, | |
| 7058 ], | 7003 ], |
| 7059 assignmentOperators: [ | 7004 assignmentOperators: [], |
| 7060 UnlinkedExprAssignOperator.assign, | |
| 7061 UnlinkedExprAssignOperator.assign, | |
| 7062 UnlinkedExprAssignOperator.assign, | |
| 7063 UnlinkedExprAssignOperator.assign, | |
| 7064 ], | |
| 7065 ints: [ | 7005 ints: [ |
| 7066 0, | 7006 0, |
| 7067 0, | 7007 0, |
| 7068 1, | |
| 7069 0, | |
| 7070 0, | |
| 7071 2, | |
| 7072 3, | |
| 7073 ], | 7008 ], |
| 7074 strings: [ | 7009 strings: [], |
| 7075 'fa1', | |
| 7076 'fb', | |
| 7077 'b', | |
| 7078 'fa2', | |
| 7079 ], | |
| 7080 referenceValidators: [ | 7010 referenceValidators: [ |
| 7081 (EntityRef r) => checkTypeRef(r, null, 'A', | 7011 (EntityRef r) => checkTypeRef(r, null, 'A', |
| 7082 expectedKind: ReferenceKind.classOrEnum), | 7012 expectedKind: ReferenceKind.classOrEnum), |
| 7083 (EntityRef r) => checkTypeRef(r, null, 'B', | |
| 7084 expectedKind: ReferenceKind.classOrEnum), | |
| 7085 ]); | 7013 ]); |
| 7086 } | 7014 } |
| 7087 | 7015 |
| 7088 test_expr_cascadeSection_invokeMethod() { | 7016 test_expr_cascadeSection_invokeMethod() { |
| 7089 if (skipNonConstInitializers) { | 7017 if (skipNonConstInitializers) { |
| 7090 return; | 7018 return; |
| 7091 } | 7019 } |
| 7092 UnlinkedVariable variable = serializeVariableText(''' | 7020 UnlinkedVariable variable = serializeVariableText(''' |
| 7093 class A { | 7021 class A { |
| 7094 int m(int _) => 0; | 7022 int m(int _) => 0; |
| 7095 } | 7023 } |
| 7096 final A a = new A(); | 7024 final A a = new A(); |
| 7097 final v = a..m(5).abs()..m(6); | 7025 final v = a..m(5).abs()..m(6); |
| 7098 '''); | 7026 '''); |
| 7099 assertUnlinkedConst(variable.initializer.bodyExpr, | 7027 assertUnlinkedConst(variable.initializer.bodyExpr, |
| 7100 isValidConst: false, | 7028 isValidConst: false, |
| 7101 operators: [ | 7029 operators: [ |
| 7102 // a | |
| 7103 UnlinkedExprOperation.pushReference, | 7030 UnlinkedExprOperation.pushReference, |
| 7104 // ..m(5) | |
| 7105 UnlinkedExprOperation.cascadeSectionBegin, | |
| 7106 UnlinkedExprOperation.pushInt, | |
| 7107 UnlinkedExprOperation.invokeMethod, | |
| 7108 // ..abs() | |
| 7109 UnlinkedExprOperation.invokeMethod, | |
| 7110 // a | |
| 7111 UnlinkedExprOperation.cascadeSectionEnd, | |
| 7112 // ..m(6) | |
| 7113 UnlinkedExprOperation.cascadeSectionBegin, | |
| 7114 UnlinkedExprOperation.pushInt, | |
| 7115 UnlinkedExprOperation.invokeMethod, | |
| 7116 // a | |
| 7117 UnlinkedExprOperation.cascadeSectionEnd, | |
| 7118 ], | 7031 ], |
| 7119 ints: [ | 7032 ints: [], |
| 7120 5, 0, 1, 0, // m(5) | 7033 strings: [], |
| 7121 0, 0, 0, // abs() | |
| 7122 6, 0, 1, 0, // m(5) | |
| 7123 ], | |
| 7124 strings: [ | |
| 7125 'm', | |
| 7126 'abs', | |
| 7127 'm', | |
| 7128 ], | |
| 7129 referenceValidators: [ | 7034 referenceValidators: [ |
| 7130 (EntityRef r) => checkTypeRef(r, null, 'a', | 7035 (EntityRef r) => checkTypeRef(r, null, 'a', |
| 7131 expectedKind: ReferenceKind.topLevelPropertyAccessor), | 7036 expectedKind: ReferenceKind.topLevelPropertyAccessor), |
| 7132 ]); | 7037 ]); |
| 7133 } | 7038 } |
| 7134 | 7039 |
| 7135 test_expr_extractIndex_ofClassField() { | 7040 test_expr_extractIndex_ofClassField() { |
| 7136 if (skipNonConstInitializers) { | 7041 if (skipNonConstInitializers) { |
| 7137 return; | 7042 return; |
| 7138 } | 7043 } |
| (...skipping 3564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10703 */ | 10608 */ |
| 10704 class _PrefixExpectation { | 10609 class _PrefixExpectation { |
| 10705 final ReferenceKind kind; | 10610 final ReferenceKind kind; |
| 10706 final String name; | 10611 final String name; |
| 10707 final String absoluteUri; | 10612 final String absoluteUri; |
| 10708 final int numTypeParameters; | 10613 final int numTypeParameters; |
| 10709 | 10614 |
| 10710 _PrefixExpectation(this.kind, this.name, | 10615 _PrefixExpectation(this.kind, this.name, |
| 10711 {this.absoluteUri, this.numTypeParameters: 0}); | 10616 {this.absoluteUri, this.numTypeParameters: 0}); |
| 10712 } | 10617 } |
| OLD | NEW |