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

Unified Diff: lib/compiler/implementation/resolution/members.dart

Issue 11229002: Handle type variable in static member. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Test update removed. Created 8 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
Index: lib/compiler/implementation/resolution/members.dart
diff --git a/lib/compiler/implementation/resolution/members.dart b/lib/compiler/implementation/resolution/members.dart
index 046faf3945b2504de1acf7a29a5369ff69f2a49c..259680e5efeda7b93d760ee5a69e44fa439d727f 100644
--- a/lib/compiler/implementation/resolution/members.dart
+++ b/lib/compiler/implementation/resolution/members.dart
@@ -348,7 +348,8 @@ class ResolverTask extends CompilerTask {
TreeElements resolveField(VariableElement element) {
Node tree = element.parseNode(compiler);
if(element.modifiers.isStatic() && element.variables.isTopLevel()) {
- error(element.modifiers.getStatic(), MessageKind.TOP_LEVEL_VARIABLE_DECLARED_STATIC);
+ error(element.modifiers.getStatic(),
+ MessageKind.TOP_LEVEL_VARIABLE_DECLARED_STATIC);
}
ResolverVisitor visitor = new ResolverVisitor(compiler, element);
initializerDo(tree, visitor.visit);
@@ -1085,23 +1086,21 @@ class TypeResolver {
// flags instead of closures.
// TODO(johnniwinther): Should never return [null] but instead an erroneous
// type.
- DartType resolveTypeAnnotation(TypeAnnotation node,
- {Scope inScope, ClassElement inClass,
- onFailure(Node, MessageKind, [List arguments]),
- whenResolved(Node, Type)}) {
+ DartType resolveTypeAnnotation(
+ TypeAnnotation node,
+ Scope scope,
+ {onFailure(Node node, MessageKind kind, [List arguments]),
+ whenResolved(Node node, DartType type)}) {
if (onFailure == null) {
onFailure = (n, k, [arguments]) {};
}
if (whenResolved == null) {
whenResolved = (n, t) {};
}
- if (inClass != null) {
- inScope = inClass.buildScope();
- }
- if (inScope == null) {
+ if (scope == null) {
compiler.internalError('resolveTypeAnnotation: no scope specified');
}
- return resolveTypeAnnotationInContext(inScope, node, onFailure,
+ return resolveTypeAnnotationInContext(scope, node, onFailure,
whenResolved);
}
@@ -1960,10 +1959,19 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
DartType resolveTypeAnnotation(TypeAnnotation node) {
+ void checkAndUseType(TypeAnnotation annotation, DartType type) {
ahe 2012/10/23 16:17:13 Add TODO to say we should get rid of this.
Johnni Winther 2012/10/24 14:28:35 Done.
+ useType(annotation, type);
+ if (type != null &&
+ identical(type.kind, TypeKind.TYPE_VARIABLE) &&
+ enclosingElement.isInStaticMember()) {
+ error(annotation, MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
+ [type]);
+ }
+ }
+
Function report = typeRequired ? error : warning;
- DartType type = typeResolver.resolveTypeAnnotation(node, inScope: scope,
- onFailure: report,
- whenResolved: useType);
+ DartType type = typeResolver.resolveTypeAnnotation(
+ node, scope, onFailure: report, whenResolved: checkAndUseType);
if (type == null) return null;
if (inCheckContext) {
compiler.enqueuer.resolution.registerIsCheck(type);
@@ -2313,7 +2321,7 @@ class TypeDefinitionVisitor extends CommonResolverVisitor<DartType> {
TypeVariableElement variableElement = typeVariable.element;
if (typeNode.bound != null) {
DartType boundType = typeResolver.resolveTypeAnnotation(
- typeNode.bound, inScope: scope, onFailure: warning);
+ typeNode.bound, scope, onFailure: warning);
if (boundType != null && boundType.element == variableElement) {
// TODO(johnniwinther): Check for more general cycles, like
// [: <A extends B, B extends C, C extends B> :].

Powered by Google App Engine
This is Rietveld 408576698