| 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 library dart2js.resolution.members; | 5 library dart2js.resolution.members; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart' show Selectors; | 8 import '../common/names.dart' show Selectors; |
| 9 import '../common/resolution.dart' show Resolution; | 9 import '../common/resolution.dart' show Resolution; |
| 10 import '../compile_time_constants.dart'; | 10 import '../compile_time_constants.dart'; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 inCheckContext = resolution.options.enableTypeAssertions && | 164 inCheckContext = resolution.options.enableTypeAssertions && |
| 165 !element.isLibrary && | 165 !element.isLibrary && |
| 166 !element.isTypedef && | 166 !element.isTypedef && |
| 167 !element.enclosingElement.isTypedef, | 167 !element.enclosingElement.isTypedef, |
| 168 inCatchBlock = false, | 168 inCatchBlock = false, |
| 169 constantState = element.isConst | 169 constantState = element.isConst |
| 170 ? ConstantState.CONSTANT | 170 ? ConstantState.CONSTANT |
| 171 : ConstantState.NON_CONSTANT, | 171 : ConstantState.NON_CONSTANT, |
| 172 super(resolution, registry); | 172 super(resolution, registry); |
| 173 | 173 |
| 174 CoreClasses get coreClasses => resolution.coreClasses; | 174 CommonElements get commonElements => resolution.commonElements; |
| 175 CoreTypes get coreTypes => resolution.coreTypes; | |
| 176 ConstantEnvironment get constants => resolution.constants; | 175 ConstantEnvironment get constants => resolution.constants; |
| 177 ResolverTask get resolver => resolution.resolver; | 176 ResolverTask get resolver => resolution.resolver; |
| 178 CompilerOptions get options => resolution.options; | 177 CompilerOptions get options => resolution.options; |
| 179 | 178 |
| 180 AsyncMarker get currentAsyncMarker { | 179 AsyncMarker get currentAsyncMarker { |
| 181 if (enclosingElement is FunctionElement) { | 180 if (enclosingElement is FunctionElement) { |
| 182 FunctionElement function = enclosingElement; | 181 FunctionElement function = enclosingElement; |
| 183 return function.asyncMarker; | 182 return function.asyncMarker; |
| 184 } | 183 } |
| 185 return AsyncMarker.SYNC; | 184 return AsyncMarker.SYNC; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 if ((ElementCategory.SUPER & allowedCategory) == 0) { | 329 if ((ElementCategory.SUPER & allowedCategory) == 0) { |
| 331 reporter.reportErrorMessage(node, MessageKind.INVALID_USE_OF_SUPER); | 330 reporter.reportErrorMessage(node, MessageKind.INVALID_USE_OF_SUPER); |
| 332 } | 331 } |
| 333 return const NoneResult(); | 332 return const NoneResult(); |
| 334 } else { | 333 } else { |
| 335 String name = node.source; | 334 String name = node.source; |
| 336 Element element = lookupInScope(reporter, node, scope, name); | 335 Element element = lookupInScope(reporter, node, scope, name); |
| 337 if (Elements.isUnresolved(element) && name == 'dynamic') { | 336 if (Elements.isUnresolved(element) && name == 'dynamic') { |
| 338 // TODO(johnniwinther): Remove this hack when we can return more complex | 337 // TODO(johnniwinther): Remove this hack when we can return more complex |
| 339 // objects than [Element] from this method. | 338 // objects than [Element] from this method. |
| 340 element = coreClasses.typeClass; | 339 element = commonElements.typeClass; |
| 341 // Set the type to be `dynamic` to mark that this is a type literal. | 340 // Set the type to be `dynamic` to mark that this is a type literal. |
| 342 registry.setType(node, const DynamicType()); | 341 registry.setType(node, const DynamicType()); |
| 343 } | 342 } |
| 344 element = reportLookupErrorIfAny(element, node, name); | 343 element = reportLookupErrorIfAny(element, node, name); |
| 345 if (element == null) { | 344 if (element == null) { |
| 346 if (!inInstanceContext) { | 345 if (!inInstanceContext) { |
| 347 element = reportCannotResolve(node, name); | 346 element = reportCannotResolve(node, name); |
| 348 } | 347 } |
| 349 } else if (element.isMalformed) { | 348 } else if (element.isMalformed) { |
| 350 // Use the malformed element. | 349 // Use the malformed element. |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 } | 1189 } |
| 1191 } else { | 1190 } else { |
| 1192 ResolutionResult expressionResult = visitExpression(expression); | 1191 ResolutionResult expressionResult = visitExpression(expression); |
| 1193 semantics = const DynamicAccess.expression(); | 1192 semantics = const DynamicAccess.expression(); |
| 1194 registry.registerDynamicUse(new DynamicUse(selector, null)); | 1193 registry.registerDynamicUse(new DynamicUse(selector, null)); |
| 1195 | 1194 |
| 1196 if (expressionResult.isConstant) { | 1195 if (expressionResult.isConstant) { |
| 1197 bool isValidConstant; | 1196 bool isValidConstant; |
| 1198 ConstantExpression expressionConstant = expressionResult.constant; | 1197 ConstantExpression expressionConstant = expressionResult.constant; |
| 1199 DartType knownExpressionType = | 1198 DartType knownExpressionType = |
| 1200 expressionConstant.getKnownType(coreTypes); | 1199 expressionConstant.getKnownType(commonElements); |
| 1201 switch (operator.kind) { | 1200 switch (operator.kind) { |
| 1202 case UnaryOperatorKind.COMPLEMENT: | 1201 case UnaryOperatorKind.COMPLEMENT: |
| 1203 isValidConstant = knownExpressionType == coreTypes.intType; | 1202 isValidConstant = knownExpressionType == commonElements.intType; |
| 1204 break; | 1203 break; |
| 1205 case UnaryOperatorKind.NEGATE: | 1204 case UnaryOperatorKind.NEGATE: |
| 1206 isValidConstant = knownExpressionType == coreTypes.intType || | 1205 isValidConstant = knownExpressionType == commonElements.intType || |
| 1207 knownExpressionType == coreTypes.doubleType; | 1206 knownExpressionType == commonElements.doubleType; |
| 1208 break; | 1207 break; |
| 1209 case UnaryOperatorKind.NOT: | 1208 case UnaryOperatorKind.NOT: |
| 1210 reporter.internalError( | 1209 reporter.internalError( |
| 1211 node, "Unexpected user definable unary operator: $operator"); | 1210 node, "Unexpected user definable unary operator: $operator"); |
| 1212 } | 1211 } |
| 1213 if (isValidConstant) { | 1212 if (isValidConstant) { |
| 1214 // TODO(johnniwinther): Handle potentially invalid constant | 1213 // TODO(johnniwinther): Handle potentially invalid constant |
| 1215 // expressions. | 1214 // expressions. |
| 1216 ConstantExpression constant = | 1215 ConstantExpression constant = |
| 1217 new UnaryConstantExpression(operator, expressionConstant); | 1216 new UnaryConstantExpression(operator, expressionConstant); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1230 /// Handle a not expression, like `!a`. | 1229 /// Handle a not expression, like `!a`. |
| 1231 ResolutionResult handleNot(Send node, UnaryOperator operator) { | 1230 ResolutionResult handleNot(Send node, UnaryOperator operator) { |
| 1232 assert(invariant(node, operator.kind == UnaryOperatorKind.NOT)); | 1231 assert(invariant(node, operator.kind == UnaryOperatorKind.NOT)); |
| 1233 | 1232 |
| 1234 Node expression = node.receiver; | 1233 Node expression = node.receiver; |
| 1235 ResolutionResult result = visitExpression(expression); | 1234 ResolutionResult result = visitExpression(expression); |
| 1236 registry.registerSendStructure(node, const NotStructure()); | 1235 registry.registerSendStructure(node, const NotStructure()); |
| 1237 | 1236 |
| 1238 if (result.isConstant) { | 1237 if (result.isConstant) { |
| 1239 ConstantExpression expressionConstant = result.constant; | 1238 ConstantExpression expressionConstant = result.constant; |
| 1240 if (expressionConstant.getKnownType(coreTypes) == coreTypes.boolType) { | 1239 if (expressionConstant.getKnownType(commonElements) == |
| 1240 commonElements.boolType) { |
| 1241 // TODO(johnniwinther): Handle potentially invalid constant expressions. | 1241 // TODO(johnniwinther): Handle potentially invalid constant expressions. |
| 1242 ConstantExpression constant = | 1242 ConstantExpression constant = |
| 1243 new UnaryConstantExpression(operator, expressionConstant); | 1243 new UnaryConstantExpression(operator, expressionConstant); |
| 1244 registry.setConstant(node, constant); | 1244 registry.setConstant(node, constant); |
| 1245 return new ConstantResult(node, constant); | 1245 return new ConstantResult(node, constant); |
| 1246 } | 1246 } |
| 1247 } | 1247 } |
| 1248 | 1248 |
| 1249 return const NoneResult(); | 1249 return const NoneResult(); |
| 1250 } | 1250 } |
| 1251 | 1251 |
| 1252 /// Handle a logical and expression, like `a && b`. | 1252 /// Handle a logical and expression, like `a && b`. |
| 1253 ResolutionResult handleLogicalAnd(Send node) { | 1253 ResolutionResult handleLogicalAnd(Send node) { |
| 1254 Node left = node.receiver; | 1254 Node left = node.receiver; |
| 1255 Node right = node.arguments.head; | 1255 Node right = node.arguments.head; |
| 1256 ResolutionResult leftResult = | 1256 ResolutionResult leftResult = |
| 1257 doInPromotionScope(left, () => visitExpression(left)); | 1257 doInPromotionScope(left, () => visitExpression(left)); |
| 1258 ResolutionResult rightResult = | 1258 ResolutionResult rightResult = |
| 1259 doInPromotionScope(right, () => visitExpression(right)); | 1259 doInPromotionScope(right, () => visitExpression(right)); |
| 1260 registry.registerSendStructure(node, const LogicalAndStructure()); | 1260 registry.registerSendStructure(node, const LogicalAndStructure()); |
| 1261 | 1261 |
| 1262 if (leftResult.isConstant && rightResult.isConstant) { | 1262 if (leftResult.isConstant && rightResult.isConstant) { |
| 1263 ConstantExpression leftConstant = leftResult.constant; | 1263 ConstantExpression leftConstant = leftResult.constant; |
| 1264 ConstantExpression rightConstant = rightResult.constant; | 1264 ConstantExpression rightConstant = rightResult.constant; |
| 1265 if (leftConstant.getKnownType(coreTypes) == coreTypes.boolType && | 1265 if (leftConstant.getKnownType(commonElements) == |
| 1266 rightConstant.getKnownType(coreTypes) == coreTypes.boolType) { | 1266 commonElements.boolType && |
| 1267 rightConstant.getKnownType(commonElements) == |
| 1268 commonElements.boolType) { |
| 1267 // TODO(johnniwinther): Handle potentially invalid constant expressions. | 1269 // TODO(johnniwinther): Handle potentially invalid constant expressions. |
| 1268 ConstantExpression constant = new BinaryConstantExpression( | 1270 ConstantExpression constant = new BinaryConstantExpression( |
| 1269 leftConstant, BinaryOperator.LOGICAL_AND, rightConstant); | 1271 leftConstant, BinaryOperator.LOGICAL_AND, rightConstant); |
| 1270 registry.setConstant(node, constant); | 1272 registry.setConstant(node, constant); |
| 1271 return new ConstantResult(node, constant); | 1273 return new ConstantResult(node, constant); |
| 1272 } | 1274 } |
| 1273 } | 1275 } |
| 1274 | 1276 |
| 1275 return const NoneResult(); | 1277 return const NoneResult(); |
| 1276 } | 1278 } |
| 1277 | 1279 |
| 1278 /// Handle a logical or expression, like `a || b`. | 1280 /// Handle a logical or expression, like `a || b`. |
| 1279 ResolutionResult handleLogicalOr(Send node) { | 1281 ResolutionResult handleLogicalOr(Send node) { |
| 1280 Node left = node.receiver; | 1282 Node left = node.receiver; |
| 1281 Node right = node.arguments.head; | 1283 Node right = node.arguments.head; |
| 1282 ResolutionResult leftResult = visitExpression(left); | 1284 ResolutionResult leftResult = visitExpression(left); |
| 1283 ResolutionResult rightResult = visitExpression(right); | 1285 ResolutionResult rightResult = visitExpression(right); |
| 1284 registry.registerSendStructure(node, const LogicalOrStructure()); | 1286 registry.registerSendStructure(node, const LogicalOrStructure()); |
| 1285 | 1287 |
| 1286 if (leftResult.isConstant && rightResult.isConstant) { | 1288 if (leftResult.isConstant && rightResult.isConstant) { |
| 1287 ConstantExpression leftConstant = leftResult.constant; | 1289 ConstantExpression leftConstant = leftResult.constant; |
| 1288 ConstantExpression rightConstant = rightResult.constant; | 1290 ConstantExpression rightConstant = rightResult.constant; |
| 1289 if (leftConstant.getKnownType(coreTypes) == coreTypes.boolType && | 1291 if (leftConstant.getKnownType(commonElements) == |
| 1290 rightConstant.getKnownType(coreTypes) == coreTypes.boolType) { | 1292 commonElements.boolType && |
| 1293 rightConstant.getKnownType(commonElements) == |
| 1294 commonElements.boolType) { |
| 1291 // TODO(johnniwinther): Handle potentially invalid constant expressions. | 1295 // TODO(johnniwinther): Handle potentially invalid constant expressions. |
| 1292 ConstantExpression constant = new BinaryConstantExpression( | 1296 ConstantExpression constant = new BinaryConstantExpression( |
| 1293 leftConstant, BinaryOperator.LOGICAL_OR, rightConstant); | 1297 leftConstant, BinaryOperator.LOGICAL_OR, rightConstant); |
| 1294 registry.setConstant(node, constant); | 1298 registry.setConstant(node, constant); |
| 1295 return new ConstantResult(node, constant); | 1299 return new ConstantResult(node, constant); |
| 1296 } | 1300 } |
| 1297 } | 1301 } |
| 1298 return const NoneResult(); | 1302 return const NoneResult(); |
| 1299 } | 1303 } |
| 1300 | 1304 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 } else { | 1365 } else { |
| 1362 ResolutionResult leftResult = visitExpression(left); | 1366 ResolutionResult leftResult = visitExpression(left); |
| 1363 ResolutionResult rightResult = visitExpression(right); | 1367 ResolutionResult rightResult = visitExpression(right); |
| 1364 registry.registerDynamicUse(new DynamicUse(selector, null)); | 1368 registry.registerDynamicUse(new DynamicUse(selector, null)); |
| 1365 semantics = const DynamicAccess.expression(); | 1369 semantics = const DynamicAccess.expression(); |
| 1366 | 1370 |
| 1367 if (leftResult.isConstant && rightResult.isConstant) { | 1371 if (leftResult.isConstant && rightResult.isConstant) { |
| 1368 bool isValidConstant; | 1372 bool isValidConstant; |
| 1369 ConstantExpression leftConstant = leftResult.constant; | 1373 ConstantExpression leftConstant = leftResult.constant; |
| 1370 ConstantExpression rightConstant = rightResult.constant; | 1374 ConstantExpression rightConstant = rightResult.constant; |
| 1371 DartType knownLeftType = leftConstant.getKnownType(coreTypes); | 1375 DartType knownLeftType = leftConstant.getKnownType(commonElements); |
| 1372 DartType knownRightType = rightConstant.getKnownType(coreTypes); | 1376 DartType knownRightType = rightConstant.getKnownType(commonElements); |
| 1373 switch (operator.kind) { | 1377 switch (operator.kind) { |
| 1374 case BinaryOperatorKind.EQ: | 1378 case BinaryOperatorKind.EQ: |
| 1375 case BinaryOperatorKind.NOT_EQ: | 1379 case BinaryOperatorKind.NOT_EQ: |
| 1376 isValidConstant = (knownLeftType == coreTypes.intType || | 1380 isValidConstant = (knownLeftType == commonElements.intType || |
| 1377 knownLeftType == coreTypes.doubleType || | 1381 knownLeftType == commonElements.doubleType || |
| 1378 knownLeftType == coreTypes.stringType || | 1382 knownLeftType == commonElements.stringType || |
| 1379 knownLeftType == coreTypes.boolType || | 1383 knownLeftType == commonElements.boolType || |
| 1380 knownLeftType == coreTypes.nullType) && | 1384 knownLeftType == commonElements.nullType) && |
| 1381 (knownRightType == coreTypes.intType || | 1385 (knownRightType == commonElements.intType || |
| 1382 knownRightType == coreTypes.doubleType || | 1386 knownRightType == commonElements.doubleType || |
| 1383 knownRightType == coreTypes.stringType || | 1387 knownRightType == commonElements.stringType || |
| 1384 knownRightType == coreTypes.boolType || | 1388 knownRightType == commonElements.boolType || |
| 1385 knownRightType == coreTypes.nullType); | 1389 knownRightType == commonElements.nullType); |
| 1386 break; | 1390 break; |
| 1387 case BinaryOperatorKind.ADD: | 1391 case BinaryOperatorKind.ADD: |
| 1388 isValidConstant = (knownLeftType == coreTypes.intType || | 1392 isValidConstant = (knownLeftType == commonElements.intType || |
| 1389 knownLeftType == coreTypes.doubleType || | 1393 knownLeftType == commonElements.doubleType || |
| 1390 knownLeftType == coreTypes.stringType) && | 1394 knownLeftType == commonElements.stringType) && |
| 1391 (knownRightType == coreTypes.intType || | 1395 (knownRightType == commonElements.intType || |
| 1392 knownRightType == coreTypes.doubleType || | 1396 knownRightType == commonElements.doubleType || |
| 1393 knownRightType == coreTypes.stringType); | 1397 knownRightType == commonElements.stringType); |
| 1394 break; | 1398 break; |
| 1395 case BinaryOperatorKind.SUB: | 1399 case BinaryOperatorKind.SUB: |
| 1396 case BinaryOperatorKind.MUL: | 1400 case BinaryOperatorKind.MUL: |
| 1397 case BinaryOperatorKind.DIV: | 1401 case BinaryOperatorKind.DIV: |
| 1398 case BinaryOperatorKind.IDIV: | 1402 case BinaryOperatorKind.IDIV: |
| 1399 case BinaryOperatorKind.MOD: | 1403 case BinaryOperatorKind.MOD: |
| 1400 case BinaryOperatorKind.GTEQ: | 1404 case BinaryOperatorKind.GTEQ: |
| 1401 case BinaryOperatorKind.GT: | 1405 case BinaryOperatorKind.GT: |
| 1402 case BinaryOperatorKind.LTEQ: | 1406 case BinaryOperatorKind.LTEQ: |
| 1403 case BinaryOperatorKind.LT: | 1407 case BinaryOperatorKind.LT: |
| 1404 isValidConstant = (knownLeftType == coreTypes.intType || | 1408 isValidConstant = (knownLeftType == commonElements.intType || |
| 1405 knownLeftType == coreTypes.doubleType) && | 1409 knownLeftType == commonElements.doubleType) && |
| 1406 (knownRightType == coreTypes.intType || | 1410 (knownRightType == commonElements.intType || |
| 1407 knownRightType == coreTypes.doubleType); | 1411 knownRightType == commonElements.doubleType); |
| 1408 break; | 1412 break; |
| 1409 case BinaryOperatorKind.SHL: | 1413 case BinaryOperatorKind.SHL: |
| 1410 case BinaryOperatorKind.SHR: | 1414 case BinaryOperatorKind.SHR: |
| 1411 case BinaryOperatorKind.AND: | 1415 case BinaryOperatorKind.AND: |
| 1412 case BinaryOperatorKind.OR: | 1416 case BinaryOperatorKind.OR: |
| 1413 case BinaryOperatorKind.XOR: | 1417 case BinaryOperatorKind.XOR: |
| 1414 isValidConstant = knownLeftType == coreTypes.intType && | 1418 isValidConstant = knownLeftType == commonElements.intType && |
| 1415 knownRightType == coreTypes.intType; | 1419 knownRightType == commonElements.intType; |
| 1416 break; | 1420 break; |
| 1417 case BinaryOperatorKind.INDEX: | 1421 case BinaryOperatorKind.INDEX: |
| 1418 isValidConstant = false; | 1422 isValidConstant = false; |
| 1419 break; | 1423 break; |
| 1420 case BinaryOperatorKind.LOGICAL_AND: | 1424 case BinaryOperatorKind.LOGICAL_AND: |
| 1421 case BinaryOperatorKind.LOGICAL_OR: | 1425 case BinaryOperatorKind.LOGICAL_OR: |
| 1422 case BinaryOperatorKind.IF_NULL: | 1426 case BinaryOperatorKind.IF_NULL: |
| 1423 reporter.internalError( | 1427 reporter.internalError( |
| 1424 node, "Unexpected binary operator '${operator}'."); | 1428 node, "Unexpected binary operator '${operator}'."); |
| 1425 break; | 1429 break; |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2058 return handleConstantTypeLiteralUpdate(node, name, typdef, type, semantics); | 2062 return handleConstantTypeLiteralUpdate(node, name, typdef, type, semantics); |
| 2059 } | 2063 } |
| 2060 | 2064 |
| 2061 /// Handle access to a type literal of the type 'dynamic'. Like `dynamic` or | 2065 /// Handle access to a type literal of the type 'dynamic'. Like `dynamic` or |
| 2062 /// `dynamic()`. | 2066 /// `dynamic()`. |
| 2063 ResolutionResult handleDynamicTypeLiteralAccess(Send node) { | 2067 ResolutionResult handleDynamicTypeLiteralAccess(Send node) { |
| 2064 DartType type = const DynamicType(); | 2068 DartType type = const DynamicType(); |
| 2065 ConstantExpression constant = new TypeConstantExpression( | 2069 ConstantExpression constant = new TypeConstantExpression( |
| 2066 // TODO(johnniwinther): Use [type] when evaluation of constants is done | 2070 // TODO(johnniwinther): Use [type] when evaluation of constants is done |
| 2067 // directly on the constant expressions. | 2071 // directly on the constant expressions. |
| 2068 node.isCall ? coreTypes.typeType : type); | 2072 node.isCall ? commonElements.typeType : type); |
| 2069 AccessSemantics semantics = new ConstantAccess.dynamicTypeLiteral(constant); | 2073 AccessSemantics semantics = new ConstantAccess.dynamicTypeLiteral(constant); |
| 2070 return handleConstantTypeLiteralAccess(node, const PublicName('dynamic'), | 2074 return handleConstantTypeLiteralAccess(node, const PublicName('dynamic'), |
| 2071 coreClasses.typeClass, type, semantics); | 2075 commonElements.typeClass, type, semantics); |
| 2072 } | 2076 } |
| 2073 | 2077 |
| 2074 /// Handle update to a type literal of the type 'dynamic'. Like `dynamic++` or | 2078 /// Handle update to a type literal of the type 'dynamic'. Like `dynamic++` or |
| 2075 /// `dynamic = 0`. | 2079 /// `dynamic = 0`. |
| 2076 ResolutionResult handleDynamicTypeLiteralUpdate(SendSet node) { | 2080 ResolutionResult handleDynamicTypeLiteralUpdate(SendSet node) { |
| 2077 DartType type = const DynamicType(); | 2081 DartType type = const DynamicType(); |
| 2078 ConstantExpression constant = | 2082 ConstantExpression constant = |
| 2079 new TypeConstantExpression(const DynamicType()); | 2083 new TypeConstantExpression(const DynamicType()); |
| 2080 AccessSemantics semantics = new ConstantAccess.dynamicTypeLiteral(constant); | 2084 AccessSemantics semantics = new ConstantAccess.dynamicTypeLiteral(constant); |
| 2081 return handleConstantTypeLiteralUpdate(node, const PublicName('dynamic'), | 2085 return handleConstantTypeLiteralUpdate(node, const PublicName('dynamic'), |
| 2082 coreClasses.typeClass, type, semantics); | 2086 commonElements.typeClass, type, semantics); |
| 2083 } | 2087 } |
| 2084 | 2088 |
| 2085 /// Handle access to a type literal of a class. Like `C` or | 2089 /// Handle access to a type literal of a class. Like `C` or |
| 2086 /// `C()` where 'C' is class. | 2090 /// `C()` where 'C' is class. |
| 2087 ResolutionResult handleClassTypeLiteralAccess( | 2091 ResolutionResult handleClassTypeLiteralAccess( |
| 2088 Send node, Name name, ClassElement cls) { | 2092 Send node, Name name, ClassElement cls) { |
| 2089 cls.ensureResolved(resolution); | 2093 cls.ensureResolved(resolution); |
| 2090 DartType type = cls.rawType; | 2094 DartType type = cls.rawType; |
| 2091 ConstantExpression constant = new TypeConstantExpression(type); | 2095 ConstantExpression constant = new TypeConstantExpression(type); |
| 2092 AccessSemantics semantics = new ConstantAccess.classTypeLiteral(constant); | 2096 AccessSemantics semantics = new ConstantAccess.classTypeLiteral(constant); |
| (...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3583 | 3587 |
| 3584 ResolutionResult visitYield(Yield node) { | 3588 ResolutionResult visitYield(Yield node) { |
| 3585 if (!resolution.target.supportsAsyncAwait) { | 3589 if (!resolution.target.supportsAsyncAwait) { |
| 3586 reporter.reportErrorMessage( | 3590 reporter.reportErrorMessage( |
| 3587 node.yieldToken, MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); | 3591 node.yieldToken, MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); |
| 3588 } else { | 3592 } else { |
| 3589 if (!currentAsyncMarker.isYielding) { | 3593 if (!currentAsyncMarker.isYielding) { |
| 3590 reporter.reportErrorMessage(node, MessageKind.INVALID_YIELD); | 3594 reporter.reportErrorMessage(node, MessageKind.INVALID_YIELD); |
| 3591 } | 3595 } |
| 3592 if (currentAsyncMarker.isAsync) { | 3596 if (currentAsyncMarker.isAsync) { |
| 3593 coreClasses.streamClass.ensureResolved(resolution); | 3597 commonElements.streamClass.ensureResolved(resolution); |
| 3594 } else { | 3598 } else { |
| 3595 coreClasses.iterableClass.ensureResolved(resolution); | 3599 commonElements.iterableClass.ensureResolved(resolution); |
| 3596 } | 3600 } |
| 3597 } | 3601 } |
| 3598 visit(node.expression); | 3602 visit(node.expression); |
| 3599 return const NoneResult(); | 3603 return const NoneResult(); |
| 3600 } | 3604 } |
| 3601 | 3605 |
| 3602 ResolutionResult visitRedirectingFactoryBody(RedirectingFactoryBody node) { | 3606 ResolutionResult visitRedirectingFactoryBody(RedirectingFactoryBody node) { |
| 3603 if (!enclosingElement.isFactoryConstructor) { | 3607 if (!enclosingElement.isFactoryConstructor) { |
| 3604 reporter.reportErrorMessage( | 3608 reporter.reportErrorMessage( |
| 3605 node, MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY); | 3609 node, MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3720 } | 3724 } |
| 3721 | 3725 |
| 3722 ResolutionResult visitAwait(Await node) { | 3726 ResolutionResult visitAwait(Await node) { |
| 3723 if (!resolution.target.supportsAsyncAwait) { | 3727 if (!resolution.target.supportsAsyncAwait) { |
| 3724 reporter.reportErrorMessage( | 3728 reporter.reportErrorMessage( |
| 3725 node.awaitToken, MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); | 3729 node.awaitToken, MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); |
| 3726 } else { | 3730 } else { |
| 3727 if (!currentAsyncMarker.isAsync) { | 3731 if (!currentAsyncMarker.isAsync) { |
| 3728 reporter.reportErrorMessage(node, MessageKind.INVALID_AWAIT); | 3732 reporter.reportErrorMessage(node, MessageKind.INVALID_AWAIT); |
| 3729 } | 3733 } |
| 3730 coreClasses.futureClass.ensureResolved(resolution); | 3734 commonElements.futureClass.ensureResolved(resolution); |
| 3731 } | 3735 } |
| 3732 visit(node.expression); | 3736 visit(node.expression); |
| 3733 return const NoneResult(); | 3737 return const NoneResult(); |
| 3734 } | 3738 } |
| 3735 | 3739 |
| 3736 ResolutionResult visitVariableDefinitions(VariableDefinitions node) { | 3740 ResolutionResult visitVariableDefinitions(VariableDefinitions node) { |
| 3737 DartType type; | 3741 DartType type; |
| 3738 if (node.type != null) { | 3742 if (node.type != null) { |
| 3739 type = resolveTypeAnnotation(node.type); | 3743 type = resolveTypeAnnotation(node.type); |
| 3740 } else { | 3744 } else { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3902 if (node.isConst) { | 3906 if (node.isConst) { |
| 3903 bool isValidAsConstant = !isInvalid && constructor.isConst; | 3907 bool isValidAsConstant = !isInvalid && constructor.isConst; |
| 3904 | 3908 |
| 3905 CommonElements commonElements = resolution.commonElements; | 3909 CommonElements commonElements = resolution.commonElements; |
| 3906 if (commonElements.isSymbolConstructor(constructor)) { | 3910 if (commonElements.isSymbolConstructor(constructor)) { |
| 3907 Node argumentNode = node.send.arguments.head; | 3911 Node argumentNode = node.send.arguments.head; |
| 3908 ConstantExpression constant = resolver.constantCompiler | 3912 ConstantExpression constant = resolver.constantCompiler |
| 3909 .compileNode(argumentNode, registry.mapping); | 3913 .compileNode(argumentNode, registry.mapping); |
| 3910 ConstantValue name = resolution.constants.getConstantValue(constant); | 3914 ConstantValue name = resolution.constants.getConstantValue(constant); |
| 3911 if (!name.isString) { | 3915 if (!name.isString) { |
| 3912 DartType type = name.getType(coreTypes); | 3916 DartType type = name.getType(commonElements); |
| 3913 reporter.reportErrorMessage( | 3917 reporter.reportErrorMessage( |
| 3914 argumentNode, MessageKind.STRING_EXPECTED, {'type': type}); | 3918 argumentNode, MessageKind.STRING_EXPECTED, {'type': type}); |
| 3915 } else { | 3919 } else { |
| 3916 StringConstantValue stringConstant = name; | 3920 StringConstantValue stringConstant = name; |
| 3917 String nameString = stringConstant.toDartString().slowToString(); | 3921 String nameString = stringConstant.toDartString().slowToString(); |
| 3918 if (validateSymbol(argumentNode, nameString)) { | 3922 if (validateSymbol(argumentNode, nameString)) { |
| 3919 registry.registerConstSymbol(nameString); | 3923 registry.registerConstSymbol(nameString); |
| 3920 } | 3924 } |
| 3921 } | 3925 } |
| 3922 } else if (commonElements.isMirrorsUsedConstructor(constructor)) { | 3926 } else if (commonElements.isMirrorsUsedConstructor(constructor)) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3976 }; | 3980 }; |
| 3977 } | 3981 } |
| 3978 | 3982 |
| 3979 analyzeConstantDeferred(node, onAnalyzed: onAnalyzed); | 3983 analyzeConstantDeferred(node, onAnalyzed: onAnalyzed); |
| 3980 } else { | 3984 } else { |
| 3981 // Not constant. | 3985 // Not constant. |
| 3982 if (resolution.commonElements.isSymbolConstructor(constructor) && | 3986 if (resolution.commonElements.isSymbolConstructor(constructor) && |
| 3983 !resolution.mirrorUsageAnalyzerTask | 3987 !resolution.mirrorUsageAnalyzerTask |
| 3984 .hasMirrorUsage(enclosingElement)) { | 3988 .hasMirrorUsage(enclosingElement)) { |
| 3985 reporter.reportHintMessage(node.newToken, MessageKind.NON_CONST_BLOAT, | 3989 reporter.reportHintMessage(node.newToken, MessageKind.NON_CONST_BLOAT, |
| 3986 {'name': coreClasses.symbolClass.name}); | 3990 {'name': commonElements.symbolClass.name}); |
| 3987 } | 3991 } |
| 3988 registry.registerNewStructure( | 3992 registry.registerNewStructure( |
| 3989 node, | 3993 node, |
| 3990 new NewInvokeStructure( | 3994 new NewInvokeStructure( |
| 3991 new ConstructorAccessSemantics(kind, constructor, type), | 3995 new ConstructorAccessSemantics(kind, constructor, type), |
| 3992 selector)); | 3996 selector)); |
| 3993 } | 3997 } |
| 3994 | 3998 |
| 3995 return resolutionResult; | 3999 return resolutionResult; |
| 3996 } | 4000 } |
| 3997 | 4001 |
| 3998 void checkConstMapKeysDontOverrideEquals( | 4002 void checkConstMapKeysDontOverrideEquals( |
| 3999 Spannable spannable, MapConstantValue map) { | 4003 Spannable spannable, MapConstantValue map) { |
| 4000 for (ConstantValue key in map.keys) { | 4004 for (ConstantValue key in map.keys) { |
| 4001 if (!key.isObject) continue; | 4005 if (!key.isObject) continue; |
| 4002 ObjectConstantValue objectConstant = key; | 4006 ObjectConstantValue objectConstant = key; |
| 4003 DartType keyType = objectConstant.type; | 4007 DartType keyType = objectConstant.type; |
| 4004 ClassElement cls = keyType.element; | 4008 ClassElement cls = keyType.element; |
| 4005 if (cls == coreClasses.stringClass) continue; | 4009 if (cls == commonElements.stringClass) continue; |
| 4006 Element equals = cls.lookupMember('=='); | 4010 Element equals = cls.lookupMember('=='); |
| 4007 if (equals.enclosingClass != coreClasses.objectClass) { | 4011 if (equals.enclosingClass != commonElements.objectClass) { |
| 4008 reporter.reportErrorMessage(spannable, | 4012 reporter.reportErrorMessage(spannable, |
| 4009 MessageKind.CONST_MAP_KEY_OVERRIDES_EQUALS, {'type': keyType}); | 4013 MessageKind.CONST_MAP_KEY_OVERRIDES_EQUALS, {'type': keyType}); |
| 4010 } | 4014 } |
| 4011 } | 4015 } |
| 4012 } | 4016 } |
| 4013 | 4017 |
| 4014 void analyzeConstant(Node node, {enforceConst: true}) { | 4018 void analyzeConstant(Node node, {enforceConst: true}) { |
| 4015 ConstantExpression constant = resolver.constantCompiler | 4019 ConstantExpression constant = resolver.constantCompiler |
| 4016 .compileNode(node, registry.mapping, enforceConst: enforceConst); | 4020 .compileNode(node, registry.mapping, enforceConst: enforceConst); |
| 4017 | 4021 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4106 } | 4110 } |
| 4107 } | 4111 } |
| 4108 } | 4112 } |
| 4109 DartType listType; | 4113 DartType listType; |
| 4110 if (typeArgument != null) { | 4114 if (typeArgument != null) { |
| 4111 if (node.isConst && typeArgument.containsTypeVariables) { | 4115 if (node.isConst && typeArgument.containsTypeVariables) { |
| 4112 reporter.reportErrorMessage( | 4116 reporter.reportErrorMessage( |
| 4113 arguments.nodes.head, MessageKind.TYPE_VARIABLE_IN_CONSTANT); | 4117 arguments.nodes.head, MessageKind.TYPE_VARIABLE_IN_CONSTANT); |
| 4114 isValidAsConstant = false; | 4118 isValidAsConstant = false; |
| 4115 } | 4119 } |
| 4116 listType = coreTypes.listType(typeArgument); | 4120 listType = commonElements.listType(typeArgument); |
| 4117 } else { | 4121 } else { |
| 4118 listType = coreTypes.listType(); | 4122 listType = commonElements.listType(); |
| 4119 } | 4123 } |
| 4120 registry.registerLiteralList(node, listType, | 4124 registry.registerLiteralList(node, listType, |
| 4121 isConstant: node.isConst, isEmpty: node.elements.isEmpty); | 4125 isConstant: node.isConst, isEmpty: node.elements.isEmpty); |
| 4122 if (node.isConst) { | 4126 if (node.isConst) { |
| 4123 List<ConstantExpression> constantExpressions = <ConstantExpression>[]; | 4127 List<ConstantExpression> constantExpressions = <ConstantExpression>[]; |
| 4124 inConstantContext(() { | 4128 inConstantContext(() { |
| 4125 for (Node element in node.elements) { | 4129 for (Node element in node.elements) { |
| 4126 ResolutionResult elementResult = visit(element); | 4130 ResolutionResult elementResult = visit(element); |
| 4127 if (isValidAsConstant && elementResult.isConstant) { | 4131 if (isValidAsConstant && elementResult.isConstant) { |
| 4128 constantExpressions.add(elementResult.constant); | 4132 constantExpressions.add(elementResult.constant); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4404 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { | 4408 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { |
| 4405 reporter.reportWarningMessage( | 4409 reporter.reportWarningMessage( |
| 4406 nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); | 4410 nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); |
| 4407 resolveTypeAnnotation(nodes.head); | 4411 resolveTypeAnnotation(nodes.head); |
| 4408 } | 4412 } |
| 4409 } | 4413 } |
| 4410 } | 4414 } |
| 4411 } | 4415 } |
| 4412 DartType mapType; | 4416 DartType mapType; |
| 4413 if (valueTypeArgument != null) { | 4417 if (valueTypeArgument != null) { |
| 4414 mapType = coreTypes.mapType(keyTypeArgument, valueTypeArgument); | 4418 mapType = commonElements.mapType(keyTypeArgument, valueTypeArgument); |
| 4415 } else { | 4419 } else { |
| 4416 mapType = coreTypes.mapType(); | 4420 mapType = commonElements.mapType(); |
| 4417 } | 4421 } |
| 4418 if (node.isConst && mapType.containsTypeVariables) { | 4422 if (node.isConst && mapType.containsTypeVariables) { |
| 4419 reporter.reportErrorMessage( | 4423 reporter.reportErrorMessage( |
| 4420 arguments, MessageKind.TYPE_VARIABLE_IN_CONSTANT); | 4424 arguments, MessageKind.TYPE_VARIABLE_IN_CONSTANT); |
| 4421 isValidAsConstant = false; | 4425 isValidAsConstant = false; |
| 4422 } | 4426 } |
| 4423 registry.registerMapLiteral(node, mapType, | 4427 registry.registerMapLiteral(node, mapType, |
| 4424 isConstant: node.isConst, isEmpty: node.entries.isEmpty); | 4428 isConstant: node.isConst, isEmpty: node.entries.isEmpty); |
| 4425 | 4429 |
| 4426 if (node.isConst) { | 4430 if (node.isConst) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4458 ResolutionResult visitLiteralMapEntry(LiteralMapEntry node) { | 4462 ResolutionResult visitLiteralMapEntry(LiteralMapEntry node) { |
| 4459 node.visitChildren(this); | 4463 node.visitChildren(this); |
| 4460 return const NoneResult(); | 4464 return const NoneResult(); |
| 4461 } | 4465 } |
| 4462 | 4466 |
| 4463 ResolutionResult visitNamedArgument(NamedArgument node) { | 4467 ResolutionResult visitNamedArgument(NamedArgument node) { |
| 4464 return visit(node.expression); | 4468 return visit(node.expression); |
| 4465 } | 4469 } |
| 4466 | 4470 |
| 4467 DartType typeOfConstant(ConstantValue constant) { | 4471 DartType typeOfConstant(ConstantValue constant) { |
| 4468 if (constant.isInt) return coreTypes.intType; | 4472 if (constant.isInt) return commonElements.intType; |
| 4469 if (constant.isBool) return coreTypes.boolType; | 4473 if (constant.isBool) return commonElements.boolType; |
| 4470 if (constant.isDouble) return coreTypes.doubleType; | 4474 if (constant.isDouble) return commonElements.doubleType; |
| 4471 if (constant.isString) return coreTypes.stringType; | 4475 if (constant.isString) return commonElements.stringType; |
| 4472 if (constant.isNull) return coreTypes.nullType; | 4476 if (constant.isNull) return commonElements.nullType; |
| 4473 if (constant.isFunction) return coreTypes.functionType; | 4477 if (constant.isFunction) return commonElements.functionType; |
| 4474 assert(constant.isObject); | 4478 assert(constant.isObject); |
| 4475 ObjectConstantValue objectConstant = constant; | 4479 ObjectConstantValue objectConstant = constant; |
| 4476 return objectConstant.type; | 4480 return objectConstant.type; |
| 4477 } | 4481 } |
| 4478 | 4482 |
| 4479 bool overridesEquals(DartType type) { | 4483 bool overridesEquals(DartType type) { |
| 4480 ClassElement cls = type.element; | 4484 ClassElement cls = type.element; |
| 4481 Element equals = cls.lookupMember('=='); | 4485 Element equals = cls.lookupMember('=='); |
| 4482 return equals.enclosingClass != coreClasses.objectClass; | 4486 return equals.enclosingClass != commonElements.objectClass; |
| 4483 } | 4487 } |
| 4484 | 4488 |
| 4485 void checkCaseExpressions(SwitchStatement node) { | 4489 void checkCaseExpressions(SwitchStatement node) { |
| 4486 CaseMatch firstCase = null; | 4490 CaseMatch firstCase = null; |
| 4487 DartType firstCaseType = null; | 4491 DartType firstCaseType = null; |
| 4488 DiagnosticMessage error; | 4492 DiagnosticMessage error; |
| 4489 List<DiagnosticMessage> infos = <DiagnosticMessage>[]; | 4493 List<DiagnosticMessage> infos = <DiagnosticMessage>[]; |
| 4490 | 4494 |
| 4491 for (Link<Node> cases = node.cases.nodes; | 4495 for (Link<Node> cases = node.cases.nodes; |
| 4492 !cases.isEmpty; | 4496 !cases.isEmpty; |
| 4493 cases = cases.tail) { | 4497 cases = cases.tail) { |
| 4494 SwitchCase switchCase = cases.head; | 4498 SwitchCase switchCase = cases.head; |
| 4495 | 4499 |
| 4496 for (Node labelOrCase in switchCase.labelsAndCases) { | 4500 for (Node labelOrCase in switchCase.labelsAndCases) { |
| 4497 CaseMatch caseMatch = labelOrCase.asCaseMatch(); | 4501 CaseMatch caseMatch = labelOrCase.asCaseMatch(); |
| 4498 if (caseMatch == null) continue; | 4502 if (caseMatch == null) continue; |
| 4499 | 4503 |
| 4500 // Analyze the constant. | 4504 // Analyze the constant. |
| 4501 ConstantExpression constant = | 4505 ConstantExpression constant = |
| 4502 registry.getConstant(caseMatch.expression); | 4506 registry.getConstant(caseMatch.expression); |
| 4503 assert(invariant(node, constant != null, | 4507 assert(invariant(node, constant != null, |
| 4504 message: 'No constant computed for $node')); | 4508 message: 'No constant computed for $node')); |
| 4505 | 4509 |
| 4506 ConstantValue value = resolution.constants.getConstantValue(constant); | 4510 ConstantValue value = resolution.constants.getConstantValue(constant); |
| 4507 DartType caseType = value.getType(coreTypes); //typeOfConstant(value); | 4511 DartType caseType = |
| 4512 value.getType(commonElements); //typeOfConstant(value); |
| 4508 | 4513 |
| 4509 if (firstCaseType == null) { | 4514 if (firstCaseType == null) { |
| 4510 firstCase = caseMatch; | 4515 firstCase = caseMatch; |
| 4511 firstCaseType = caseType; | 4516 firstCaseType = caseType; |
| 4512 | 4517 |
| 4513 // We only report the bad type on the first class element. All others | 4518 // We only report the bad type on the first class element. All others |
| 4514 // get a "type differs" error. | 4519 // get a "type differs" error. |
| 4515 if (caseType == coreTypes.doubleType) { | 4520 if (caseType == commonElements.doubleType) { |
| 4516 reporter.reportErrorMessage( | 4521 reporter.reportErrorMessage( |
| 4517 node, | 4522 node, |
| 4518 MessageKind.SWITCH_CASE_VALUE_OVERRIDES_EQUALS, | 4523 MessageKind.SWITCH_CASE_VALUE_OVERRIDES_EQUALS, |
| 4519 {'type': "double"}); | 4524 {'type': "double"}); |
| 4520 } else if (caseType == coreTypes.functionType) { | 4525 } else if (caseType == commonElements.functionType) { |
| 4521 reporter.reportErrorMessage( | 4526 reporter.reportErrorMessage( |
| 4522 node, MessageKind.SWITCH_CASE_FORBIDDEN, {'type': "Function"}); | 4527 node, MessageKind.SWITCH_CASE_FORBIDDEN, {'type': "Function"}); |
| 4523 } else if (value.isObject && overridesEquals(caseType)) { | 4528 } else if (value.isObject && overridesEquals(caseType)) { |
| 4524 reporter.reportErrorMessage( | 4529 reporter.reportErrorMessage( |
| 4525 firstCase.expression, | 4530 firstCase.expression, |
| 4526 MessageKind.SWITCH_CASE_VALUE_OVERRIDES_EQUALS, | 4531 MessageKind.SWITCH_CASE_VALUE_OVERRIDES_EQUALS, |
| 4527 {'type': caseType}); | 4532 {'type': caseType}); |
| 4528 } | 4533 } |
| 4529 } else { | 4534 } else { |
| 4530 if (caseType != firstCaseType) { | 4535 if (caseType != firstCaseType) { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4733 VariableElementX exceptionElement = | 4738 VariableElementX exceptionElement = |
| 4734 registry.getDefinition(exceptionVariable); | 4739 registry.getDefinition(exceptionVariable); |
| 4735 exceptionElement.variables.type = exceptionType; | 4740 exceptionElement.variables.type = exceptionType; |
| 4736 } | 4741 } |
| 4737 registry.registerTypeUse(new TypeUse.catchType(exceptionType)); | 4742 registry.registerTypeUse(new TypeUse.catchType(exceptionType)); |
| 4738 } | 4743 } |
| 4739 if (stackTraceDefinition != null) { | 4744 if (stackTraceDefinition != null) { |
| 4740 Node stackTraceVariable = stackTraceDefinition.definitions.nodes.head; | 4745 Node stackTraceVariable = stackTraceDefinition.definitions.nodes.head; |
| 4741 VariableElementX stackTraceElement = | 4746 VariableElementX stackTraceElement = |
| 4742 registry.getDefinition(stackTraceVariable); | 4747 registry.getDefinition(stackTraceVariable); |
| 4743 InterfaceType stackTraceType = coreTypes.stackTraceType; | 4748 InterfaceType stackTraceType = commonElements.stackTraceType; |
| 4744 stackTraceElement.variables.type = stackTraceType; | 4749 stackTraceElement.variables.type = stackTraceType; |
| 4745 } | 4750 } |
| 4746 return const NoneResult(); | 4751 return const NoneResult(); |
| 4747 } | 4752 } |
| 4748 } | 4753 } |
| 4749 | 4754 |
| 4750 /// Looks up [name] in [scope] and unwraps the result. | 4755 /// Looks up [name] in [scope] and unwraps the result. |
| 4751 Element lookupInScope( | 4756 Element lookupInScope( |
| 4752 DiagnosticReporter reporter, Node node, Scope scope, String name) { | 4757 DiagnosticReporter reporter, Node node, Scope scope, String name) { |
| 4753 return Elements.unwrap(scope.lookup(name), reporter, node); | 4758 return Elements.unwrap(scope.lookup(name), reporter, node); |
| 4754 } | 4759 } |
| OLD | NEW |