Skip to content

Commit 791a7db

Browse files
committed
C#: Use the relation in the ExtensionType relation in the QL library.
1 parent ca5e18e commit 791a7db

File tree

1 file changed

+10
-4
lines changed
  • csharp/ql/lib/semmle/code/csharp

1 file changed

+10
-4
lines changed

csharp/ql/lib/semmle/code/csharp/Type.qll

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,16 +1339,22 @@ class ExtensionType extends Parameterizable, @extension_type {
13391339
/**
13401340
* Gets the receiver parameter of this extension type, if any.
13411341
*/
1342-
Parameter getReceiverParameter() { params(result, _, _, 0, _, this, _) }
1342+
Parameter getReceiverParameter() { result = this.getParameter(0) }
13431343

13441344
/**
13451345
* Holds if this extension type has a receiver parameter.
13461346
*/
13471347
predicate hasReceiverParameter() { exists(this.getReceiverParameter()) }
13481348

1349-
/** Gets the type being extended by this extension type. */
1350-
// TODO: This doesn't handle the case where there is no parameter.
1351-
Type getExtendedType() { result = this.getReceiverParameter().getType() }
1349+
/**
1350+
* Gets the type being extended by this extension type.
1351+
*/
1352+
Type getExtendedType() {
1353+
extension_receiver_type(this, result)
1354+
or
1355+
not extension_receiver_type(this, any(Type t)) and
1356+
extension_receiver_type(this, getTypeRef(result))
1357+
}
13521358

13531359
override string getAPrimaryQlClass() { result = "ExtensionType" }
13541360
}

0 commit comments

Comments
 (0)