@@ -140,36 +140,29 @@ class ReturnTypeVerifier {
140140 var S = getStaticType (expression);
141141
142142 void reportTypeError () {
143- String displayName = enclosingExecutable.element.displayName;
144- if (enclosingExecutable.isConstructor) {
145- var constructor = enclosingExecutable.element as ConstructorElement ;
146- var className = constructor.enclosingElement.displayName;
147- var constructorBaseName = constructor.displayName;
148- var constructorName = constructorBaseName.isEmpty
149- ? className
150- : '$className .$constructorBaseName ' ;
151- _errorReporter.reportErrorForNode (
152- StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_CONSTRUCTOR ,
153- expression,
154- [S , T , constructorName],
155- );
156- } else if (displayName.isEmpty) {
143+ if (enclosingExecutable.isClosure) {
157144 _errorReporter.reportErrorForNode (
158145 StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_CLOSURE ,
159146 expression,
160147 [S , T ],
161148 );
162- } else if (enclosingExecutable.isMethod ) {
149+ } else if (enclosingExecutable.isConstructor ) {
163150 _errorReporter.reportErrorForNode (
164- StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_METHOD ,
151+ StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_CONSTRUCTOR ,
165152 expression,
166- [S , T , displayName],
153+ [S , T , enclosingExecutable. displayName],
167154 );
168- } else {
155+ } else if (enclosingExecutable.isFunction) {
169156 _errorReporter.reportErrorForNode (
170157 StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_FUNCTION ,
171158 expression,
172- [S , T , displayName],
159+ [S , T , enclosingExecutable.displayName],
160+ );
161+ } else if (enclosingExecutable.isMethod) {
162+ _errorReporter.reportErrorForNode (
163+ StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_METHOD ,
164+ expression,
165+ [S , T , enclosingExecutable.displayName],
173166 );
174167 }
175168 }
@@ -248,36 +241,29 @@ class ReturnTypeVerifier {
248241 var S = getStaticType (expression);
249242
250243 void reportTypeError () {
251- String displayName = enclosingExecutable.element.displayName;
252- if (enclosingExecutable.isConstructor) {
253- var constructor = enclosingExecutable.element as ConstructorElement ;
254- var className = constructor.enclosingElement.displayName;
255- var constructorBaseName = constructor.displayName;
256- var constructorName = constructorBaseName.isEmpty
257- ? className
258- : '$className .$constructorBaseName ' ;
259- _errorReporter.reportErrorForNode (
260- StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_CONSTRUCTOR ,
261- expression,
262- [S , T , constructorName],
263- );
264- } else if (displayName.isEmpty) {
244+ if (enclosingExecutable.isClosure) {
265245 _errorReporter.reportErrorForNode (
266246 StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_CLOSURE ,
267247 expression,
268248 [S , T ],
269249 );
270- } else if (enclosingExecutable.isMethod ) {
250+ } else if (enclosingExecutable.isConstructor ) {
271251 _errorReporter.reportErrorForNode (
272- StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_METHOD ,
252+ StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_CONSTRUCTOR ,
273253 expression,
274- [S , T , displayName],
254+ [S , T , enclosingExecutable. displayName],
275255 );
276- } else {
256+ } else if (enclosingExecutable.isFunction) {
277257 _errorReporter.reportErrorForNode (
278258 StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_FUNCTION ,
279259 expression,
280- [S , T , displayName],
260+ [S , T , enclosingExecutable.displayName],
261+ );
262+ } else if (enclosingExecutable.isMethod) {
263+ _errorReporter.reportErrorForNode (
264+ StaticTypeWarningCode .RETURN_OF_INVALID_TYPE_FROM_METHOD ,
265+ expression,
266+ [S , T , enclosingExecutable.displayName],
281267 );
282268 }
283269 }
0 commit comments