Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
Stop passing functions to assert – only bool expressions
Browse files Browse the repository at this point in the history
DDC in Dart SDK 2.0.0-dev.0.0 removed this feature
Plans to remove it entirely in Dart 2: dart-lang/sdk#30326

Closes #634

PiperOrigin-RevId: 169286011
  • Loading branch information
kevmoo authored and alorenzen committed Sep 20, 2017
1 parent 2739aa9 commit fa9b4ed
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions angular/lib/src/core/application_ref.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool _inPlatformCreate = false;
/// Creates a platform.
/// Platforms have to be eagerly created via this function.
PlatformRefImpl createPlatform(Injector injector) {
assert(() {
assert((() {
if (_inPlatformCreate) {
throw new BaseException('Already creating a platform...');
}
Expand All @@ -36,7 +36,7 @@ PlatformRefImpl createPlatform(Injector injector) {
'previous one to create a new one.');
}
return true;
});
})());
if (isDartVM && !assertionsEnabled()) {
window.console.warn(''
'When using Dartium, CHECKED mode is recommended to catch type and '
Expand Down Expand Up @@ -126,13 +126,13 @@ class PlatformRefImpl extends PlatformRef {

/// Given an injector, gets platform initializers to initialize at bootstrap.
void init(Injector injector) {
assert(() {
assert((() {
if (!_inPlatformCreate) {
throw new BaseException(
'Platforms have to be initialized via `createPlatform`!');
}
return true;
});
})());
_injector = injector;

List initializers = injector.get(PLATFORM_INITIALIZER, null);
Expand Down Expand Up @@ -338,14 +338,14 @@ class ApplicationRefImpl extends ApplicationRef {
}

ComponentRef<T> bootstrap<T>(ComponentFactory<T> componentFactory) {
assert(() {
assert((() {
if (!_asyncInitDone) {
throw new BaseException(
'Cannot bootstrap as there are still asynchronous initializers '
'running. Wait for them using waitForAsyncInitializers().');
}
return true;
});
})());

return run(() {
_rootComponentFactories.add(componentFactory);
Expand Down Expand Up @@ -413,12 +413,12 @@ class ApplicationRefImpl extends ApplicationRef {
// Protect against tick being called recursively in development mode.
//
// This is mostly to assert valid changes to the framework, not user code.
assert(() {
assert((() {
if (_runningTick) {
throw new BaseException('ApplicationRef.tick is called recursively');
}
return true;
});
})());

// Run the top-level 'tick' (i.e. detectChanges on root components).
try {
Expand Down
4 changes: 2 additions & 2 deletions angular/lib/src/core/linker/app_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,12 @@ abstract class AppView<T> {
}

// Sanity check in dev-mode that a destroyed view is not checked again.
assert(() {
assert((() {
if (viewData.destroyed) {
throw new ViewDestroyedException('detectChanges');
}
return true;
});
})());

if (lastGuardedView != null) {
// Run change detection in "slow-mode" to catch thrown exceptions.
Expand Down
8 changes: 4 additions & 4 deletions angular/lib/src/di/reflector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ void registerComponent(Type type, dynamic /*ComponentFactory*/ component) {
/// Returns the static factory for [type].
/*ComponentFactory*/ dynamic getComponent(Type type) {
final component = _components[type];
assert(() {
assert((() {
if (component == null) {
throw new StateError('Could not find a component factory for $type.');
}
return true;
});
})());
return component;
}

Expand All @@ -52,12 +52,12 @@ void registerFactory(Object typeOrFunc, Function factory) {
/// Returns a factory function for creating [type].
Function getFactory(Type type) {
final factory = _factories[type];
assert(() {
assert((() {
if (factory == null) {
throw new StateError('Could not find a factory for $type.');
}
return true;
});
})());
return factory;
}

Expand Down
4 changes: 2 additions & 2 deletions angular/lib/src/security/style_sanitizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ String internalSanitizeStyle(String value) {
}
if (!failed) return value;
}
assert(() {
assert((() {
_logger.warning('Sanitizing unsafe style value $value '
'(see http://g.co/ng/security#xss).');
return true;
});
})());
return 'unsafe';
}

0 comments on commit fa9b4ed

Please sign in to comment.