@@ -139,8 +139,7 @@ reveal_type(f(A())) # revealed: A
139
139
reveal_type(f(* (A(),))) # revealed: A
140
140
141
141
reveal_type(f(B())) # revealed: A
142
- # TODO : revealed: A
143
- reveal_type(f(* (B(),))) # revealed: Unknown
142
+ reveal_type(f(* (B(),))) # revealed: A
144
143
145
144
# But, in this case, the arity check filters out the first overload, so we only have one match:
146
145
reveal_type(f(B(), 1 )) # revealed: B
@@ -551,16 +550,13 @@ from overloaded import MyEnumSubclass, ActualEnum, f
551
550
552
551
def _ (actual_enum : ActualEnum, my_enum_instance : MyEnumSubclass):
553
552
reveal_type(f(actual_enum)) # revealed: Both
554
- # TODO : revealed: Both
555
- reveal_type(f(* (actual_enum,))) # revealed: Unknown
553
+ reveal_type(f(* (actual_enum,))) # revealed: Both
556
554
557
555
reveal_type(f(ActualEnum.A)) # revealed: OnlyA
558
- # TODO : revealed: OnlyA
559
- reveal_type(f(* (ActualEnum.A,))) # revealed: Unknown
556
+ reveal_type(f(* (ActualEnum.A,))) # revealed: OnlyA
560
557
561
558
reveal_type(f(ActualEnum.B)) # revealed: OnlyB
562
- # TODO : revealed: OnlyB
563
- reveal_type(f(* (ActualEnum.B,))) # revealed: Unknown
559
+ reveal_type(f(* (ActualEnum.B,))) # revealed: OnlyB
564
560
565
561
reveal_type(f(my_enum_instance)) # revealed: MyEnumSubclass
566
562
reveal_type(f(* (my_enum_instance,))) # revealed: MyEnumSubclass
@@ -1097,12 +1093,10 @@ reveal_type(f(*(1,))) # revealed: str
1097
1093
1098
1094
def _ (list_int : list[int ], list_any : list[Any]):
1099
1095
reveal_type(f(list_int)) # revealed: int
1100
- # TODO : revealed: int
1101
- reveal_type(f(* (list_int,))) # revealed: Unknown
1096
+ reveal_type(f(* (list_int,))) # revealed: int
1102
1097
1103
1098
reveal_type(f(list_any)) # revealed: int
1104
- # TODO : revealed: int
1105
- reveal_type(f(* (list_any,))) # revealed: Unknown
1099
+ reveal_type(f(* (list_any,))) # revealed: int
1106
1100
```
1107
1101
1108
1102
### Single list argument (ambiguous)
@@ -1136,8 +1130,7 @@ def _(list_int: list[int], list_any: list[Any]):
1136
1130
# All materializations of `list[int]` are assignable to `list[int]`, so it matches the first
1137
1131
# overload.
1138
1132
reveal_type(f(list_int)) # revealed: int
1139
- # TODO : revealed: int
1140
- reveal_type(f(* (list_int,))) # revealed: Unknown
1133
+ reveal_type(f(* (list_int,))) # revealed: int
1141
1134
1142
1135
# All materializations of `list[Any]` are assignable to `list[int]` and `list[Any]`, but the
1143
1136
# return type of first and second overloads are not equivalent, so the overload matching
@@ -1170,25 +1163,21 @@ reveal_type(f("a")) # revealed: str
1170
1163
reveal_type(f(* (" a" ,))) # revealed: str
1171
1164
1172
1165
reveal_type(f((1 , " b" ))) # revealed: int
1173
- # TODO : revealed: int
1174
- reveal_type(f(* ((1 , " b" ),))) # revealed: Unknown
1166
+ reveal_type(f(* ((1 , " b" ),))) # revealed: int
1175
1167
1176
1168
reveal_type(f((1 , 2 ))) # revealed: int
1177
- # TODO : revealed: int
1178
- reveal_type(f(* ((1 , 2 ),))) # revealed: Unknown
1169
+ reveal_type(f(* ((1 , 2 ),))) # revealed: int
1179
1170
1180
1171
def _ (int_str : tuple[int , str ], int_any : tuple[int , Any], any_any : tuple[Any, Any]):
1181
1172
# All materializations are assignable to first overload, so second and third overloads are
1182
1173
# eliminated
1183
1174
reveal_type(f(int_str)) # revealed: int
1184
- # TODO : revealed: int
1185
- reveal_type(f(* (int_str,))) # revealed: Unknown
1175
+ reveal_type(f(* (int_str,))) # revealed: int
1186
1176
1187
1177
# All materializations are assignable to second overload, so the third overload is eliminated;
1188
1178
# the return type of first and second overload is equivalent
1189
1179
reveal_type(f(int_any)) # revealed: int
1190
- # TODO : revealed: int
1191
- reveal_type(f(* (int_any,))) # revealed: Unknown
1180
+ reveal_type(f(* (int_any,))) # revealed: int
1192
1181
1193
1182
# All materializations of `tuple[Any, Any]` are assignable to the parameters of all the
1194
1183
# overloads, but the return types aren't equivalent, so the overload matching is ambiguous
@@ -1266,26 +1255,22 @@ def _(list_int: list[int], list_any: list[Any], int_str: tuple[int, str], int_an
1266
1255
# All materializations of both argument types are assignable to the first overload, so the
1267
1256
# second and third overloads are filtered out
1268
1257
reveal_type(f(list_int, int_str)) # revealed: A
1269
- # TODO : revealed: A
1270
- reveal_type(f(* (list_int, int_str))) # revealed: Unknown
1258
+ reveal_type(f(* (list_int, int_str))) # revealed: A
1271
1259
1272
1260
# All materialization of first argument is assignable to first overload and for the second
1273
1261
# argument, they're assignable to the second overload, so the third overload is filtered out
1274
1262
reveal_type(f(list_int, int_any)) # revealed: A
1275
- # TODO : revealed: A
1276
- reveal_type(f(* (list_int, int_any))) # revealed: Unknown
1263
+ reveal_type(f(* (list_int, int_any))) # revealed: A
1277
1264
1278
1265
# All materialization of first argument is assignable to second overload and for the second
1279
1266
# argument, they're assignable to the first overload, so the third overload is filtered out
1280
1267
reveal_type(f(list_any, int_str)) # revealed: A
1281
- # TODO : revealed: A
1282
- reveal_type(f(* (list_any, int_str))) # revealed: Unknown
1268
+ reveal_type(f(* (list_any, int_str))) # revealed: A
1283
1269
1284
1270
# All materializations of both arguments are assignable to the second overload, so the third
1285
1271
# overload is filtered out
1286
1272
reveal_type(f(list_any, int_any)) # revealed: A
1287
- # TODO : revealed: A
1288
- reveal_type(f(* (list_any, int_any))) # revealed: Unknown
1273
+ reveal_type(f(* (list_any, int_any))) # revealed: A
1289
1274
1290
1275
# All materializations of first argument is assignable to the second overload and for the second
1291
1276
# argument, they're assignable to the third overload, so no overloads are filtered out; the
@@ -1316,8 +1301,7 @@ from overloaded import f
1316
1301
1317
1302
def _ (literal : LiteralString, string : str , any : Any):
1318
1303
reveal_type(f(literal)) # revealed: LiteralString
1319
- # TODO : revealed: LiteralString
1320
- reveal_type(f(* (literal,))) # revealed: Unknown
1304
+ reveal_type(f(* (literal,))) # revealed: LiteralString
1321
1305
1322
1306
reveal_type(f(string)) # revealed: str
1323
1307
reveal_type(f(* (string,))) # revealed: str
@@ -1355,12 +1339,10 @@ from overloaded import f
1355
1339
1356
1340
def _ (list_int : list[int ], list_str : list[str ], list_any : list[Any], any : Any):
1357
1341
reveal_type(f(list_int)) # revealed: A
1358
- # TODO : revealed: A
1359
- reveal_type(f(* (list_int,))) # revealed: Unknown
1342
+ reveal_type(f(* (list_int,))) # revealed: A
1360
1343
1361
1344
reveal_type(f(list_str)) # revealed: str
1362
- # TODO : Should be `str`
1363
- reveal_type(f(* (list_str,))) # revealed: Unknown
1345
+ reveal_type(f(* (list_str,))) # revealed: str
1364
1346
1365
1347
reveal_type(f(list_any)) # revealed: Unknown
1366
1348
reveal_type(f(* (list_any,))) # revealed: Unknown
@@ -1561,12 +1543,10 @@ def _(any: Any):
1561
1543
reveal_type(f(* (any ,), flag = False )) # revealed: str
1562
1544
1563
1545
def _ (args : tuple[Any, Literal[True ]]):
1564
- # TODO : revealed: int
1565
- reveal_type(f(* args)) # revealed: Unknown
1546
+ reveal_type(f(* args)) # revealed: int
1566
1547
1567
1548
def _ (args : tuple[Any, Literal[False ]]):
1568
- # TODO : revealed: str
1569
- reveal_type(f(* args)) # revealed: Unknown
1549
+ reveal_type(f(* args)) # revealed: str
1570
1550
```
1571
1551
1572
1552
### Argument type expansion
0 commit comments