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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 11415028: Remove NullPointerException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed VM bugs. Created 8 years, 1 month 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
Index: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
index 8e9dbb1d3049b63bb4315684e785c763713ae8c1..8d912dd7d79037859a96195b13860b698d0c5dae 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -62,7 +62,7 @@ leB(var a, var b) => (a is num && b is num)
: identical(le$slow(a, b), true);
index(var a, var index) {
- // The type test may cause a NullPointerException to be thrown but
+ // The type test may cause a NoSuchMethodError to be thrown but
// that matches the specification of what the indexing operator is
// supposed to do.
bool isJsArrayOrString = JS('bool',
@@ -78,7 +78,7 @@ index(var a, var index) {
}
indexSet(var a, var index, var value) {
- // The type test may cause a NullPointerException to be thrown but
+ // The type test may cause a NoSuchMethodError to be thrown but
// that matches the specification of what the indexing operator is
// supposed to do.
bool isMutableJsArray = JS('bool',
@@ -105,7 +105,6 @@ bool checkNumbers(var a, var b) {
if (b is num) {
return true;
} else {
- checkNull(b);
throw new ArgumentError(b);
}
}
@@ -659,7 +658,6 @@ class Primitives {
}
static valueFromDateString(str) {
- checkNull(str);
if (str is !String) throw new ArgumentError(str);
var value = JS('num', r'Date.parse(#)', str);
if (value.isNaN) throw new ArgumentError(str);
@@ -667,16 +665,14 @@ class Primitives {
}
static getProperty(object, key) {
- checkNull(object);
- if (object is bool || object is num || object is String) {
+ if (object == null || object is bool || object is num || object is String) {
throw new ArgumentError(object);
}
return JS('var', '#[#]', object, key);
}
static void setProperty(object, key, value) {
- checkNull(object);
- if (object is bool || object is num || object is String) {
+ if (object == null || object is bool || object is num || object is String) {
throw new ArgumentError(object);
}
JS('void', '#[#] = #', object, key, value);
@@ -750,8 +746,6 @@ listInsertRange(receiver, start, length, initialValue) {
if (length == 0) {
return;
}
- checkNull(start); // TODO(ahe): This is not specified but co19 tests it.
- checkNull(length); // TODO(ahe): This is not specified but co19 tests it.
if (length is !int) throw new ArgumentError(length);
if (length < 0) throw new ArgumentError(length);
if (start is !int) throw new ArgumentError(start);
@@ -779,13 +773,12 @@ stringLastIndexOfUnchecked(receiver, element, start)
checkNull(object) {
- if (object == null) throw new NullPointerException();
+ if (object == null) throw new ArgumentError(null);
return object;
}
checkNum(value) {
if (value is !num) {
- checkNull(value);
throw new ArgumentError(value);
}
return value;
@@ -793,7 +786,6 @@ checkNum(value) {
checkInt(value) {
if (value is !int) {
- checkNull(value);
throw new ArgumentError(value);
}
return value;
@@ -801,7 +793,6 @@ checkInt(value) {
checkBool(value) {
if (value is !bool) {
- checkNull(value);
throw new ArgumentError(value);
}
return value;
@@ -809,7 +800,6 @@ checkBool(value) {
checkString(value) {
if (value is !String) {
- checkNull(value);
throw new ArgumentError(value);
}
return value;
@@ -894,7 +884,7 @@ class MathNatives {
* object out of the wrapper again.
*/
$throw(ex) {
- if (ex == null) ex = const NullPointerException();
+ if (ex == null) ex = const NullThrownError();
var jsError = JS('var', r'new Error()');
JS('void', r'#.name = #', jsError, ex);
JS('void', r'#.description = #', jsError, ex);
@@ -958,7 +948,7 @@ unwrapException(ex) {
type == 'called_non_callable' ||
type == 'non_object_property_call' ||
type == 'non_object_property_load') {
- return new NullPointerException();
+ return new NoSuchMethodError(null, name, [], {});
} else if (type == 'undefined_method') {
return new NoSuchMethodError('', name, [], {});
}
@@ -972,7 +962,7 @@ unwrapException(ex) {
if (message.endsWith('is null') ||
message.endsWith('is undefined') ||
message.endsWith('is null or undefined')) {
- return new NullPointerException();
+ return new NoSuchMethodError(null, '<unknown>', [], {});
} else if (message.contains(' is not a function') ||
(ieErrorCode == 438 && ieFacilityNumber == 10)) {
// Examples:

Powered by Google App Engine
This is Rietveld 408576698