@@ -1020,14 +1020,12 @@ private Type inferTryExprType(TryExpr te, TypePath path) {
10201020}
10211021
10221022pragma [ nomagic]
1023- private StructType inferLiteralType ( LiteralExpr le ) {
1023+ private Type inferLiteralType ( LiteralExpr le , TypePath path ) {
1024+ path .isEmpty ( ) and
10241025 exists ( Builtins:: BuiltinType t | result = TStruct ( t ) |
10251026 le instanceof CharLiteralExpr and
10261027 t instanceof Builtins:: Char
10271028 or
1028- le instanceof StringLiteralExpr and
1029- t instanceof Builtins:: Str
1030- or
10311029 le =
10321030 any ( NumberLiteralExpr ne |
10331031 t .getName ( ) = ne .getSuffix ( )
@@ -1045,6 +1043,14 @@ private StructType inferLiteralType(LiteralExpr le) {
10451043 le instanceof BooleanLiteralExpr and
10461044 t instanceof Builtins:: Bool
10471045 )
1046+ or
1047+ le instanceof StringLiteralExpr and
1048+ (
1049+ path .isEmpty ( ) and result = TRefType ( )
1050+ or
1051+ path = TypePath:: singleton ( TRefTypeParameter ( ) ) and
1052+ result = TStruct ( any ( Builtins:: Str s ) )
1053+ )
10481054}
10491055
10501056pragma [ nomagic]
@@ -1578,8 +1584,7 @@ private module Cached {
15781584 or
15791585 result = inferTryExprType ( n , path )
15801586 or
1581- result = inferLiteralType ( n ) and
1582- path .isEmpty ( )
1587+ result = inferLiteralType ( n , path )
15831588 or
15841589 result = inferAsyncBlockExprRootType ( n ) and
15851590 path .isEmpty ( )
0 commit comments