-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve cast warnings/errors logic #337
Conversation
framework/src/main/java/org/checkerframework/framework/type/QualifierHierarchy.java
Outdated
Show resolved
Hide resolved
framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java
Show resolved
Hide resolved
framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java
Outdated
Show resolved
Hide resolved
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all your work on this! I have a few questions about naming and how to structure this change.
checker/src/main/java/org/checkerframework/checker/index/inequality/LessThanVisitor.java
Show resolved
Hide resolved
checker/src/main/java/org/checkerframework/checker/interning/InterningVisitor.java
Show resolved
Hide resolved
checker/src/main/java/org/checkerframework/checker/interning/InterningVisitor.java
Show resolved
Hide resolved
checker/src/main/java/org/checkerframework/checker/mustcall/MustCallVisitor.java
Outdated
Show resolved
Hide resolved
checker/src/main/java/org/checkerframework/checker/mustcall/MustCallVisitor.java
Outdated
Show resolved
Hide resolved
framework/src/main/java/org/checkerframework/common/value/ValueVisitor.java
Show resolved
Hide resolved
javacutil/src/main/java/org/checkerframework/javacutil/TypesUtils.java
Outdated
Show resolved
Hide resolved
framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java
Outdated
Show resolved
Hide resolved
javacutil/src/main/java/org/checkerframework/javacutil/TypesUtils.java
Outdated
Show resolved
Hide resolved
* @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 T
s that just happen to have the same name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 base
variable to@bot derived
type, both the pluggable types and java types are downcasting, and supposederived
class can only be annotated with@bot
. we believe this kinds of downcasts can be statically verified in checkerframework. Case1: Ifbase
is really aderived
instance and this instance could only be annotated with@bot
, it's okay we cast from top to bot; Case2: ifbase
is not aderived
instance, and we can rely on javac or java-runtime to report ainconvertible types
orclasscastexception
.Enumerate all the conditions:
Main logic:
method isUpcast(...) logic:
isSafeDowncast logic:
isSafeIncomparableCast() logic: