mirror of https://github.com/sbt/sbt.git
Ensure that `parents` for java classes have all the ancestors
Currently, only immediate parents classes are picked up for java classes. This could be problematic, for example, in detecting Fingerprint for test frameworks. So far, Scala types are not affected –– all the ancestors are available for them.
This commit is contained in:
parent
2bb2aed1f6
commit
2525eeb7e6
|
|
@ -76,8 +76,17 @@ object ClassToAPI
|
|||
private val lzyEmptyTpeArray = lzy(emptyTypeArray)
|
||||
private val lzyEmptyDefArray = lzy(new Array[xsbti.api.Definition](0))
|
||||
|
||||
private def allSuperclasses(t: Type): Seq[Type] =
|
||||
{
|
||||
def accumulate(t: Type, accum: Seq[Type] = Seq.empty): Seq[Type] = t match {
|
||||
case cl: Class[_] => { val s = cl.getGenericSuperclass ; accumulate(s, accum :+ s) }
|
||||
case _ => accum
|
||||
}
|
||||
accumulate(t)
|
||||
}
|
||||
|
||||
def parents(c: Class[_]): Seq[api.Type] =
|
||||
types(c.getGenericSuperclass +: c.getGenericInterfaces)
|
||||
types(allSuperclasses(c) ++ c.getGenericInterfaces)
|
||||
def types(ts: Seq[Type]): Array[api.Type] = ts filter (_ ne null) map reference toArray;
|
||||
def upperBounds(ts: Array[Type]): api.Type =
|
||||
new api.Structure(lzy(types(ts)), lzyEmptyDefArray, lzyEmptyDefArray)
|
||||
|
|
|
|||
|
|
@ -1277,7 +1277,7 @@ trait BuildExtra extends BuildCommon
|
|||
|
||||
/** Disables post-compilation hook for determining tests for tab-completion (such as for 'test-only').
|
||||
* This is useful for reducing test:compile time when not running test. */
|
||||
def noTestCompletion(config: Configuration = Test): Setting[_] = inConfig(config)( Seq(definedTests <<= Defaults.detectTests) ).head
|
||||
def noTestCompletion(config: Configuration = Test): Setting[_] = inConfig(config)( Seq(definedTests <<= detectTests) ).head
|
||||
|
||||
def filterKeys(ss: Seq[Setting[_]], transitive: Boolean = false)(f: ScopedKey[_] => Boolean): Seq[Setting[_]] =
|
||||
ss filter ( s => f(s.key) && (!transitive || s.dependencies.forall(f)) )
|
||||
|
|
|
|||
Loading…
Reference in New Issue