@@ -1045,14 +1045,12 @@ private Type inferTryExprType(TryExpr te, TypePath path) {
10451045}
10461046
10471047pragma [ nomagic]
1048- private StructType inferLiteralType ( LiteralExpr le ) {
1048+ private Type inferLiteralType ( LiteralExpr le , TypePath path ) {
1049+ path .isEmpty ( ) and
10491050 exists ( Builtins:: BuiltinType t | result = TStruct ( t ) |
10501051 le instanceof CharLiteralExpr and
10511052 t instanceof Builtins:: Char
10521053 or
1053- le instanceof StringLiteralExpr and
1054- t instanceof Builtins:: Str
1055- or
10561054 le =
10571055 any ( NumberLiteralExpr ne |
10581056 t .getName ( ) = ne .getSuffix ( )
@@ -1070,6 +1068,14 @@ private StructType inferLiteralType(LiteralExpr le) {
10701068 le instanceof BooleanLiteralExpr and
10711069 t instanceof Builtins:: Bool
10721070 )
1071+ or
1072+ le instanceof StringLiteralExpr and
1073+ (
1074+ path .isEmpty ( ) and result = TRefType ( )
1075+ or
1076+ path = TypePath:: singleton ( TRefTypeParameter ( ) ) and
1077+ result = TStruct ( any ( Builtins:: Str s ) )
1078+ )
10731079}
10741080
10751081pragma [ nomagic]
@@ -1635,8 +1641,7 @@ private module Cached {
16351641 or
16361642 result = inferTryExprType ( n , path )
16371643 or
1638- result = inferLiteralType ( n ) and
1639- path .isEmpty ( )
1644+ result = inferLiteralType ( n , path )
16401645 or
16411646 result = inferAsyncBlockExprRootType ( n ) and
16421647 path .isEmpty ( )
0 commit comments