@@ -394,13 +394,7 @@ private module Input3 implements InputSig3 {
394394 }
395395 }
396396
397- class Call extends Expr instanceof FunctionCallMatchingInput:: Access {
398- Type getTypeArgument ( TypeArgumentPosition apos , TypePath path ) {
399- result = super .getTypeArgument ( apos , path )
400- }
401-
402- AstNode getNodeAt ( TypePosition pos ) { result = super .getNodeAt ( pos ) }
403-
397+ class Call extends FunctionCallMatchingInput:: Access {
404398 /** Gets the target of this call. */
405399 Callable getTargetCertain ( ) {
406400 exists ( ImplOrTraitItemNodeOption i , FunctionDeclaration f , Path p |
@@ -617,14 +611,22 @@ private module Input3 implements InputSig3 {
617611 result = inferTypeFromAnnotationTopDown ( n , path )
618612 or
619613 result = inferClosureExprBodyTypeTopDown ( n , path )
614+ or
615+ exists ( FunctionPosition pos | not pos .isReturn ( ) |
616+ result = inferConstructionType ( n , pos , path )
617+ or
618+ result = inferOperationType ( n , pos , path )
619+ )
620620 }
621621
622622 Type inferTypeSpecific ( AstNode n , TypePath path ) {
623623 result = inferAssignmentOperationType ( n , path )
624624 or
625- result = inferConstructionType ( n , path )
626- or
627- result = inferOperationType ( n , path )
625+ exists ( FunctionPosition pos | pos .isReturn ( ) |
626+ result = inferConstructionType ( n , pos , path )
627+ or
628+ result = inferOperationType ( n , pos , path )
629+ )
628630 or
629631 result = inferFieldExprType ( n , path )
630632 or
@@ -1082,7 +1084,7 @@ private module ContextTyping {
10821084 * context in which the call appears, for example a call like
10831085 * `Default::default()`.
10841086 */
1085- abstract class ContextTypedCallCand extends AstNode {
1087+ abstract class ContextTypedCallCand extends Expr {
10861088 abstract Type getTypeArgument ( TypeArgumentPosition apos , TypePath path ) ;
10871089
10881090 predicate hasTypeArgument ( TypeArgumentPosition apos ) { exists ( this .getTypeArgument ( apos , _) ) }
@@ -2653,7 +2655,9 @@ private module FunctionCallMatchingInput implements MatchingWithEnvironmentInput
26532655 )
26542656 }
26552657
2656- abstract class Access extends ContextTyping:: ContextTypedCallCand {
2658+ final class Access = AccessImpl ;
2659+
2660+ abstract private class AccessImpl extends ContextTyping:: ContextTypedCallCand {
26572661 abstract AstNode getNodeAt ( FunctionPosition pos ) ;
26582662
26592663 bindingset [ derefChainBorrow]
@@ -2668,7 +2672,7 @@ private module FunctionCallMatchingInput implements MatchingWithEnvironmentInput
26682672 abstract predicate hasUnknownTypeAt ( string derefChainBorrow , FunctionPosition pos , TypePath path ) ;
26692673 }
26702674
2671- private class AssocFunctionCallAccess extends Access instanceof AssocFunctionResolution:: AssocFunctionCall
2675+ private class AssocFunctionCallAccess extends AccessImpl instanceof AssocFunctionResolution:: AssocFunctionCall
26722676 {
26732677 AssocFunctionCallAccess ( ) {
26742678 // handled in the `OperationMatchingInput` module
@@ -2755,7 +2759,7 @@ private module FunctionCallMatchingInput implements MatchingWithEnvironmentInput
27552759 }
27562760 }
27572761
2758- private class NonAssocFunctionCallAccess extends Access instanceof NonAssocCallExpr ,
2762+ private class NonAssocFunctionCallAccess extends AccessImpl instanceof NonAssocCallExpr ,
27592763 CallExprImpl:: CallExprCall
27602764 {
27612765 pragma [ nomagic]
@@ -3024,16 +3028,13 @@ private module ConstructionMatchingInput implements MatchingInputSig {
30243028private module ConstructionMatching = Matching< ConstructionMatchingInput > ;
30253029
30263030pragma [ nomagic]
3027- private Type inferConstructionTypePreCheck ( AstNode n , FunctionPosition pos , TypePath path ) {
3031+ private Type inferConstructionType ( AstNode n , FunctionPosition pos , TypePath path ) {
30283032 exists ( ConstructionMatchingInput:: Access a |
30293033 n = a .getNodeAt ( pos ) and
30303034 result = ConstructionMatching:: inferAccessType ( a , pos , path )
30313035 )
30323036}
30333037
3034- private predicate inferConstructionType =
3035- CheckContextTyping< inferConstructionTypePreCheck / 3 > :: check / 2 ;
3036-
30373038pragma [ nomagic]
30383039private Type inferUnknownType ( AstNode n , TypePath path ) {
30393040 result = TUnknownType ( ) and
@@ -3119,16 +3120,14 @@ private module OperationMatchingInput implements MatchingInputSig {
31193120private module OperationMatching = Matching< OperationMatchingInput > ;
31203121
31213122pragma [ nomagic]
3122- private Type inferOperationTypePreCheck ( AstNode n , FunctionPosition pos , TypePath path ) {
3123+ private Type inferOperationType ( AstNode n , FunctionPosition pos , TypePath path ) {
31233124 exists ( OperationMatchingInput:: Access a |
31243125 n = a .getNodeAt ( pos ) and
31253126 result = OperationMatching:: inferAccessType ( a , pos , path ) and
31263127 if pos .asPosition ( ) = 0 then not path .isEmpty ( ) else any ( )
31273128 )
31283129}
31293130
3130- private predicate inferOperationType = CheckContextTyping< inferOperationTypePreCheck / 3 > :: check / 2 ;
3131-
31323131pragma [ nomagic]
31333132private Type getFieldExprLookupType ( FieldExpr fe , string name , DerefChain derefChain ) {
31343133 exists ( TypePath path |
@@ -3741,11 +3740,10 @@ private module Debug {
37413740 // n = getRelevantLocatable() and
37423741 // t = inferFunctionCallType(n, path)
37433742 // }
3744- predicate debugInferConstructionType ( AstNode n , TypePath path , Type t ) {
3745- n = getRelevantLocatable ( ) and
3746- t = inferConstructionType ( n , path )
3747- }
3748-
3743+ // predicate debugInferConstructionType(AstNode n, TypePath path, Type t) {
3744+ // n = getRelevantLocatable() and
3745+ // t = inferConstructionType(n, path)
3746+ // }
37493747 predicate debugTypeMention ( TypeMention tm , TypePath path , Type type ) {
37503748 tm = getRelevantLocatable ( ) and
37513749 tm .getTypeAt ( path ) = type
0 commit comments