Skip to content

Conversation

@liufengyun
Copy link
Contributor

Skip caret when source is missing in initialization checker

@liufengyun liufengyun marked this pull request as ready for review September 15, 2025 12:50
@liufengyun liufengyun requested a review from olhotak September 15, 2025 18:19
* The method SourceFile#exists always return true thus cannot be used.
*/
def fileExists(source: SourceFile): Boolean =
source.content().nonEmpty
Copy link
Contributor

Choose a reason for hiding this comment

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

FileContentNonEmpty?

* The method SourceFile#exists always return true thus cannot be used.
*/
def fileExists(source: SourceFile): Boolean =
source.content().nonEmpty
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just headOption,does the nonEmpty read the content?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SourceFile#content is a special method with cache. If it is not empty, we will need to read lines from it (thus force loading the content).

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean maybe just need to check the first char or line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean. If you check the overall design for code caching and SourceFile#content, you will see there is no need/opportunity for optimization here.

Copy link
Contributor

@olhotak olhotak left a comment

Choose a reason for hiding this comment

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

LGTM

In CompilationTests.scala, we are accumulating quite a few ad hoc cases where we compile some files somehow, and later compile some other files together with the output of the first compilation. As a future issue/PR, we should think about ways to factor out any commonality to clean this up.

@liufengyun
Copy link
Contributor Author

LGTM

In CompilationTests.scala, we are accumulating quite a few ad hoc cases where we compile some files somehow, and later compile some other files together with the output of the first compilation. As a future issue/PR, we should think about ways to factor out any commonality to clean this up.

We forgot to merge this PR. We can think about the refactoring later: as the code is short & subtle, we need to make sure code reuse/abstraction does not harm maintainability.

@liufengyun
Copy link
Contributor Author

@hamzaremmal This PR is ready, please merge it if it does not cause potential problem with release schedule. Thank you.

@olhotak olhotak merged commit d8605c3 into scala:main Dec 18, 2025
46 checks passed
@olhotak olhotak deleted the fix-init-trace branch December 18, 2025 14:51
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