@@ -141,6 +141,16 @@ module TypeResolution {
141141 )
142142 }
143143
144+ private predicate functionReturnType ( Function func , Node returnType ) {
145+ returnType = func .getReturnTypeAnnotation ( )
146+ or
147+ not exists ( func .getReturnTypeAnnotation ( ) ) and
148+ exists ( Function functionType |
149+ contextualType ( func , trackFunctionType ( functionType ) ) and
150+ returnType = functionType .getReturnTypeAnnotation ( )
151+ )
152+ }
153+
144154 private predicate contextualType ( Node value , Node type ) {
145155 exists ( InvokeExpr call , Function target , int i |
146156 callTarget ( call , target ) and
@@ -150,15 +160,8 @@ module TypeResolution {
150160 or
151161 exists ( Function lambda |
152162 not lambda .isAsyncOrGenerator ( ) and
153- value = lambda .getAReturnedExpr ( )
154- |
155- type = lambda .getReturnTypeAnnotation ( )
156- or
157- not exists ( lambda .getReturnTypeAnnotation ( ) ) and
158- exists ( Function functionType |
159- contextualType ( lambda , trackFunctionType ( functionType ) ) and
160- type = functionType .getReturnTypeAnnotation ( )
161- )
163+ value = lambda .getAReturnedExpr ( ) and
164+ functionReturnType ( lambda , type )
162165 )
163166 or
164167 exists ( ObjectExpr object , Node objectType , Node host , string name |
0 commit comments