OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /** | 5 /** |
6 * This library is capable of producing linked summaries from unlinked | 6 * This library is capable of producing linked summaries from unlinked |
7 * ones (or prelinked ones). It functions by building a miniature | 7 * ones (or prelinked ones). It functions by building a miniature |
8 * element model to represent the contents of the summaries, and then | 8 * element model to represent the contents of the summaries, and then |
9 * scanning the element model to gather linked information and adding | 9 * scanning the element model to gather linked information and adding |
10 * it to the summary data structures. | 10 * it to the summary data structures. |
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 'Linker tried to access linked type from current build unit'); | 1349 'Linker tried to access linked type from current build unit'); |
1350 } | 1350 } |
1351 | 1351 |
1352 /** | 1352 /** |
1353 * Perform type inference and const cycle detection on this | 1353 * Perform type inference and const cycle detection on this |
1354 * compilation unit. | 1354 * compilation unit. |
1355 */ | 1355 */ |
1356 void link() { | 1356 void link() { |
1357 if (library._linker.strongMode) { | 1357 if (library._linker.strongMode) { |
1358 new InstanceMemberInferrer( | 1358 new InstanceMemberInferrer( |
1359 enclosingElement._linker.typeProvider, | 1359 enclosingElement._linker.typeProvider, |
1360 (clazz) => (clazz.library as LibraryElementInBuildUnit) | 1360 (clazz) => (clazz.library as LibraryElementInBuildUnit) |
1361 .inheritanceManager, | 1361 .inheritanceManager).inferCompilationUnit(this); |
1362 new Set<FieldElement>()) | |
1363 .inferCompilationUnit(this); | |
1364 for (TopLevelVariableElementForLink variable in topLevelVariables) { | 1362 for (TopLevelVariableElementForLink variable in topLevelVariables) { |
1365 variable.link(this); | 1363 variable.link(this); |
1366 } | 1364 } |
1367 } | 1365 } |
1368 for (ClassElementForLink classElement in types) { | 1366 for (ClassElementForLink classElement in types) { |
1369 classElement.link(this); | 1367 classElement.link(this); |
1370 } | 1368 } |
1371 } | 1369 } |
1372 | 1370 |
1373 /** | 1371 /** |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2123 case UnlinkedExprOperation.pushNull: | 2121 case UnlinkedExprOperation.pushNull: |
2124 stack.add(typeProvider.nullType); | 2122 stack.add(typeProvider.nullType); |
2125 break; | 2123 break; |
2126 case UnlinkedExprOperation.pushSuper: | 2124 case UnlinkedExprOperation.pushSuper: |
2127 stack.add(DynamicTypeImpl.instance); | 2125 stack.add(DynamicTypeImpl.instance); |
2128 break; | 2126 break; |
2129 case UnlinkedExprOperation.pushThis: | 2127 case UnlinkedExprOperation.pushThis: |
2130 stack.add(DynamicTypeImpl.instance); | 2128 stack.add(DynamicTypeImpl.instance); |
2131 break; | 2129 break; |
2132 case UnlinkedExprOperation.pushReference: | 2130 case UnlinkedExprOperation.pushReference: |
2133 try { | 2131 _doPushReference(); |
2134 _doPushReference(); | |
2135 } on _InferenceFailedError { | |
2136 errorKind = TopLevelInferenceErrorKind.instanceGetter; | |
2137 return DynamicTypeImpl.instance; | |
2138 } | |
2139 break; | 2132 break; |
2140 case UnlinkedExprOperation.extractProperty: | 2133 case UnlinkedExprOperation.extractProperty: |
2141 try { | 2134 _doExtractProperty(); |
2142 _doExtractProperty(); | |
2143 } on _InferenceFailedError { | |
2144 errorKind = TopLevelInferenceErrorKind.instanceGetter; | |
2145 return DynamicTypeImpl.instance; | |
2146 } | |
2147 break; | 2135 break; |
2148 case UnlinkedExprOperation.invokeConstructor: | 2136 case UnlinkedExprOperation.invokeConstructor: |
2149 _doInvokeConstructor(); | 2137 _doInvokeConstructor(); |
2150 break; | 2138 break; |
2151 case UnlinkedExprOperation.makeUntypedList: | 2139 case UnlinkedExprOperation.makeUntypedList: |
2152 _doMakeUntypedList(); | 2140 _doMakeUntypedList(); |
2153 break; | 2141 break; |
2154 case UnlinkedExprOperation.makeUntypedMap: | 2142 case UnlinkedExprOperation.makeUntypedMap: |
2155 _doMakeUntypedMap(); | 2143 _doMakeUntypedMap(); |
2156 break; | 2144 break; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2219 case UnlinkedExprOperation.lessEqual: | 2207 case UnlinkedExprOperation.lessEqual: |
2220 _computeBinaryExpressionType(TokenType.LT_EQ); | 2208 _computeBinaryExpressionType(TokenType.LT_EQ); |
2221 break; | 2209 break; |
2222 case UnlinkedExprOperation.modulo: | 2210 case UnlinkedExprOperation.modulo: |
2223 _computeBinaryExpressionType(TokenType.PERCENT); | 2211 _computeBinaryExpressionType(TokenType.PERCENT); |
2224 break; | 2212 break; |
2225 case UnlinkedExprOperation.conditional: | 2213 case UnlinkedExprOperation.conditional: |
2226 _doConditional(); | 2214 _doConditional(); |
2227 break; | 2215 break; |
2228 case UnlinkedExprOperation.assignToIndex: | 2216 case UnlinkedExprOperation.assignToIndex: |
| 2217 _doAssignToIndex(); |
| 2218 break; |
2229 case UnlinkedExprOperation.assignToProperty: | 2219 case UnlinkedExprOperation.assignToProperty: |
| 2220 _doAssignToProperty(); |
| 2221 break; |
2230 case UnlinkedExprOperation.assignToRef: | 2222 case UnlinkedExprOperation.assignToRef: |
2231 errorKind = TopLevelInferenceErrorKind.assignment; | 2223 _doAssignToRef(); |
2232 return DynamicTypeImpl.instance; | 2224 break; |
2233 case UnlinkedExprOperation.await: | 2225 case UnlinkedExprOperation.await: |
2234 _doAwait(); | 2226 _doAwait(); |
2235 break; | 2227 break; |
2236 case UnlinkedExprOperation.extractIndex: | 2228 case UnlinkedExprOperation.extractIndex: |
2237 _doExtractIndex(); | 2229 _doExtractIndex(); |
2238 break; | 2230 break; |
2239 case UnlinkedExprOperation.invokeMethodRef: | 2231 case UnlinkedExprOperation.invokeMethodRef: |
2240 try { | 2232 _doInvokeMethodRef(); |
2241 _doInvokeMethodRef(); | |
2242 } on _InferenceFailedError { | |
2243 errorKind = TopLevelInferenceErrorKind.instanceGetter; | |
2244 return DynamicTypeImpl.instance; | |
2245 } | |
2246 break; | 2233 break; |
2247 case UnlinkedExprOperation.invokeMethod: | 2234 case UnlinkedExprOperation.invokeMethod: |
2248 _doInvokeMethod(); | 2235 _doInvokeMethod(); |
2249 break; | 2236 break; |
2250 case UnlinkedExprOperation.cascadeSectionBegin: | 2237 case UnlinkedExprOperation.cascadeSectionBegin: |
2251 stack.add(stack.last); | 2238 stack.add(stack.last); |
2252 break; | 2239 break; |
2253 case UnlinkedExprOperation.cascadeSectionEnd: | 2240 case UnlinkedExprOperation.cascadeSectionEnd: |
2254 stack.removeLast(); | 2241 stack.removeLast(); |
2255 break; | 2242 break; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2304 operand.lookUpInheritedMethod(operatorName, library: library); | 2291 operand.lookUpInheritedMethod(operatorName, library: library); |
2305 if (method != null) { | 2292 if (method != null) { |
2306 DartType type = method.returnType; | 2293 DartType type = method.returnType; |
2307 stack.add(type); | 2294 stack.add(type); |
2308 return; | 2295 return; |
2309 } | 2296 } |
2310 } | 2297 } |
2311 stack.add(DynamicTypeImpl.instance); | 2298 stack.add(DynamicTypeImpl.instance); |
2312 } | 2299 } |
2313 | 2300 |
| 2301 void _doAssignment() { |
| 2302 UnlinkedExprAssignOperator operator = |
| 2303 unlinkedConst.assignmentOperators[assignmentOperatorPtr++]; |
| 2304 if (isIncrementOrDecrement(operator)) { |
| 2305 _doIncrementOrDecrement(operator); |
| 2306 return; |
| 2307 } |
| 2308 if (operator == UnlinkedExprAssignOperator.assign) { |
| 2309 stack.removeLast(); |
| 2310 return; // type is on the stack |
| 2311 } |
| 2312 TokenType binaryOperator = _convertAssignOperatorToTokenType(operator); |
| 2313 _computeBinaryExpressionType(binaryOperator); |
| 2314 } |
| 2315 |
| 2316 void _doAssignToIndex() { |
| 2317 _doExtractIndex(); |
| 2318 _doAssignment(); |
| 2319 } |
| 2320 |
| 2321 void _doAssignToProperty() { |
| 2322 _doExtractProperty(); |
| 2323 _doAssignment(); |
| 2324 } |
| 2325 |
| 2326 void _doAssignToRef() { |
| 2327 EntityRef ref = _getNextRef(); |
| 2328 ReferenceableElementForLink element = unit.resolveRef(ref.reference); |
| 2329 stack.add(element.asStaticType); |
| 2330 _doAssignment(); |
| 2331 } |
| 2332 |
2314 void _doAwait() { | 2333 void _doAwait() { |
2315 DartType type = stack.removeLast(); | 2334 DartType type = stack.removeLast(); |
2316 DartType typeArgument = type?.flattenFutures(linker.typeSystem); | 2335 DartType typeArgument = type?.flattenFutures(linker.typeSystem); |
2317 typeArgument = _dynamicIfNull(typeArgument); | 2336 typeArgument = _dynamicIfNull(typeArgument); |
2318 stack.add(typeArgument); | 2337 stack.add(typeArgument); |
2319 } | 2338 } |
2320 | 2339 |
2321 void _doConditional() { | 2340 void _doConditional() { |
2322 DartType elseType = stack.removeLast(); | 2341 DartType elseType = stack.removeLast(); |
2323 DartType thenType = stack.removeLast(); | 2342 DartType thenType = stack.removeLast(); |
(...skipping 22 matching lines...) Expand all Loading... |
2346 DartType target = stack.removeLast(); | 2365 DartType target = stack.removeLast(); |
2347 if (target.isDynamic) { | 2366 if (target.isDynamic) { |
2348 target = typeProvider.objectType; | 2367 target = typeProvider.objectType; |
2349 } | 2368 } |
2350 String propertyName = _getNextString(); | 2369 String propertyName = _getNextString(); |
2351 stack.add(() { | 2370 stack.add(() { |
2352 if (target is InterfaceType) { | 2371 if (target is InterfaceType) { |
2353 ExecutableElement element = target | 2372 ExecutableElement element = target |
2354 .lookUpInheritedGetterOrMethod(propertyName, library: library); | 2373 .lookUpInheritedGetterOrMethod(propertyName, library: library); |
2355 if (element != null) { | 2374 if (element != null) { |
2356 _throwIfInstanceFieldOrAccessor(element); | |
2357 if (element is PropertyAccessorElement) { | 2375 if (element is PropertyAccessorElement) { |
2358 return element.returnType; | 2376 return element.returnType; |
2359 } else { | 2377 } else { |
2360 // Method tear-off | 2378 // Method tear-off |
2361 return element.type; | 2379 return element.type; |
2362 } | 2380 } |
2363 } | 2381 } |
2364 } | 2382 } |
2365 return DynamicTypeImpl.instance; | 2383 return DynamicTypeImpl.instance; |
2366 }()); | 2384 }()); |
2367 } | 2385 } |
2368 | 2386 |
2369 void _doIfNull() { | 2387 void _doIfNull() { |
2370 DartType secondType = stack.removeLast(); | 2388 DartType secondType = stack.removeLast(); |
2371 DartType firstType = stack.removeLast(); | 2389 DartType firstType = stack.removeLast(); |
2372 DartType type = _leastUpperBound(firstType, secondType); | 2390 DartType type = _leastUpperBound(firstType, secondType); |
2373 type = _dynamicIfNull(type); | 2391 type = _dynamicIfNull(type); |
2374 stack.add(type); | 2392 stack.add(type); |
2375 } | 2393 } |
2376 | 2394 |
| 2395 void _doIncrementOrDecrement(UnlinkedExprAssignOperator operator) { |
| 2396 switch (operator) { |
| 2397 case UnlinkedExprAssignOperator.prefixDecrement: |
| 2398 stack.add(typeProvider.intType); |
| 2399 _computeBinaryExpressionType(TokenType.MINUS); |
| 2400 return; |
| 2401 case UnlinkedExprAssignOperator.prefixIncrement: |
| 2402 stack.add(typeProvider.intType); |
| 2403 _computeBinaryExpressionType(TokenType.PLUS); |
| 2404 return; |
| 2405 case UnlinkedExprAssignOperator.postfixDecrement: |
| 2406 case UnlinkedExprAssignOperator.postfixIncrement: |
| 2407 return; // Return the operand type |
| 2408 default: |
| 2409 stack.removeLast(); |
| 2410 stack.add(DynamicTypeImpl.instance); |
| 2411 return; |
| 2412 } |
| 2413 } |
| 2414 |
2377 void _doInvokeConstructor() { | 2415 void _doInvokeConstructor() { |
2378 int numNamed = unlinkedConst.ints[intPtr++]; | 2416 int numNamed = unlinkedConst.ints[intPtr++]; |
2379 int numPositional = unlinkedConst.ints[intPtr++]; | 2417 int numPositional = unlinkedConst.ints[intPtr++]; |
2380 List<String> namedArgNames = _getNextStrings(numNamed); | 2418 List<String> namedArgNames = _getNextStrings(numNamed); |
2381 List<DartType> namedArgTypeList = _popList(numNamed); | 2419 List<DartType> namedArgTypeList = _popList(numNamed); |
2382 List<DartType> positionalArgTypes = _popList(numPositional); | 2420 List<DartType> positionalArgTypes = _popList(numPositional); |
2383 | 2421 |
2384 EntityRef ref = _getNextRef(); | 2422 EntityRef ref = _getNextRef(); |
2385 ReferenceableElementForLink refElement = unit.resolveRef(ref.reference); | 2423 ReferenceableElementForLink refElement = unit.resolveRef(ref.reference); |
2386 ConstructorElementForLink constructorElement = refElement.asConstructor; | 2424 ConstructorElementForLink constructorElement = refElement.asConstructor; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2461 } | 2499 } |
2462 | 2500 |
2463 void _doInvokeMethodRef() { | 2501 void _doInvokeMethodRef() { |
2464 int numNamed = _getNextInt(); | 2502 int numNamed = _getNextInt(); |
2465 int numPositional = _getNextInt(); | 2503 int numPositional = _getNextInt(); |
2466 List<String> namedArgNames = _getNextStrings(numNamed); | 2504 List<String> namedArgNames = _getNextStrings(numNamed); |
2467 List<DartType> namedArgTypeList = _popList(numNamed); | 2505 List<DartType> namedArgTypeList = _popList(numNamed); |
2468 List<DartType> positionalArgTypes = _popList(numPositional); | 2506 List<DartType> positionalArgTypes = _popList(numPositional); |
2469 EntityRef ref = _getNextRef(); | 2507 EntityRef ref = _getNextRef(); |
2470 ReferenceableElementForLink element = unit.resolveRef(ref.reference); | 2508 ReferenceableElementForLink element = unit.resolveRef(ref.reference); |
2471 _throwIfInstanceFieldOrAccessor(element); | |
2472 List<DartType> typeArguments = _getTypeArguments(); | 2509 List<DartType> typeArguments = _getTypeArguments(); |
2473 stack.add(() { | 2510 stack.add(() { |
2474 DartType rawType = element.asStaticType; | 2511 DartType rawType = element.asStaticType; |
2475 if (rawType is FunctionType) { | 2512 if (rawType is FunctionType) { |
2476 FunctionType inferredType = _inferExecutableType( | 2513 FunctionType inferredType = _inferExecutableType( |
2477 rawType, | 2514 rawType, |
2478 numNamed, | 2515 numNamed, |
2479 numPositional, | 2516 numPositional, |
2480 namedArgNames, | 2517 namedArgNames, |
2481 namedArgTypeList, | 2518 namedArgTypeList, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2535 if (ref.paramReference != 0) { | 2572 if (ref.paramReference != 0) { |
2536 stack.add(typeProvider.typeType); | 2573 stack.add(typeProvider.typeType); |
2537 } else { | 2574 } else { |
2538 // Synthetic function types can't be directly referred | 2575 // Synthetic function types can't be directly referred |
2539 // to by expressions. | 2576 // to by expressions. |
2540 assert(ref.syntheticReturnType == null); | 2577 assert(ref.syntheticReturnType == null); |
2541 // Nor can implicit function types derived from | 2578 // Nor can implicit function types derived from |
2542 // function-typed parameters. | 2579 // function-typed parameters. |
2543 assert(ref.implicitFunctionTypeIndices.isEmpty); | 2580 assert(ref.implicitFunctionTypeIndices.isEmpty); |
2544 ReferenceableElementForLink element = unit.resolveRef(ref.reference); | 2581 ReferenceableElementForLink element = unit.resolveRef(ref.reference); |
2545 _throwIfInstanceFieldOrAccessor(element); | |
2546 stack.add(element.asStaticType); | 2582 stack.add(element.asStaticType); |
2547 } | 2583 } |
2548 } | 2584 } |
2549 | 2585 |
2550 /** | 2586 /** |
2551 * Find the parameter in scope called [parameterName] and return its type. | 2587 * Find the parameter in scope called [parameterName] and return its type. |
2552 */ | 2588 */ |
2553 DartType _findParameterType(String parameterName) { | 2589 DartType _findParameterType(String parameterName) { |
2554 FunctionElementForLink_Local f = this.function; | 2590 FunctionElementForLink_Local f = this.function; |
2555 while (true) { | 2591 while (true) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2686 DartType type = method.returnType; | 2722 DartType type = method.returnType; |
2687 type = linker.typeSystem | 2723 type = linker.typeSystem |
2688 .refineBinaryExpressionType(left, operator, right, type); | 2724 .refineBinaryExpressionType(left, operator, right, type); |
2689 stack.add(type); | 2725 stack.add(type); |
2690 return; | 2726 return; |
2691 } | 2727 } |
2692 } | 2728 } |
2693 stack.add(DynamicTypeImpl.instance); | 2729 stack.add(DynamicTypeImpl.instance); |
2694 } | 2730 } |
2695 | 2731 |
2696 void _throwIfInstanceFieldOrAccessor(Object element) { | 2732 static TokenType _convertAssignOperatorToTokenType( |
2697 if (element is NonstaticMemberElementForLink && | 2733 UnlinkedExprAssignOperator o) { |
2698 element.hasInstanceGetterReference || | 2734 switch (o) { |
2699 element is FieldElement && !element.isStatic || | 2735 case UnlinkedExprAssignOperator.assign: |
2700 element is PropertyAccessorElement && !element.isStatic) { | 2736 return null; |
2701 throw new _InferenceFailedError( | 2737 case UnlinkedExprAssignOperator.ifNull: |
2702 'Instance fields cannot be used for type inference.'); | 2738 return TokenType.QUESTION_QUESTION; |
| 2739 case UnlinkedExprAssignOperator.multiply: |
| 2740 return TokenType.STAR; |
| 2741 case UnlinkedExprAssignOperator.divide: |
| 2742 return TokenType.SLASH; |
| 2743 case UnlinkedExprAssignOperator.floorDivide: |
| 2744 return TokenType.TILDE_SLASH; |
| 2745 case UnlinkedExprAssignOperator.modulo: |
| 2746 return TokenType.PERCENT; |
| 2747 case UnlinkedExprAssignOperator.plus: |
| 2748 return TokenType.PLUS; |
| 2749 case UnlinkedExprAssignOperator.minus: |
| 2750 return TokenType.MINUS; |
| 2751 case UnlinkedExprAssignOperator.shiftLeft: |
| 2752 return TokenType.LT_LT; |
| 2753 case UnlinkedExprAssignOperator.shiftRight: |
| 2754 return TokenType.GT_GT; |
| 2755 case UnlinkedExprAssignOperator.bitAnd: |
| 2756 return TokenType.AMPERSAND; |
| 2757 case UnlinkedExprAssignOperator.bitXor: |
| 2758 return TokenType.CARET; |
| 2759 case UnlinkedExprAssignOperator.bitOr: |
| 2760 return TokenType.BAR; |
| 2761 case UnlinkedExprAssignOperator.prefixIncrement: |
| 2762 return TokenType.PLUS_PLUS; |
| 2763 case UnlinkedExprAssignOperator.prefixDecrement: |
| 2764 return TokenType.MINUS_MINUS; |
| 2765 case UnlinkedExprAssignOperator.postfixIncrement: |
| 2766 return TokenType.PLUS_PLUS; |
| 2767 case UnlinkedExprAssignOperator.postfixDecrement: |
| 2768 return TokenType.MINUS_MINUS; |
2703 } | 2769 } |
| 2770 return null; |
2704 } | 2771 } |
2705 } | 2772 } |
2706 | 2773 |
2707 /** | 2774 /** |
2708 * Element representing a field resynthesized from a summary during | 2775 * Element representing a field resynthesized from a summary during |
2709 * linking. | 2776 * linking. |
2710 */ | 2777 */ |
2711 abstract class FieldElementForLink implements FieldElement { | 2778 abstract class FieldElementForLink implements FieldElement { |
2712 @override | 2779 @override |
2713 PropertyAccessorElementForLink get getter; | 2780 PropertyAccessorElementForLink get getter; |
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4166 return element.type; | 4233 return element.type; |
4167 } | 4234 } |
4168 } | 4235 } |
4169 } | 4236 } |
4170 return DynamicTypeImpl.instance; | 4237 return DynamicTypeImpl.instance; |
4171 } | 4238 } |
4172 | 4239 |
4173 @override | 4240 @override |
4174 TypeInferenceNode get asTypeInferenceNode => _target.asTypeInferenceNode; | 4241 TypeInferenceNode get asTypeInferenceNode => _target.asTypeInferenceNode; |
4175 | 4242 |
4176 /** | |
4177 * Return `true` if this element is an instance getter, or its target | |
4178 * is an instance getter (recursively). | |
4179 */ | |
4180 bool get hasInstanceGetterReference { | |
4181 ExecutableElement element = asExecutableElement; | |
4182 if (element is PropertyAccessorElement) { | |
4183 return !element.isStatic; | |
4184 } | |
4185 ReferenceableElementForLink target = _target; | |
4186 if (target is NonstaticMemberElementForLink) { | |
4187 return target.hasInstanceGetterReference; | |
4188 } | |
4189 return false; | |
4190 } | |
4191 | |
4192 @override | 4243 @override |
4193 ReferenceableElementForLink getContainedName(String name) { | 4244 ReferenceableElementForLink getContainedName(String name) { |
4194 return new NonstaticMemberElementForLink(_library, this, name); | 4245 return new NonstaticMemberElementForLink(_library, this, name); |
4195 } | 4246 } |
4196 | 4247 |
4197 @override | 4248 @override |
4198 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 4249 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
4199 | 4250 |
4200 @override | 4251 @override |
4201 String toString() => '$_target.(dynamic)$_name'; | 4252 String toString() => '$_target.(dynamic)$_name'; |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5024 break; | 5075 break; |
5025 case UnlinkedExprOperation.makeTypedList: | 5076 case UnlinkedExprOperation.makeTypedList: |
5026 refPtr++; | 5077 refPtr++; |
5027 intPtr++; | 5078 intPtr++; |
5028 break; | 5079 break; |
5029 case UnlinkedExprOperation.makeTypedMap: | 5080 case UnlinkedExprOperation.makeTypedMap: |
5030 refPtr += 2; | 5081 refPtr += 2; |
5031 intPtr++; | 5082 intPtr++; |
5032 break; | 5083 break; |
5033 case UnlinkedExprOperation.assignToRef: | 5084 case UnlinkedExprOperation.assignToRef: |
5034 // TODO(paulberry): if this reference refers to a variable, should it | 5085 EntityRef ref = unlinkedConst.references[refPtr++]; |
5035 // be considered a type inference dependency? | 5086 // TODO(paulberry): cache these resolved references for |
5036 refPtr++; | 5087 // later use by evaluate(). |
| 5088 TypeInferenceNode dependency = |
| 5089 compilationUnit.resolveRef(ref.reference).asTypeInferenceNode; |
| 5090 if (dependency != null) { |
| 5091 dependencies.add(dependency); |
| 5092 } |
5037 break; | 5093 break; |
5038 case UnlinkedExprOperation.invokeMethodRef: | 5094 case UnlinkedExprOperation.invokeMethodRef: |
5039 EntityRef ref = unlinkedConst.references[refPtr++]; | 5095 EntityRef ref = unlinkedConst.references[refPtr++]; |
5040 TypeInferenceNode dependency = | 5096 TypeInferenceNode dependency = |
5041 compilationUnit.resolveRef(ref.reference).asTypeInferenceNode; | 5097 compilationUnit.resolveRef(ref.reference).asTypeInferenceNode; |
5042 if (dependency != null) { | 5098 if (dependency != null) { |
5043 dependencies.add(dependency); | 5099 dependencies.add(dependency); |
5044 } | 5100 } |
5045 intPtr += 2; | 5101 intPtr += 2; |
5046 int numTypeArguments = unlinkedConst.ints[intPtr++]; | 5102 int numTypeArguments = unlinkedConst.ints[intPtr++]; |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5446 * there are no type parameters in scope. | 5502 * there are no type parameters in scope. |
5447 */ | 5503 */ |
5448 TypeParameterizedElementMixin get _typeParameterContext; | 5504 TypeParameterizedElementMixin get _typeParameterContext; |
5449 | 5505 |
5450 @override | 5506 @override |
5451 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 5507 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
5452 | 5508 |
5453 @override | 5509 @override |
5454 String toString() => '$enclosingElement.$name'; | 5510 String toString() => '$enclosingElement.$name'; |
5455 } | 5511 } |
5456 | |
5457 /** | |
5458 * This exception is thrown when [ExprTypeComputer] cannot inference the type. | |
5459 */ | |
5460 class _InferenceFailedError { | |
5461 final String message; | |
5462 | |
5463 _InferenceFailedError(this.message); | |
5464 } | |
OLD | NEW |