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

Side by Side Diff: lib/compiler/implementation/typechecker.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: Produce warning and dynamic type error instead of compile-time error. 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 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 class TypeCheckerTask extends CompilerTask { 5 class TypeCheckerTask extends CompilerTask {
6 TypeCheckerTask(Compiler compiler) : super(compiler); 6 TypeCheckerTask(Compiler compiler) : super(compiler);
7 String get name => "Type checker"; 7 String get name => "Type checker";
8 8
9 static const bool LOG_FAILURES = false; 9 static const bool LOG_FAILURES = false;
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 DartType unalias(Compiler compiler) => this; 112 DartType unalias(Compiler compiler) => this;
113 113
114 int hashCode() => 1729; 114 int hashCode() => 1729;
115 115
116 bool operator ==(other) => other is VoidType; 116 bool operator ==(other) => other is VoidType;
117 117
118 String toString() => name.slowToString(); 118 String toString() => name.slowToString();
119 } 119 }
120 120
121 class MalformedType implements DartType {
122 const MalformedType(this.element);
123 SourceString get name => element.name;
124 final MalformedTypeElement element;
125
126 DartType unalias(Compiler compiler) => this;
127
128 int hashCode() => 1733;
129
130 bool operator ==(other) => other is MalformedType;
131
132 String toString() => name.slowToString();
133 }
134
121 class InterfaceType implements DartType { 135 class InterfaceType implements DartType {
122 final Element element; 136 final Element element;
123 final Link<DartType> arguments; 137 final Link<DartType> arguments;
124 138
125 const InterfaceType(this.element, 139 const InterfaceType(this.element,
126 [this.arguments = const EmptyLink<DartType>()]); 140 [this.arguments = const EmptyLink<DartType>()]);
127 141
128 SourceString get name => element.name; 142 SourceString get name => element.name;
129 143
130 DartType unalias(Compiler compiler) => this; 144 DartType unalias(Compiler compiler) => this;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 s === dynamicType || 283 s === dynamicType ||
270 s.element === compiler.objectClass || 284 s.element === compiler.objectClass ||
271 t.element === compiler.nullClass) { 285 t.element === compiler.nullClass) {
272 return true; 286 return true;
273 } 287 }
274 t = t.unalias(compiler); 288 t = t.unalias(compiler);
275 s = s.unalias(compiler); 289 s = s.unalias(compiler);
276 290
277 if (t is VoidType) { 291 if (t is VoidType) {
278 return false; 292 return false;
293 } else if (t is MalformedType) {
294 return false;
279 } else if (t is InterfaceType) { 295 } else if (t is InterfaceType) {
280 if (s is !InterfaceType) return false; 296 if (s is !InterfaceType) return false;
281 ClassElement tc = t.element; 297 ClassElement tc = t.element;
282 if (tc === s.element) return true; 298 if (tc === s.element) return true;
283 for (Link<DartType> supertypes = tc.allSupertypes; 299 for (Link<DartType> supertypes = tc.allSupertypes;
284 supertypes != null && !supertypes.isEmpty(); 300 supertypes != null && !supertypes.isEmpty();
285 supertypes = supertypes.tail) { 301 supertypes = supertypes.tail) {
286 DartType supertype = supertypes.head; 302 DartType supertype = supertypes.head;
287 if (supertype.element === s.element) return true; 303 if (supertype.element === s.element) return true;
288 } 304 }
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 } 994 }
979 995
980 DartType visitStatement(Statement node) { 996 DartType visitStatement(Statement node) {
981 compiler.unimplemented('visitNode', node: node); 997 compiler.unimplemented('visitNode', node: node);
982 } 998 }
983 999
984 DartType visitStringNode(StringNode node) { 1000 DartType visitStringNode(StringNode node) {
985 compiler.unimplemented('visitNode', node: node); 1001 compiler.unimplemented('visitNode', node: node);
986 } 1002 }
987 } 1003 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698