OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.serialization.util; | 5 library dart2js.serialization.util; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 /// the [Element] is deserialized directly from [elementKey] in [encoder]. | 499 /// the [Element] is deserialized directly from [elementKey] in [encoder]. |
500 Element deserializeElementReference( | 500 Element deserializeElementReference( |
501 Element context, Key elementKey, Key nameKey, ObjectDecoder decoder, | 501 Element context, Key elementKey, Key nameKey, ObjectDecoder decoder, |
502 {bool isOptional: false}) { | 502 {bool isOptional: false}) { |
503 Element element = decoder.getElement(elementKey, isOptional: true); | 503 Element element = decoder.getElement(elementKey, isOptional: true); |
504 if (element == null) { | 504 if (element == null) { |
505 String elementName = decoder.getString(nameKey, isOptional: isOptional); | 505 String elementName = decoder.getString(nameKey, isOptional: isOptional); |
506 if (elementName == null) { | 506 if (elementName == null) { |
507 return null; | 507 return null; |
508 } | 508 } |
509 assert(invariant(NO_LOCATION_SPANNABLE, context.isConstructor, | 509 ClassElement cls; |
510 message: "Unexpected reference of forwarding constructor " | 510 if (context is ClassElement) { |
511 "'${elementName}' from $context.")); | 511 assert(invariant(NO_LOCATION_SPANNABLE, context.isNamedMixinApplication, |
512 ClassElement superclass = context.enclosingClass.superclass; | 512 message: "Unexpected reference of forwarding constructor " |
| 513 "'${elementName}' from $context.")); |
| 514 cls = context; |
| 515 } else { |
| 516 assert(invariant(NO_LOCATION_SPANNABLE, context.isConstructor, |
| 517 message: "Unexpected reference of forwarding constructor " |
| 518 "'${elementName}' from $context.")); |
| 519 cls = context.enclosingClass; |
| 520 } |
| 521 ClassElement superclass = cls.superclass; |
513 element = superclass.lookupConstructor(elementName); | 522 element = superclass.lookupConstructor(elementName); |
514 assert(invariant(NO_LOCATION_SPANNABLE, element != null, | 523 assert(invariant(NO_LOCATION_SPANNABLE, element != null, |
515 message: "Unresolved reference of forwarding constructor " | 524 message: "Unresolved reference of forwarding constructor " |
516 "'${elementName}' from $context.")); | 525 "'${elementName}' from $context.")); |
517 } | 526 } |
518 return element; | 527 return element; |
519 } | 528 } |
OLD | NEW |