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 /// ----------------------------------------------------------------------- | 5 /// ----------------------------------------------------------------------- |
6 /// ERROR HANDLING | 6 /// ERROR HANDLING |
7 /// ----------------------------------------------------------------------- | 7 /// ----------------------------------------------------------------------- |
8 /// | 8 /// |
9 /// As a rule of thumb, errors that can be detected statically are handled by | 9 /// As a rule of thumb, errors that can be detected statically are handled by |
10 /// the frontend, typically by translating the erroneous code into a 'throw' or | 10 /// the frontend, typically by translating the erroneous code into a 'throw' or |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 /// Should only be used on code compiled in strong mode, as this method | 1544 /// Should only be used on code compiled in strong mode, as this method |
1545 /// assumes the IR is strongly typed. | 1545 /// assumes the IR is strongly typed. |
1546 DartType getStaticType(TypeEnvironment types); | 1546 DartType getStaticType(TypeEnvironment types); |
1547 | 1547 |
1548 /// Returns the static type of the expression as an instantiation of | 1548 /// Returns the static type of the expression as an instantiation of |
1549 /// [superclass]. | 1549 /// [superclass]. |
1550 /// | 1550 /// |
1551 /// Should only be used on code compiled in strong mode, as this method | 1551 /// Should only be used on code compiled in strong mode, as this method |
1552 /// assumes the IR is strongly typed. | 1552 /// assumes the IR is strongly typed. |
1553 /// | 1553 /// |
1554 /// This method futhermore assumes that the type of the expression actually | 1554 /// This method furthermore assumes that the type of the expression actually |
1555 /// is a subtype of (some instantiation of) the given [superclass]. | 1555 /// is a subtype of (some instantiation of) the given [superclass]. |
1556 /// If this is not the case, either an exception is thrown or the raw type of | 1556 /// If this is not the case, either an exception is thrown or the raw type of |
1557 /// [superclass] is returned. | 1557 /// [superclass] is returned. |
1558 InterfaceType getStaticTypeAsInstanceOf( | 1558 InterfaceType getStaticTypeAsInstanceOf( |
1559 Class superclass, TypeEnvironment types) { | 1559 Class superclass, TypeEnvironment types) { |
1560 // This method assumes the program is correctly typed, so if the superclass | 1560 // This method assumes the program is correctly typed, so if the superclass |
1561 // is not generic, we can just return its raw type without computing the | 1561 // is not generic, we can just return its raw type without computing the |
1562 // type of this expression. It also ensures that all types are considered | 1562 // type of this expression. It also ensures that all types are considered |
1563 // subtypes of Object (not just interface types), and function types are | 1563 // subtypes of Object (not just interface types), and function types are |
1564 // considered subtypes of Function. | 1564 // considered subtypes of Function. |
(...skipping 3051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4616 /// typedef has not been assigned a canonical name yet. | 4616 /// typedef has not been assigned a canonical name yet. |
4617 /// | 4617 /// |
4618 /// Returns `null` if the typedef is `null`. | 4618 /// Returns `null` if the typedef is `null`. |
4619 CanonicalName getCanonicalNameOfTypedef(Typedef typedef_) { | 4619 CanonicalName getCanonicalNameOfTypedef(Typedef typedef_) { |
4620 if (typedef_ == null) return null; | 4620 if (typedef_ == null) return null; |
4621 if (typedef_.canonicalName == null) { | 4621 if (typedef_.canonicalName == null) { |
4622 throw '$typedef_ has no canonical name'; | 4622 throw '$typedef_ has no canonical name'; |
4623 } | 4623 } |
4624 return typedef_.canonicalName; | 4624 return typedef_.canonicalName; |
4625 } | 4625 } |
OLD | NEW |