Overlapping Method Overloads with Unboxing Cause False Positive?

Sonar Version: 4.5.1
Sonar Scanner: MSBuild 4.5
Language Analyzer: C# (?)

IBulkCachePrefetcher WithCache<TCache>()
    where TCache : ICache;

IBulkCachePrefetcher WithCache<TCache>(dynamic key = null)
    where TCache : IKeyedCache;

The second method signature will elicit the rule: Method overloads with default parameter values should not overlap. However with unboxing and the where clause, this undesired behaviour should not be possible, by my understanding.

Thank you and please clarify!

Hi @dwick. Sorry for the late answer.

It really depends on your code, whether IKeyedCache is a subtype of ICache. In that case, the two method probably overlap.

For example, if you have

interface ICache {}
interface IKeyedCache : ICache {}
class KeyedCache : IKeyedCache {}

What should WithCache<KeyedCache>(); call?