@@ -152,10 +152,11 @@ void ReportError(TExprContext& ctx, const TIssue& issue);
152
152
153
153
class TTypeAnnotationNode {
154
154
protected:
155
- TTypeAnnotationNode(ETypeAnnotationKind kind, ui32 flags, ui64 hash)
155
+ TTypeAnnotationNode(ETypeAnnotationKind kind, ui32 flags, ui64 hash, ui64 usedPgExtensions )
156
156
: Kind(kind)
157
157
, Flags(flags)
158
158
, Hash(hash)
159
+ , UsedPgExtensions(usedPgExtensions)
159
160
{
160
161
}
161
162
@@ -278,6 +279,10 @@ class TTypeAnnotationNode {
278
279
return Hash;
279
280
}
280
281
282
+ ui64 GetUsedPgExtensions() const {
283
+ return UsedPgExtensions;
284
+ }
285
+
281
286
bool Equals(const TTypeAnnotationNode& node) const;
282
287
void Accept(TTypeAnnotationVisitor& visitor) const;
283
288
@@ -310,10 +315,21 @@ class TTypeAnnotationNode {
310
315
return flags;
311
316
}
312
317
318
+ template <typename T>
319
+ static ui64 CombinePgExtensions(const T& items) {
320
+ ui64 mask = 0;
321
+ for (auto& item : items) {
322
+ mask |= item->GetUsedPgExtensions();
323
+ }
324
+
325
+ return mask;
326
+ }
327
+
313
328
private:
314
329
const ETypeAnnotationKind Kind;
315
330
const ui32 Flags;
316
331
const ui64 Hash;
332
+ const ui64 UsedPgExtensions;
317
333
};
318
334
319
335
class TUnitExprType : public TTypeAnnotationNode {
@@ -322,7 +338,7 @@ class TUnitExprType : public TTypeAnnotationNode {
322
338
323
339
TUnitExprType(ui64 hash)
324
340
: TTypeAnnotationNode(KindValue,
325
- TypeNonComputable | TypeNonPersistable, hash)
341
+ TypeNonComputable | TypeNonPersistable, hash, 0 )
326
342
{
327
343
}
328
344
@@ -341,7 +357,7 @@ class TTupleExprType : public TTypeAnnotationNode {
341
357
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Tuple;
342
358
343
359
TTupleExprType(ui64 hash, const TTypeAnnotationNode::TListType& items)
344
- : TTypeAnnotationNode(KindValue, CombineFlags(items), hash)
360
+ : TTypeAnnotationNode(KindValue, CombineFlags(items), hash, CombinePgExtensions(items) )
345
361
, Items(items)
346
362
{
347
363
}
@@ -390,7 +406,7 @@ class TMultiExprType : public TTypeAnnotationNode {
390
406
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Multi;
391
407
392
408
TMultiExprType(ui64 hash, const TTypeAnnotationNode::TListType& items)
393
- : TTypeAnnotationNode(KindValue, CombineFlags(items), hash)
409
+ : TTypeAnnotationNode(KindValue, CombineFlags(items), hash, CombinePgExtensions(items) )
394
410
, Items(items)
395
411
{
396
412
}
@@ -445,7 +461,7 @@ class TItemExprType : public TTypeAnnotationNode {
445
461
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Item;
446
462
447
463
TItemExprType(ui64 hash, const TStringBuf& name, const TTypeAnnotationNode* itemType)
448
- : TTypeAnnotationNode(KindValue, itemType->GetFlags(), hash)
464
+ : TTypeAnnotationNode(KindValue, itemType->GetFlags(), hash, itemType->GetUsedPgExtensions() )
449
465
, Name(name)
450
466
, ItemType(itemType)
451
467
{
@@ -501,7 +517,7 @@ class TStructExprType : public TTypeAnnotationNode {
501
517
};
502
518
503
519
TStructExprType(ui64 hash, const TVector<const TItemExprType*>& items)
504
- : TTypeAnnotationNode(KindValue, TypeNonComparable | CombineFlags(items), hash)
520
+ : TTypeAnnotationNode(KindValue, TypeNonComparable | CombineFlags(items), hash, CombinePgExtensions(items) )
505
521
, Items(items)
506
522
{
507
523
}
@@ -623,7 +639,7 @@ class TListExprType : public TTypeAnnotationNode {
623
639
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::List;
624
640
625
641
TListExprType(ui64 hash, const TTypeAnnotationNode* itemType)
626
- : TTypeAnnotationNode(KindValue, itemType->GetFlags() | TypeHasDynamicSize, hash)
642
+ : TTypeAnnotationNode(KindValue, itemType->GetFlags() | TypeHasDynamicSize, hash, itemType->GetUsedPgExtensions() )
627
643
, ItemType(itemType)
628
644
{
629
645
}
@@ -650,7 +666,7 @@ class TStreamExprType : public TTypeAnnotationNode {
650
666
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Stream;
651
667
652
668
TStreamExprType(ui64 hash, const TTypeAnnotationNode* itemType)
653
- : TTypeAnnotationNode(KindValue, itemType->GetFlags() | TypeNonPersistable, hash)
669
+ : TTypeAnnotationNode(KindValue, itemType->GetFlags() | TypeNonPersistable, hash, itemType->GetUsedPgExtensions() )
654
670
, ItemType(itemType)
655
671
{
656
672
}
@@ -677,7 +693,7 @@ class TFlowExprType : public TTypeAnnotationNode {
677
693
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Flow;
678
694
679
695
TFlowExprType(ui64 hash, const TTypeAnnotationNode* itemType)
680
- : TTypeAnnotationNode(KindValue, itemType->GetFlags() | TypeNonPersistable, hash)
696
+ : TTypeAnnotationNode(KindValue, itemType->GetFlags() | TypeNonPersistable, hash, itemType->GetUsedPgExtensions() )
681
697
, ItemType(itemType)
682
698
{
683
699
}
@@ -704,7 +720,7 @@ class TBlockExprType : public TTypeAnnotationNode {
704
720
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Block;
705
721
706
722
TBlockExprType(ui64 hash, const TTypeAnnotationNode* itemType)
707
- : TTypeAnnotationNode(KindValue, itemType->GetFlags() | TypeNonPersistable, hash)
723
+ : TTypeAnnotationNode(KindValue, itemType->GetFlags() | TypeNonPersistable, hash, itemType->GetUsedPgExtensions() )
708
724
, ItemType(itemType)
709
725
{
710
726
}
@@ -731,7 +747,7 @@ class TScalarExprType : public TTypeAnnotationNode {
731
747
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Scalar;
732
748
733
749
TScalarExprType(ui64 hash, const TTypeAnnotationNode* itemType)
734
- : TTypeAnnotationNode(KindValue, itemType->GetFlags() | TypeNonPersistable, hash)
750
+ : TTypeAnnotationNode(KindValue, itemType->GetFlags() | TypeNonPersistable, hash, itemType->GetUsedPgExtensions() )
735
751
, ItemType(itemType)
736
752
{
737
753
}
@@ -758,7 +774,7 @@ class TDataExprType : public TTypeAnnotationNode {
758
774
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Data;
759
775
760
776
TDataExprType(ui64 hash, EDataSlot slot)
761
- : TTypeAnnotationNode(KindValue, GetFlags(slot), hash)
777
+ : TTypeAnnotationNode(KindValue, GetFlags(slot), hash, 0 )
762
778
, Slot(slot)
763
779
{
764
780
}
@@ -853,7 +869,7 @@ class TPgExprType : public TTypeAnnotationNode {
853
869
854
870
// TODO: TypeHasDynamicSize for Pg types
855
871
TPgExprType(ui64 hash, ui32 typeId)
856
- : TTypeAnnotationNode(KindValue, GetFlags(typeId), hash)
872
+ : TTypeAnnotationNode(KindValue, GetFlags(typeId), hash, GetPgExtensionsMask(typeId) )
857
873
, TypeId(typeId)
858
874
{
859
875
}
@@ -875,18 +891,21 @@ class TPgExprType : public TTypeAnnotationNode {
875
891
876
892
private:
877
893
ui32 GetFlags(ui32 typeId);
894
+ ui64 GetPgExtensionsMask(ui32 typeId);
878
895
879
896
private:
880
897
ui32 TypeId;
881
898
};
882
899
900
+ ui64 MakePgExtensionMask(ui32 extensionIndex);
901
+
883
902
class TWorldExprType : public TTypeAnnotationNode {
884
903
public:
885
904
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::World;
886
905
887
906
TWorldExprType(ui64 hash)
888
907
: TTypeAnnotationNode(KindValue,
889
- TypeNonComposable | TypeNonComputable | TypeNonPersistable | TypeNonInspectable, hash)
908
+ TypeNonComposable | TypeNonComputable | TypeNonPersistable | TypeNonInspectable, hash, 0 )
890
909
{
891
910
}
892
911
@@ -905,7 +924,7 @@ class TOptionalExprType : public TTypeAnnotationNode {
905
924
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Optional;
906
925
907
926
TOptionalExprType(ui64 hash, const TTypeAnnotationNode* itemType)
908
- : TTypeAnnotationNode(KindValue, GetFlags(itemType), hash)
927
+ : TTypeAnnotationNode(KindValue, GetFlags(itemType), hash, itemType->GetUsedPgExtensions() )
909
928
, ItemType(itemType)
910
929
{
911
930
}
@@ -945,7 +964,7 @@ class TVariantExprType : public TTypeAnnotationNode {
945
964
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Variant;
946
965
947
966
TVariantExprType(ui64 hash, const TTypeAnnotationNode* underlyingType)
948
- : TTypeAnnotationNode(KindValue, MakeFlags(underlyingType), hash)
967
+ : TTypeAnnotationNode(KindValue, MakeFlags(underlyingType), hash, underlyingType->GetUsedPgExtensions() )
949
968
, UnderlyingType(underlyingType)
950
969
{
951
970
}
@@ -977,7 +996,7 @@ class TTypeExprType : public TTypeAnnotationNode {
977
996
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Type;
978
997
979
998
TTypeExprType(ui64 hash, const TTypeAnnotationNode* type)
980
- : TTypeAnnotationNode(KindValue, TypeNonPersistable | TypeNonComputable, hash)
999
+ : TTypeAnnotationNode(KindValue, TypeNonPersistable | TypeNonComputable, hash, 0 )
981
1000
, Type(type)
982
1001
{
983
1002
}
@@ -1005,7 +1024,8 @@ class TDictExprType : public TTypeAnnotationNode {
1005
1024
1006
1025
TDictExprType(ui64 hash, const TTypeAnnotationNode* keyType, const TTypeAnnotationNode* payloadType)
1007
1026
: TTypeAnnotationNode(KindValue, TypeNonComparable | TypeHasDynamicSize |
1008
- keyType->GetFlags() | payloadType->GetFlags(), hash)
1027
+ keyType->GetFlags() | payloadType->GetFlags(), hash,
1028
+ keyType->GetUsedPgExtensions() | payloadType->GetUsedPgExtensions())
1009
1029
, KeyType(keyType)
1010
1030
, PayloadType(payloadType)
1011
1031
{
@@ -1042,7 +1062,7 @@ class TVoidExprType : public TTypeAnnotationNode {
1042
1062
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Void;
1043
1063
1044
1064
TVoidExprType(ui64 hash)
1045
- : TTypeAnnotationNode(KindValue, 0, hash)
1065
+ : TTypeAnnotationNode(KindValue, 0, hash, 0 )
1046
1066
{
1047
1067
}
1048
1068
@@ -1061,7 +1081,7 @@ class TNullExprType : public TTypeAnnotationNode {
1061
1081
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Null;
1062
1082
1063
1083
TNullExprType(ui64 hash)
1064
- : TTypeAnnotationNode(KindValue, TypeHasNull, hash)
1084
+ : TTypeAnnotationNode(KindValue, TypeHasNull, hash, 0 )
1065
1085
{
1066
1086
}
1067
1087
@@ -1101,7 +1121,7 @@ class TCallableExprType : public TTypeAnnotationNode {
1101
1121
1102
1122
TCallableExprType(ui64 hash, const TTypeAnnotationNode* returnType, const TVector<TArgumentInfo>& arguments
1103
1123
, size_t optionalArgumentsCount, const TStringBuf& payload)
1104
- : TTypeAnnotationNode(KindValue, MakeFlags(returnType), hash)
1124
+ : TTypeAnnotationNode(KindValue, MakeFlags(returnType), hash, returnType->GetUsedPgExtensions() )
1105
1125
, ReturnType(returnType)
1106
1126
, Arguments(arguments)
1107
1127
, OptionalArgumentsCount(optionalArgumentsCount)
@@ -1207,7 +1227,7 @@ class TGenericExprType : public TTypeAnnotationNode {
1207
1227
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Generic;
1208
1228
1209
1229
TGenericExprType(ui64 hash)
1210
- : TTypeAnnotationNode(KindValue, TypeNonComputable, hash)
1230
+ : TTypeAnnotationNode(KindValue, TypeNonComputable, hash, 0 )
1211
1231
{
1212
1232
}
1213
1233
@@ -1226,7 +1246,7 @@ class TResourceExprType : public TTypeAnnotationNode {
1226
1246
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Resource;
1227
1247
1228
1248
TResourceExprType(ui64 hash, const TStringBuf& tag)
1229
- : TTypeAnnotationNode(KindValue, TypeNonPersistable | TypeHasManyValues, hash)
1249
+ : TTypeAnnotationNode(KindValue, TypeNonPersistable | TypeHasManyValues, hash, 0 )
1230
1250
, Tag(tag)
1231
1251
{}
1232
1252
@@ -1253,7 +1273,7 @@ class TTaggedExprType : public TTypeAnnotationNode {
1253
1273
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Tagged;
1254
1274
1255
1275
TTaggedExprType(ui64 hash, const TTypeAnnotationNode* baseType, const TStringBuf& tag)
1256
- : TTypeAnnotationNode(KindValue, baseType->GetFlags(), hash)
1276
+ : TTypeAnnotationNode(KindValue, baseType->GetFlags(), hash, baseType->GetUsedPgExtensions() )
1257
1277
, BaseType(baseType)
1258
1278
, Tag(tag)
1259
1279
{}
@@ -1290,7 +1310,7 @@ class TErrorExprType : public TTypeAnnotationNode {
1290
1310
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::Error;
1291
1311
1292
1312
TErrorExprType(ui64 hash, const TIssue& error)
1293
- : TTypeAnnotationNode(KindValue, 0, hash)
1313
+ : TTypeAnnotationNode(KindValue, 0, hash, 0 )
1294
1314
, Error(error)
1295
1315
{}
1296
1316
@@ -1315,7 +1335,7 @@ class TEmptyListExprType : public TTypeAnnotationNode {
1315
1335
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::EmptyList;
1316
1336
1317
1337
TEmptyListExprType(ui64 hash)
1318
- : TTypeAnnotationNode(KindValue, 0, hash)
1338
+ : TTypeAnnotationNode(KindValue, 0, hash, 0 )
1319
1339
{
1320
1340
}
1321
1341
@@ -1334,7 +1354,7 @@ class TEmptyDictExprType : public TTypeAnnotationNode {
1334
1354
static constexpr ETypeAnnotationKind KindValue = ETypeAnnotationKind::EmptyDict;
1335
1355
1336
1356
TEmptyDictExprType(ui64 hash)
1337
- : TTypeAnnotationNode(KindValue, 0, hash)
1357
+ : TTypeAnnotationNode(KindValue, 0, hash, 0 )
1338
1358
{
1339
1359
}
1340
1360
0 commit comments