@@ -165,6 +165,21 @@ class ClassDecl with ClassMember, Annotated implements Element<ClassDecl> {
165
165
@JsonKey (includeFromJson: false )
166
166
late final Map <String , int > methodNumsAfterRenaming;
167
167
168
+ /// Populated by [Linker] .
169
+ @JsonKey (includeFromJson: false )
170
+ final Map <Operator , Method > operators = {};
171
+
172
+ /// The `compareTo` method of this class.
173
+ ///
174
+ /// This method must take a single parameter of the same type of the enclosing
175
+ /// class, and return integer.
176
+ ///
177
+ /// Used for overloading comparison operators.
178
+ ///
179
+ /// Populated by [Linker] .
180
+ @JsonKey (includeFromJson: false )
181
+ Method ? compareTo;
182
+
168
183
@override
169
184
String toString () {
170
185
return 'Java class declaration for $binaryName ' ;
@@ -682,8 +697,9 @@ class Method with ClassMember, Annotated implements Element<Method> {
682
697
@override
683
698
late String finalName;
684
699
700
+ /// Populated by [KotlinProcessor] .
685
701
@JsonKey (includeFromJson: false )
686
- late bool isOverridden ;
702
+ KotlinFunction ? kotlinFunction ;
687
703
688
704
/// The actual return type when the method is a Kotlin's suspend fun.
689
705
///
@@ -1040,6 +1056,7 @@ class KotlinFunction {
1040
1056
this .typeParameters = const [],
1041
1057
required this .flags,
1042
1058
required this .isSuspend,
1059
+ required this .isOperator,
1043
1060
});
1044
1061
1045
1062
/// Name in the byte code.
@@ -1056,6 +1073,7 @@ class KotlinFunction {
1056
1073
final List <KotlinTypeParameter > typeParameters;
1057
1074
final int flags;
1058
1075
final bool isSuspend;
1076
+ final bool isOperator;
1059
1077
1060
1078
factory KotlinFunction .fromJson (Map <String , dynamic > json) =>
1061
1079
_$KotlinFunctionFromJson (json);
@@ -1251,3 +1269,31 @@ class KotlinTypeProjection extends KotlinTypeArgument {
1251
1269
final KotlinType type;
1252
1270
final KmVariance variance;
1253
1271
}
1272
+
1273
+ enum Operator {
1274
+ plus ('+' , parameterCount: 1 ),
1275
+ minus ('-' , parameterCount: 1 ),
1276
+ times ('*' , parameterCount: 1 ),
1277
+ div ('/' , parameterCount: 1 ),
1278
+ rem ('%' , parameterCount: 1 ),
1279
+ get ('[]' , parameterCount: 1 ),
1280
+ set ('[]=' , parameterCount: 2 , returnsVoid: true );
1281
+
1282
+ final String dartSymbol;
1283
+
1284
+ /// The number of parameters this operator must have in Dart.
1285
+ final int parameterCount;
1286
+
1287
+ /// Whether the return type that this operator must have in Dart is void.
1288
+ final bool returnsVoid;
1289
+
1290
+ const Operator (
1291
+ this .dartSymbol, {
1292
+ required this .parameterCount,
1293
+ this .returnsVoid = false ,
1294
+ });
1295
+
1296
+ bool isCompatibleWith (Method method) {
1297
+ return parameterCount == method.params.length;
1298
+ }
1299
+ }
0 commit comments