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

Side by Side Diff: pkg/analyzer/lib/src/dart/element/member.dart

Issue 2291103004: fix #25740 again, making sure we have the substituted bound in inference (Closed)
Patch Set: merge and add todo Created 4 years, 3 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/type_system_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.dart.element.member; 5 library analyzer.src.dart.element.member;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/constant/value.dart'; 8 import 'package:analyzer/dart/constant/value.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 * 930 *
931 * If we have `C<num>.m` and we ask for the type parameter "S", we should get 931 * If we have `C<num>.m` and we ask for the type parameter "S", we should get
932 * `<S extends num>` instead of `<S extends T>`. This is how the parameter 932 * `<S extends num>` instead of `<S extends T>`. This is how the parameter
933 * and return types work, see: [FunctionType.parameters], 933 * and return types work, see: [FunctionType.parameters],
934 * [FunctionType.returnType], and [ParameterMember]. 934 * [FunctionType.returnType], and [ParameterMember].
935 */ 935 */
936 class TypeParameterMember extends Member implements TypeParameterElement { 936 class TypeParameterMember extends Member implements TypeParameterElement {
937 @override 937 @override
938 final DartType bound; 938 final DartType bound;
939 939
940 DartType _type;
941
940 TypeParameterMember( 942 TypeParameterMember(
941 TypeParameterElement baseElement, DartType definingType, this.bound) 943 TypeParameterElement baseElement, DartType definingType, this.bound)
942 : super(baseElement, definingType); 944 : super(baseElement, definingType) {
945 _type = new TypeParameterTypeImpl(this);
946 }
943 947
944 @override 948 @override
945 TypeParameterElement get baseElement => 949 TypeParameterElement get baseElement =>
946 super.baseElement as TypeParameterElement; 950 super.baseElement as TypeParameterElement;
947 951
948 @override 952 @override
949 Element get enclosingElement => baseElement.enclosingElement; 953 Element get enclosingElement => baseElement.enclosingElement;
950 954
951 @override 955 @override
952 TypeParameterType get type => baseElement.type; 956 TypeParameterType get type => _type;
953 957
954 @override 958 @override
955 accept(ElementVisitor visitor) => visitor.visitTypeParameterElement(this); 959 accept(ElementVisitor visitor) => visitor.visitTypeParameterElement(this);
956 960
961 @override
962 int get hashCode => baseElement.hashCode;
963
964 @override
965 bool operator ==(obj) =>
966 // TODO(jmesserly): this equality should consider the bound, see:
967 // https://github.com/dart-lang/sdk/issues/27210
968 obj is TypeParameterMember && obj.baseElement == baseElement;
969
957 /** 970 /**
958 * If the given [parameter]'s type is different when any type parameters from 971 * If the given [parameter]'s type is different when any type parameters from
959 * the defining type's declaration are replaced with the actual type 972 * the defining type's declaration are replaced with the actual type
960 * arguments from the [definingType], create a parameter member representing 973 * arguments from the [definingType], create a parameter member representing
961 * the given parameter. Return the member that was created, or the base 974 * the given parameter. Return the member that was created, or the base
962 * parameter if no member was created. 975 * parameter if no member was created.
963 */ 976 */
964 static TypeParameterElement from( 977 static TypeParameterElement from(
965 TypeParameterElement parameter, ParameterizedType definingType) { 978 TypeParameterElement parameter, ParameterizedType definingType) {
966 if (parameter?.bound == null || definingType.typeArguments.isEmpty) { 979 if (parameter?.bound == null || definingType.typeArguments.isEmpty) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 DartObject computeConstantValue() => baseElement.computeConstantValue(); 1060 DartObject computeConstantValue() => baseElement.computeConstantValue();
1048 1061
1049 @override 1062 @override
1050 void visitChildren(ElementVisitor visitor) { 1063 void visitChildren(ElementVisitor visitor) {
1051 // TODO(brianwilkerson) We need to finish implementing the accessors used 1064 // TODO(brianwilkerson) We need to finish implementing the accessors used
1052 // below so that we can safely invoke them. 1065 // below so that we can safely invoke them.
1053 super.visitChildren(visitor); 1066 super.visitChildren(visitor);
1054 baseElement.initializer?.accept(visitor); 1067 baseElement.initializer?.accept(visitor);
1055 } 1068 }
1056 } 1069 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/type_system_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698