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

Side by Side Diff: frog/type.dart

Issue 8618006: Warnings for instantiating an abstract type. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « frog/member.dart ('k') | frog/utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 Type implements Named, Hashable { 5 class Type implements Named, Hashable {
6 final String name; 6 final String name;
7 bool isTested; 7 bool isTested;
8 8
9 /** 9 /**
10 * For core types (int, String, etc) this is the generated type assertion 10 * For core types (int, String, etc) this is the generated type assertion
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 bool get isNative() => isNativeType; // TODO(jimhug): remove isNativeType. 84 bool get isNative() => isNativeType; // TODO(jimhug): remove isNativeType.
85 85
86 bool get hasTypeParams() => false; 86 bool get hasTypeParams() => false;
87 87
88 String get typeofName() => null; 88 String get typeofName() => null;
89 89
90 String get jsname() => _jsname == null ? name : _jsname; 90 String get jsname() => _jsname == null ? name : _jsname;
91 91
92 set jsname(String name) => _jsname = name; 92 set jsname(String name) => _jsname = name;
93 93
94 /** The members directly on this type. */
95 // TODO(jmesserly): should this be directMembers?
94 Map<String, Member> get members() => null; 96 Map<String, Member> get members() => null;
97
95 Definition get definition() => null; 98 Definition get definition() => null;
96 FactoryMap get factories() => null; 99 FactoryMap get factories() => null;
97 100
98 // TODO(jmesserly): should try using a const list instead of null to represent 101 // TODO(jmesserly): should try using a const list instead of null to represent
99 // the absence of type parameters. 102 // the absence of type parameters.
100 Collection<Type> get typeArgsInOrder() => null; 103 Collection<Type> get typeArgsInOrder() => null;
101 DefinedType get genericType() => this; 104 DefinedType get genericType() => this;
102 105
103 // TODO(jmesserly): what should these do for ParameterType? 106 // TODO(jmesserly): what should these do for ParameterType?
104 List<Type> get interfaces() => null; 107 List<Type> get interfaces() => null;
105 Type get parent() => null; 108 Type get parent() => null;
106 109
107 Map<String, Member> getAllMembers() => {}; 110 Map<String, Member> getAllMembers() => {};
108 111
109 int hashCode() => name.hashCode(); 112 int hashCode() => name.hashCode();
110 113
114 bool _isAbstract;
115 bool get isAbstract() {
116 if (_isAbstract == null) {
117 if (isClass) {
118 _isAbstract = inheritedMembers.getValues().some((m) => m.isAbstract);
119 } else {
120 _isAbstract = true;
121 }
122 }
123 return _isAbstract;
124 }
125
126 Map<String, Member> _inheritedMembers;
127 /**
128 * Gets all members in the class with the corresponding most-derived
129 * member.
130 */
131 // TODO(jmesserly): use this for getMember and do _checkOverride here?
132 Map<String, Member> get inheritedMembers() {
133 if (_inheritedMembers == null) {
134 _inheritedMembers = _getInheritedMembers(<String, Member>{});
135 }
136 return _inheritedMembers;
137 }
138
139 _getInheritedMembers(Map<String, Member> flattened) {
140 if (interfaces != null) {
141 for (var i in interfaces) {
142 i._getInheritedMembers(flattened);
143 }
144 }
145 if (parent != null) {
146 parent._getInheritedMembers(flattened);
147 }
148 // Add my members last so they take precedence
149 for (var m in getAllMembers().getValues()) {
150 flattened[m.name] = m;
151 }
152 return flattened;
153 }
154
111 void _checkOverride(Member member) { 155 void _checkOverride(Member member) {
112 // always look in parents to check that any overloads are legal 156 // always look in parents to check that any overloads are legal
113 var parentMember = _getMemberInParents(member.name); 157 var parentMember = _getMemberInParents(member.name);
114 if (parentMember != null) { 158 if (parentMember != null) {
115 // TODO(jimhug): Ensure that this is only done once. 159 // TODO(jimhug): Ensure that this is only done once.
116 if (!member.isPrivate || member.library == parentMember.library) { 160 if (!member.isPrivate || member.library == parentMember.library) {
117 member.override(parentMember); 161 member.override(parentMember);
118 } 162 }
119 } 163 }
120 } 164 }
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 var name = _getCallStubName('call', args); 1316 var name = _getCallStubName('call', args);
1273 if (varStubs == null) varStubs = {}; 1317 if (varStubs == null) varStubs = {};
1274 var stub = varStubs[name]; 1318 var stub = varStubs[name];
1275 if (stub == null) { 1319 if (stub == null) {
1276 stub = new VarFunctionStub(name, args); 1320 stub = new VarFunctionStub(name, args);
1277 varStubs[name] = stub; 1321 varStubs[name] = stub;
1278 } 1322 }
1279 return stub; 1323 return stub;
1280 } 1324 }
1281 } 1325 }
OLDNEW
« no previous file with comments | « frog/member.dart ('k') | frog/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698