@@ -1045,14 +1045,15 @@ private Type inferTryExprType(TryExpr te, TypePath path) {
10451045}
10461046
10471047pragma [ nomagic]
1048- private StructType inferLiteralType ( LiteralExpr le ) {
1048+ private StructType getStrStruct ( ) { result = TStruct ( any ( Builtins:: Str s ) ) }
1049+
1050+ pragma [ nomagic]
1051+ private Type inferLiteralType ( LiteralExpr le , TypePath path ) {
1052+ path .isEmpty ( ) and
10491053 exists ( Builtins:: BuiltinType t | result = TStruct ( t ) |
10501054 le instanceof CharLiteralExpr and
10511055 t instanceof Builtins:: Char
10521056 or
1053- le instanceof StringLiteralExpr and
1054- t instanceof Builtins:: Str
1055- or
10561057 le =
10571058 any ( NumberLiteralExpr ne |
10581059 t .getName ( ) = ne .getSuffix ( )
@@ -1070,6 +1071,14 @@ private StructType inferLiteralType(LiteralExpr le) {
10701071 le instanceof BooleanLiteralExpr and
10711072 t instanceof Builtins:: Bool
10721073 )
1074+ or
1075+ le instanceof StringLiteralExpr and
1076+ (
1077+ path .isEmpty ( ) and result = TRefType ( )
1078+ or
1079+ path = TypePath:: singleton ( TRefTypeParameter ( ) ) and
1080+ result = getStrStruct ( )
1081+ )
10731082}
10741083
10751084pragma [ nomagic]
@@ -1635,8 +1644,7 @@ private module Cached {
16351644 or
16361645 result = inferTryExprType ( n , path )
16371646 or
1638- result = inferLiteralType ( n ) and
1639- path .isEmpty ( )
1647+ result = inferLiteralType ( n , path )
16401648 or
16411649 result = inferAsyncBlockExprRootType ( n ) and
16421650 path .isEmpty ( )
0 commit comments