File tree Expand file tree Collapse file tree 6 files changed +11
-9
lines changed
src/Domain/HydraScript.Domain.IR/Types Expand file tree Collapse file tree 6 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ namespace HydraScript.Domain.IR.Types;
55[ ExcludeFromCodeCoverage ]
66public class Any ( ) : Type ( "any" )
77{
8- public override bool Equals ( object ? obj ) => true ;
8+ public override bool Equals ( Type ? obj ) => true ;
99
1010 public override int GetHashCode ( ) => "any" . GetHashCode ( ) ;
1111}
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ public override void ResolveReference(
1515 Type . ResolveReference ( reference , refId , visited ) ;
1616 }
1717
18- public override bool Equals ( object ? obj )
18+ public override bool Equals ( Type ? obj )
1919 {
2020 if ( obj is ArrayType that )
2121 return Equals ( Type , that . Type ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ namespace HydraScript.Domain.IR.Types;
22
33public class NullType ( ) : Type ( "null" )
44{
5- public override bool Equals ( object ? obj ) =>
5+ public override bool Equals ( Type ? obj ) =>
66 obj is ObjectType or NullableType or NullType or Any ;
77
88 public override int GetHashCode ( ) =>
Original file line number Diff line number Diff line change @@ -15,12 +15,12 @@ public override void ResolveReference(
1515 Type . ResolveReference ( reference , refId , visited ) ;
1616 }
1717
18- public override bool Equals ( object ? obj )
18+ public override bool Equals ( Type ? obj )
1919 {
2020 if ( obj is NullableType that )
2121 return Equals ( Type , that . Type ) ;
2222
23- return obj is NullType or Any || ( obj is Type type && type . Equals ( Type ) ) ;
23+ return obj is NullType or Any || ( obj is not null && obj . Equals ( Type ) ) ;
2424 }
2525
2626 public override int GetHashCode ( ) =>
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ public override void ResolveReference(
6969 this [ key ] ! . ResolveReference ( reference , refId , visited ) ;
7070 }
7171
72- public override bool Equals ( object ? obj )
72+ public override bool Equals ( Type ? obj )
7373 {
7474 if ( obj is ObjectType that )
7575 return ReferenceEquals ( this , that ) ||
Original file line number Diff line number Diff line change 11namespace HydraScript . Domain . IR . Types ;
22
3- public class Type
3+ public class Type : IEquatable < Type >
44{
55 private readonly string _name = string . Empty ;
66
@@ -18,14 +18,16 @@ public virtual void ResolveReference(
1818 {
1919 }
2020
21- public override bool Equals ( object ? obj ) =>
21+ public virtual bool Equals ( Type ? obj ) =>
2222 obj switch
2323 {
2424 Any => true ,
25- Type that => _name == that . _name ,
25+ not null => _name == obj . _name ,
2626 _ => false
2727 } ;
2828
29+ public override bool Equals ( object ? obj ) => Equals ( obj as Type ) ;
30+
2931 public override int GetHashCode ( ) =>
3032 _name . GetHashCode ( ) ;
3133
You can’t perform that action at this time.
0 commit comments