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

Unified Diff: pkg/analyzer/lib/src/summary/link.dart

Issue 1963593003: Implement 'instantiate to bounds' feature in resynthesizer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes for review comments. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/type.dart ('k') | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/link.dart
diff --git a/pkg/analyzer/lib/src/summary/link.dart b/pkg/analyzer/lib/src/summary/link.dart
index ee222edc865bbcd84179853c658a1a8011fec2df..6d6865c88e35a6b9e0a1b2ae9b261c89e4f9e9c2 100644
--- a/pkg/analyzer/lib/src/summary/link.dart
+++ b/pkg/analyzer/lib/src/summary/link.dart
@@ -582,12 +582,13 @@ class ClassElementForLink_Class extends ClassElementForLink
DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) {
int numTypeParameters = _unlinkedClass.typeParameters.length;
if (numTypeParameters != 0) {
- List<DartType> typeArguments = new List<DartType>(numTypeParameters);
- for (int i = 0; i < numTypeParameters; i++) {
- typeArguments[i] = getTypeArgument(i);
- }
- return new InterfaceTypeImpl.elementWithNameAndArgs(
- this, name, typeArguments);
+ return new InterfaceTypeImpl.elementWithNameAndArgs(this, name, () {
+ List<DartType> typeArguments = new List<DartType>(numTypeParameters);
+ for (int i = 0; i < numTypeParameters; i++) {
+ typeArguments[i] = getTypeArgument(i);
+ }
+ return typeArguments;
+ });
} else {
return _type ??= new InterfaceTypeImpl(this);
}
@@ -2242,12 +2243,21 @@ class ExprTypeComputer {
ConstructorElementForLink element =
unit._resolveRef(ref.reference).asConstructor;
if (element != null) {
- stack.add(element.enclosingClass.buildType(
- (int i) => i >= ref.typeArguments.length
- ? DynamicTypeImpl.instance
- : unit._resolveTypeRef(
- ref.typeArguments[i], variable._typeParameterContext),
- const []));
+ ClassElementForLink_Class enclosingClass = element.enclosingClass;
+ int numTypeParameters = enclosingClass.typeParameters.length;
+ int numTypeArguments = ref.typeArguments.length;
+ stack.add(enclosingClass.buildType((int i) {
+ if (linker.strongMode &&
+ numTypeArguments != numTypeParameters &&
+ i < numTypeParameters) {
Paul Berry 2016/05/10 15:55:59 I *think* this will work, but the logic seems stra
+ TypeParameterElement typeParameter = enclosingClass.typeParameters[i];
+ return typeParameter.bound ?? DynamicTypeImpl.instance;
+ }
+ return i >= numTypeArguments
+ ? DynamicTypeImpl.instance
+ : unit._resolveTypeRef(
+ ref.typeArguments[i], variable._typeParameterContext);
+ }, const []));
} else {
stack.add(DynamicTypeImpl.instance);
}
@@ -4291,6 +4301,8 @@ class TypeParameterElementForLink implements TypeParameterElementImpl {
TypeParameterTypeImpl _type;
ElementLocation _location;
+ DartType _bound;
+
TypeParameterElementForLink(
this.enclosingElement, this._unlinkedTypeParam, this.nestingLevel);
@@ -4299,8 +4311,8 @@ class TypeParameterElementForLink implements TypeParameterElementImpl {
if (_unlinkedTypeParam.bound == null) {
return null;
}
- // TODO(scheglov) implement
- throw new UnimplementedError();
+ return _bound ??= enclosingElement.compilationUnit
+ ._resolveTypeRef(_unlinkedTypeParam.bound, enclosingElement);
}
@override
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/type.dart ('k') | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698