GithubHelp home page GithubHelp logo

Comments (1)

smillst avatar smillst commented on September 7, 2024

From: Jonathan Burke

Hi Everyone,

Did we have a final decision as to what annotations on the class declaration mean? Is it just that all types must be below the declaration? Currently, I think declaration annotation just get added to any instance of the type. Should it just act like a bound?

It looks like the manual was update since we last asked this question. Here is what the manual says:

Writing an annotation on a class declaration makes that annotation implicit for all uses of the class (see Section 25.3). If you write class @MyQual MyClass { ... }, then every unannotated use of MyClass is@MyQual MyClass. A user is permitted to strengthen the type by writing a more restrictive annotation on a use of MyClass, such as @MyMoreRestrictiveQual MyClass.

So it seems that for inference, to handle this correctly we could treat it like a parametric (non-defaultable) type and infer whether or not it exists.
Does that seem reasonable?

Jonathan


From: Michael Ernst

Right, that sounds right. The annotation being missing is different than it being present.

Thanks!

-Mike


From: Werner Dietl

Hi Jonathan,

I'm not quite sure what you mean with "infer whether or not it exists".
The annotations on a class declaration (let's not call it a declaration
annotation as that is a broader concept) has two meanings:

  1. if a particular class is annotated, that annotation is implicit for
    all uses of the class, overriding the usual default; it is also an upper
    bound for possible type uses: only more restrictive qualifiers can be
    used explicitly.
  2. if no annotation is given on a particular class, we still have an
    implicit annotation on the class declaration, per the discussion at

https://groups.google.com/d/msg/checker-framework-dev/vk2V6ZFKPLk/v3hENw-e7gsJ

"Default annotations on type declarations".
This default is then used as an upper bound for all uses of the type,
but it is not used implicitly for those uses. That is, the normal
default is used for uses of the class, but that default still has to be
more restrictive than the default on type declarations.

At least that's how the Checker Framework behaves at the moment.
For inference this means that there is always a subtype constraint
between the annotation on a type use and the (implicit or explicit)
annotation on the type declaration.
If there is an explicit annotation on the type declaration, inference
doesn't need to change - but when determining whether the inferred
result is equal to the default, the annotation on the declaration needs
to be considered.

Does this agree with how you interpret this?

cu, WMD.


From: Jonathan Burke

Hi Werner,

I believe that does match what I was intending to implement. I'll take a closer look.

Jonathan

from checker-framework-inference.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.