@@ -119,7 +119,7 @@ private TypeMention getTypeAnnotation(AstNode n) {
119
119
120
120
/** Gets the type of `n`, which has an explicit type annotation. */
121
121
pragma [ nomagic]
122
- private Type resolveAnnotatedType ( AstNode n , TypePath path ) {
122
+ private Type inferAnnotatedType ( AstNode n , TypePath path ) {
123
123
result = getTypeAnnotation ( n ) .resolveTypeAt ( path )
124
124
}
125
125
@@ -159,8 +159,8 @@ private predicate typeSymmetry(AstNode n1, TypePath path1, AstNode n2, TypePath
159
159
}
160
160
161
161
pragma [ nomagic]
162
- private Type resolveTypeSymmetry ( AstNode n , TypePath path ) {
163
- exists ( AstNode n2 , TypePath path2 | result = resolveType ( n2 , path2 ) |
162
+ private Type inferTypeSymmetry ( AstNode n , TypePath path ) {
163
+ exists ( AstNode n2 , TypePath path2 | result = inferType ( n2 , path2 ) |
164
164
typeSymmetry ( n , path , n2 , path2 )
165
165
or
166
166
typeSymmetry ( n2 , path2 , n , path )
@@ -193,12 +193,12 @@ private Type getRefAdjustImplicitSelfType(SelfParam self, TypePath suffix, Type
193
193
}
194
194
195
195
pragma [ nomagic]
196
- private Type resolveImplSelfType ( Impl i , TypePath path ) {
196
+ private Type inferImplSelfType ( Impl i , TypePath path ) {
197
197
result = i .getSelfTy ( ) .( TypeReprMention ) .resolveTypeAt ( path )
198
198
}
199
199
200
200
pragma [ nomagic]
201
- private Type resolveTraitSelfType ( Trait t , TypePath path ) {
201
+ private Type inferTraitSelfType ( Trait t , TypePath path ) {
202
202
result = TTrait ( t ) and
203
203
path .isEmpty ( )
204
204
or
@@ -208,15 +208,15 @@ private Type resolveTraitSelfType(Trait t, TypePath path) {
208
208
209
209
/** Gets the type at `path` of the implicitly typed `self` parameter. */
210
210
pragma [ nomagic]
211
- private Type resolveImplicitSelfType ( SelfParam self , TypePath path ) {
211
+ private Type inferImplicitSelfType ( SelfParam self , TypePath path ) {
212
212
exists ( ImplOrTraitItemNode i , Function f , TypePath suffix , Type t |
213
213
f = i .getAnAssocItem ( ) and
214
214
self = f .getParamList ( ) .getSelfParam ( ) and
215
215
result = getRefAdjustImplicitSelfType ( self , suffix , t , path )
216
216
|
217
- t = resolveImplSelfType ( i , suffix )
217
+ t = inferImplSelfType ( i , suffix )
218
218
or
219
- t = resolveTraitSelfType ( i , suffix )
219
+ t = inferTraitSelfType ( i , suffix )
220
220
)
221
221
}
222
222
@@ -327,8 +327,8 @@ private module RecordExprMatchingInput implements MatchingInputSig {
327
327
apos .isRecordPos ( )
328
328
}
329
329
330
- Type getResolvedType ( AccessPosition apos , TypePath path ) {
331
- result = resolveType ( this .getNodeAt ( apos ) , path )
330
+ Type getInferredType ( AccessPosition apos , TypePath path ) {
331
+ result = inferType ( this .getNodeAt ( apos ) , path )
332
332
}
333
333
334
334
Declaration getTarget ( ) { result = resolvePath ( this .getPath ( ) ) }
@@ -346,15 +346,15 @@ private module RecordExprMatching = Matching<RecordExprMatchingInput>;
346
346
* a field expression of a record expression.
347
347
*/
348
348
pragma [ nomagic]
349
- private Type resolveRecordExprType ( AstNode n , TypePath path ) {
349
+ private Type inferRecordExprType ( AstNode n , TypePath path ) {
350
350
exists ( RecordExprMatchingInput:: Access a , RecordExprMatchingInput:: AccessPosition apos |
351
351
n = a .getNodeAt ( apos ) and
352
- result = RecordExprMatching:: resolveAccessType ( a , apos , path )
352
+ result = RecordExprMatching:: inferAccessType ( a , apos , path )
353
353
)
354
354
}
355
355
356
356
pragma [ nomagic]
357
- private Type resolvePathExprType ( PathExpr pe , TypePath path ) {
357
+ private Type inferPathExprType ( PathExpr pe , TypePath path ) {
358
358
// nullary struct/variant constructors
359
359
not exists ( CallExpr ce | pe = ce .getFunction ( ) ) and
360
360
path .isEmpty ( ) and
@@ -466,7 +466,7 @@ private module CallExprBaseMatchingInput implements MatchingInputSig {
466
466
}
467
467
468
468
pragma [ nomagic]
469
- private Type resolveAnnotatedTypeInclSelf ( AstNode n , TypePath path ) {
469
+ private Type inferAnnotatedTypeInclSelf ( AstNode n , TypePath path ) {
470
470
result = getTypeAnnotation ( n ) .resolveTypeAtInclSelf ( path )
471
471
}
472
472
@@ -477,18 +477,18 @@ private module CallExprBaseMatchingInput implements MatchingInputSig {
477
477
exists ( Param p , int i , boolean inMethod |
478
478
paramPos ( this .getParamList ( ) , p , i , inMethod ) and
479
479
dpos = TPositionalDeclarationPosition ( i , inMethod ) and
480
- result = resolveAnnotatedTypeInclSelf ( p .getPat ( ) , path )
480
+ result = inferAnnotatedTypeInclSelf ( p .getPat ( ) , path )
481
481
)
482
482
or
483
483
exists ( SelfParam self |
484
484
self = pragma [ only_bind_into ] ( this .getParamList ( ) .getSelfParam ( ) ) and
485
485
dpos .isSelf ( )
486
486
|
487
487
// `self` parameter with type annotation
488
- result = resolveAnnotatedTypeInclSelf ( self , path )
488
+ result = inferAnnotatedTypeInclSelf ( self , path )
489
489
or
490
490
// `self` parameter without type annotation
491
- result = resolveImplicitSelfType ( self , path )
491
+ result = inferImplicitSelfType ( self , path )
492
492
or
493
493
// `self` parameter without type annotation should also have the special `Self` type
494
494
result = getRefAdjustImplicitSelfType ( self , TypePath:: nil ( ) , TSelfTypeParameter ( ) , path )
@@ -559,8 +559,8 @@ private module CallExprBaseMatchingInput implements MatchingInputSig {
559
559
apos = TReturnAccessPosition ( )
560
560
}
561
561
562
- Type getResolvedType ( AccessPosition apos , TypePath path ) {
563
- result = resolveType ( this .getNodeAt ( apos ) , path )
562
+ Type getInferredType ( AccessPosition apos , TypePath path ) {
563
+ result = inferType ( this .getNodeAt ( apos ) , path )
564
564
}
565
565
566
566
Declaration getTarget ( ) {
@@ -644,9 +644,9 @@ private module CallExprBaseMatchingInput implements MatchingInputSig {
644
644
}
645
645
646
646
pragma [ nomagic]
647
- additional Type resolveReceiverType ( AstNode n ) {
647
+ additional Type inferReceiverType ( AstNode n ) {
648
648
exists ( Access a , AccessPosition apos |
649
- result = resolveType ( n ) and
649
+ result = inferType ( n ) and
650
650
n = a .getNodeAt ( apos ) and
651
651
apos .isSelf ( )
652
652
)
@@ -660,17 +660,17 @@ private module CallExprBaseMatching = Matching<CallExprBaseMatchingInput>;
660
660
* argument/receiver of a call.
661
661
*/
662
662
pragma [ nomagic]
663
- private Type resolveCallExprBaseType ( AstNode n , TypePath path ) {
663
+ private Type inferCallExprBaseType ( AstNode n , TypePath path ) {
664
664
exists (
665
665
CallExprBaseMatchingInput:: Access a , CallExprBaseMatchingInput:: AccessPosition apos ,
666
666
TypePath path0
667
667
|
668
668
n = a .getNodeAt ( apos ) and
669
- result = CallExprBaseMatching:: resolveAccessType ( a , apos , path0 )
669
+ result = CallExprBaseMatching:: inferAccessType ( a , apos , path0 )
670
670
|
671
671
if apos .isSelf ( )
672
672
then
673
- exists ( Type receiverType | receiverType = CallExprBaseMatchingInput:: resolveReceiverType ( n ) |
673
+ exists ( Type receiverType | receiverType = CallExprBaseMatchingInput:: inferReceiverType ( n ) |
674
674
if receiverType = TRefType ( )
675
675
then
676
676
path = path0 and
@@ -758,8 +758,8 @@ private module FieldExprMatchingInput implements MatchingInputSig {
758
758
apos .isField ( )
759
759
}
760
760
761
- Type getResolvedType ( AccessPosition apos , TypePath path ) {
762
- result = resolveType ( this .getNodeAt ( apos ) , path )
761
+ Type getInferredType ( AccessPosition apos , TypePath path ) {
762
+ result = inferType ( this .getNodeAt ( apos ) , path )
763
763
}
764
764
765
765
Declaration getTarget ( ) {
@@ -795,9 +795,9 @@ private module FieldExprMatchingInput implements MatchingInputSig {
795
795
}
796
796
797
797
pragma [ nomagic]
798
- additional Type resolveReceiverType ( AstNode n ) {
798
+ additional Type inferReceiverType ( AstNode n ) {
799
799
exists ( Access a , AccessPosition apos |
800
- result = resolveType ( n ) and
800
+ result = inferType ( n ) and
801
801
n = a .getNodeAt ( apos ) and
802
802
apos .isSelf ( )
803
803
)
@@ -811,16 +811,16 @@ private module FieldExprMatching = Matching<FieldExprMatchingInput>;
811
811
* the receiver of field expression call.
812
812
*/
813
813
pragma [ nomagic]
814
- private Type resolveFieldExprType ( AstNode n , TypePath path ) {
814
+ private Type inferFieldExprType ( AstNode n , TypePath path ) {
815
815
exists (
816
816
FieldExprMatchingInput:: Access a , FieldExprMatchingInput:: AccessPosition apos , TypePath path0
817
817
|
818
818
n = a .getNodeAt ( apos ) and
819
- result = FieldExprMatching:: resolveAccessType ( a , apos , path0 )
819
+ result = FieldExprMatching:: inferAccessType ( a , apos , path0 )
820
820
|
821
821
if apos .isSelf ( )
822
822
then
823
- exists ( Type receiverType | receiverType = FieldExprMatchingInput:: resolveReceiverType ( n ) |
823
+ exists ( Type receiverType | receiverType = FieldExprMatchingInput:: inferReceiverType ( n ) |
824
824
if receiverType = TRefType ( )
825
825
then
826
826
// adjust for implicit deref
@@ -838,14 +838,14 @@ private Type resolveFieldExprType(AstNode n, TypePath path) {
838
838
* `& x` or an expression `x` inside a reference expression `& x`.
839
839
*/
840
840
pragma [ nomagic]
841
- private Type resolveRefExprType ( Expr e , TypePath path ) {
841
+ private Type inferRefExprType ( Expr e , TypePath path ) {
842
842
exists ( RefExpr re |
843
843
e = re and
844
844
path .isEmpty ( ) and
845
845
result = TRefType ( )
846
846
or
847
847
e = re and
848
- exists ( TypePath exprPath | result = resolveType ( re .getExpr ( ) , exprPath ) |
848
+ exists ( TypePath exprPath | result = inferType ( re .getExpr ( ) , exprPath ) |
849
849
if exprPath .startsWith ( TRefTypeParameter ( ) , _)
850
850
then
851
851
// `&x` simply means `x` when `x` already has reference type
@@ -858,9 +858,9 @@ private Type resolveRefExprType(Expr e, TypePath path) {
858
858
or
859
859
e = re .getExpr ( ) and
860
860
exists ( TypePath exprPath , TypePath refPath , Type exprType |
861
- result = resolveType ( re , exprPath ) and
861
+ result = inferType ( re , exprPath ) and
862
862
exprPath = TypePath:: cons ( TRefTypeParameter ( ) , refPath ) and
863
- exprType = resolveType ( e )
863
+ exprType = inferType ( e )
864
864
|
865
865
if exprType = TRefType ( )
866
866
then
@@ -878,11 +878,11 @@ private module Cached {
878
878
pragma [ inline]
879
879
private Type getLookupType ( AstNode n ) {
880
880
exists ( Type t |
881
- t = resolveType ( n ) and
881
+ t = inferType ( n ) and
882
882
if t = TRefType ( )
883
883
then
884
884
// for reference types, lookup members in the type being referenced
885
- result = resolveType ( n , TypePath:: singleton ( TRefTypeParameter ( ) ) )
885
+ result = inferType ( n , TypePath:: singleton ( TRefTypeParameter ( ) ) )
886
886
else result = t
887
887
)
888
888
}
@@ -894,7 +894,7 @@ private module Cached {
894
894
}
895
895
896
896
/**
897
- * Gets a method that the method call `mce` resolves to, if any.
897
+ * Gets a method that the method call `mce` infers to, if any.
898
898
*/
899
899
cached
900
900
Function resolveMethodCallExpr ( MethodCallExpr mce ) {
@@ -908,7 +908,7 @@ private module Cached {
908
908
}
909
909
910
910
/**
911
- * Gets the record field that the field expression `fe` resolves to, if any.
911
+ * Gets the record field that the field expression `fe` infers to, if any.
912
912
*/
913
913
cached
914
914
RecordField resolveRecordFieldExpr ( FieldExpr fe ) {
@@ -924,15 +924,15 @@ private module Cached {
924
924
}
925
925
926
926
/**
927
- * Gets the tuple field that the field expression `fe` resolves to, if any.
927
+ * Gets the tuple field that the field expression `fe` infers to, if any.
928
928
*/
929
929
cached
930
930
TupleField resolveTupleFieldExpr ( FieldExpr fe ) {
931
931
exists ( int i | result = getTupleFieldExprLookupType ( fe , i ) .getTupleField ( i ) )
932
932
}
933
933
934
934
/**
935
- * Gets a type at `path` that `n` resolves to, if any.
935
+ * Gets a type at `path` that `n` infers to, if any.
936
936
*
937
937
* The type inference implementation works by computing all possible types, so
938
938
* the result is not necessarily unique. For example, in
@@ -971,29 +971,29 @@ private module Cached {
971
971
* 5. `x.bar()` has type `&MyTrait` (via 2 and 4).
972
972
*/
973
973
cached
974
- Type resolveType ( AstNode n , TypePath path ) {
974
+ Type inferType ( AstNode n , TypePath path ) {
975
975
Stages:: TypeInference:: backref ( ) and
976
- result = resolveAnnotatedType ( n , path )
976
+ result = inferAnnotatedType ( n , path )
977
977
or
978
- result = resolveTypeSymmetry ( n , path )
978
+ result = inferTypeSymmetry ( n , path )
979
979
or
980
- result = resolveImplicitSelfType ( n , path )
980
+ result = inferImplicitSelfType ( n , path )
981
981
or
982
- result = resolveRecordExprType ( n , path )
982
+ result = inferRecordExprType ( n , path )
983
983
or
984
- result = resolvePathExprType ( n , path )
984
+ result = inferPathExprType ( n , path )
985
985
or
986
- result = resolveCallExprBaseType ( n , path )
986
+ result = inferCallExprBaseType ( n , path )
987
987
or
988
- result = resolveFieldExprType ( n , path )
988
+ result = inferFieldExprType ( n , path )
989
989
or
990
- result = resolveRefExprType ( n , path )
990
+ result = inferRefExprType ( n , path )
991
991
}
992
992
}
993
993
994
994
import Cached
995
995
996
996
/**
997
- * Gets a type that `n` resolves to, if any.
997
+ * Gets a type that `n` infers to, if any.
998
998
*/
999
- Type resolveType ( AstNode n ) { result = resolveType ( n , TypePath:: nil ( ) ) }
999
+ Type inferType ( AstNode n ) { result = inferType ( n , TypePath:: nil ( ) ) }
0 commit comments