@@ -2773,29 +2773,21 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
27732773 private module InvocationMatchingInput implements MatchingWithEnvironmentInputSig {
27742774 import InvocationTypeQualifierMatchingInput
27752775
2776- private newtype TDeclarationPosition =
2777- TParameterPosition ( int i ) { exists ( any ( Parameterizable p ) .getParameter ( i ) ) } or
2778- TReturnPosition ( )
2779-
2780- class DeclarationPosition extends TDeclarationPosition {
2781- int asParameter ( ) { this = TParameterPosition ( result ) }
2782-
2783- predicate isReturn ( ) { this = TReturnPosition ( ) }
2784-
2785- string toString ( ) {
2786- result = "parameter " + this .asParameter ( )
2787- or
2788- this .isReturn ( ) and
2789- result = "return"
2790- }
2791- }
2776+ class DeclarationPosition = int ;
27922777
27932778 class AccessPosition = DeclarationPosition ;
27942779
2780+ bindingset [ apos]
2781+ bindingset [ dpos]
27952782 predicate accessDeclarationPositionMatch ( AccessPosition apos , DeclarationPosition dpos ) {
27962783 apos = dpos
27972784 }
27982785
2786+ /** Gets the position used to represent the return type of a callable/type of a call. */
2787+ additional int getReturnPosition ( ) {
2788+ result = min ( int i | exists ( any ( Parameterizable p ) .getParameter ( i ) ) | i ) - 1
2789+ }
2790+
27992791 class Declaration extends ParameterizableFinal {
28002792 TypeParameter getTypeParameter ( int pos ) {
28012793 // include type parameters that are matched via a type qualifier
@@ -2811,9 +2803,9 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
28112803 }
28122804
28132805 Type getDeclaredType ( DeclarationPosition dpos , TypePath path ) {
2814- result = this .getParameter ( dpos . asParameter ( ) ) .getType ( ) .getTypeAt ( path )
2806+ result = this .getParameter ( dpos ) .getType ( ) .getTypeAt ( path )
28152807 or
2816- dpos . isReturn ( ) and
2808+ dpos = getReturnPosition ( ) and
28172809 result = getParameterizableReturnType ( this , path )
28182810 }
28192811 }
@@ -2843,12 +2835,12 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
28432835 pragma [ nomagic]
28442836 private Type getInferredReturnType ( AccessPosition apos , TypePath path ) {
28452837 result = inferInvocationTypeContextual ( this , path ) and
2846- apos . isReturn ( )
2838+ apos = getReturnPosition ( )
28472839 }
28482840
28492841 bindingset [ e]
28502842 Type getInferredType ( AccessEnvironment e , AccessPosition apos , TypePath path ) {
2851- result = inferInvocationArgumentType ( this , e , apos . asParameter ( ) , path )
2843+ result = inferInvocationArgumentType ( this , e , apos , path )
28522844 or
28532845 result = this .getInferredReturnType ( apos , path ) and
28542846 exists ( e )
@@ -2867,10 +2859,9 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
28672859 */
28682860 pragma [ nomagic]
28692861 Type inferInvocationTypeDefault ( Invocation invocation , ResolutionContext ctx , TypePath path ) {
2870- exists ( InvocationMatchingInput:: AccessPosition apos |
2871- result = InvocationMatching:: inferAccessType ( invocation , ctx , apos , path ) and
2872- apos .isReturn ( )
2873- )
2862+ result =
2863+ InvocationMatching:: inferAccessType ( invocation , ctx ,
2864+ InvocationMatchingInput:: getReturnPosition ( ) , path )
28742865 }
28752866
28762867 /**
@@ -2881,12 +2872,9 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
28812872 Type inferInvocationArgumentTypeContextualDefault (
28822873 Invocation invocation , ResolutionContext ctx , int pos , Expr arg , TypePath path
28832874 ) {
2884- exists ( InvocationMatchingInput:: AccessPosition apos |
2885- pos = apos .asParameter ( ) and
2886- arg = invocation .getArgument ( pos ) and
2887- result = InvocationMatching:: inferAccessType ( invocation , ctx , apos , path ) and
2888- ContextualTyping:: hasUnknownType ( arg )
2889- )
2875+ arg = invocation .getArgument ( pos ) and
2876+ result = InvocationMatching:: inferAccessType ( invocation , ctx , pos , path ) and
2877+ ContextualTyping:: hasUnknownType ( arg )
28902878 }
28912879
28922880 /**
0 commit comments