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

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

Issue 10996039: Bring type variables into static scope, but produce compile-time error when they are used. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed passing test from the exception list. Created 8 years, 3 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/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index ef8c2274e9123266caef50952b78fc5b8ae411e7..ff6a54ecd610b011fb36807a34e0129b8e2fefdf 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1130,6 +1130,11 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
DartType useType(TypeAnnotation annotation, DartType type) {
if (type !== null) {
+ if (type.element.isTypeVariable() && enclosingElement.inStaticContext()) {
+ error(annotation,
+ MessageKind.CANNOT_ACCESS_TYPE_VARIABLE_IN_STATIC_CONTEXT,
+ [type.name]);
+ }
mapping.setType(annotation, type);
useElement(annotation, type.element);
}
@@ -2841,8 +2846,6 @@ class BlockScope extends MethodScope {
* scope and inherited members are available, in the given order.
*/
class ClassScope extends TypeDeclarationScope {
- bool inStaticContext = false;
ahe 2012/10/02 07:50:25 This is great.
-
ClassScope(Scope parentScope, ClassElement element)
: super(parentScope, element);
@@ -2850,13 +2853,7 @@ class ClassScope extends TypeDeclarationScope {
ClassElement cls = element;
Element result = cls.lookupLocalMember(name);
if (result !== null) return result;
- if (!inStaticContext) {
- // If not in a static context, we can lookup in the
- // TypeDeclaration scope, which contains the type variables of
- // the class.
- return super.localLookup(name);
- }
- return null;
+ return super.localLookup(name);
}
Element lookup(SourceString name) {

Powered by Google App Engine
This is Rietveld 408576698