Skip to content

Conversation

@hamzaremmal
Copy link
Member

Do not infer public flexible type in the stdlib.
This is the only remaining exposed flexible type in the library:

[warn] -- Warning: /Users/hamzaremmal/Desktop/scala/scala3/library/src/scala/util/control/NoStackTrace.scala:27:42 
[warn] 27 |    if (NoStackTrace.noSuppression) super.fillInStackTrace()
[warn]    |                                          ^
[warn]    |method scala$util$control$NoStackTrace$$super$fillInStackTrace exposes a flexible type in its inferred result type (Throwable)?. Consider annotating the type explicitly

@hamzaremmal hamzaremmal requested a review from a team as a code owner October 28, 2025 15:07
@hamzaremmal hamzaremmal requested a review from noti0na1 October 28, 2025 15:07
@noti0na1
Copy link
Member

The remaining flexible types are either inside anonymous classes or at private/protected definitions, so I didn't fix them. I was planning to update the flexible type checker later. Do we have to fix them now?

@hamzaremmal
Copy link
Member Author

The main reason I opened this PR is to reduce the number of warnings. I didn't go in depth into the logic behind the warning and if they should have been a warning in the first place.

Copy link
Member

@noti0na1 noti0na1 left a comment

Choose a reason for hiding this comment

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

I think it is fine to merge this. We will update the checker later so we don't report warnings on definitions that are not really public, for example, members of anonymous or private classes.

@hamzaremmal hamzaremmal enabled auto-merge October 28, 2025 16:51
@sjrd
Copy link
Member

sjrd commented Oct 28, 2025

The remaining flexible types are either inside anonymous classes or at private/protected definitions

protected definitions are part of the public API. We shouldn't have flexible types in them either.

@hamzaremmal hamzaremmal merged commit 840804f into scala:main Oct 28, 2025
51 checks passed
@hamzaremmal hamzaremmal deleted the no-exposed-flexible-type branch October 28, 2025 23:22
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