Skip to content

Javaparser & ElimRepeated fixes & Annotation-fixes #213

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

Merged
merged 46 commits into from
Nov 24, 2014

Conversation

DarkDimius
Copy link
Contributor

This branch includes everything in #184 #183 and #206
And additionally fixes several annotation-related errors.

Last commit rises two problems with reading annotations from java and java bytecode.
Java treats annotations which have array-value (eg java.lang.annotation.Target) as also having a repeated-argument constructor. Potential workaround could be to synthesize one more constructor for annotations.

The second problems comes from scala not having specific single-argument apply inside Array$. This means that calling Array("hi") goes through generic path and requires implicit resolution to provide a ClassTag.
This means that deferring reading annotations after frontend requires calling them with context at phase frontend. Which itself leads to errors as implicit resolution will start flowing Context owner chain and will see a non-perioded context as direct ancestor of current one.

@DarkDimius
Copy link
Contributor Author

@odersky @olhotak All tests that were failing previously now succeed, but we have several new failing tests that were previously succeeding, but now fail due to new phases not able to work on java-defined trees:

2 tests have a call from scala to java-defined method with repeated arguments that doesn't retypecheck after elim-repeated.(either typer should use JavaSeqLiteral in such cases or ElimRepeated should adapt trees).

And there's one test disabled due to breaking of owner chains.

I propose to merge this as we want all phases to be tested also on java and fix those small errors in different PR.

@DarkDimius DarkDimius changed the title [WIP] Javaparser & ElimRepeated fixes & Annotation-fixes Javaparser & ElimRepeated fixes & Annotation-fixes Nov 17, 2014
@olhotak
Copy link
Contributor

olhotak commented Nov 17, 2014

When I had similar problems on other tests, @odersky suggested that we should drop all trees of all Java compilation units immediately after FrontEnd.

@DarkDimius
Copy link
Contributor Author

@odersky all commits before 4dcec1c were already reviewed. Could you please have a look on last 10 commits?

@odersky
Copy link
Contributor

odersky commented Nov 20, 2014

See comments on commits. I would recommend to parse array arguments to Java annotations as JavaSeqLiterals.

odersky and others added 21 commits November 22, 2014 20:10
Helps to track where erroneous type was created.
This doesn't require additional argument. Decision can be made solely from the phaseId.
Check now fails after erasure.
Should become error after fixed.
Ported from scalac 2.11.x branch SHA 9753f23f9362b25a9f481b11dd8d51187187882a

This is mostly a direct port, with few significant dotty-specific
changes needed. The two more significant changes are:

In dotty, the first constructor of a class is pulled out separately from
the other stats in the Template.

The keyword detection code (buildKeywordArray) was moved into Tokens so
that it can more cleanly be shared by the Scala and Java scanners.
olhotak and others added 25 commits November 22, 2014 20:10
A Java constructor needs to see the import of the companion object of the class. It is not necessary to move to an outer context because a Java constructor does not have an implementation. scalac also does it this way: see Namers.Namer.createNamer.isConstrParam.
The dummy constructor is needed so that the real constructors see the import of the companion object.

The constructor has a parameter of type Unit so that no Java code can call it.
transformSym explicitly checks that a field is JavaDefined and does not create a symbol for it.

Creation of a setter body looks for the symbol and fails because it does not find it.

We do not need setter bodies for Java fields because we are not generating bytecode for them.
Required as gettersAndSetters ignores modifiers
 in tree and uses ones in the type instead.
This means that gettersAndSetters carries over
modifiers from type to tree and this one violates postconditions.
Annotations in java could be compiled as-if array-only
annotation had <repeated> arguments constructor.
That isn't true for scala.

Also, type checking creation of single-element array
requires implicit resolution to provide ClassTag.
This makes problems while reading deferred annotation.
Packages also get a JavaDefined flag, but they shouldn't be removed by FirstTransform.
DarkDimius added a commit that referenced this pull request Nov 24, 2014
Javaparser & ElimRepeated fixes & Annotation-fixes
@DarkDimius DarkDimius merged commit 779afd2 into scala:master Nov 24, 2014
@allanrenucci allanrenucci deleted the javaparser branch December 14, 2017 19:23
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.

3 participants