Skip to content

Commit f715445

Browse files
committed
Fix effective privateness of explicitly implemented members
1 parent a240062 commit f715445

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

csharp/ql/src/semmle/code/csharp/Member.qll

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ class Modifiable extends Declaration, @modifiable {
102102
*/
103103
predicate isEffectivelyPrivate() {
104104
this.isPrivate() or
105-
this.getDeclaringType+().isPrivate()
105+
this.getDeclaringType+().isPrivate() or
106+
this.(Virtualizable).getExplicitlyImplementedInterface().isEffectivelyPrivate()
106107
}
107108

108109
/**
@@ -111,7 +112,8 @@ class Modifiable extends Declaration, @modifiable {
111112
*/
112113
predicate isEffectivelyInternal() {
113114
this.isInternal() or
114-
this.getDeclaringType+().isInternal()
115+
this.getDeclaringType+().isInternal() or
116+
this.(Virtualizable).getExplicitlyImplementedInterface().isInternal()
115117
}
116118

117119
/**
@@ -159,6 +161,11 @@ class Virtualizable extends Member, @virtualizable {
159161
implementsExplicitInterface()
160162
}
161163

164+
override predicate isPrivate() {
165+
Member.super.isPrivate() and
166+
not implementsExplicitInterface()
167+
}
168+
162169
/**
163170
* Gets any interface this member explicitly implements; this only applies
164171
* to members that can be declared on an interface, i.e. methods, properties,

csharp/ql/test/library-tests/modifiers/Effectively.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626
| Modifiers.cs:63:14:63:15 | M2 | public |
2727
| Modifiers.cs:68:14:68:15 | M1 | internal |
2828
| Modifiers.cs:71:18:71:19 | C2 | public |
29+
| Modifiers.cs:73:17:73:18 | M1 | internal |

0 commit comments

Comments
 (0)