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 resolution.compute_members; | 5 library resolution.compute_members; |
6 | 6 |
7 import '../elements/elements.dart' | 7 import '../elements/elements.dart' |
8 show Element, | 8 show Element, |
9 Name, | 9 Name, |
10 PublicName, | 10 PublicName, |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 for (MemberSignature other in inheritedMembers) { | 214 for (MemberSignature other in inheritedMembers) { |
215 if (!compiler.types.isSubtype(inherited.functionType, | 215 if (!compiler.types.isSubtype(inherited.functionType, |
216 other.functionType)) { | 216 other.functionType)) { |
217 continue outer; | 217 continue outer; |
218 } | 218 } |
219 } | 219 } |
220 subtypesOfAllInherited.putIfAbsent(inherited.functionType, | 220 subtypesOfAllInherited.putIfAbsent(inherited.functionType, |
221 () => new Set<Member>()).add(inherited); | 221 () => new Set<Member>()).add(inherited); |
222 } | 222 } |
223 if (someAreGetters && !allAreGetters) { | 223 if (someAreGetters && !allAreGetters) { |
224 compiler.reportWarningCode(cls, | 224 compiler.reportWarning(cls, |
225 MessageKind.INHERIT_GETTER_AND_METHOD, | 225 MessageKind.INHERIT_GETTER_AND_METHOD, |
226 {'class': thisType, 'name': name.text }); | 226 {'class': thisType, 'name': name.text }); |
227 for (Member inherited in inheritedMembers) { | 227 for (Member inherited in inheritedMembers) { |
228 MessageKind kind; | 228 MessageKind kind; |
229 if (inherited.isMethod) { | 229 if (inherited.isMethod) { |
230 kind = MessageKind.INHERITED_METHOD; | 230 kind = MessageKind.INHERITED_METHOD; |
231 } else { | 231 } else { |
232 assert(invariant(cls, inherited.isGetter, | 232 assert(invariant(cls, inherited.isGetter, |
233 message: 'Conflicting member is neither a method nor a ' | 233 message: 'Conflicting member is neither a method nor a ' |
234 'getter.')); | 234 'getter.')); |
235 if (inherited.isDeclaredByField) { | 235 if (inherited.isDeclaredByField) { |
236 kind = MessageKind.INHERITED_IMPLICIT_GETTER; | 236 kind = MessageKind.INHERITED_IMPLICIT_GETTER; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 interfaceMember.declarer.element == cls) { | 350 interfaceMember.declarer.element == cls) { |
351 // Abstract method declared in [cls]. | 351 // Abstract method declared in [cls]. |
352 MessageKind kind = MessageKind.ABSTRACT_METHOD; | 352 MessageKind kind = MessageKind.ABSTRACT_METHOD; |
353 if (interfaceMember.isSetter) { | 353 if (interfaceMember.isSetter) { |
354 kind = MessageKind.ABSTRACT_SETTER; | 354 kind = MessageKind.ABSTRACT_SETTER; |
355 } else if (interfaceMember.isGetter) { | 355 } else if (interfaceMember.isGetter) { |
356 kind = MessageKind.ABSTRACT_GETTER; | 356 kind = MessageKind.ABSTRACT_GETTER; |
357 } | 357 } |
358 reportMessage( | 358 reportMessage( |
359 interfaceMember.element, MessageKind.ABSTRACT_METHOD, () { | 359 interfaceMember.element, MessageKind.ABSTRACT_METHOD, () { |
360 compiler.reportWarningCode( | 360 compiler.reportWarning( |
361 interfaceMember.element, kind, | 361 interfaceMember.element, kind, |
362 {'class': cls.name, 'name': name.text}); | 362 {'class': cls.name, 'name': name.text}); |
363 }); | 363 }); |
364 } else { | 364 } else { |
365 reportWarning(MessageKind singleKind, | 365 reportWarning(MessageKind singleKind, |
366 MessageKind multipleKind, | 366 MessageKind multipleKind, |
367 MessageKind explicitlyDeclaredKind, | 367 MessageKind explicitlyDeclaredKind, |
368 [MessageKind implicitlyDeclaredKind]) { | 368 [MessageKind implicitlyDeclaredKind]) { |
369 Member inherited = interfaceMember.declarations.first; | 369 Member inherited = interfaceMember.declarations.first; |
370 reportMessage( | 370 reportMessage( |
371 interfaceMember, MessageKind.UNIMPLEMENTED_METHOD, () { | 371 interfaceMember, MessageKind.UNIMPLEMENTED_METHOD, () { |
372 compiler.reportWarningCode(cls, | 372 compiler.reportWarning(cls, |
373 interfaceMember.declarations.length == 1 | 373 interfaceMember.declarations.length == 1 |
374 ? singleKind : multipleKind, | 374 ? singleKind : multipleKind, |
375 {'class': cls.name, | 375 {'class': cls.name, |
376 'name': name.text, | 376 'name': name.text, |
377 'method': interfaceMember, | 377 'method': interfaceMember, |
378 'declarer': inherited.declarer}); | 378 'declarer': inherited.declarer}); |
379 for (Member inherited in interfaceMember.declarations) { | 379 for (Member inherited in interfaceMember.declarations) { |
380 compiler.reportInfo(inherited.element, | 380 compiler.reportInfo(inherited.element, |
381 inherited.isDeclaredByField ? | 381 inherited.isDeclaredByField ? |
382 implicitlyDeclaredKind : explicitlyDeclaredKind, | 382 implicitlyDeclaredKind : explicitlyDeclaredKind, |
(...skipping 28 matching lines...) Expand all Loading... |
411 if (superMember == null) { | 411 if (superMember == null) { |
412 // No override. | 412 // No override. |
413 if (!declared.isStatic) { | 413 if (!declared.isStatic) { |
414 ClassElement superclass = cls.superclass; | 414 ClassElement superclass = cls.superclass; |
415 while (superclass != null) { | 415 while (superclass != null) { |
416 Member superMember = | 416 Member superMember = |
417 superclass.lookupClassMember(declared.name); | 417 superclass.lookupClassMember(declared.name); |
418 if (superMember != null && superMember.isStatic) { | 418 if (superMember != null && superMember.isStatic) { |
419 reportMessage(superMember, MessageKind.INSTANCE_STATIC_SAME_NAME, | 419 reportMessage(superMember, MessageKind.INSTANCE_STATIC_SAME_NAME, |
420 () { | 420 () { |
421 compiler.reportWarningCode( | 421 compiler.reportWarning( |
422 declared.element, | 422 declared.element, |
423 MessageKind.INSTANCE_STATIC_SAME_NAME, | 423 MessageKind.INSTANCE_STATIC_SAME_NAME, |
424 {'memberName': declared.name, | 424 {'memberName': declared.name, |
425 'className': superclass.name}); | 425 'className': superclass.name}); |
426 compiler.reportInfo(superMember.element, | 426 compiler.reportInfo(superMember.element, |
427 MessageKind.INSTANCE_STATIC_SAME_NAME_CONT); | 427 MessageKind.INSTANCE_STATIC_SAME_NAME_CONT); |
428 }); | 428 }); |
429 break; | 429 break; |
430 } | 430 } |
431 superclass = superclass.superclass; | 431 superclass = superclass.superclass; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 } else if (declared.isMethod && inherited.isGetter) { | 472 } else if (declared.isMethod && inherited.isGetter) { |
473 reportError(MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD, | 473 reportError(MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD, |
474 MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT); | 474 MessageKind.CANNOT_OVERRIDE_GETTER_WITH_METHOD_CONT); |
475 } else { | 475 } else { |
476 DartType inheritedType = inherited.functionType; | 476 DartType inheritedType = inherited.functionType; |
477 if (!compiler.types.isSubtype(declaredType, inheritedType)) { | 477 if (!compiler.types.isSubtype(declaredType, inheritedType)) { |
478 void reportWarning(var marker, | 478 void reportWarning(var marker, |
479 MessageKind warningKind, | 479 MessageKind warningKind, |
480 MessageKind infoKind) { | 480 MessageKind infoKind) { |
481 reportMessage(marker, MessageKind.INVALID_OVERRIDE_METHOD, () { | 481 reportMessage(marker, MessageKind.INVALID_OVERRIDE_METHOD, () { |
482 compiler.reportWarningCode(declared.element, warningKind, | 482 compiler.reportWarning(declared.element, warningKind, |
483 {'declaredType': declared.type, | 483 {'declaredType': declared.type, |
484 'name': declared.name.text, | 484 'name': declared.name.text, |
485 'class': cls.thisType, | 485 'class': cls.thisType, |
486 'inheritedType': inherited.type, | 486 'inheritedType': inherited.type, |
487 'inheritedClass': inherited.declarer}); | 487 'inheritedClass': inherited.declarer}); |
488 compiler.reportInfo(inherited.element, infoKind, | 488 compiler.reportInfo(inherited.element, infoKind, |
489 {'name': declared.name.text, | 489 {'name': declared.name.text, |
490 'class': inherited.declarer}); | 490 'class': inherited.declarer}); |
491 }); | 491 }); |
492 } | 492 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 } | 548 } |
549 | 549 |
550 static void computeClassMembers(Compiler compiler, BaseClassElementX cls) { | 550 static void computeClassMembers(Compiler compiler, BaseClassElementX cls) { |
551 if (cls.classMembers != null) return; | 551 if (cls.classMembers != null) return; |
552 MembersCreator creator = new MembersCreator(compiler, cls); | 552 MembersCreator creator = new MembersCreator(compiler, cls); |
553 creator.computeMembers(); | 553 creator.computeMembers(); |
554 cls.classMembers = creator.classMembers; | 554 cls.classMembers = creator.classMembers; |
555 cls.interfaceMembers = creator.interfaceMembers; | 555 cls.interfaceMembers = creator.interfaceMembers; |
556 } | 556 } |
557 } | 557 } |
OLD | NEW |