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

Side by Side Diff: pkg/kernel/lib/ast.dart

Issue 2866593003: Add an optional bound to type parameter references (Closed)
Patch Set: Don't leak the bound if it ever becomes non-null Created 3 years, 7 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 | « pkg/kernel/binary.md ('k') | pkg/kernel/lib/binary/ast_from_binary.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) 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 /// ERROR HANDLING 6 /// ERROR HANDLING
7 /// ----------------------------------------------------------------------- 7 /// -----------------------------------------------------------------------
8 /// 8 ///
9 /// As a rule of thumb, errors that can be detected statically are handled by 9 /// As a rule of thumb, errors that can be detected statically are handled by
10 /// the frontend, typically by translating the erroneous code into a 'throw' or 10 /// the frontend, typically by translating the erroneous code into a 'throw' or
(...skipping 4085 matching lines...) Expand 10 before | Expand all | Expand 10 after
4096 4096
4097 /// Stores the hash code of function type parameters while computing the hash 4097 /// Stores the hash code of function type parameters while computing the hash
4098 /// code of a [FunctionType] object. 4098 /// code of a [FunctionType] object.
4099 /// 4099 ///
4100 /// This ensures that distinct [FunctionType] objects get the same hash code 4100 /// This ensures that distinct [FunctionType] objects get the same hash code
4101 /// if they represent the same type, even though their type parameters are 4101 /// if they represent the same type, even though their type parameters are
4102 /// represented by different objects. 4102 /// represented by different objects.
4103 final Map<TypeParameter, int> _temporaryHashCodeTable = <TypeParameter, int>{}; 4103 final Map<TypeParameter, int> _temporaryHashCodeTable = <TypeParameter, int>{};
4104 4104
4105 /// Reference to a type variable. 4105 /// Reference to a type variable.
4106 ///
4107 /// A type variable has an optional bound because type promotion can change the
4108 /// bound. A bound of `null` indicates that the bound has not been promoted and
4109 /// is the same as the [TypeParameter]'s bound. This allows one to detect
4110 /// whether the bound has been promoted.
4106 class TypeParameterType extends DartType { 4111 class TypeParameterType extends DartType {
4107 TypeParameter parameter; 4112 TypeParameter parameter;
4108 4113
4109 TypeParameterType(this.parameter); 4114 /// An optional promoted bound on the type parameter.
4115 ///
4116 /// 'null' indicates that the type parameter's bound has not been promoted and
4117 /// is therefore the same as the bound of [parameter].
4118 DartType bound;
4119
4120 TypeParameterType(this.parameter, [this.bound]);
4110 4121
4111 accept(DartTypeVisitor v) => v.visitTypeParameterType(this); 4122 accept(DartTypeVisitor v) => v.visitTypeParameterType(this);
4112 4123
4113 visitChildren(Visitor v) {} 4124 visitChildren(Visitor v) {}
4114 4125
4115 bool operator ==(Object other) { 4126 bool operator ==(Object other) {
4116 return other is TypeParameterType && parameter == other.parameter; 4127 return other is TypeParameterType && parameter == other.parameter;
4117 } 4128 }
4118 4129
4119 int get hashCode => _temporaryHashCodeTable[parameter] ?? parameter.hashCode; 4130 int get hashCode => _temporaryHashCodeTable[parameter] ?? parameter.hashCode;
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
4474 /// typedef has not been assigned a canonical name yet. 4485 /// typedef has not been assigned a canonical name yet.
4475 /// 4486 ///
4476 /// Returns `null` if the typedef is `null`. 4487 /// Returns `null` if the typedef is `null`.
4477 CanonicalName getCanonicalNameOfTypedef(Typedef typedef_) { 4488 CanonicalName getCanonicalNameOfTypedef(Typedef typedef_) {
4478 if (typedef_ == null) return null; 4489 if (typedef_ == null) return null;
4479 if (typedef_.canonicalName == null) { 4490 if (typedef_.canonicalName == null) {
4480 throw '$typedef_ has no canonical name'; 4491 throw '$typedef_ has no canonical name';
4481 } 4492 }
4482 return typedef_.canonicalName; 4493 return typedef_.canonicalName;
4483 } 4494 }
OLDNEW
« no previous file with comments | « pkg/kernel/binary.md ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698