Skip to content

Commit ae06040

Browse files
committed
Address review comments
1 parent 8f35c99 commit ae06040

File tree

4 files changed

+134
-146
lines changed

4 files changed

+134
-146
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,24 +2102,6 @@ private predicate uselessTypebound(DataFlowType dt) {
21022102
)
21032103
}
21042104

2105-
pragma[nomagic]
2106-
private predicate typeStrongerThanNonDelegate(DataFlowType t1, DataFlowType t2) {
2107-
t1 != t2 and
2108-
t1.asGvnType() = getANonTypeParameterSubTypeRestricted(t2.asGvnType())
2109-
or
2110-
t1.asGvnType() instanceof RelevantGvnType and
2111-
not uselessTypebound(t1) and
2112-
uselessTypebound(t2)
2113-
}
2114-
2115-
bindingset[t1, t2]
2116-
predicate typeStrongerThan(DataFlowType t1, DataFlowType t2) {
2117-
typeStrongerThanNonDelegate(t1, t2)
2118-
or
2119-
exists(t1.asDelegate()) and
2120-
t1 != t2
2121-
}
2122-
21232105
pragma[inline]
21242106
private predicate compatibleTypesDelegateLeft(DataFlowType dt1, DataFlowType dt2) {
21252107
exists(Gvn::GvnType t1, Gvn::GvnType t2 |
@@ -2176,6 +2158,18 @@ predicate compatibleTypes(DataFlowType dt1, DataFlowType dt2) {
21762158
dt1.asDelegate() = dt2.asDelegate()
21772159
}
21782160

2161+
pragma[nomagic]
2162+
predicate typeStrongerThan(DataFlowType t1, DataFlowType t2) {
2163+
t1 != t2 and
2164+
t1.asGvnType() = getANonTypeParameterSubTypeRestricted(t2.asGvnType())
2165+
or
2166+
t1.asGvnType() instanceof RelevantGvnType and
2167+
not uselessTypebound(t1) and
2168+
uselessTypebound(t2)
2169+
or
2170+
compatibleTypesDelegateLeft(t1, t2)
2171+
}
2172+
21792173
/**
21802174
* A node associated with an object after an operation that might have
21812175
* changed its state.

csharp/ql/test/library-tests/dataflow/typeflow-dispatch/TypeFlowDispatch.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ public class A
88

99
public static void Sink<T>(T t) { }
1010

11-
interface MyConsumer
12-
{
13-
void run(Object o);
14-
}
15-
1611
static void Apply1<T>(Action<T> f, T x)
1712
{
1813
f(x);

0 commit comments

Comments
 (0)