From 7199398092ee67b67595ac858166cfa7bc73286a Mon Sep 17 00:00:00 2001 From: Kun Zhao Date: Tue, 16 Feb 2016 14:10:33 -0800 Subject: [PATCH] Fix unhandle exception when access ElementAnnotationImpl.constantValue BUG= R=brianwilkerson@google.com Review URL: https://codereview.chromium.org/1693223002 . Patch from Kun Zhao . --- pkg/analyzer/lib/src/dart/element/element.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart index 81f557c958b6..9677e893fea3 100644 --- a/pkg/analyzer/lib/src/dart/element/element.dart +++ b/pkg/analyzer/lib/src/dart/element/element.dart @@ -1221,7 +1221,7 @@ class ConstFieldElementImpl extends FieldElementImpl with ConstVariableElement { ConstFieldElementImpl.forNode(Identifier name) : super.forNode(name); @override - DartObject get constantValue => _result.value; + DartObject get constantValue => _result?.value; @override EvaluationResultImpl get evaluationResult => _result; @@ -1255,7 +1255,7 @@ class ConstLocalVariableElementImpl extends LocalVariableElementImpl ConstLocalVariableElementImpl.forNode(Identifier name) : super.forNode(name); @override - DartObject get constantValue => _result.value; + DartObject get constantValue => _result?.value; @override EvaluationResultImpl get evaluationResult => _result; @@ -1414,7 +1414,7 @@ class ConstTopLevelVariableElementImpl extends TopLevelVariableElementImpl : super.forNode(name); @override - DartObject get constantValue => _result.value; + DartObject get constantValue => _result?.value; @override EvaluationResultImpl get evaluationResult => _result; @@ -1473,7 +1473,7 @@ class DefaultFieldFormalParameterElementImpl : super.forNode(name); @override - DartObject get constantValue => _result.value; + DartObject get constantValue => _result?.value; @override EvaluationResultImpl get evaluationResult => _result; @@ -1507,7 +1507,7 @@ class DefaultParameterElementImpl extends ParameterElementImpl DefaultParameterElementImpl.forNode(Identifier name) : super.forNode(name); @override - DartObject get constantValue => _result.value; + DartObject get constantValue => _result?.value; @override EvaluationResultImpl get evaluationResult => _result; @@ -1610,7 +1610,7 @@ class ElementAnnotationImpl implements ElementAnnotation { ElementAnnotationImpl(this.compilationUnit); @override - DartObject get constantValue => evaluationResult.value; + DartObject get constantValue => evaluationResult?.value; @override AnalysisContext get context => compilationUnit.library.context;