Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 2827463002: Issue 29360. Fix type name resolution for GenericTypeAliasElement. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.generated.resolver; 5 library analyzer.src.generated.resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
(...skipping 8401 matching lines...) Expand 10 before | Expand all | Expand 10 after
8412 for (int i = 0; i < parameterCount; i++) { 8412 for (int i = 0; i < parameterCount; i++) {
8413 typeArguments[i] = _getType(arguments[i]); 8413 typeArguments[i] = _getType(arguments[i]);
8414 } 8414 }
8415 } else { 8415 } else {
8416 reportErrorForNode(_getInvalidTypeParametersErrorCode(node), node, 8416 reportErrorForNode(_getInvalidTypeParametersErrorCode(node), node,
8417 [typeName.name, parameterCount, argumentCount]); 8417 [typeName.name, parameterCount, argumentCount]);
8418 for (int i = 0; i < parameterCount; i++) { 8418 for (int i = 0; i < parameterCount; i++) {
8419 typeArguments[i] = dynamicType; 8419 typeArguments[i] = dynamicType;
8420 } 8420 }
8421 } 8421 }
8422 type = typeSystem.instantiateType(type, typeArguments); 8422 if (element is GenericTypeAliasElementImpl) {
8423 type = element.typeAfterSubstitution(typeArguments) ?? dynamicType;
8424 } else {
8425 type = typeSystem.instantiateType(type, typeArguments);
8426 }
8423 } else { 8427 } else {
8424 type = typeSystem.instantiateToBounds(type); 8428 if (element is GenericTypeAliasElementImpl) {
8429 type = element.typeAfterSubstitution(null) ?? dynamicType;
8430 } else {
8431 type = typeSystem.instantiateToBounds(type);
8432 }
8425 } 8433 }
8426 typeName.staticType = type; 8434 typeName.staticType = type;
8427 node.type = type; 8435 node.type = type;
8428 } 8436 }
8429 8437
8430 /** 8438 /**
8431 * The number of type arguments in the given [typeName] does not match the 8439 * The number of type arguments in the given [typeName] does not match the
8432 * number of parameters in the corresponding class element. Return the error 8440 * number of parameters in the corresponding class element. Return the error
8433 * code that should be used to report this error. 8441 * code that should be used to report this error.
8434 */ 8442 */
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
8479 TypeArgumentList argumentList = annotation.typeArguments; 8487 TypeArgumentList argumentList = annotation.typeArguments;
8480 List<DartType> typeArguments = null; 8488 List<DartType> typeArguments = null;
8481 if (argumentList != null) { 8489 if (argumentList != null) {
8482 List<TypeAnnotation> arguments = argumentList.arguments; 8490 List<TypeAnnotation> arguments = argumentList.arguments;
8483 int argumentCount = arguments.length; 8491 int argumentCount = arguments.length;
8484 typeArguments = new List<DartType>(argumentCount); 8492 typeArguments = new List<DartType>(argumentCount);
8485 for (int i = 0; i < argumentCount; i++) { 8493 for (int i = 0; i < argumentCount; i++) {
8486 typeArguments[i] = _getType(arguments[i]); 8494 typeArguments[i] = _getType(arguments[i]);
8487 } 8495 }
8488 } 8496 }
8489 return element.typeAfterSubstitution(typeArguments); 8497 return element.typeAfterSubstitution(typeArguments) ?? dynamicType;
8490 } 8498 }
8491 } 8499 }
8492 return type; 8500 return type;
8493 } 8501 }
8494 8502
8495 /** 8503 /**
8496 * Returns the simple identifier of the given (may be qualified) type name. 8504 * Returns the simple identifier of the given (may be qualified) type name.
8497 * 8505 *
8498 * @param typeName the (may be qualified) qualified type name 8506 * @param typeName the (may be qualified) qualified type name
8499 * @return the simple identifier of the given (may be qualified) type name. 8507 * @return the simple identifier of the given (may be qualified) type name.
(...skipping 2423 matching lines...) Expand 10 before | Expand all | Expand 10 after
10923 return null; 10931 return null;
10924 } 10932 }
10925 if (identical(node.staticElement, variable)) { 10933 if (identical(node.staticElement, variable)) {
10926 if (node.inSetterContext()) { 10934 if (node.inSetterContext()) {
10927 result = true; 10935 result = true;
10928 } 10936 }
10929 } 10937 }
10930 return null; 10938 return null;
10931 } 10939 }
10932 } 10940 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698