Repository navigation
Add support for type annotations (old) - #3992
PiIsRational wants to merge 72 commits into
Conversation
|
I have a stupid questions:
|
Review: PR #3992 — “Add support for type annotations”
SummaryThe PR reads type annotations from Java sources, stores them in The mechanical part of the refactor is careful and consistent; everything compiles, including the test sources. The new logic in the annotation path has several correctness problems that should be fixed before merge. High severity1.
|
WolframPfeifer
left a comment
There was a problem hiding this comment.
As discussed in a direct meeting, this is (some of) the feedback that I have.
| @@ -40,6 +41,11 @@ public abstract class TypeReferenceImp extends JavaNonTerminalProgramElement | |||
| */ | |||
| protected final ProgramElementName name; | |||
|
|
|||
| /** | |||
| * Annotations. | |||
There was a problem hiding this comment.
This is not a helpful JavaDoc. In such a case, preferably add some description/examples (@Nullable, @NonNull, @Rep, @Peer), or remove the JavaDoc.
| if (!(pe instanceof TypeReference) | ||
| || ((TypeReference) pe).getDimensions() != getDimensions()) { | ||
|
|
||
| if (pe instanceof TypeReference tr |
There was a problem hiding this comment.
Before this PR, if pe was not instance of TypeReference, null would be returned. Now, super.match is called. Is this intentional? Does it have the desired behavior?
| @@ -295,6 +294,8 @@ private MethodDeclaration createInitializeMethod(TypeDeclaration<?> td) { | |||
| */ | |||
| @Override | |||
| public void apply(TypeDeclaration<?> td) { | |||
| if (td.isAnnotationDeclaration()) | |||
| return; | |||
There was a problem hiding this comment.
Why do we return early in this case?
| @@ -159,6 +158,8 @@ private MethodDeclaration createPrepareMethod(TypeDeclaration<?> td) { | |||
| * the TypeDeclaration | |||
| */ | |||
| public void apply(TypeDeclaration<?> td) { | |||
| if (td.isAnnotationDeclaration()) | |||
| return; | |||
There was a problem hiding this comment.
Why do we return early in this case?
| @@ -109,6 +109,12 @@ application { | |||
| mainClass.set("de.uka.ilkd.key.core.Main") | |||
| } | |||
|
|
|||
| java { | |||
| toolchain { | |||
| languageVersion = JavaLanguageVersion.of(21) | |||
| \forall int x; (p(x) -> p(add(x, Z(1(#))))) | ||
| & p(Z(0(#))) | ||
| -> p(Z(2(#))) | ||
| \forall int x; true & !false |
There was a problem hiding this comment.
Something is weird here. Git detected a renaming, but I think it is actually a deletion + change.
Why are many *.proof files deleted?
|
Regarding the First Review i followed all points except point 3. So the behaviour of KeY remains fully for annotations that are not Marker Annotations. |
|
This PR gets replaced by #3996 |
Intended Change
The Goal of this Pull Request is to be able to use Java Type Annotations in Taclets.
To make this work the Type Annotations were added to the KeY Ast at the
TypeReferencelevel.The annotations were added to the type references, since they correspond to the syntactical
version of the types. Since in most places
KeYJavaTypes were used, there was the needto replace them.
The default matching behaviour was not altered and is compatible with the current
master branch. This means that there is no semantic difference between
Object oand
@Rep Object o. Therefore, no taclets need to be altered and annotations are simplyignored per default.
To interact with annotations in taclets there are currently 3 variable conditions:
hasAnnotation(SchemaVariable variable, String annot):It checks that the type (
TypeReference) ofvariablehas an annotation whosefully qualified name matches
annot. It supportsProgramVariables,New(simple constuctor calls) and Fields.
addAnnotation(SchemaVariable store, SchemaVariable read, String annot):It creates a copy of
readand stores instoreexcept that the last annotationof the type of
storenow corresponds toannot. If the given stringannotdoesnot match an annotation, the variable condition fails.
It supports
ProgramVariables andNew(simple constructor calls).removeAnnotation(SchemaVariable store, SchemaVariable read, String annot):It creates a copy of
readwhere all annotations of the type ofreadwith the fully qualified name matching
annotare removed and stores it instore.This variable condition matches always and only supports
New(simple constructor calls).Currently only, Marker annotations so annotations with no arguments
(such as
@NonNullor@Rep) are supported.Example
In the context of a Nullness type system (where the
@NonNull) annotationis type checked we could have something like the following snippet:
To be able to use the guarantee expressed by the annotation we could write the following
Taclet:
A further (similar) example can be found here.
The main use of this change is PR #3724 and can be found here (mainly in
universeDefs.key).Plan
Type of pull request
Ensuring quality
Additional information and contact(s)
@WolframPfeifer is involved in this Pull Request
The contributions within this pull request are licensed under GPLv2 (only) for inclusion in KeY.