OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart._js_helper; | 5 library dart._js_helper; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'dart:_debugger' show stackTraceMapper; | 9 import 'dart:_debugger' show stackTraceMapper; |
10 | 10 |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 // When they are, remove the 'Implementation' here. | 773 // When they are, remove the 'Implementation' here. |
774 | 774 |
775 /** Thrown by type assertions that fail. */ | 775 /** Thrown by type assertions that fail. */ |
776 class TypeErrorImplementation extends Error implements TypeError { | 776 class TypeErrorImplementation extends Error implements TypeError { |
777 final String message; | 777 final String message; |
778 | 778 |
779 /** | 779 /** |
780 * Normal type error caused by a failed subtype test. | 780 * Normal type error caused by a failed subtype test. |
781 */ | 781 */ |
782 // TODO(sra): Include [value] in message. | 782 // TODO(sra): Include [value] in message. |
783 TypeErrorImplementation(Object value, Object actualType, Object expectedType) | 783 TypeErrorImplementation(Object value, Object actualType, Object expectedType, |
| 784 bool strongModeError) |
784 : message = "Type '${actualType}' is not a subtype " | 785 : message = "Type '${actualType}' is not a subtype " |
785 "of type '${expectedType}'"; | 786 "of type '${expectedType}'" + |
| 787 (strongModeError ? "" : " in strong mode"); |
786 | 788 |
787 TypeErrorImplementation.fromMessage(String this.message); | 789 TypeErrorImplementation.fromMessage(String this.message); |
788 | 790 |
789 String toString() => message; | 791 String toString() => message; |
790 } | 792 } |
791 | 793 |
792 /** Thrown by the 'as' operator if the cast isn't valid. */ | 794 /** Thrown by the 'as' operator if the cast isn't valid. */ |
793 class CastErrorImplementation extends Error implements CastError { | 795 class CastErrorImplementation extends Error implements CastError { |
794 // TODO(lrn): Rename to CastError (and move implementation into core). | 796 // TODO(lrn): Rename to CastError (and move implementation into core). |
795 final String message; | 797 final String message; |
796 | 798 |
797 /** | 799 /** |
798 * Normal cast error caused by a failed type cast. | 800 * Normal cast error caused by a failed type cast. |
799 */ | 801 */ |
800 // TODO(sra): Include [value] in message. | 802 // TODO(sra): Include [value] in message. |
801 CastErrorImplementation(Object value, Object actualType, Object expectedType) | 803 CastErrorImplementation(Object value, Object actualType, Object expectedType, |
| 804 bool strongModeError) |
802 : message = "CastError: Casting value of type '$actualType' to" | 805 : message = "CastError: Casting value of type '$actualType' to" |
803 " incompatible type '$expectedType'"; | 806 " type '$expectedType' which is incompatible" + |
| 807 (strongModeError ? "" : " in strong mode"); |
804 | 808 |
805 String toString() => message; | 809 String toString() => message; |
806 } | 810 } |
807 | 811 |
808 /// Thrown by type assertions that fail in strong mode that would have passed in | |
809 /// standard Dart. | |
810 class StrongModeTypeError extends Error implements TypeError, StrongModeError { | |
811 final String message; | |
812 // TODO(sra): Include [value] in message. | |
813 StrongModeTypeError(Object value, Object actualType, Object expectedType) | |
814 : message = "Type '${actualType}' is not a subtype " | |
815 "of type '${expectedType}' in strong mode"; | |
816 String toString() => message; | |
817 } | |
818 | |
819 /// Thrown by casts that fail in strong mode that would have passed in standard | |
820 /// Dart. | |
821 class StrongModeCastError extends Error implements CastError, StrongModeError { | |
822 final String message; | |
823 // TODO(sra): Include [value] in message. | |
824 StrongModeCastError(Object value, Object actualType, Object expectedType) | |
825 : message = "CastError: Casting value of type '$actualType' to" | |
826 " type '$expectedType' which is incompatible in strong mode"; | |
827 String toString() => message; | |
828 } | |
829 | |
830 /// Used for Strong-mode errors other than type assertions and casts. | 812 /// Used for Strong-mode errors other than type assertions and casts. |
831 class StrongModeErrorImplementation extends Error implements StrongModeError { | 813 // TODO(jmesserly): remove this: https://github.com/dart-lang/sdk/issues/30095 |
| 814 class StrongModeErrorImplementation extends Error { |
832 final String message; | 815 final String message; |
833 StrongModeErrorImplementation(this.message); | 816 StrongModeErrorImplementation(this.message); |
834 String toString() => message; | 817 String toString() => message; |
835 } | 818 } |
836 | 819 |
837 class FallThroughErrorImplementation extends FallThroughError { | 820 class FallThroughErrorImplementation extends FallThroughError { |
838 FallThroughErrorImplementation(); | 821 FallThroughErrorImplementation(); |
839 String toString() => "Switch case fall-through."; | 822 String toString() => "Switch case fall-through."; |
840 } | 823 } |
841 | 824 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 if (dart.polyfill(object)) { | 897 if (dart.polyfill(object)) { |
915 dart.applyAllExtensions(object); | 898 dart.applyAllExtensions(object); |
916 } | 899 } |
917 } catch (e) { | 900 } catch (e) { |
918 // This may fail due to cross-origin errors. In that case, we shouldn't | 901 // This may fail due to cross-origin errors. In that case, we shouldn't |
919 // need to polyfill as we can't get objects from that frame. | 902 // need to polyfill as we can't get objects from that frame. |
920 | 903 |
921 // TODO(vsm): Detect this more robustly - ideally before we try to polyfill. | 904 // TODO(vsm): Detect this more robustly - ideally before we try to polyfill. |
922 } | 905 } |
923 } | 906 } |
OLD | NEW |