OLD | NEW |
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 library dart2js.resolution.compute_members; | 5 library dart2js.resolution.compute_members; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/names.dart' show Identifiers, Names; | 8 import '../common/names.dart' show Identifiers, Names; |
9 import '../common/resolution.dart' show Resolution; | 9 import '../common/resolution.dart' show Resolution; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 // TODO(johnniwinther): If [cls] is not abstract, check that for all | 303 // TODO(johnniwinther): If [cls] is not abstract, check that for all |
304 // interface members, there is a class member whose type is a subtype of | 304 // interface members, there is a class member whose type is a subtype of |
305 // the interface member. | 305 // the interface member. |
306 } | 306 } |
307 | 307 |
308 /// Checks that [cls], if it implements Function, has defined call(). | 308 /// Checks that [cls], if it implements Function, has defined call(). |
309 void checkImplementsFunctionWithCall() { | 309 void checkImplementsFunctionWithCall() { |
310 assert(!cls.isAbstract); | 310 assert(!cls.isAbstract); |
311 | 311 |
312 ClassElement functionClass = resolution.coreClasses.functionClass; | 312 ClassElement functionClass = resolution.coreClasses.functionClass; |
| 313 functionClass.ensureResolved(resolution); |
313 if (cls.asInstanceOf(functionClass) == null) return; | 314 if (cls.asInstanceOf(functionClass) == null) return; |
314 if (cls.lookupMember(Identifiers.call) != null) return; | 315 if (cls.lookupMember(Identifiers.call) != null) return; |
315 // TODO(johnniwinther): Make separate methods for backend exceptions. | 316 // TODO(johnniwinther): Make separate methods for backend exceptions. |
316 // Avoid warnings on backend implementation classes for closures. | 317 // Avoid warnings on backend implementation classes for closures. |
317 if (resolution.target.isTargetSpecificLibrary(cls.library)) return; | 318 if (resolution.target.isTargetSpecificLibrary(cls.library)) return; |
318 | 319 |
319 reportMessage(functionClass, MessageKind.UNIMPLEMENTED_METHOD, () { | 320 reportMessage(functionClass, MessageKind.UNIMPLEMENTED_METHOD, () { |
320 reporter.reportWarningMessage(cls, MessageKind.UNIMPLEMENTED_METHOD_ONE, { | 321 reporter.reportWarningMessage(cls, MessageKind.UNIMPLEMENTED_METHOD_ONE, { |
321 'class': cls.name, | 322 'class': cls.name, |
322 'name': Identifiers.call, | 323 'name': Identifiers.call, |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 if (!declared.isStatic) { | 682 if (!declared.isStatic) { |
682 interfaceMembers[name] = declared; | 683 interfaceMembers[name] = declared; |
683 } | 684 } |
684 } else if (inheritedMembers.length == 1) { | 685 } else if (inheritedMembers.length == 1) { |
685 interfaceMembers[name] = inheritedMembers.single; | 686 interfaceMembers[name] = inheritedMembers.single; |
686 } else { | 687 } else { |
687 bool someAreGetters = false; | 688 bool someAreGetters = false; |
688 bool allAreGetters = true; | 689 bool allAreGetters = true; |
689 Map<DartType, Setlet<Member>> subtypesOfAllInherited = | 690 Map<DartType, Setlet<Member>> subtypesOfAllInherited = |
690 new Map<DartType, Setlet<Member>>(); | 691 new Map<DartType, Setlet<Member>>(); |
691 outer: | 692 outer: for (Member inherited in inheritedMembers) { |
692 for (Member inherited in inheritedMembers) { | |
693 if (inherited.isGetter) { | 693 if (inherited.isGetter) { |
694 someAreGetters = true; | 694 someAreGetters = true; |
695 if (!allAreGetters) break outer; | 695 if (!allAreGetters) break outer; |
696 } else { | 696 } else { |
697 allAreGetters = false; | 697 allAreGetters = false; |
698 if (someAreGetters) break outer; | 698 if (someAreGetters) break outer; |
699 } | 699 } |
700 for (MemberSignature other in inheritedMembers) { | 700 for (MemberSignature other in inheritedMembers) { |
701 if (!resolution.types | 701 if (!resolution.types |
702 .isSubtype(inherited.functionType, other.functionType)) { | 702 .isSubtype(inherited.functionType, other.functionType)) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 message: "Members have not been fully computed for $this.")); | 954 message: "Members have not been fully computed for $this.")); |
955 if (interfaceMembersAreClassMembers) { | 955 if (interfaceMembersAreClassMembers) { |
956 classMembers.forEach((_, member) { | 956 classMembers.forEach((_, member) { |
957 if (!member.isStatic) f(member); | 957 if (!member.isStatic) f(member); |
958 }); | 958 }); |
959 } else { | 959 } else { |
960 interfaceMembers.forEach((_, member) => f(member)); | 960 interfaceMembers.forEach((_, member) => f(member)); |
961 } | 961 } |
962 } | 962 } |
963 } | 963 } |
OLD | NEW |