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

Unified Diff: lib/analyzer/ast_from_analyzer.dart

Issue 2439043002: Introduce Substitution class and Supertype class. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | lib/analyzer/loader.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/analyzer/ast_from_analyzer.dart
diff --git a/lib/analyzer/ast_from_analyzer.dart b/lib/analyzer/ast_from_analyzer.dart
index f40d06c3a7402f18dfa96dd2b4727750e1bd88db..0ff713a456583ad7ae23ea8a0be4a72719143a9e 100644
--- a/lib/analyzer/ast_from_analyzer.dart
+++ b/lib/analyzer/ast_from_analyzer.dart
@@ -320,6 +320,22 @@ class TypeScope extends ReferenceScope {
return new TypeAnnotationBuilder(this).buildFromDartType(type);
}
+ ast.Supertype buildSupertype(DartType type) {
+ if (type is InterfaceType) {
+ var classElement = type.element;
+ if (classElement == null) return getRootClassReference().asRawSupertype;
+ var classNode = getClassReference(classElement);
+ if (classNode.typeParameters.isEmpty ||
+ classNode.typeParameters.length != type.typeArguments.length) {
+ return classNode.asRawSupertype;
+ } else {
+ return new ast.Supertype(classNode,
+ type.typeArguments.map(buildType).toList(growable: false));
+ }
+ }
+ return getRootClassReference().asRawSupertype;
+ }
+
ast.DartType buildTypeAnnotation(AstNode node) {
return new TypeAnnotationBuilder(this).build(node);
}
@@ -2274,7 +2290,7 @@ class ClassBodyBuilder extends GeneralizingAstVisitor<Null> {
/// This should only be used to recover from a compile-time error.
void buildBrokenClass() {
currentClass.name = element.name;
- currentClass.supertype = scope.getRootClassReference().rawType;
+ currentClass.supertype = scope.getRootClassReference().asRawSupertype;
currentClass.constructors.add(
new ast.Constructor(new ast.FunctionNode(new ast.InvalidStatement())));
}
« no previous file with comments | « no previous file | lib/analyzer/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698