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

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

Issue 11416144: Produce run-time error when type parameters are accessed from static context. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed dart2dart unchcked tests. Created 8 years, 1 month 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: sdk/lib/_internal/compiler/implementation/elements/elements.dart
diff --git a/sdk/lib/_internal/compiler/implementation/elements/elements.dart b/sdk/lib/_internal/compiler/implementation/elements/elements.dart
index e322c4ee1e1e5d5e7b3025e522c0975c218f8c78..2a68ad8e6918bcec87e96005c49d9dbe5c753e8a 100644
--- a/sdk/lib/_internal/compiler/implementation/elements/elements.dart
+++ b/sdk/lib/_internal/compiler/implementation/elements/elements.dart
@@ -120,6 +120,8 @@ class ElementKind {
const ElementKind('ambiguous', ElementCategory.NONE);
static const ElementKind ERROR =
const ElementKind('error', ElementCategory.NONE);
+ static const ElementKind MALFORMED_TYPE =
+ const ElementKind('malformed', ElementCategory.NONE);
toString() => id;
}
@@ -200,6 +202,8 @@ class Element implements Spannable {
/** See [AmbiguousElement] for documentation. */
bool isAmbiguous() => false;
+ bool isMalformed() => false;
+
/**
* Is [:true:] if this element has a corresponding patch.
*
@@ -1319,6 +1323,19 @@ class VoidElement extends Element {
bool impliesType() => true;
}
+class MalformedTypeElement extends Element {
+ final TypeAnnotation type;
ahe 2012/11/22 12:41:30 This is an ast node. Do we assume that enclosing
ahe 2012/11/22 12:41:30 Separate field from constructor with a new line.
aam-me 2012/11/23 02:16:47 Currently in both cases when MalformedTypEelement
ahe 2012/11/23 06:16:13 All AST nodes and tokens record a character offset
aam-me 2012/11/23 14:02:27 I see. In our case "enclosing" is either class ele
ahe 2012/11/23 15:26:10 That makes sense. But we have to watch out for Jo
+ MalformedTypeElement(this.type, Element enclosing)
+ : super(const SourceString('malformed'),
+ ElementKind.MALFORMED_TYPE,
+ enclosing);
ahe 2012/11/22 12:41:30 Add newline.
aam-me 2012/11/23 02:16:47 Done.
+ DartType computeType(compiler) => compiler.types.malformedType;
ahe 2012/11/22 12:41:30 Ditto.
aam-me 2012/11/23 02:16:47 Done.
+ Node parseNode(_) => type;
ahe 2012/11/22 12:41:30 Ditto.
aam-me 2012/11/23 02:16:47 Done.
+ bool impliesType() => true;
+
+ bool isMalformed() => true;
+}
+
/**
* [TypeDeclarationElement] defines the common interface for class/interface
* declarations and typedefs.
@@ -1724,8 +1741,9 @@ abstract class ClassElement extends ScopeContainerElement
}
class Elements {
- static bool isUnresolved(Element e) => e == null || e.isErroneous();
+ static bool isUnresolved(Element e) => e == null || e.isErroneous() || e.isMalformed();
ahe 2012/11/22 12:41:30 Long line. As a matter of style, I then prefer to
aam-me 2012/11/23 02:16:47 Done.
static bool isErroneousElement(Element e) => e != null && e.isErroneous();
+ static bool isMalformedElement(Element e) => e != null && e.isMalformed();
static bool isClass(Element e) => e != null && e.kind == ElementKind.CLASS;
static bool isTypedef(Element e) {

Powered by Google App Engine
This is Rietveld 408576698