Skip to content

Add/instantiation checks #471

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

Closed
wants to merge 9 commits into from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 12, 2015

Add checks that abstract classes are not instantiated and that self types conform.

This was much more involved than previously thought. Major work was needed to

  • correctly compute self types outside of the classes in which they are defined.
  • propagate information whether a class needs to be abstract (particular challenge: Java annotations).

Review by @DarkDimius

odersky added 9 commits April 11, 2015 11:36
Add stylechecking to test suite, fix style errors
Now prints `C{...}` instead of `$anon`.
The self type as given (or implied for module classes) in the source.
Also defined and updated for normal types, not just ClassInfo types.
Common functionality between this and baseTypeWithArgs has been pulled
into RefinedType#wrapIfMember.
Check that the self type of a class conforms to the self types of its parent classes.
Used to test whether a tree has an attachment of a given key value.
The attachments label `New` nodes that are parents or annotations.
These nodes will be treated specially when it comes to checking whether
a class can be instantiated. Specifically, parents and Java-defined annotations
are allowed to be abstract.

Also: New convenience method: isAnnotation
- Abstract classes cannot be instantiated (exceptions:
  parent news and Java annotations)
- Instantiateed class must conform to its self type.
An error message might be suppressed because it contains internal code. But
if it is the first one, we should still print it. Otherwise, we risk a scenario where
we see "2 errors" but none is printed.
@odersky odersky force-pushed the add/instantiation-checks branch from 812cd98 to 60828d2 Compare April 12, 2015 16:41
@odersky
Copy link
Contributor Author

odersky commented Apr 13, 2015

I am going to try an alternative: do the instantiation checks in a separate traversal. Let's hold off with reviewing until we have both of them.

This was referenced Apr 13, 2015
@odersky
Copy link
Contributor Author

odersky commented Apr 13, 2015

This and #474 are two alternatives that handle the same functionality,

@DarkDimius DarkDimius closed this Apr 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants