@@ -3289,6 +3289,51 @@ private Type getTupleFieldExprLookupType(FieldExpr fe, int pos, DerefChain deref
32893289 )
32903290}
32913291
3292+ /** Gets the root type of the reference expression `ref`. */
3293+ pragma [ nomagic]
3294+ private Type inferRefExprType ( RefExpr ref ) {
3295+ if ref .isRaw ( )
3296+ then
3297+ ref .isMut ( ) and result instanceof PtrMutType
3298+ or
3299+ ref .isConst ( ) and result instanceof PtrConstType
3300+ else
3301+ if ref .isMut ( )
3302+ then result instanceof RefMutType
3303+ else result instanceof RefSharedType
3304+ }
3305+
3306+ /** Gets the root type of the reference node `ref`. */
3307+ pragma [ nomagic]
3308+ private Type inferRefPatType ( AstNode ref ) {
3309+ exists ( boolean isMut |
3310+ ref =
3311+ any ( IdentPat ip |
3312+ ip .isRef ( ) and
3313+ if ip .isMut ( ) then isMut = true else isMut = false
3314+ ) .getName ( )
3315+ or
3316+ ref = any ( RefPat rp | if rp .isMut ( ) then isMut = true else isMut = false )
3317+ |
3318+ result = getRefType ( isMut )
3319+ )
3320+ }
3321+
3322+ pragma [ nomagic]
3323+ private Type inferTryExprType ( TryExpr te , TypePath path ) {
3324+ exists ( TypeParam tp , TypePath path0 |
3325+ result = inferType ( te .getExpr ( ) , path0 ) and
3326+ path0 .isCons ( TTypeParamTypeParameter ( tp ) , path )
3327+ |
3328+ tp = any ( ResultEnum r ) .getGenericParamList ( ) .getGenericParam ( 0 )
3329+ or
3330+ tp = any ( OptionEnum o ) .getGenericParamList ( ) .getGenericParam ( 0 )
3331+ )
3332+ }
3333+
3334+ pragma [ nomagic]
3335+ private StructType getStrStruct ( ) { result = TDataType ( any ( Builtins:: Str s ) ) }
3336+
32923337/**
32933338 * A matching configuration for resolving types of field expressions like `x.field`.
32943339 */
@@ -3441,51 +3486,6 @@ private Type inferFieldExprType(AstNode n, TypePath path) {
34413486 )
34423487}
34433488
3444- /** Gets the root type of the reference expression `ref`. */
3445- pragma [ nomagic]
3446- private Type inferRefExprType ( RefExpr ref ) {
3447- if ref .isRaw ( )
3448- then
3449- ref .isMut ( ) and result instanceof PtrMutType
3450- or
3451- ref .isConst ( ) and result instanceof PtrConstType
3452- else
3453- if ref .isMut ( )
3454- then result instanceof RefMutType
3455- else result instanceof RefSharedType
3456- }
3457-
3458- /** Gets the root type of the reference node `ref`. */
3459- pragma [ nomagic]
3460- private Type inferRefPatType ( AstNode ref ) {
3461- exists ( boolean isMut |
3462- ref =
3463- any ( IdentPat ip |
3464- ip .isRef ( ) and
3465- if ip .isMut ( ) then isMut = true else isMut = false
3466- ) .getName ( )
3467- or
3468- ref = any ( RefPat rp | if rp .isMut ( ) then isMut = true else isMut = false )
3469- |
3470- result = getRefType ( isMut )
3471- )
3472- }
3473-
3474- pragma [ nomagic]
3475- private Type inferTryExprType ( TryExpr te , TypePath path ) {
3476- exists ( TypeParam tp , TypePath path0 |
3477- result = inferType ( te .getExpr ( ) , path0 ) and
3478- path0 .isCons ( TTypeParamTypeParameter ( tp ) , path )
3479- |
3480- tp = any ( ResultEnum r ) .getGenericParamList ( ) .getGenericParam ( 0 )
3481- or
3482- tp = any ( OptionEnum o ) .getGenericParamList ( ) .getGenericParam ( 0 )
3483- )
3484- }
3485-
3486- pragma [ nomagic]
3487- private StructType getStrStruct ( ) { result = TDataType ( any ( Builtins:: Str s ) ) }
3488-
34893489pragma [ nomagic]
34903490private Type inferLiteralType ( LiteralExpr le , TypePath path , boolean certain ) {
34913491 path .isEmpty ( ) and
0 commit comments