At the moment casts without any further dependencies on the target type are not detected as dependencies. I.e.
SomeClass example(Object rawInput) {
return (SomeClassImpl) rawInput; // should forbid dependencies on SomeClassImpl
}
Since there are no further dependencies on SomeClassImpl this would be missed. It does likely not cause a maintenance problem later, because the cast could at any time be weakened to (SomeClass) without any further compile or runtime issues, but still it would be nice to detect these things. Also to be able to access all casts that a class or method applies could be useful for other scenarios.
We could add this the following way:
- extend
Set<TypeCast> JavaCodeUnit.getCasts() (compare InstanceofCheck)
- add the
TypeCasts to JavaClass.directDependencies{From/To}Self
(open for discussion: What is the best name for the domain object? TypeCast, Cast, JavaCast, ClassCast, ...?)
At the moment casts without any further dependencies on the target type are not detected as dependencies. I.e.
Since there are no further dependencies on
SomeClassImplthis would be missed. It does likely not cause a maintenance problem later, because the cast could at any time be weakened to(SomeClass)without any further compile or runtime issues, but still it would be nice to detect these things. Also to be able to access all casts that a class or method applies could be useful for other scenarios.We could add this the following way:
Set<TypeCast> JavaCodeUnit.getCasts()(compareInstanceofCheck)TypeCasts toJavaClass.directDependencies{From/To}Self(open for discussion: What is the best name for the domain object?
TypeCast,Cast,JavaCast,ClassCast, ...?)