Skip to content
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

Add compilation unit info to ClassSymbol #19010

Merged

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Nov 21, 2023

Fixes #18933

@nicolasstucki nicolasstucki self-assigned this Nov 21, 2023
@nicolasstucki nicolasstucki force-pushed the keep-compilation-unit-info-in-symbol branch 7 times, most recently from eff9c27 to 2a0282f Compare November 21, 2023 14:53
@nicolasstucki nicolasstucki force-pushed the keep-compilation-unit-info-in-symbol branch from 2a0282f to ada4552 Compare November 21, 2023 16:47
@nicolasstucki nicolasstucki force-pushed the keep-compilation-unit-info-in-symbol branch 2 times, most recently from 6722aaa to b00bb30 Compare November 22, 2023 07:21
else compUnitInfo.tastyVersion

/** If this class has explicit nulls enabled */
def explicitNulls(using Context): Boolean =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noti0na1 here is what you need to know if a symbol (from TASTy or source) was compiled using explicit nulls.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

lastDenot.topLevelClass.compilationUnitInfo

/** The version of TASTy from which the symbol was loaded, None if not applicable. */
def tastyVersion(using Context): Option[TastyVersion] =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EugeneFlesselle here is the new version of the TASTy version. I changed a bit your original design, now we only have a TASTy version if the symbol vas loaded from TASTy. For symbols created from source we can assume they have the current TASTy version.

@nicolasstucki nicolasstucki marked this pull request as ready for review November 22, 2023 07:25
@nicolasstucki
Copy link
Contributor Author

@bishabosha I sugest looking at the individual commits.

@nicolasstucki nicolasstucki force-pushed the keep-compilation-unit-info-in-symbol branch from b00bb30 to 2f36da4 Compare November 22, 2023 08:25
@nicolasstucki
Copy link
Contributor Author

All commits passed the CI. I had to rebase due to a conflict with a new test that used infix notation with non-infix operations.

Copy link
Member

@bishabosha bishabosha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only other comment would be - can the "compilation unit info" be cached per source file? (would require source file tasty attribute), then the symbols from the classpath may share a "compilation unit info", but still have independent associatedFile

Edit: this is probably not useful because then it makes it impossible to read older tasty

@nicolasstucki
Copy link
Contributor Author

Only other comment would be - can the "compilation unit info" be cached per source file?

We only set it on top-level classes. The cache might not be that useful.

(would require source file tasty attribute), then the symbols from the classpath may share a "compilation unit info", but still have independent associatedFile

That will be added in #18948. I needed to add the CompitionUnitInfo first to be able to use it properly.

- Test major TASTy version
- strip margins of `s".."`
- Cache `CompilationUnit` in `SymbolLoaders`
@nicolasstucki nicolasstucki force-pushed the keep-compilation-unit-info-in-symbol branch 2 times, most recently from 71266bf to f360a33 Compare November 22, 2023 15:33
@nicolasstucki nicolasstucki force-pushed the keep-compilation-unit-info-in-symbol branch from f360a33 to 9597a61 Compare November 23, 2023 08:54
@nicolasstucki
Copy link
Contributor Author

or as was suggested previously, use an opaque type wrapping Long/Int

I analyzed this a bit and we might end up boxing in some other places. The cached case class might be the best option memory-wise.


object TastyVersion {

private val cache: java.util.concurrent.ConcurrentHashMap[TastyVersion, TastyVersion] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fails the re-entrant check

Suggested change
private val cache: java.util.concurrent.ConcurrentHashMap[TastyVersion, TastyVersion] =
@scala.annotation.internal.sharable
private val cache: java.util.concurrent.ConcurrentHashMap[TastyVersion, TastyVersion] =

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually we can't use this annotation in tasty-core because it needs to compile with Scala 2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we have to remove the re-entrant check for this project?
or we never actually published a tasty-core for scala 2, it was only to check source compatibility, so maybe we can add the scala 3 class path

Co-authored-by: Nicolas Stucki <[email protected]>
Co-authored-by: Jamie Thompson <[email protected]>
@bishabosha bishabosha force-pushed the keep-compilation-unit-info-in-symbol branch from 9597a61 to 97d8171 Compare November 23, 2023 10:45
@bishabosha bishabosha merged commit 08ab809 into scala:main Nov 23, 2023
17 checks passed
@bishabosha bishabosha deleted the keep-compilation-unit-info-in-symbol branch November 23, 2023 14:01
@Kordyjan Kordyjan added this to the 3.4.0 milestone Dec 20, 2023
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.

Sould infix work on enum?
4 participants