Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1821)

Unified Diff: runtime/lib/errors_patch.dart

Issue 2759973004: Fix observatory tests broken by running dartfmt. Temporarily reverted formatting for evaluate_activ… (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/double_patch.dart ('k') | runtime/lib/expando_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/errors_patch.dart
diff --git a/runtime/lib/errors_patch.dart b/runtime/lib/errors_patch.dart
index 898f7f6abe52bd2c4dfdbb1b1813ad3653d8de0c..cf42b572f7c9a7904b0c590174835b36af7ade8b 100644
--- a/runtime/lib/errors_patch.dart
+++ b/runtime/lib/errors_patch.dart
@@ -2,25 +2,27 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-@patch class Error {
- @patch static String _objectToString(Object object) {
+@patch
+class Error {
+ @patch
+ static String _objectToString(Object object) {
return Object._toString(object);
}
- @patch static String _stringToSafeString(String string) {
+ @patch
+ static String _stringToSafeString(String string) {
return JSON.encode(string);
}
- @patch StackTrace get stackTrace => _stackTrace;
+ @patch
+ StackTrace get stackTrace => _stackTrace;
StackTrace _stackTrace;
}
class _AssertionError extends Error implements AssertionError {
_AssertionError._create(
- this._failedAssertion, this._url, this._line, this._column,
- this.message);
-
+ this._failedAssertion, this._url, this._line, this._column, this.message);
// AssertionError_throwNew in errors.cc fishes the assertion source code
// out of the script. It expects a Dart stack frame from class
@@ -30,7 +32,7 @@ class _AssertionError extends Error implements AssertionError {
}
static _doThrowNew(int assertionStart, int assertionEnd, Object message)
- native "AssertionError_throwNew";
+ native "AssertionError_throwNew";
static _evaluateAssertion(condition) {
if (identical(condition, true) || identical(condition, false)) {
@@ -64,6 +66,7 @@ class _AssertionError extends Error implements AssertionError {
return "'$_url': Failed assertion: line $_line$columnInfo: "
"'$_failedAssertion': $_messageString";
}
+
final String _failedAssertion;
final String _url;
final int _line;
@@ -75,19 +78,16 @@ class _TypeError extends _AssertionError implements TypeError {
_TypeError._create(String url, int line, int column, String errorMsg)
: super._create("is assignable", url, line, column, errorMsg);
- static _throwNew(int location,
- Object src_value,
- _Type dst_type,
- String dst_name,
- String bound_error_msg)
- native "TypeError_throwNew";
-
- static _throwNewIfNotLoaded(_LibraryPrefix prefix,
- int location,
- Object src_value,
- _Type dst_type,
- String dst_name,
- String bound_error_msg) {
+ static _throwNew(int location, Object src_value, _Type dst_type,
+ String dst_name, String bound_error_msg) native "TypeError_throwNew";
+
+ static _throwNewIfNotLoaded(
+ _LibraryPrefix prefix,
+ int location,
+ Object src_value,
+ _Type dst_type,
+ String dst_name,
+ String bound_error_msg) {
if (!prefix.isLoaded()) {
_throwNew(location, src_value, dst_type, dst_name, bound_error_msg);
}
@@ -111,7 +111,8 @@ class _CastError extends Error implements CastError {
final String _errorMsg;
}
-@patch class FallThroughError {
+@patch
+class FallThroughError {
FallThroughError._create(this._url, this._line);
static _throwNew(int case_clause_pos) native "FallThroughError_throwNew";
@@ -133,28 +134,32 @@ class _InternalError {
final String _msg;
}
-@patch class UnsupportedError {
+@patch
+class UnsupportedError {
static _throwNew(String msg) {
throw new UnsupportedError(msg);
}
}
-@patch class CyclicInitializationError {
+@patch
+class CyclicInitializationError {
static _throwNew(String variableName) {
throw new CyclicInitializationError(variableName);
}
}
-@patch class AbstractClassInstantiationError {
+@patch
+class AbstractClassInstantiationError {
AbstractClassInstantiationError._create(
this._className, this._url, this._line);
static _throwNew(int case_clause_pos, String className)
native "AbstractClassInstantiationError_throwNew";
- @patch String toString() {
+ @patch
+ String toString() {
return "Cannot instantiate abstract class $_className: "
- "_url '$_url' line $_line";
+ "_url '$_url' line $_line";
}
// These new fields cannot be declared final, because a constructor exists
@@ -163,16 +168,13 @@ class _InternalError {
int _line;
}
-@patch class NoSuchMethodError {
+@patch
+class NoSuchMethodError {
// The compiler emits a call to _throwNew when it cannot resolve a static
// method at compile time. The receiver is actually the literal class of the
// unresolved method.
- static void _throwNew(Object receiver,
- String memberName,
- int invocation_type,
- List arguments,
- List argumentNames,
- List existingArgumentNames) {
+ static void _throwNew(Object receiver, String memberName, int invocation_type,
+ List arguments, List argumentNames, List existingArgumentNames) {
int numNamedArguments = argumentNames == null ? 0 : argumentNames.length;
int numPositionalArguments = arguments == null ? 0 : arguments.length;
numPositionalArguments -= numNamedArguments;
@@ -191,24 +193,26 @@ class _InternalError {
var arg_value = arguments[numPositionalArguments + i];
namedArguments[new Symbol(argumentNames[i])] = arg_value;
}
- throw new NoSuchMethodError._withType(receiver,
- new Symbol(memberName),
- invocation_type,
- positionalArguments,
- namedArguments,
- existingArgumentNames);
+ throw new NoSuchMethodError._withType(
+ receiver,
+ new Symbol(memberName),
+ invocation_type,
+ positionalArguments,
+ namedArguments,
+ existingArgumentNames);
}
- static void _throwNewIfNotLoaded(_LibraryPrefix prefix,
- Object receiver,
- String memberName,
- int invocation_type,
- List arguments,
- List argumentNames,
- List existingArgumentNames) {
+ static void _throwNewIfNotLoaded(
+ _LibraryPrefix prefix,
+ Object receiver,
+ String memberName,
+ int invocation_type,
+ List arguments,
+ List argumentNames,
+ List existingArgumentNames) {
if (!prefix.isLoaded()) {
- _throwNew(receiver, memberName, invocation_type, arguments,
- argumentNames, existingArgumentNames);
+ _throwNew(receiver, memberName, invocation_type, arguments, argumentNames,
+ existingArgumentNames);
}
}
@@ -218,11 +222,9 @@ class _InternalError {
final int _invocation_type;
@patch
- NoSuchMethodError(Object receiver,
- Symbol memberName,
- List positionalArguments,
- Map<Symbol, dynamic> namedArguments,
- [List existingArgumentNames = null])
+ NoSuchMethodError(Object receiver, Symbol memberName,
+ List positionalArguments, Map<Symbol, dynamic> namedArguments,
+ [List existingArgumentNames = null])
: _receiver = receiver,
_memberName = memberName,
_arguments = positionalArguments,
@@ -232,29 +234,30 @@ class _InternalError {
// This constructor seems to be called with either strings or
// values read from another NoSuchMethodError.
- NoSuchMethodError._withType(this._receiver,
- /*String|Symbol*/ memberName,
- this._invocation_type,
- this._arguments,
- Map<dynamic, dynamic> namedArguments,
- [List existingArgumentNames = null])
+ NoSuchMethodError._withType(
+ this._receiver,
+ /*String|Symbol*/ memberName,
+ this._invocation_type,
+ this._arguments,
+ Map<dynamic, dynamic> namedArguments,
+ [List existingArgumentNames = null])
: this._memberName =
(memberName is String) ? new Symbol(memberName) : memberName,
- this._namedArguments =
- (namedArguments == null)
- ? null
- : new Map<Symbol, dynamic>.fromIterable(
- namedArguments.keys,
- key: (k) => (k is String) ? new Symbol(k) : k,
- value: (k) => namedArguments[k]),
+ this._namedArguments = (namedArguments == null)
+ ? null
+ : new Map<Symbol, dynamic>.fromIterable(namedArguments.keys,
+ key: (k) => (k is String) ? new Symbol(k) : k,
+ value: (k) => namedArguments[k]),
this._existingArgumentNames = existingArgumentNames;
- @patch String toString() {
+ @patch
+ String toString() {
var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) &
_InvocationMirror._CALL_MASK;
var type = _invocation_type & _InvocationMirror._TYPE_MASK;
- String memberName = (_memberName == null) ? "" :
- internal.Symbol.getUnmangledName(_memberName);
+ String memberName = (_memberName == null)
+ ? ""
+ : internal.Symbol.getUnmangledName(_memberName);
if (type == _InvocationMirror._LOCAL_VAR) {
return "NoSuchMethodError: Cannot assign to final variable '$memberName'";
@@ -286,61 +289,73 @@ class _InternalError {
String type_str;
if (type >= 0 && type < 5) {
- type_str = (const ["method", "getter", "setter", "getter or setter",
- "variable"])[type];
+ type_str = (const [
+ "method",
+ "getter",
+ "setter",
+ "getter or setter",
+ "variable"
+ ])[type];
}
StringBuffer msg_buf = new StringBuffer("NoSuchMethodError: ");
bool is_type_call = false;
switch (level) {
- case _InvocationMirror._DYNAMIC: {
- if (_receiver == null) {
- if (args_mismatch) {
- msg_buf.writeln("The null object does not have a $type_str "
- "'$memberName'$args_message.");
- } else {
- msg_buf.writeln("The $type_str '$memberName' was called on null.");
- }
- } else {
- if (_receiver is Function) {
- msg_buf.writeln("Closure call with mismatched arguments: "
- "function '$memberName'");
- } else if (_receiver is _Type && memberName == "call") {
- is_type_call = true;
- String name = _receiver.toString();
- msg_buf.writeln("Attempted to use type '$name' as a function. "
- "Since types do not define a method 'call', this is not "
- "possible. Did you intend to call the $name constructor and "
- "forget the 'new' operator?");
+ case _InvocationMirror._DYNAMIC:
+ {
+ if (_receiver == null) {
+ if (args_mismatch) {
+ msg_buf.writeln("The null object does not have a $type_str "
+ "'$memberName'$args_message.");
+ } else {
+ msg_buf
+ .writeln("The $type_str '$memberName' was called on null.");
+ }
} else {
- msg_buf.writeln("Class '${_receiver.runtimeType}' has no instance "
- "$type_str '$memberName'$args_message.");
+ if (_receiver is Function) {
+ msg_buf.writeln("Closure call with mismatched arguments: "
+ "function '$memberName'");
+ } else if (_receiver is _Type && memberName == "call") {
+ is_type_call = true;
+ String name = _receiver.toString();
+ msg_buf.writeln("Attempted to use type '$name' as a function. "
+ "Since types do not define a method 'call', this is not "
+ "possible. Did you intend to call the $name constructor and "
+ "forget the 'new' operator?");
+ } else {
+ msg_buf
+ .writeln("Class '${_receiver.runtimeType}' has no instance "
+ "$type_str '$memberName'$args_message.");
+ }
}
+ break;
}
- break;
- }
- case _InvocationMirror._SUPER: {
- msg_buf.writeln("Super class of class '${_receiver.runtimeType}' has "
+ case _InvocationMirror._SUPER:
+ {
+ msg_buf.writeln("Super class of class '${_receiver.runtimeType}' has "
"no instance $type_str '$memberName'$args_message.");
- memberName = "super.$memberName";
- break;
- }
- case _InvocationMirror._STATIC: {
- msg_buf.writeln("No static $type_str '$memberName'$args_message "
- "declared in class '$_receiver'.");
- break;
- }
- case _InvocationMirror._CONSTRUCTOR: {
- msg_buf.writeln("No constructor '$memberName'$args_message declared "
- "in class '$_receiver'.");
- memberName = "new $memberName";
- break;
- }
- case _InvocationMirror._TOP_LEVEL: {
- msg_buf.writeln("No top-level $type_str '$memberName'$args_message "
- "declared.");
- break;
- }
+ memberName = "super.$memberName";
+ break;
+ }
+ case _InvocationMirror._STATIC:
+ {
+ msg_buf.writeln("No static $type_str '$memberName'$args_message "
+ "declared in class '$_receiver'.");
+ break;
+ }
+ case _InvocationMirror._CONSTRUCTOR:
+ {
+ msg_buf.writeln("No constructor '$memberName'$args_message declared "
+ "in class '$_receiver'.");
+ memberName = "new $memberName";
+ break;
+ }
+ case _InvocationMirror._TOP_LEVEL:
+ {
+ msg_buf.writeln("No top-level $type_str '$memberName'$args_message "
+ "declared.");
+ break;
+ }
}
if (level == _InvocationMirror._TOP_LEVEL) {
@@ -375,7 +390,6 @@ class _InternalError {
}
}
-
class _CompileTimeError extends Error {
final String _errorMsg;
_CompileTimeError(this._errorMsg);
« no previous file with comments | « runtime/lib/double_patch.dart ('k') | runtime/lib/expando_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698