-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make into
a preview feature
#24090
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
base: main
Are you sure you want to change the base?
Make into
a preview feature
#24090
Conversation
* `T`. Hence, we don't need to use `.underlying` to go from an into type to its | ||
* underlying type in the types of local parameters. | ||
*/ | ||
@experimental |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it now use @scala.annotation.internal.preview
annotation instead of making it stable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not really needed. It is an internal annotation that people will not use manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, even then. In theory it's part of a preview feature, and could be altered. (Very very unlikely in this case, but let's follow the procedure, so that the next person who comes to this PR in search for a reference of how a feature becomes preview doesn't get misled.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, if we were to be pedantic, we should put it. I just claimed that from an implementation point of view, it is not really needed.
* @see [[https://dotty.epfl.ch/docs/reference/experimental/into-modifier]] | ||
*/ | ||
@compileTimeOnly("`into` can only be used at compile time in import statements") | ||
@deprecated("The into language import is no longer needed since the feature is now standard", since = "3.9") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this one, and how it should be handled. From the perspective of user it would be better to now get hint about preview, and standard
when it's actually standardised in 3.9 or later
@deprecated("The into language import is no longer needed since the feature is now standard", since = "3.9") | |
@deprecated("The into language import is no longer needed since the feature is now in preview", since = "3.9") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps hint about preview since 3.8...
and standard whenever we stabilise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not say since 3.9.0
in 3.8.0
. It makes no sense. I think we should say (preview, 3.8.0) and change it to (stable, 3.9.0) later or say directly (stable, 3.8.0).
* `T`. Hence, we don't need to use `.underlying` to go from an into type to its | ||
* underlying type in the types of local parameters. | ||
*/ | ||
@experimental |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not really needed. It is an internal annotation that people will not use manually.
* @see [[https://dotty.epfl.ch/docs/reference/experimental/into-modifier]] | ||
*/ | ||
@compileTimeOnly("`into` can only be used at compile time in import statements") | ||
@deprecated("The into language import is no longer needed since the feature is now standard", since = "3.9") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deprecated("The into language import is no longer needed since the feature is now standard", since = "3.9") | |
@deprecated("The into language import is no longer needed since the feature is now standard", since = "3.8.0") |
library/src/scala/language.scala
Outdated
* @see [[https://dotty.epfl.ch/docs/reference/experimental/into-modifier]] | ||
*/ | ||
@compileTimeOnly("`into` can only be used at compile time in import statements") | ||
@deprecated("The into language import is no longer needed since the feature is now standard", since = "3.9") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deprecated("The into language import is no longer needed since the feature is now standard", since = "3.9") | |
@deprecated("The into language import is no longer needed since the feature is now standard", since = "3.8.0") |
TRACKED | ||
INTO -- a tracked class parameter / a dependent class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TRACKED | |
INTO -- a tracked class parameter / a dependent class | |
TRACKED -- a tracked class parameter / a dependent class | |
INTO |
* conversions are tried from the type of `t` to `T`. `into[T]` types are erased to `T` | ||
* in all covariant positions of the types of parameter symbols. | ||
*/ | ||
@experimental |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is important, if we don't mark this alias with @preview
, we will not be able to enforce it.
|
||
/** Unwrap an `into` */ | ||
extension [T](x: into[T]) | ||
@experimental def underlying: T = x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should also be marked as @preview
, otherwise we will be compiling the library with -preview
- Make all aspects of into a -preview feature - Drop experimental import in tests
Since SIP 71 is now accepted, we can ship it as -preview in 3.8 and standard in 3.9.
Note to tooling implementers
There are two relevant pieces that need to be implemented in IDEs:
into
is a new soft modifier for classes, traits, and enums. Types withinto
are legal conversion target types. SeeisConversionTargetType
inTypes.scala
.Conversion.into
type is a regular opaque type, so should not need any support by itself. However, there's a rule that no-flip covariant occurrences ofinto[T]
in method parameters are mapped toT @$into
, where$into
is an annotation inannotation.internal
. The annotation is "silent" which means it should not be shown in inferred types. The purpose of that mapping is thatinto[...]
does not have to be explicitly stripped in method bodies. SeesuppressInto
andrevealInto
in TypeOps./cc @unkarjedy @tgodzik