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

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

Issue 2762863002: Issue 28580. Relax instantiate to bounds. (Closed)
Patch Set: Created 3 years, 9 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 8682 matching lines...) Expand 10 before | Expand all | Expand 10 after
8693 void setType(VariableElement element, DartType type) { 8693 void setType(VariableElement element, DartType type) {
8694 _overriddenTypes[element] = type; 8694 _overriddenTypes[element] = type;
8695 } 8695 }
8696 } 8696 }
8697 8697
8698 /** 8698 /**
8699 * This class resolves bounds of type parameters of classes, class and function 8699 * This class resolves bounds of type parameters of classes, class and function
8700 * type aliases. 8700 * type aliases.
8701 */ 8701 */
8702 class TypeParameterBoundsResolver { 8702 class TypeParameterBoundsResolver {
8703 final TypeProvider typeProvider; 8703 final TypeSystem typeSystem;
8704 final LibraryElement library; 8704 final LibraryElement library;
8705 final Source source; 8705 final Source source;
8706 final AnalysisErrorListener errorListener; 8706 final AnalysisErrorListener errorListener;
8707 8707
8708 Scope libraryScope = null; 8708 Scope libraryScope = null;
8709 TypeNameResolver typeNameResolver = null; 8709 TypeNameResolver typeNameResolver = null;
8710 8710
8711 TypeParameterBoundsResolver( 8711 TypeParameterBoundsResolver(
8712 this.typeProvider, this.library, this.source, this.errorListener); 8712 this.typeSystem, this.library, this.source, this.errorListener);
8713 8713
8714 /** 8714 /**
8715 * Resolve bounds of type parameters of classes, class and function type 8715 * Resolve bounds of type parameters of classes, class and function type
8716 * aliases. 8716 * aliases.
8717 */ 8717 */
8718 void resolveTypeBounds(CompilationUnit unit) { 8718 void resolveTypeBounds(CompilationUnit unit) {
8719 for (CompilationUnitMember unitMember in unit.declarations) { 8719 for (CompilationUnitMember unitMember in unit.declarations) {
8720 if (unitMember is ClassDeclaration) { 8720 if (unitMember is ClassDeclaration) {
8721 _resolveTypeParameters(unitMember.typeParameters, 8721 _resolveTypeParameters(unitMember.typeParameters,
8722 () => new TypeParameterScope(libraryScope, unitMember.element)); 8722 () => new TypeParameterScope(libraryScope, unitMember.element));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
8756 bound.type = typeParameterElement.bound; 8756 bound.type = typeParameterElement.bound;
8757 } else { 8757 } else {
8758 // TODO(brianwilkerson) Add resolution of GenericFunctionType 8758 // TODO(brianwilkerson) Add resolution of GenericFunctionType
8759 throw new ArgumentError( 8759 throw new ArgumentError(
8760 'Cannot resolve a ${bound.runtimeType}'); 8760 'Cannot resolve a ${bound.runtimeType}');
8761 } 8761 }
8762 } else { 8762 } else {
8763 libraryScope ??= new LibraryScope(library); 8763 libraryScope ??= new LibraryScope(library);
8764 typeParametersScope ??= createTypeParametersScope(); 8764 typeParametersScope ??= createTypeParametersScope();
8765 typeNameResolver ??= new TypeNameResolver( 8765 typeNameResolver ??= new TypeNameResolver(
8766 new TypeSystemImpl(typeProvider), 8766 typeSystem,
8767 typeProvider, 8767 typeSystem.typeProvider,
8768 library, 8768 library,
8769 source, 8769 source,
8770 errorListener); 8770 errorListener);
8771 typeNameResolver.nameScope = typeParametersScope; 8771 typeNameResolver.nameScope = typeParametersScope;
8772 _resolveTypeName(bound); 8772 _resolveTypeName(bound);
8773 typeParameterElement.bound = bound.type; 8773 typeParameterElement.bound = bound.type;
8774 } 8774 }
8775 } 8775 }
8776 } 8776 }
8777 } 8777 }
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after
10776 return null; 10776 return null;
10777 } 10777 }
10778 if (identical(node.staticElement, variable)) { 10778 if (identical(node.staticElement, variable)) {
10779 if (node.inSetterContext()) { 10779 if (node.inSetterContext()) {
10780 result = true; 10780 result = true;
10781 } 10781 }
10782 } 10782 }
10783 return null; 10783 return null;
10784 } 10784 }
10785 } 10785 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698