-
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
Make into
a preview feature
#24090
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package scala | ||
|
||
import language.experimental.captureChecking | ||
import annotation.internal.preview | ||
|
||
/** A class for implicit values that can serve as implicit conversions. | ||
* The implicit resolution algorithm will act as if there existed | ||
|
@@ -41,10 +42,11 @@ object Conversion: | |
* 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 | ||
@preview | ||
opaque type into[+T] >: T = T | ||
|
||
/** 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 commentThe reason will be displayed to describe this comment to others. Learn more. This one should also be marked as |
||
@preview | ||
def underlying: T = x | ||
end Conversion |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
package scala.annotation.internal | ||
|
||
import language.experimental.captureChecking | ||
|
||
import annotation.experimental | ||
|
||
/** An internal annotation on (part of) a parameter type that serves as a marker where | ||
* the original type was of the form `into[T]`. These annotated types are mapped back | ||
* to `into[T]` types when forming a method types from the parameter types. The idea is | ||
* that `T @$into` is equivalent to `T`, whereas `into[T]` is only a known supertype of | ||
* `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 commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it now use There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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. |
||
@preview | ||
class $into extends annotation.StaticAnnotation |
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.