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

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: 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
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..9c843a3fe9ca6666c3706693977f2b9534218e4c 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,17 @@ 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;
+ stack.add(enclosingClass.buildType((int i) {
+ TypeParameterElement typeParameter = enclosingClass.typeParameters[i];
+ if (linker.strongMode && typeParameter.bound != null) {
Paul Berry 2016/05/09 21:26:36 I don't think the logic is right here. Consider t
scheglov 2016/05/10 02:42:42 Fixed.
+ return typeParameter.bound;
+ }
+ return i >= ref.typeArguments.length
+ ? DynamicTypeImpl.instance
+ : unit._resolveTypeRef(
+ ref.typeArguments[i], variable._typeParameterContext);
+ }, const []));
} else {
stack.add(DynamicTypeImpl.instance);
}
@@ -4291,6 +4297,8 @@ class TypeParameterElementForLink implements TypeParameterElementImpl {
TypeParameterTypeImpl _type;
ElementLocation _location;
+ DartType _bound;
+
TypeParameterElementForLink(
this.enclosingElement, this._unlinkedTypeParam, this.nestingLevel);
@@ -4299,8 +4307,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

Powered by Google App Engine
This is Rietveld 408576698