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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/typechecker.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 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart2js; 5 part of dart2js;
6 6
7 class TypeCheckerTask extends CompilerTask { 7 class TypeCheckerTask extends CompilerTask {
8 TypeCheckerTask(Compiler compiler) : super(compiler); 8 TypeCheckerTask(Compiler compiler) : super(compiler);
9 String get name => "Type checker"; 9 String get name => "Type checker";
10 10
(...skipping 18 matching lines...) Expand all
29 class TypeKind { 29 class TypeKind {
30 final String id; 30 final String id;
31 31
32 const TypeKind(String this.id); 32 const TypeKind(String this.id);
33 33
34 static const TypeKind FUNCTION = const TypeKind('function'); 34 static const TypeKind FUNCTION = const TypeKind('function');
35 static const TypeKind INTERFACE = const TypeKind('interface'); 35 static const TypeKind INTERFACE = const TypeKind('interface');
36 static const TypeKind STATEMENT = const TypeKind('statement'); 36 static const TypeKind STATEMENT = const TypeKind('statement');
37 static const TypeKind TYPEDEF = const TypeKind('typedef'); 37 static const TypeKind TYPEDEF = const TypeKind('typedef');
38 static const TypeKind TYPE_VARIABLE = const TypeKind('type variable'); 38 static const TypeKind TYPE_VARIABLE = const TypeKind('type variable');
39 static const TypeKind MALFORMED_TYPE = const TypeKind('malformed');
39 static const TypeKind VOID = const TypeKind('void'); 40 static const TypeKind VOID = const TypeKind('void');
40 41
41 String toString() => id; 42 String toString() => id;
42 } 43 }
43 44
44 abstract class DartType { 45 abstract class DartType {
45 SourceString get name; 46 SourceString get name;
46 47
47 TypeKind get kind; 48 TypeKind get kind;
48 49
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 144
144 DartType unalias(Compiler compiler) => this; 145 DartType unalias(Compiler compiler) => this;
145 146
146 int get hashCode => 1729; 147 int get hashCode => 1729;
147 148
148 bool operator ==(other) => other is VoidType; 149 bool operator ==(other) => other is VoidType;
149 150
150 String toString() => name.slowToString(); 151 String toString() => name.slowToString();
151 } 152 }
152 153
154 class MalformedType extends DartType {
155 const MalformedType(this.element);
156
157 TypeKind get kind => TypeKind.MALFORMED_TYPE;
158
159 SourceString get name => element.name;
160
161 final MalformedTypeElement element;
162
163 DartType unalias(Compiler compiler) => this;
164
165 int get hashCode => 1733;
166
167 bool operator ==(other) => other is MalformedType;
168
169 String toString() => name.slowToString();
170 }
171
153 class InterfaceType extends DartType { 172 class InterfaceType extends DartType {
154 final Element element; 173 final Element element;
155 final Link<DartType> arguments; 174 final Link<DartType> arguments;
156 175
157 const InterfaceType(this.element, 176 const InterfaceType(this.element,
158 [this.arguments = const Link<DartType>()]); 177 [this.arguments = const Link<DartType>()]);
159 178
160 TypeKind get kind => TypeKind.INTERFACE; 179 TypeKind get kind => TypeKind.INTERFACE;
161 180
162 SourceString get name => element.name; 181 SourceString get name => element.name;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 identical(s, dynamicType) || 331 identical(s, dynamicType) ||
313 identical(s.element, compiler.objectClass) || 332 identical(s.element, compiler.objectClass) ||
314 identical(t.element, compiler.nullClass)) { 333 identical(t.element, compiler.nullClass)) {
315 return true; 334 return true;
316 } 335 }
317 t = t.unalias(compiler); 336 t = t.unalias(compiler);
318 s = s.unalias(compiler); 337 s = s.unalias(compiler);
319 338
320 if (t is VoidType) { 339 if (t is VoidType) {
321 return false; 340 return false;
341 } else if (t is MalformedType) {
342 return false;
322 } else if (t is InterfaceType) { 343 } else if (t is InterfaceType) {
323 if (s is !InterfaceType) return false; 344 if (s is !InterfaceType) return false;
324 ClassElement tc = t.element; 345 ClassElement tc = t.element;
325 if (identical(tc, s.element)) return true; 346 if (identical(tc, s.element)) return true;
326 for (Link<DartType> supertypes = tc.allSupertypes; 347 for (Link<DartType> supertypes = tc.allSupertypes;
327 supertypes != null && !supertypes.isEmpty; 348 supertypes != null && !supertypes.isEmpty;
328 supertypes = supertypes.tail) { 349 supertypes = supertypes.tail) {
329 DartType supertype = supertypes.head; 350 DartType supertype = supertypes.head;
330 if (identical(supertype.element, s.element)) return true; 351 if (identical(supertype.element, s.element)) return true;
331 } 352 }
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 } 1051 }
1031 1052
1032 DartType visitStringNode(StringNode node) { 1053 DartType visitStringNode(StringNode node) {
1033 compiler.unimplemented('visitNode', node: node); 1054 compiler.unimplemented('visitNode', node: node);
1034 } 1055 }
1035 1056
1036 DartType visitLibraryDependency(LibraryDependency node) { 1057 DartType visitLibraryDependency(LibraryDependency node) {
1037 compiler.unimplemented('visitNode', node: node); 1058 compiler.unimplemented('visitNode', node: node);
1038 } 1059 }
1039 } 1060 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698