| 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/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| (...skipping 5939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5950 } | 5950 } |
| 5951 class B { | 5951 class B { |
| 5952 C c; | 5952 C c; |
| 5953 } | 5953 } |
| 5954 class C { | 5954 class C { |
| 5955 List<int> f = <int>[0, 1, 2]; | 5955 List<int> f = <int>[0, 1, 2]; |
| 5956 } | 5956 } |
| 5957 A a = new A(); | 5957 A a = new A(); |
| 5958 final v = (a.b.c.f[1] = 5); | 5958 final v = (a.b.c.f[1] = 5); |
| 5959 '''); | 5959 '''); |
| 5960 _assertUnlinkedConst(variable.constExpr, operators: [ | 5960 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 5961 UnlinkedConstOperation.pushInt, | 5961 UnlinkedConstOperation.pushInt, |
| 5962 UnlinkedConstOperation.pushReference, | 5962 UnlinkedConstOperation.pushReference, |
| 5963 UnlinkedConstOperation.pushInt, | 5963 UnlinkedConstOperation.pushInt, |
| 5964 UnlinkedConstOperation.assignToIndex, | 5964 UnlinkedConstOperation.assignToIndex, |
| 5965 ], assignmentOperators: [ | 5965 ], assignmentOperators: [ |
| 5966 (UnlinkedExprAssignOperator.assign) | 5966 (UnlinkedExprAssignOperator.assign) |
| 5967 ], ints: [ | 5967 ], ints: [ |
| 5968 5, | 5968 5, |
| 5969 1 | 5969 1 |
| 5970 ], strings: [], referenceValidators: [ | 5970 ], strings: [], referenceValidators: [ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5989 } | 5989 } |
| 5990 class B { | 5990 class B { |
| 5991 List<C> c; | 5991 List<C> c; |
| 5992 } | 5992 } |
| 5993 class C { | 5993 class C { |
| 5994 List<int> f = <int>[0, 1, 2]; | 5994 List<int> f = <int>[0, 1, 2]; |
| 5995 } | 5995 } |
| 5996 A a = new A(); | 5996 A a = new A(); |
| 5997 final v = (a.b[1].c[2].f[3] = 5); | 5997 final v = (a.b[1].c[2].f[3] = 5); |
| 5998 '''); | 5998 '''); |
| 5999 _assertUnlinkedConst(variable.constExpr, operators: [ | 5999 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6000 // 5 | 6000 // 5 |
| 6001 UnlinkedConstOperation.pushInt, | 6001 UnlinkedConstOperation.pushInt, |
| 6002 // a.b[1] | 6002 // a.b[1] |
| 6003 UnlinkedConstOperation.pushReference, | 6003 UnlinkedConstOperation.pushReference, |
| 6004 UnlinkedConstOperation.pushInt, | 6004 UnlinkedConstOperation.pushInt, |
| 6005 UnlinkedConstOperation.extractIndex, | 6005 UnlinkedConstOperation.extractIndex, |
| 6006 // c[2] | 6006 // c[2] |
| 6007 UnlinkedConstOperation.extractProperty, | 6007 UnlinkedConstOperation.extractProperty, |
| 6008 UnlinkedConstOperation.pushInt, | 6008 UnlinkedConstOperation.pushInt, |
| 6009 UnlinkedConstOperation.extractIndex, | 6009 UnlinkedConstOperation.extractIndex, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6030 } | 6030 } |
| 6031 | 6031 |
| 6032 test_expr_assignToIndex_ofTopLevelVariable() { | 6032 test_expr_assignToIndex_ofTopLevelVariable() { |
| 6033 if (skipNonConstInitializers) { | 6033 if (skipNonConstInitializers) { |
| 6034 return; | 6034 return; |
| 6035 } | 6035 } |
| 6036 UnlinkedVariable variable = serializeVariableText(''' | 6036 UnlinkedVariable variable = serializeVariableText(''' |
| 6037 List<int> a = <int>[0, 1, 2]; | 6037 List<int> a = <int>[0, 1, 2]; |
| 6038 final v = (a[1] = 5); | 6038 final v = (a[1] = 5); |
| 6039 '''); | 6039 '''); |
| 6040 _assertUnlinkedConst(variable.constExpr, operators: [ | 6040 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6041 UnlinkedConstOperation.pushInt, | 6041 UnlinkedConstOperation.pushInt, |
| 6042 UnlinkedConstOperation.pushReference, | 6042 UnlinkedConstOperation.pushReference, |
| 6043 UnlinkedConstOperation.pushInt, | 6043 UnlinkedConstOperation.pushInt, |
| 6044 UnlinkedConstOperation.assignToIndex, | 6044 UnlinkedConstOperation.assignToIndex, |
| 6045 ], assignmentOperators: [ | 6045 ], assignmentOperators: [ |
| 6046 (UnlinkedExprAssignOperator.assign) | 6046 (UnlinkedExprAssignOperator.assign) |
| 6047 ], ints: [ | 6047 ], ints: [ |
| 6048 5, | 6048 5, |
| 6049 1, | 6049 1, |
| 6050 ], strings: [], referenceValidators: [ | 6050 ], strings: [], referenceValidators: [ |
| 6051 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 6051 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
| 6052 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 6052 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 6053 ]); | 6053 ]); |
| 6054 } | 6054 } |
| 6055 | 6055 |
| 6056 test_expr_assignToProperty_ofInstanceCreation() { | 6056 test_expr_assignToProperty_ofInstanceCreation() { |
| 6057 if (skipNonConstInitializers) { | 6057 if (skipNonConstInitializers) { |
| 6058 return; | 6058 return; |
| 6059 } | 6059 } |
| 6060 UnlinkedVariable variable = serializeVariableText(''' | 6060 UnlinkedVariable variable = serializeVariableText(''' |
| 6061 class C { | 6061 class C { |
| 6062 int f; | 6062 int f; |
| 6063 } | 6063 } |
| 6064 final v = (new C().f = 5); | 6064 final v = (new C().f = 5); |
| 6065 '''); | 6065 '''); |
| 6066 _assertUnlinkedConst(variable.constExpr, operators: [ | 6066 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6067 UnlinkedConstOperation.pushInt, | 6067 UnlinkedConstOperation.pushInt, |
| 6068 UnlinkedConstOperation.invokeConstructor, | 6068 UnlinkedConstOperation.invokeConstructor, |
| 6069 UnlinkedConstOperation.assignToProperty, | 6069 UnlinkedConstOperation.assignToProperty, |
| 6070 ], assignmentOperators: [ | 6070 ], assignmentOperators: [ |
| 6071 (UnlinkedExprAssignOperator.assign) | 6071 (UnlinkedExprAssignOperator.assign) |
| 6072 ], ints: [ | 6072 ], ints: [ |
| 6073 5, | 6073 5, |
| 6074 0, | 6074 0, |
| 6075 0, | 6075 0, |
| 6076 ], strings: [ | 6076 ], strings: [ |
| 6077 'f' | 6077 'f' |
| 6078 ], referenceValidators: [ | 6078 ], referenceValidators: [ |
| 6079 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 6079 (EntityRef r) => checkTypeRef(r, null, null, 'C', |
| 6080 expectedKind: ReferenceKind.classOrEnum) | 6080 expectedKind: ReferenceKind.classOrEnum) |
| 6081 ]); | 6081 ]); |
| 6082 } | 6082 } |
| 6083 | 6083 |
| 6084 test_expr_assignToRef_classStaticField() { | 6084 test_expr_assignToRef_classStaticField() { |
| 6085 if (skipNonConstInitializers) { | 6085 if (skipNonConstInitializers) { |
| 6086 return; | 6086 return; |
| 6087 } | 6087 } |
| 6088 UnlinkedVariable variable = serializeVariableText(''' | 6088 UnlinkedVariable variable = serializeVariableText(''' |
| 6089 class C { | 6089 class C { |
| 6090 static int f; | 6090 static int f; |
| 6091 } | 6091 } |
| 6092 final v = (C.f = 1); | 6092 final v = (C.f = 1); |
| 6093 '''); | 6093 '''); |
| 6094 _assertUnlinkedConst(variable.constExpr, operators: [ | 6094 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6095 UnlinkedConstOperation.pushInt, | 6095 UnlinkedConstOperation.pushInt, |
| 6096 UnlinkedConstOperation.assignToRef, | 6096 UnlinkedConstOperation.assignToRef, |
| 6097 ], assignmentOperators: [ | 6097 ], assignmentOperators: [ |
| 6098 (UnlinkedExprAssignOperator.assign) | 6098 (UnlinkedExprAssignOperator.assign) |
| 6099 ], ints: [ | 6099 ], ints: [ |
| 6100 1, | 6100 1, |
| 6101 ], strings: [], referenceValidators: [ | 6101 ], strings: [], referenceValidators: [ |
| 6102 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 6102 (EntityRef r) => checkTypeRef(r, null, null, 'f', |
| 6103 expectedKind: ReferenceKind.unresolved, | 6103 expectedKind: ReferenceKind.unresolved, |
| 6104 prefixExpectations: [ | 6104 prefixExpectations: [ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6117 } | 6117 } |
| 6118 class B { | 6118 class B { |
| 6119 C c; | 6119 C c; |
| 6120 } | 6120 } |
| 6121 class C { | 6121 class C { |
| 6122 int f; | 6122 int f; |
| 6123 } | 6123 } |
| 6124 A a = new A(); | 6124 A a = new A(); |
| 6125 final v = (a.b.c.f = 1); | 6125 final v = (a.b.c.f = 1); |
| 6126 '''); | 6126 '''); |
| 6127 _assertUnlinkedConst(variable.constExpr, operators: [ | 6127 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6128 UnlinkedConstOperation.pushInt, | 6128 UnlinkedConstOperation.pushInt, |
| 6129 UnlinkedConstOperation.assignToRef, | 6129 UnlinkedConstOperation.assignToRef, |
| 6130 ], assignmentOperators: [ | 6130 ], assignmentOperators: [ |
| 6131 (UnlinkedExprAssignOperator.assign) | 6131 (UnlinkedExprAssignOperator.assign) |
| 6132 ], ints: [ | 6132 ], ints: [ |
| 6133 1, | 6133 1, |
| 6134 ], strings: [], referenceValidators: [ | 6134 ], strings: [], referenceValidators: [ |
| 6135 (EntityRef r) => checkTypeRef(r, null, null, 'f', | 6135 (EntityRef r) => checkTypeRef(r, null, null, 'f', |
| 6136 expectedKind: ReferenceKind.unresolved, | 6136 expectedKind: ReferenceKind.unresolved, |
| 6137 prefixExpectations: [ | 6137 prefixExpectations: [ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 6164 } | 6164 } |
| 6165 | 6165 |
| 6166 test_expr_assignToRef_topLevelVariable() { | 6166 test_expr_assignToRef_topLevelVariable() { |
| 6167 if (skipNonConstInitializers) { | 6167 if (skipNonConstInitializers) { |
| 6168 return; | 6168 return; |
| 6169 } | 6169 } |
| 6170 UnlinkedVariable variable = serializeVariableText(''' | 6170 UnlinkedVariable variable = serializeVariableText(''' |
| 6171 int a = 0; | 6171 int a = 0; |
| 6172 final v = (a = 1); | 6172 final v = (a = 1); |
| 6173 '''); | 6173 '''); |
| 6174 _assertUnlinkedConst(variable.constExpr, operators: [ | 6174 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6175 UnlinkedConstOperation.pushInt, | 6175 UnlinkedConstOperation.pushInt, |
| 6176 UnlinkedConstOperation.assignToRef, | 6176 UnlinkedConstOperation.assignToRef, |
| 6177 ], assignmentOperators: [ | 6177 ], assignmentOperators: [ |
| 6178 (UnlinkedExprAssignOperator.assign) | 6178 (UnlinkedExprAssignOperator.assign) |
| 6179 ], ints: [ | 6179 ], ints: [ |
| 6180 1, | 6180 1, |
| 6181 ], strings: [], referenceValidators: [ | 6181 ], strings: [], referenceValidators: [ |
| 6182 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 6182 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
| 6183 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 6183 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 6184 ]); | 6184 ]); |
| 6185 } | 6185 } |
| 6186 | 6186 |
| 6187 test_expr_assignToRef_topLevelVariable_imported() { | 6187 test_expr_assignToRef_topLevelVariable_imported() { |
| 6188 if (skipNonConstInitializers) { | 6188 if (skipNonConstInitializers) { |
| 6189 return; | 6189 return; |
| 6190 } | 6190 } |
| 6191 addNamedSource( | 6191 addNamedSource( |
| 6192 '/a.dart', | 6192 '/a.dart', |
| 6193 ''' | 6193 ''' |
| 6194 int a = 0; | 6194 int a = 0; |
| 6195 '''); | 6195 '''); |
| 6196 UnlinkedVariable variable = serializeVariableText(''' | 6196 UnlinkedVariable variable = serializeVariableText(''' |
| 6197 import 'a.dart'; | 6197 import 'a.dart'; |
| 6198 final v = (a = 1); | 6198 final v = (a = 1); |
| 6199 '''); | 6199 '''); |
| 6200 _assertUnlinkedConst(variable.constExpr, operators: [ | 6200 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6201 UnlinkedConstOperation.pushInt, | 6201 UnlinkedConstOperation.pushInt, |
| 6202 UnlinkedConstOperation.assignToRef, | 6202 UnlinkedConstOperation.assignToRef, |
| 6203 ], assignmentOperators: [ | 6203 ], assignmentOperators: [ |
| 6204 (UnlinkedExprAssignOperator.assign) | 6204 (UnlinkedExprAssignOperator.assign) |
| 6205 ], ints: [ | 6205 ], ints: [ |
| 6206 1, | 6206 1, |
| 6207 ], strings: [], referenceValidators: [ | 6207 ], strings: [], referenceValidators: [ |
| 6208 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', | 6208 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', |
| 6209 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 6209 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 6210 ]); | 6210 ]); |
| 6211 } | 6211 } |
| 6212 | 6212 |
| 6213 test_expr_assignToRef_topLevelVariable_imported_withPrefix() { | 6213 test_expr_assignToRef_topLevelVariable_imported_withPrefix() { |
| 6214 if (skipNonConstInitializers) { | 6214 if (skipNonConstInitializers) { |
| 6215 return; | 6215 return; |
| 6216 } | 6216 } |
| 6217 addNamedSource( | 6217 addNamedSource( |
| 6218 '/a.dart', | 6218 '/a.dart', |
| 6219 ''' | 6219 ''' |
| 6220 int a = 0; | 6220 int a = 0; |
| 6221 '''); | 6221 '''); |
| 6222 UnlinkedVariable variable = serializeVariableText(''' | 6222 UnlinkedVariable variable = serializeVariableText(''' |
| 6223 import 'a.dart' as p; | 6223 import 'a.dart' as p; |
| 6224 final v = (p.a = 1); | 6224 final v = (p.a = 1); |
| 6225 '''); | 6225 '''); |
| 6226 _assertUnlinkedConst(variable.constExpr, operators: [ | 6226 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6227 UnlinkedConstOperation.pushInt, | 6227 UnlinkedConstOperation.pushInt, |
| 6228 UnlinkedConstOperation.assignToRef, | 6228 UnlinkedConstOperation.assignToRef, |
| 6229 ], assignmentOperators: [ | 6229 ], assignmentOperators: [ |
| 6230 (UnlinkedExprAssignOperator.assign) | 6230 (UnlinkedExprAssignOperator.assign) |
| 6231 ], ints: [ | 6231 ], ints: [ |
| 6232 1, | 6232 1, |
| 6233 ], strings: [], referenceValidators: [ | 6233 ], strings: [], referenceValidators: [ |
| 6234 (EntityRef r) { | 6234 (EntityRef r) { |
| 6235 return checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', | 6235 return checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a', |
| 6236 expectedKind: ReferenceKind.topLevelPropertyAccessor, | 6236 expectedKind: ReferenceKind.topLevelPropertyAccessor, |
| 6237 expectedPrefix: 'p'); | 6237 expectedPrefix: 'p'); |
| 6238 } | 6238 } |
| 6239 ]); | 6239 ]); |
| 6240 } | 6240 } |
| 6241 | 6241 |
| 6242 test_expr_cascadeSection_assignToIndex() { | 6242 test_expr_cascadeSection_assignToIndex() { |
| 6243 if (skipNonConstInitializers) { | 6243 if (skipNonConstInitializers) { |
| 6244 return; | 6244 return; |
| 6245 } | 6245 } |
| 6246 UnlinkedVariable variable = serializeVariableText(''' | 6246 UnlinkedVariable variable = serializeVariableText(''' |
| 6247 class C { | 6247 class C { |
| 6248 List<int> items; | 6248 List<int> items; |
| 6249 } | 6249 } |
| 6250 final C c = new C(); | 6250 final C c = new C(); |
| 6251 final v = c.items..[1] = 2; | 6251 final v = c.items..[1] = 2; |
| 6252 '''); | 6252 '''); |
| 6253 _assertUnlinkedConst(variable.constExpr, operators: [ | 6253 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6254 UnlinkedConstOperation.pushReference, | 6254 UnlinkedConstOperation.pushReference, |
| 6255 // ..[1] = 2 | 6255 // ..[1] = 2 |
| 6256 UnlinkedConstOperation.cascadeSectionBegin, | 6256 UnlinkedConstOperation.cascadeSectionBegin, |
| 6257 UnlinkedConstOperation.pushInt, | 6257 UnlinkedConstOperation.pushInt, |
| 6258 UnlinkedConstOperation.pushInt, | 6258 UnlinkedConstOperation.pushInt, |
| 6259 UnlinkedConstOperation.assignToIndex, | 6259 UnlinkedConstOperation.assignToIndex, |
| 6260 // c | 6260 // c |
| 6261 UnlinkedConstOperation.cascadeSectionEnd, | 6261 UnlinkedConstOperation.cascadeSectionEnd, |
| 6262 ], assignmentOperators: [ | 6262 ], assignmentOperators: [ |
| 6263 UnlinkedExprAssignOperator.assign, | 6263 UnlinkedExprAssignOperator.assign, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 6278 if (skipNonConstInitializers) { | 6278 if (skipNonConstInitializers) { |
| 6279 return; | 6279 return; |
| 6280 } | 6280 } |
| 6281 UnlinkedVariable variable = serializeVariableText(''' | 6281 UnlinkedVariable variable = serializeVariableText(''' |
| 6282 class C { | 6282 class C { |
| 6283 int f1 = 0; | 6283 int f1 = 0; |
| 6284 int f2 = 0; | 6284 int f2 = 0; |
| 6285 } | 6285 } |
| 6286 final v = new C()..f1 = 1..f2 += 2; | 6286 final v = new C()..f1 = 1..f2 += 2; |
| 6287 '''); | 6287 '''); |
| 6288 _assertUnlinkedConst(variable.constExpr, operators: [ | 6288 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6289 // new C() | 6289 // new C() |
| 6290 UnlinkedConstOperation.invokeConstructor, | 6290 UnlinkedConstOperation.invokeConstructor, |
| 6291 // ..f1 = 1 | 6291 // ..f1 = 1 |
| 6292 UnlinkedConstOperation.cascadeSectionBegin, | 6292 UnlinkedConstOperation.cascadeSectionBegin, |
| 6293 UnlinkedConstOperation.pushInt, | 6293 UnlinkedConstOperation.pushInt, |
| 6294 UnlinkedConstOperation.assignToProperty, | 6294 UnlinkedConstOperation.assignToProperty, |
| 6295 // C | 6295 // C |
| 6296 UnlinkedConstOperation.cascadeSectionEnd, | 6296 UnlinkedConstOperation.cascadeSectionEnd, |
| 6297 // ..f2 += 2 | 6297 // ..f2 += 2 |
| 6298 UnlinkedConstOperation.cascadeSectionBegin, | 6298 UnlinkedConstOperation.cascadeSectionBegin, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6327 int fa2; | 6327 int fa2; |
| 6328 } | 6328 } |
| 6329 class B { | 6329 class B { |
| 6330 int fb; | 6330 int fb; |
| 6331 } | 6331 } |
| 6332 final v = new A() | 6332 final v = new A() |
| 6333 ..fa1 = 1 | 6333 ..fa1 = 1 |
| 6334 ..b = (new B()..fb = 2) | 6334 ..b = (new B()..fb = 2) |
| 6335 ..fa2 = 3; | 6335 ..fa2 = 3; |
| 6336 '''); | 6336 '''); |
| 6337 _assertUnlinkedConst(variable.constExpr, operators: [ | 6337 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6338 // new A() | 6338 // new A() |
| 6339 UnlinkedConstOperation.invokeConstructor, | 6339 UnlinkedConstOperation.invokeConstructor, |
| 6340 // ..fa1 = 1 | 6340 // ..fa1 = 1 |
| 6341 UnlinkedConstOperation.cascadeSectionBegin, | 6341 UnlinkedConstOperation.cascadeSectionBegin, |
| 6342 UnlinkedConstOperation.pushInt, | 6342 UnlinkedConstOperation.pushInt, |
| 6343 UnlinkedConstOperation.assignToProperty, | 6343 UnlinkedConstOperation.assignToProperty, |
| 6344 UnlinkedConstOperation.cascadeSectionEnd, | 6344 UnlinkedConstOperation.cascadeSectionEnd, |
| 6345 // ..b | 6345 // ..b |
| 6346 UnlinkedConstOperation.cascadeSectionBegin, | 6346 UnlinkedConstOperation.cascadeSectionBegin, |
| 6347 // new B() | 6347 // new B() |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6389 if (skipNonConstInitializers) { | 6389 if (skipNonConstInitializers) { |
| 6390 return; | 6390 return; |
| 6391 } | 6391 } |
| 6392 UnlinkedVariable variable = serializeVariableText(''' | 6392 UnlinkedVariable variable = serializeVariableText(''' |
| 6393 class A { | 6393 class A { |
| 6394 int m(int _) => 0; | 6394 int m(int _) => 0; |
| 6395 } | 6395 } |
| 6396 final A a = new A(); | 6396 final A a = new A(); |
| 6397 final v = a..m(5).abs()..m(6); | 6397 final v = a..m(5).abs()..m(6); |
| 6398 '''); | 6398 '''); |
| 6399 _assertUnlinkedConst(variable.constExpr, operators: [ | 6399 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6400 // a | 6400 // a |
| 6401 UnlinkedConstOperation.pushReference, | 6401 UnlinkedConstOperation.pushReference, |
| 6402 // ..m(5) | 6402 // ..m(5) |
| 6403 UnlinkedConstOperation.cascadeSectionBegin, | 6403 UnlinkedConstOperation.cascadeSectionBegin, |
| 6404 UnlinkedConstOperation.pushInt, | 6404 UnlinkedConstOperation.pushInt, |
| 6405 UnlinkedConstOperation.invokeMethod, | 6405 UnlinkedConstOperation.invokeMethod, |
| 6406 // ..abs() | 6406 // ..abs() |
| 6407 UnlinkedConstOperation.invokeMethod, | 6407 UnlinkedConstOperation.invokeMethod, |
| 6408 // a | 6408 // a |
| 6409 UnlinkedConstOperation.cascadeSectionEnd, | 6409 UnlinkedConstOperation.cascadeSectionEnd, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6430 test_expr_extractIndex_ofClassField() { | 6430 test_expr_extractIndex_ofClassField() { |
| 6431 if (skipNonConstInitializers) { | 6431 if (skipNonConstInitializers) { |
| 6432 return; | 6432 return; |
| 6433 } | 6433 } |
| 6434 UnlinkedVariable variable = serializeVariableText(''' | 6434 UnlinkedVariable variable = serializeVariableText(''' |
| 6435 class C { | 6435 class C { |
| 6436 List<int> get items => null; | 6436 List<int> get items => null; |
| 6437 } | 6437 } |
| 6438 final v = new C().items[5]; | 6438 final v = new C().items[5]; |
| 6439 '''); | 6439 '''); |
| 6440 _assertUnlinkedConst(variable.constExpr, operators: [ | 6440 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6441 UnlinkedConstOperation.invokeConstructor, | 6441 UnlinkedConstOperation.invokeConstructor, |
| 6442 UnlinkedConstOperation.extractProperty, | 6442 UnlinkedConstOperation.extractProperty, |
| 6443 UnlinkedConstOperation.pushInt, | 6443 UnlinkedConstOperation.pushInt, |
| 6444 UnlinkedConstOperation.extractIndex, | 6444 UnlinkedConstOperation.extractIndex, |
| 6445 ], ints: [ | 6445 ], ints: [ |
| 6446 0, | 6446 0, |
| 6447 0, | 6447 0, |
| 6448 5 | 6448 5 |
| 6449 ], strings: [ | 6449 ], strings: [ |
| 6450 'items' | 6450 'items' |
| 6451 ], referenceValidators: [ | 6451 ], referenceValidators: [ |
| 6452 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 6452 (EntityRef r) => checkTypeRef(r, null, null, 'C', |
| 6453 expectedKind: ReferenceKind.classOrEnum) | 6453 expectedKind: ReferenceKind.classOrEnum) |
| 6454 ]); | 6454 ]); |
| 6455 } | 6455 } |
| 6456 | 6456 |
| 6457 test_expr_extractProperty_ofInvokeConstructor() { | 6457 test_expr_extractProperty_ofInvokeConstructor() { |
| 6458 if (skipNonConstInitializers) { | 6458 if (skipNonConstInitializers) { |
| 6459 return; | 6459 return; |
| 6460 } | 6460 } |
| 6461 UnlinkedVariable variable = serializeVariableText(''' | 6461 UnlinkedVariable variable = serializeVariableText(''' |
| 6462 class C { | 6462 class C { |
| 6463 int f = 0; | 6463 int f = 0; |
| 6464 } | 6464 } |
| 6465 final v = new C().f; | 6465 final v = new C().f; |
| 6466 '''); | 6466 '''); |
| 6467 _assertUnlinkedConst(variable.constExpr, operators: [ | 6467 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6468 UnlinkedConstOperation.invokeConstructor, | 6468 UnlinkedConstOperation.invokeConstructor, |
| 6469 UnlinkedConstOperation.extractProperty, | 6469 UnlinkedConstOperation.extractProperty, |
| 6470 ], ints: [ | 6470 ], ints: [ |
| 6471 0, | 6471 0, |
| 6472 0 | 6472 0 |
| 6473 ], strings: [ | 6473 ], strings: [ |
| 6474 'f' | 6474 'f' |
| 6475 ], referenceValidators: [ | 6475 ], referenceValidators: [ |
| 6476 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 6476 (EntityRef r) => checkTypeRef(r, null, null, 'C', |
| 6477 expectedKind: ReferenceKind.classOrEnum) | 6477 expectedKind: ReferenceKind.classOrEnum) |
| 6478 ]); | 6478 ]); |
| 6479 } | 6479 } |
| 6480 | 6480 |
| 6481 test_expr_functionExpression_asArgument() { | 6481 test_expr_functionExpression_asArgument() { |
| 6482 if (skipNonConstInitializers) { | 6482 if (skipNonConstInitializers) { |
| 6483 return; | 6483 return; |
| 6484 } | 6484 } |
| 6485 UnlinkedVariable variable = serializeVariableText(''' | 6485 UnlinkedVariable variable = serializeVariableText(''' |
| 6486 final v = foo(5, () => 42); | 6486 final v = foo(5, () => 42); |
| 6487 foo(a, b) {} | 6487 foo(a, b) {} |
| 6488 '''); | 6488 '''); |
| 6489 _assertUnlinkedConst(variable.constExpr, operators: [ | 6489 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6490 UnlinkedConstOperation.pushInt, | 6490 UnlinkedConstOperation.pushInt, |
| 6491 UnlinkedConstOperation.pushNull, | 6491 UnlinkedConstOperation.pushNull, |
| 6492 UnlinkedConstOperation.invokeMethodRef | 6492 UnlinkedConstOperation.invokeMethodRef |
| 6493 ], ints: [ | 6493 ], ints: [ |
| 6494 5, | 6494 5, |
| 6495 0, | 6495 0, |
| 6496 2 | 6496 2 |
| 6497 ], referenceValidators: [ | 6497 ], referenceValidators: [ |
| 6498 (EntityRef r) => checkTypeRef(r, null, null, 'foo', | 6498 (EntityRef r) => checkTypeRef(r, null, null, 'foo', |
| 6499 expectedKind: ReferenceKind.topLevelFunction) | 6499 expectedKind: ReferenceKind.topLevelFunction) |
| 6500 ]); | 6500 ]); |
| 6501 } | 6501 } |
| 6502 | 6502 |
| 6503 test_expr_functionExpression_withBlockBody() { | 6503 test_expr_functionExpression_withBlockBody() { |
| 6504 if (skipNonConstInitializers) { | 6504 if (skipNonConstInitializers) { |
| 6505 return; | 6505 return; |
| 6506 } | 6506 } |
| 6507 UnlinkedVariable variable = serializeVariableText(''' | 6507 UnlinkedVariable variable = serializeVariableText(''' |
| 6508 final v = () { return 42; }; | 6508 final v = () { return 42; }; |
| 6509 '''); | 6509 '''); |
| 6510 _assertUnlinkedConst(variable.constExpr, | 6510 _assertUnlinkedConst(variable.constExpr, |
| 6511 operators: [UnlinkedConstOperation.pushNull]); | 6511 isValidConst: false, operators: [UnlinkedConstOperation.pushNull]); |
| 6512 } | 6512 } |
| 6513 | 6513 |
| 6514 test_expr_functionExpression_withExpressionBody() { | 6514 test_expr_functionExpression_withExpressionBody() { |
| 6515 if (skipNonConstInitializers) { | 6515 if (skipNonConstInitializers) { |
| 6516 return; | 6516 return; |
| 6517 } | 6517 } |
| 6518 UnlinkedVariable variable = serializeVariableText(''' | 6518 UnlinkedVariable variable = serializeVariableText(''' |
| 6519 final v = () => 42; | 6519 final v = () => 42; |
| 6520 '''); | 6520 '''); |
| 6521 _assertUnlinkedConst(variable.constExpr, | 6521 _assertUnlinkedConst(variable.constExpr, |
| 6522 operators: [UnlinkedConstOperation.pushNull]); | 6522 isValidConst: false, operators: [UnlinkedConstOperation.pushNull]); |
| 6523 } | 6523 } |
| 6524 | 6524 |
| 6525 test_expr_functionExpressionInvocation_withBlockBody() { | 6525 test_expr_functionExpressionInvocation_withBlockBody() { |
| 6526 if (skipNonConstInitializers) { | 6526 if (skipNonConstInitializers) { |
| 6527 return; | 6527 return; |
| 6528 } | 6528 } |
| 6529 UnlinkedVariable variable = serializeVariableText(''' | 6529 UnlinkedVariable variable = serializeVariableText(''' |
| 6530 final v = ((a, b) {return 42;})(1, 2); | 6530 final v = ((a, b) {return 42;})(1, 2); |
| 6531 '''); | 6531 '''); |
| 6532 _assertUnlinkedConst(variable.constExpr, | 6532 _assertUnlinkedConst(variable.constExpr, |
| 6533 operators: [UnlinkedConstOperation.pushNull]); | 6533 isValidConst: false, operators: [UnlinkedConstOperation.pushNull]); |
| 6534 } | 6534 } |
| 6535 | 6535 |
| 6536 test_expr_functionExpressionInvocation_withExpressionBody() { | 6536 test_expr_functionExpressionInvocation_withExpressionBody() { |
| 6537 if (skipNonConstInitializers) { | 6537 if (skipNonConstInitializers) { |
| 6538 return; | 6538 return; |
| 6539 } | 6539 } |
| 6540 UnlinkedVariable variable = serializeVariableText(''' | 6540 UnlinkedVariable variable = serializeVariableText(''' |
| 6541 final v = ((a, b) => 42)(1, 2); | 6541 final v = ((a, b) => 42)(1, 2); |
| 6542 '''); | 6542 '''); |
| 6543 _assertUnlinkedConst(variable.constExpr, | 6543 _assertUnlinkedConst(variable.constExpr, |
| 6544 operators: [UnlinkedConstOperation.pushNull]); | 6544 isValidConst: false, operators: [UnlinkedConstOperation.pushNull]); |
| 6545 } | 6545 } |
| 6546 | 6546 |
| 6547 test_expr_invokeMethod_instance() { | 6547 test_expr_invokeMethod_instance() { |
| 6548 if (skipNonConstInitializers) { | 6548 if (skipNonConstInitializers) { |
| 6549 return; | 6549 return; |
| 6550 } | 6550 } |
| 6551 UnlinkedVariable variable = serializeVariableText(''' | 6551 UnlinkedVariable variable = serializeVariableText(''' |
| 6552 class C { | 6552 class C { |
| 6553 int m(a, {b, c}) => 42; | 6553 int m(a, {b, c}) => 42; |
| 6554 } | 6554 } |
| 6555 final v = new C().m(1, b: 2, c: 3); | 6555 final v = new C().m(1, b: 2, c: 3); |
| 6556 '''); | 6556 '''); |
| 6557 _assertUnlinkedConst(variable.constExpr, operators: [ | 6557 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6558 UnlinkedConstOperation.invokeConstructor, | 6558 UnlinkedConstOperation.invokeConstructor, |
| 6559 UnlinkedConstOperation.pushInt, | 6559 UnlinkedConstOperation.pushInt, |
| 6560 UnlinkedConstOperation.pushInt, | 6560 UnlinkedConstOperation.pushInt, |
| 6561 UnlinkedConstOperation.pushInt, | 6561 UnlinkedConstOperation.pushInt, |
| 6562 UnlinkedConstOperation.invokeMethod, | 6562 UnlinkedConstOperation.invokeMethod, |
| 6563 ], ints: [ | 6563 ], ints: [ |
| 6564 0, | 6564 0, |
| 6565 0, | 6565 0, |
| 6566 1, | 6566 1, |
| 6567 2, | 6567 2, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6588 } | 6588 } |
| 6589 class B { | 6589 class B { |
| 6590 C c; | 6590 C c; |
| 6591 } | 6591 } |
| 6592 class C { | 6592 class C { |
| 6593 int m(int a, int b) => a + b; | 6593 int m(int a, int b) => a + b; |
| 6594 } | 6594 } |
| 6595 A a = new A(); | 6595 A a = new A(); |
| 6596 final v = a.b.c.m(10, 20); | 6596 final v = a.b.c.m(10, 20); |
| 6597 '''); | 6597 '''); |
| 6598 _assertUnlinkedConst(variable.constExpr, operators: [ | 6598 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6599 UnlinkedConstOperation.pushInt, | 6599 UnlinkedConstOperation.pushInt, |
| 6600 UnlinkedConstOperation.pushInt, | 6600 UnlinkedConstOperation.pushInt, |
| 6601 UnlinkedConstOperation.invokeMethodRef, | 6601 UnlinkedConstOperation.invokeMethodRef, |
| 6602 ], ints: [ | 6602 ], ints: [ |
| 6603 10, | 6603 10, |
| 6604 20, | 6604 20, |
| 6605 0, | 6605 0, |
| 6606 2 | 6606 2 |
| 6607 ], strings: [], referenceValidators: [ | 6607 ], strings: [], referenceValidators: [ |
| 6608 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 6608 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6624 '/a.dart', | 6624 '/a.dart', |
| 6625 ''' | 6625 ''' |
| 6626 class C { | 6626 class C { |
| 6627 static int m() => 42; | 6627 static int m() => 42; |
| 6628 } | 6628 } |
| 6629 '''); | 6629 '''); |
| 6630 UnlinkedVariable variable = serializeVariableText(''' | 6630 UnlinkedVariable variable = serializeVariableText(''' |
| 6631 import 'a.dart' as p; | 6631 import 'a.dart' as p; |
| 6632 final v = p.C.m(); | 6632 final v = p.C.m(); |
| 6633 '''); | 6633 '''); |
| 6634 _assertUnlinkedConst(variable.constExpr, operators: [ | 6634 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6635 UnlinkedConstOperation.invokeMethodRef, | 6635 UnlinkedConstOperation.invokeMethodRef, |
| 6636 ], ints: [ | 6636 ], ints: [ |
| 6637 0, | 6637 0, |
| 6638 0 | 6638 0 |
| 6639 ], strings: [], referenceValidators: [ | 6639 ], strings: [], referenceValidators: [ |
| 6640 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 6640 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
| 6641 expectedKind: ReferenceKind.method, | 6641 expectedKind: ReferenceKind.method, |
| 6642 prefixExpectations: [ | 6642 prefixExpectations: [ |
| 6643 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', | 6643 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 6644 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), | 6644 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
| 6645 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 6645 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 6646 ]) | 6646 ]) |
| 6647 ]); | 6647 ]); |
| 6648 } | 6648 } |
| 6649 | 6649 |
| 6650 test_expr_throwException() { | 6650 test_expr_throwException() { |
| 6651 if (skipNonConstInitializers) { | 6651 if (skipNonConstInitializers) { |
| 6652 return; | 6652 return; |
| 6653 } | 6653 } |
| 6654 UnlinkedVariable variable = serializeVariableText(''' | 6654 UnlinkedVariable variable = serializeVariableText(''' |
| 6655 final v = throw 1 + 2; | 6655 final v = throw 1 + 2; |
| 6656 '''); | 6656 '''); |
| 6657 _assertUnlinkedConst(variable.constExpr, operators: [ | 6657 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6658 UnlinkedConstOperation.pushInt, | 6658 UnlinkedConstOperation.pushInt, |
| 6659 UnlinkedConstOperation.pushInt, | 6659 UnlinkedConstOperation.pushInt, |
| 6660 UnlinkedConstOperation.add, | 6660 UnlinkedConstOperation.add, |
| 6661 UnlinkedConstOperation.throwException, | 6661 UnlinkedConstOperation.throwException, |
| 6662 ], ints: [ | 6662 ], ints: [ |
| 6663 1, | 6663 1, |
| 6664 2 | 6664 2 |
| 6665 ]); | 6665 ]); |
| 6666 } | 6666 } |
| 6667 | 6667 |
| 6668 test_expr_typeCast() { | 6668 test_expr_typeCast() { |
| 6669 if (skipNonConstInitializers) { | 6669 if (skipNonConstInitializers) { |
| 6670 return; | 6670 return; |
| 6671 } | 6671 } |
| 6672 UnlinkedVariable variable = serializeVariableText(''' | 6672 UnlinkedVariable variable = serializeVariableText(''' |
| 6673 final v = 42 as num; | 6673 final v = 42 as num; |
| 6674 '''); | 6674 '''); |
| 6675 _assertUnlinkedConst(variable.constExpr, operators: [ | 6675 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6676 UnlinkedConstOperation.pushInt, | 6676 UnlinkedConstOperation.pushInt, |
| 6677 UnlinkedConstOperation.pushReference, | 6677 UnlinkedConstOperation.pushReference, |
| 6678 UnlinkedConstOperation.typeCast, | 6678 UnlinkedConstOperation.typeCast, |
| 6679 ], ints: [ | 6679 ], ints: [ |
| 6680 42 | 6680 42 |
| 6681 ], referenceValidators: [ | 6681 ], referenceValidators: [ |
| 6682 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'num', | 6682 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'num', |
| 6683 expectedKind: ReferenceKind.classOrEnum) | 6683 expectedKind: ReferenceKind.classOrEnum) |
| 6684 ]); | 6684 ]); |
| 6685 } | 6685 } |
| 6686 | 6686 |
| 6687 test_expr_typeCheck() { | 6687 test_expr_typeCheck() { |
| 6688 if (skipNonConstInitializers) { | 6688 if (skipNonConstInitializers) { |
| 6689 return; | 6689 return; |
| 6690 } | 6690 } |
| 6691 UnlinkedVariable variable = serializeVariableText(''' | 6691 UnlinkedVariable variable = serializeVariableText(''' |
| 6692 final v = 42 is num; | 6692 final v = 42 is num; |
| 6693 '''); | 6693 '''); |
| 6694 _assertUnlinkedConst(variable.constExpr, operators: [ | 6694 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6695 UnlinkedConstOperation.pushInt, | 6695 UnlinkedConstOperation.pushInt, |
| 6696 UnlinkedConstOperation.pushReference, | 6696 UnlinkedConstOperation.pushReference, |
| 6697 UnlinkedConstOperation.typeCheck, | 6697 UnlinkedConstOperation.typeCheck, |
| 6698 ], ints: [ | 6698 ], ints: [ |
| 6699 42 | 6699 42 |
| 6700 ], referenceValidators: [ | 6700 ], referenceValidators: [ |
| 6701 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'num', | 6701 (EntityRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'num', |
| 6702 expectedKind: ReferenceKind.classOrEnum) | 6702 expectedKind: ReferenceKind.classOrEnum) |
| 6703 ]); | 6703 ]); |
| 6704 } | 6704 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6744 operators: [UnlinkedConstOperation.pushInt], ints: [0]); | 6744 operators: [UnlinkedConstOperation.pushInt], ints: [0]); |
| 6745 } | 6745 } |
| 6746 | 6746 |
| 6747 test_field_final_notConstExpr() { | 6747 test_field_final_notConstExpr() { |
| 6748 UnlinkedVariable variable = serializeClassText(r''' | 6748 UnlinkedVariable variable = serializeClassText(r''' |
| 6749 class C { | 6749 class C { |
| 6750 final int f = 1 + m(); | 6750 final int f = 1 + m(); |
| 6751 static int m() => 42; | 6751 static int m() => 42; |
| 6752 }''').fields[0]; | 6752 }''').fields[0]; |
| 6753 expect(variable.isFinal, isTrue); | 6753 expect(variable.isFinal, isTrue); |
| 6754 _assertUnlinkedConst(variable.constExpr, operators: [ | 6754 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 6755 UnlinkedConstOperation.pushInt, | 6755 UnlinkedConstOperation.pushInt, |
| 6756 UnlinkedConstOperation.invokeMethodRef, | 6756 UnlinkedConstOperation.invokeMethodRef, |
| 6757 UnlinkedConstOperation.add, | 6757 UnlinkedConstOperation.add, |
| 6758 ], ints: [ | 6758 ], ints: [ |
| 6759 1, | 6759 1, |
| 6760 0, | 6760 0, |
| 6761 0 | 6761 0 |
| 6762 ], strings: [], referenceValidators: [ | 6762 ], strings: [], referenceValidators: [ |
| 6763 (EntityRef r) => checkTypeRef(r, null, null, 'm', | 6763 (EntityRef r) => checkTypeRef(r, null, null, 'm', |
| 6764 expectedKind: ReferenceKind.method, | 6764 expectedKind: ReferenceKind.method, |
| (...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9153 */ | 9153 */ |
| 9154 void _assertAssignmentOperator( | 9154 void _assertAssignmentOperator( |
| 9155 String expr, UnlinkedExprAssignOperator expectedAssignOperator) { | 9155 String expr, UnlinkedExprAssignOperator expectedAssignOperator) { |
| 9156 if (skipNonConstInitializers) { | 9156 if (skipNonConstInitializers) { |
| 9157 return; | 9157 return; |
| 9158 } | 9158 } |
| 9159 UnlinkedVariable variable = serializeVariableText(''' | 9159 UnlinkedVariable variable = serializeVariableText(''' |
| 9160 int a = 0; | 9160 int a = 0; |
| 9161 final v = $expr; | 9161 final v = $expr; |
| 9162 '''); | 9162 '''); |
| 9163 _assertUnlinkedConst(variable.constExpr, operators: [ | 9163 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 9164 UnlinkedConstOperation.pushInt, | 9164 UnlinkedConstOperation.pushInt, |
| 9165 UnlinkedConstOperation.pushInt, | 9165 UnlinkedConstOperation.pushInt, |
| 9166 UnlinkedConstOperation.add, | 9166 UnlinkedConstOperation.add, |
| 9167 UnlinkedConstOperation.assignToRef, | 9167 UnlinkedConstOperation.assignToRef, |
| 9168 UnlinkedConstOperation.pushInt, | 9168 UnlinkedConstOperation.pushInt, |
| 9169 UnlinkedConstOperation.add, | 9169 UnlinkedConstOperation.add, |
| 9170 ], assignmentOperators: [ | 9170 ], assignmentOperators: [ |
| 9171 expectedAssignOperator | 9171 expectedAssignOperator |
| 9172 ], ints: [ | 9172 ], ints: [ |
| 9173 1, | 9173 1, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9214 */ | 9214 */ |
| 9215 void _assertRefPrefixPostfixIncrementDecrement( | 9215 void _assertRefPrefixPostfixIncrementDecrement( |
| 9216 String expr, UnlinkedExprAssignOperator expectedAssignmentOperator) { | 9216 String expr, UnlinkedExprAssignOperator expectedAssignmentOperator) { |
| 9217 if (skipNonConstInitializers) { | 9217 if (skipNonConstInitializers) { |
| 9218 return; | 9218 return; |
| 9219 } | 9219 } |
| 9220 UnlinkedVariable variable = serializeVariableText(''' | 9220 UnlinkedVariable variable = serializeVariableText(''' |
| 9221 int a = 0; | 9221 int a = 0; |
| 9222 final v = $expr; | 9222 final v = $expr; |
| 9223 '''); | 9223 '''); |
| 9224 _assertUnlinkedConst(variable.constExpr, operators: [ | 9224 _assertUnlinkedConst(variable.constExpr, isValidConst: false, operators: [ |
| 9225 UnlinkedConstOperation.assignToRef, | 9225 UnlinkedConstOperation.assignToRef, |
| 9226 UnlinkedConstOperation.pushInt, | 9226 UnlinkedConstOperation.pushInt, |
| 9227 UnlinkedConstOperation.add, | 9227 UnlinkedConstOperation.add, |
| 9228 ], assignmentOperators: [ | 9228 ], assignmentOperators: [ |
| 9229 expectedAssignmentOperator | 9229 expectedAssignmentOperator |
| 9230 ], ints: [ | 9230 ], ints: [ |
| 9231 2 | 9231 2 |
| 9232 ], strings: [], referenceValidators: [ | 9232 ], strings: [], referenceValidators: [ |
| 9233 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 9233 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
| 9234 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 9234 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 9235 ]); | 9235 ]); |
| 9236 } | 9236 } |
| 9237 | 9237 |
| 9238 /** | 9238 /** |
| 9239 * TODO(scheglov) rename "Const" to "Expr" everywhere | 9239 * TODO(scheglov) rename "Const" to "Expr" everywhere |
| 9240 */ | 9240 */ |
| 9241 void _assertUnlinkedConst(UnlinkedConst constExpr, | 9241 void _assertUnlinkedConst(UnlinkedConst constExpr, |
| 9242 {bool isInvalid: false, | 9242 {bool isValidConst: true, |
| 9243 List<UnlinkedConstOperation> operators: const <UnlinkedConstOperation>[], | 9243 List<UnlinkedConstOperation> operators: const <UnlinkedConstOperation>[], |
| 9244 List<UnlinkedExprAssignOperator> assignmentOperators: | 9244 List<UnlinkedExprAssignOperator> assignmentOperators: |
| 9245 const <UnlinkedExprAssignOperator>[], | 9245 const <UnlinkedExprAssignOperator>[], |
| 9246 List<int> ints: const <int>[], | 9246 List<int> ints: const <int>[], |
| 9247 List<double> doubles: const <double>[], | 9247 List<double> doubles: const <double>[], |
| 9248 List<String> strings: const <String>[], | 9248 List<String> strings: const <String>[], |
| 9249 List<_EntityRefValidator> referenceValidators: | 9249 List<_EntityRefValidator> referenceValidators: |
| 9250 const <_EntityRefValidator>[]}) { | 9250 const <_EntityRefValidator>[]}) { |
| 9251 expect(constExpr, isNotNull); | 9251 expect(constExpr, isNotNull); |
| 9252 expect(constExpr.isInvalid, isInvalid); | 9252 expect(constExpr.isValidConst, isValidConst); |
| 9253 expect(constExpr.operations, operators); | 9253 expect(constExpr.operations, operators); |
| 9254 expect(constExpr.ints, ints); | 9254 expect(constExpr.ints, ints); |
| 9255 expect(constExpr.doubles, doubles); | 9255 expect(constExpr.doubles, doubles); |
| 9256 expect(constExpr.strings, strings); | 9256 expect(constExpr.strings, strings); |
| 9257 expect(constExpr.assignmentOperators, assignmentOperators); | 9257 expect(constExpr.assignmentOperators, assignmentOperators); |
| 9258 expect(constExpr.references, hasLength(referenceValidators.length)); | 9258 expect(constExpr.references, hasLength(referenceValidators.length)); |
| 9259 for (int i = 0; i < referenceValidators.length; i++) { | 9259 for (int i = 0; i < referenceValidators.length; i++) { |
| 9260 referenceValidators[i](constExpr.references[i]); | 9260 referenceValidators[i](constExpr.references[i]); |
| 9261 } | 9261 } |
| 9262 } | 9262 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 9277 class _PrefixExpectation { | 9277 class _PrefixExpectation { |
| 9278 final ReferenceKind kind; | 9278 final ReferenceKind kind; |
| 9279 final String name; | 9279 final String name; |
| 9280 final String absoluteUri; | 9280 final String absoluteUri; |
| 9281 final String relativeUri; | 9281 final String relativeUri; |
| 9282 final int numTypeParameters; | 9282 final int numTypeParameters; |
| 9283 | 9283 |
| 9284 _PrefixExpectation(this.kind, this.name, | 9284 _PrefixExpectation(this.kind, this.name, |
| 9285 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 9285 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 9286 } | 9286 } |
| OLD | NEW |