зеркало из https://github.com/github/codeql.git
Avoid pathological case where getExampleMethodName picks a very common method name
This commit is contained in:
Родитель
ed9a6bd820
Коммит
c79da8b2b5
|
@ -1064,10 +1064,19 @@ class ErrorType extends Type {
|
|||
ErrorType() { this.implements(Builtin::error().getType().getUnderlyingType()) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of types with method `name`.
|
||||
*/
|
||||
bindingset[name]
|
||||
int numberOfTypesWithMethodName(string name) { result = count(Type t | t.hasMethod(name, _)) }
|
||||
|
||||
/**
|
||||
* Gets the name of a method in the method set of `i`.
|
||||
*
|
||||
* This is used to restrict the set of interfaces to consider in the definition of `implements`,
|
||||
* so it does not matter which method name is chosen (we use the lexicographically least).
|
||||
* so it does not matter which method name is chosen (we use the most unusual name the interface
|
||||
* require; this is the most discriminating and so shrinks the search space the most).
|
||||
*/
|
||||
private string getExampleMethodName(InterfaceType i) { result = min(string m | i.hasMethod(m, _)) }
|
||||
private string getExampleMethodName(InterfaceType i) {
|
||||
result = min(string m | i.hasMethod(m, _) | m order by numberOfTypesWithMethodName(m))
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче