@@ -114,22 +114,11 @@ module TypeResolution {
114114 )
115115 }
116116
117- predicate valueHasContextualType ( Node value , Node type ) {
117+ private predicate contextualType ( Node value , Node contextualType ) {
118118 exists ( InvokeExpr call , Function target , int i |
119119 callTarget ( call , target ) and
120120 value = call .getArgument ( i ) and
121- type = target .getParameter ( i ) .getTypeAnnotation ( )
122- )
123- or
124- exists ( VariableDeclarator decl |
125- value = decl .getInit ( ) and
126- type = decl .getTypeAnnotation ( )
127- )
128- or
129- exists ( Function functionValue , Function functionType |
130- valueHasContextualType ( functionValue , trackFunctionType ( functionType ) ) and
131- value = functionValue .getAReturnedExpr ( ) and
132- type = functionType .getReturnTypeAnnotation ( )
121+ contextualType = target .getParameter ( i ) .getTypeAnnotation ( )
133122 )
134123 }
135124
@@ -165,10 +154,10 @@ module TypeResolution {
165154 or
166155 // Contextual typing for parameters
167156 exists ( Function lambda , Function functionType , int i |
168- valueHasContextualType ( lambda , trackFunctionType ( functionType ) )
157+ contextualType ( lambda , trackFunctionType ( functionType ) )
169158 or
170159 exists ( InterfaceDefinition interface |
171- valueHasContextualType ( lambda , trackType ( interface ) ) and
160+ contextualType ( lambda , trackType ( interface ) ) and
172161 functionType = interface .getACallSignature ( ) .getBody ( )
173162 )
174163 |
0 commit comments