Improve cast warnings/errors logic#337
Conversation
|
|
|
|
wmdietl
left a comment
There was a problem hiding this comment.
Thanks for all your work on this! I have a few questions about naming and how to structure this change.
| * @param v2 a type variable | ||
| * @return whether the arguments are the same type variables | ||
| */ | ||
| public static boolean areSameTypeVariables(TypeVariable v1, TypeVariable v2) { |
There was a problem hiding this comment.
This method seems very dangerous... can you add a warning to the method. I think this only works if the TypeVariables are from the same context. If one compares TVs from e.g. a declaration to a TV from a use site, there could be two different Ts that just happen to have the same name.
There was a problem hiding this comment.
Thanks for pointing this out! I will leave a comment there.
Co-authored-by: Werner Dietl <wdietl@gmail.com>
|
Further updates in #1049. |
Fixes #155.
Merge together with eisop-codespecs/daikon#2.
This PR aims at refining the typecasting logic in Checker-Framework.
@top basevariable to@bot derivedtype, both the pluggable types and java types are downcasting, and supposederivedclass can only be annotated with@bot. we believe this kinds of downcasts can be statically verified in checkerframework. Case1: Ifbaseis really aderivedinstance and this instance could only be annotated with@bot, it's okay we cast from top to bot; Case2: ifbaseis not aderivedinstance, and we can rely on javac or java-runtime to report ainconvertible typesorclasscastexception.Enumerate all the conditions:

Main logic:
method isUpcast(...) logic:
isSafeDowncast logic:
isSafeIncomparableCast() logic:
