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

Unified Diff: lib/compiler/implementation/elements/elements.dart

Issue 10170025: Use the correct current element when computing the type of function elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add a test. Created 8 years, 8 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 | « frog/tests/leg/src/CompilerTest.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/elements/elements.dart
diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart
index 498bad83e06c16d1248ffdd84ac9eacf253d3d01..1190c6c4dd605b525ccf89b57f35ab50c9588f59 100644
--- a/lib/compiler/implementation/elements/elements.dart
+++ b/lib/compiler/implementation/elements/elements.dart
@@ -494,8 +494,10 @@ Type getType(TypeAnnotation typeAnnotation,
}
Identifier identifier = typeAnnotation.typeName.asIdentifier();
if (identifier === null) {
- compiler.reportWarning(typeAnnotation.typeName,
- 'library prefixes not handled');
+ compiler.reportWarning(
+ typeAnnotation.typeName,
+ new ResolutionWarning(MessageKind.GENERIC,
+ ['library prefixes not handled']));
return compiler.types.dynamicType;
}
SourceString name = identifier.source;
@@ -619,21 +621,23 @@ class FunctionElement extends Element {
FunctionType computeType(Compiler compiler) {
if (type != null) return type;
- FunctionParameters parameters = computeParameters(compiler);
- Types types = compiler.types;
- FunctionExpression node =
- compiler.parser.measure(() => parseNode(compiler));
- Type returnType = getType(node.returnType, compiler, getLibrary());
- if (returnType === null) returnType = types.dynamicType;
-
- LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>();
- for (Link<Element> link = parameters.requiredParameters;
- !link.isEmpty();
- link = link.tail) {
- parameterTypes.addLast(link.head.computeType(compiler));
- }
- type = new FunctionType(returnType, parameterTypes.toLink(), this);
- return type;
+ return compiler.withCurrentElement(this, () {
+ FunctionParameters parameters = computeParameters(compiler);
+ Types types = compiler.types;
+ FunctionExpression node =
+ compiler.parser.measure(() => parseNode(compiler));
+ Type returnType = getType(node.returnType, compiler, getLibrary());
+ if (returnType === null) returnType = types.dynamicType;
+
+ LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>();
+ for (Link<Element> link = parameters.requiredParameters;
+ !link.isEmpty();
+ link = link.tail) {
+ parameterTypes.addLast(link.head.computeType(compiler));
+ }
+ type = new FunctionType(returnType, parameterTypes.toLink(), this);
+ return type;
+ });
}
Node parseNode(DiagnosticListener listener) => cachedNode;
« no previous file with comments | « frog/tests/leg/src/CompilerTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698