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

Unified Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 2898403002: Use failedAt in more places (Closed)
Patch Set: Created 3 years, 7 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
Index: pkg/compiler/lib/src/js_backend/backend.dart
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index e587bbfc06d18e308f6785f4cef188ae7eb93ff1..e783dc20f7e0721e3419bf2f49b2cfb2961cf8b1 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -354,8 +354,8 @@ class JavaScriptBackend {
Namer _namer;
Namer get namer {
- assert(invariant(NO_LOCATION_SPANNABLE, _namer != null,
- message: "Namer has not been created yet."));
+ assert(_namer != null,
+ failedAt(NO_LOCATION_SPANNABLE, "Namer has not been created yet."));
return _namer;
}
@@ -537,24 +537,28 @@ class JavaScriptBackend {
/// Resolution support for generating table of interceptors and
/// constructors for custom elements.
CustomElementsResolutionAnalysis get customElementsResolutionAnalysis {
- assert(invariant(
- NO_LOCATION_SPANNABLE, _customElementsResolutionAnalysis != null,
- message: "CustomElementsResolutionAnalysis has not been created yet."));
+ assert(
+ _customElementsResolutionAnalysis != null,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "CustomElementsResolutionAnalysis has not been created yet."));
return _customElementsResolutionAnalysis;
}
/// Codegen support for generating table of interceptors and
/// constructors for custom elements.
CustomElementsCodegenAnalysis get customElementsCodegenAnalysis {
- assert(invariant(
- NO_LOCATION_SPANNABLE, _customElementsCodegenAnalysis != null,
- message: "CustomElementsCodegenAnalysis has not been created yet."));
+ assert(
+ _customElementsCodegenAnalysis != null,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "CustomElementsCodegenAnalysis has not been created yet."));
return _customElementsCodegenAnalysis;
}
NativeBasicData get nativeBasicData {
- assert(invariant(NO_LOCATION_SPANNABLE, _nativeBasicData != null,
- message: "NativeBasicData has not been computed yet."));
+ assert(
+ _nativeBasicData != null,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "NativeBasicData has not been computed yet."));
return _nativeBasicData;
}
@@ -562,17 +566,19 @@ class JavaScriptBackend {
/// Resolution analysis for tracking reflective access to type variables.
TypeVariableResolutionAnalysis get typeVariableResolutionAnalysis {
- assert(invariant(
- NO_LOCATION_SPANNABLE, _typeVariableCodegenAnalysis == null,
- message: "TypeVariableHandler has already been created."));
+ assert(
+ _typeVariableCodegenAnalysis == null,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "TypeVariableHandler has already been created."));
return _typeVariableResolutionAnalysis;
}
/// Codegen handler for reflective access to type variables.
TypeVariableCodegenAnalysis get typeVariableCodegenAnalysis {
- assert(invariant(
- NO_LOCATION_SPANNABLE, _typeVariableCodegenAnalysis != null,
- message: "TypeVariableHandler has not been created yet."));
+ assert(
+ _typeVariableCodegenAnalysis != null,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "TypeVariableHandler has not been created yet."));
return _typeVariableCodegenAnalysis;
}
@@ -586,47 +592,61 @@ class JavaScriptBackend {
/// Codegen support for computing reflectable elements.
MirrorsCodegenAnalysis get mirrorsCodegenAnalysis {
- assert(invariant(NO_LOCATION_SPANNABLE, _mirrorsCodegenAnalysis != null,
- message: "MirrorsCodegenAnalysis has not been created yet."));
+ assert(
+ _mirrorsCodegenAnalysis != null,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "MirrorsCodegenAnalysis has not been created yet."));
return _mirrorsCodegenAnalysis;
}
/// Codegen support for tree-shaking entries of `LookupMap`.
LookupMapAnalysis get lookupMapAnalysis {
- assert(invariant(NO_LOCATION_SPANNABLE, _lookupMapAnalysis != null,
- message: "LookupMapAnalysis has not been created yet."));
+ assert(
+ _lookupMapAnalysis != null,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "LookupMapAnalysis has not been created yet."));
return _lookupMapAnalysis;
}
OneShotInterceptorData get oneShotInterceptorData {
- assert(invariant(NO_LOCATION_SPANNABLE, _oneShotInterceptorData != null,
- message: "OneShotInterceptorData has not been prepared yet."));
+ assert(
+ _oneShotInterceptorData != null,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "OneShotInterceptorData has not been prepared yet."));
return _oneShotInterceptorData;
}
RuntimeTypesNeed get rtiNeed {
- assert(invariant(NO_LOCATION_SPANNABLE, _rtiNeed != null,
- message: "RuntimeTypesNeed has not been computed yet."));
+ assert(
+ _rtiNeed != null,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "RuntimeTypesNeed has not been computed yet."));
return _rtiNeed;
}
RuntimeTypesNeedBuilder get rtiNeedBuilder {
- assert(invariant(NO_LOCATION_SPANNABLE, _rtiNeed == null,
- message: "RuntimeTypesNeed has already been computed."));
+ assert(
+ _rtiNeed == null,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "RuntimeTypesNeed has already been computed."));
return _rtiNeedBuilder;
}
RuntimeTypesChecksBuilder get rtiChecksBuilder {
- assert(invariant(NO_LOCATION_SPANNABLE, !_rti.rtiChecksBuilderClosed,
- message: "RuntimeTypesChecks has already been computed."));
+ assert(
+ !_rti.rtiChecksBuilderClosed,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "RuntimeTypesChecks has already been computed."));
return _rti;
}
RuntimeTypesSubstitutions get rtiSubstitutions => _rti;
RuntimeTypesEncoder get rtiEncoder {
- assert(invariant(NO_LOCATION_SPANNABLE, _rtiEncoder != null,
- message: "RuntimeTypesEncoder has not been created."));
+ assert(
+ _rtiEncoder != null,
+ failedAt(NO_LOCATION_SPANNABLE,
+ "RuntimeTypesEncoder has not been created."));
return _rtiEncoder;
}
@@ -721,9 +741,10 @@ class JavaScriptBackend {
.lookupClassMember(interceptorClass, member.name);
// Interceptors must override all Object methods due to calling convention
// differences.
- assert(invariant(interceptorMember,
+ assert(
interceptorMember.enclosingClass == interceptorClass,
- message:
+ failedAt(
+ interceptorMember,
"Member ${member.name} not overridden in ${interceptorClass}. "
"Found $interceptorMember from "
"${interceptorMember.enclosingClass}."));
@@ -949,12 +970,13 @@ class JavaScriptBackend {
.transformCodegenImpact(work.registry.worldImpact);
}
} else {
- assert(invariant(
- variableElement,
+ assert(
variableElement.isInstanceMember ||
constant.isImplicit ||
constant.isPotential,
- message: "Constant expression without value: "
+ failedAt(
+ variableElement,
+ "Constant expression without value: "
"${constant.toStructuredText()}."));
}
} else {
@@ -1000,7 +1022,7 @@ class JavaScriptBackend {
* Invariant: [element] must be a declaration element.
*/
String getGeneratedCode(Element element) {
- assert(invariant(element, element.isDeclaration));
+ assert(element.isDeclaration, failedAt(element));
return jsAst.prettyPrint(generatedCode[element], compiler.options);
}

Powered by Google App Engine
This is Rietveld 408576698