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

Unified Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 1933763002: Use null-aware operators to clean up the code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Additional clean-up Created 4 years, 8 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 | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/lib/src/generated/incremental_resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/error_verifier.dart
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 7984357e986018cc14937ecbbeb96e04156bf638..6d2f8b98276c829a7c62906b45c5325d8e7de2ea 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -648,8 +648,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
try {
_inAsync = node.isAsynchronous;
_inGenerator = node.isGenerator;
- FunctionType functionType =
- _enclosingFunction == null ? null : _enclosingFunction.type;
+ FunctionType functionType = _enclosingFunction?.type;
DartType expectedReturnType = functionType == null
? DynamicTypeImpl.instance
: functionType.returnType;
@@ -1796,8 +1795,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
return;
}
FormalParameterList formalParameterList = method.parameters;
- NodeList<FormalParameter> parameterList =
- formalParameterList != null ? formalParameterList.parameters : null;
+ NodeList<FormalParameter> parameterList = formalParameterList?.parameters;
List<AstNode> parameters =
parameterList != null ? new List.from(parameterList) : null;
_checkForAllInvalidOverrideErrorCodesForExecutable(executableElement,
@@ -1920,8 +1918,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
* [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE].
*/
void _checkForAllReturnStatementErrorCodes(ReturnStatement statement) {
- FunctionType functionType =
- _enclosingFunction == null ? null : _enclosingFunction.type;
+ FunctionType functionType = _enclosingFunction?.type;
DartType expectedReturnType = functionType == null
? DynamicTypeImpl.instance
: functionType.returnType;
@@ -2038,8 +2035,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
return;
}
ParameterElement staticParameterElement = argument.staticParameterElement;
- DartType staticParameterType =
- staticParameterElement == null ? null : staticParameterElement.type;
+ DartType staticParameterType = staticParameterElement?.type;
_checkForArgumentTypeNotAssignableWithExpectedTypes(argument,
staticParameterType, StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE);
}
@@ -3703,9 +3699,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
// The type of the loop variable.
- SimpleIdentifier variable = node.identifier != null
- ? node.identifier
- : node.loopVariable.identifier;
+ SimpleIdentifier variable = node.identifier ?? node.loopVariable.identifier;
DartType variableType = getStaticType(variable);
DartType loopType = node.awaitKeyword != null
@@ -3792,8 +3786,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
!executableElement.isOperator) {
HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
InterfaceType superclassType = _enclosingClass.supertype;
- ClassElement superclassElement =
- superclassType == null ? null : superclassType.element;
+ ClassElement superclassElement = superclassType?.element;
bool executableElementPrivate =
Identifier.isPrivateName(executableElementName);
while (superclassElement != null &&
@@ -3845,8 +3838,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
}
superclassType = superclassElement.supertype;
- superclassElement =
- superclassType == null ? null : superclassType.element;
+ superclassElement = superclassType?.element;
}
}
return false;
@@ -3864,8 +3856,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
return;
}
ParameterElement staticParameterElement = argument.staticParameterElement;
- DartType staticParameterType =
- staticParameterElement == null ? null : staticParameterElement.type;
+ DartType staticParameterType = staticParameterElement?.type;
_checkForArgumentTypeNotAssignable(argument, staticParameterType, _intType,
StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE);
}
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/lib/src/generated/incremental_resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698