Skip to content

Commit

Permalink
Add a comment about bad generics in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Markoutte committed Jul 26, 2023
1 parent f9039ab commit 3b25239
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ class AbstractsObjectValueProvider(
return isAccessible(jClass, description.description.packageName) &&
jClass.declaredConstructors.any { isAccessible(it, description.description.packageName) } &&
jClass.let {
// This won't work in case of implementations with generics like `Impl<T> implements A<T>`.
// Should be reworked with accurate generic matching between all classes.
toFuzzerType(it, description.typeCache).traverseHierarchy(description.typeCache).contains(type)
}
} catch (ignore: Throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ class JavaTypesTest {

val goodType = toFuzzerType(Implementations.AInteger::class.java, cache)
val goodTypeHierarchy = goodType.traverseHierarchy(cache).toSet()
Assertions.assertEquals(2, badTypeHierarchy.size) { "There's only one class (Object) and one interface should be found" }
Assertions.assertTrue(goodTypeHierarchy.contains(type)) { "Bad type hierarchy should contain tested type $type" }
Assertions.assertEquals(2, goodTypeHierarchy.size) { "There's only one class (Object) and one interface should be found" }
Assertions.assertTrue(goodTypeHierarchy.contains(type)) { "Good type hierarchy should contain tested type $type" }
}
}
}

0 comments on commit 3b25239

Please sign in to comment.