File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
csharp/ql/src/semmle/code/dotnet Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -92,13 +92,25 @@ abstract class Constructor extends Callable { }
9292/** A destructor/finalizer. */
9393abstract class Destructor extends Callable { }
9494
95+ pragma [ nomagic]
96+ private ValueOrRefType getARecordBaseType ( ValueOrRefType t ) {
97+ exists ( Callable c |
98+ c .hasName ( "<Clone>$" ) and
99+ c .getNumberOfParameters ( ) = 0 and
100+ t = c .getDeclaringType ( ) and
101+ result = t
102+ )
103+ or
104+ result = getARecordBaseType ( t ) .getABaseType ( )
105+ }
106+
95107/** A clone method on a record. */
96108class RecordCloneCallable extends Callable {
97109 RecordCloneCallable ( ) {
98110 this .getDeclaringType ( ) instanceof ValueOrRefType and
99111 this .hasName ( "<Clone>$" ) and
100112 this .getNumberOfParameters ( ) = 0 and
101- this .getReturnType ( ) = this .getDeclaringType ( ) . ( ValueOrRefType ) . getABaseType * ( ) and
113+ this .getReturnType ( ) = getARecordBaseType ( this .getDeclaringType ( ) ) and
102114 this .( Member ) .isPublic ( ) and
103115 not this .( Member ) .isStatic ( )
104116 }
You can’t perform that action at this time.
0 commit comments