Skip to content

Commit dd0c26d

Browse files
committed
Address review comments
- Make all aspects of into a -preview feature - Drop experimental import in tests
1 parent 0e80aae commit dd0c26d

File tree

20 files changed

+42
-48
lines changed

20 files changed

+42
-48
lines changed

library/src/scala/Conversion.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package scala
22

33
import language.experimental.captureChecking
4+
import annotation.internal.preview
45

56
/** A class for implicit values that can serve as implicit conversions.
67
* The implicit resolution algorithm will act as if there existed
@@ -41,9 +42,11 @@ object Conversion:
4142
* conversions are tried from the type of `t` to `T`. `into[T]` types are erased to `T`
4243
* in all covariant positions of the types of parameter symbols.
4344
*/
45+
@preview
4446
opaque type into[+T] >: T = T
4547

4648
/** Unwrap an `into` */
4749
extension [T](x: into[T])
50+
@preview
4851
def underlying: T = x
4952
end Conversion

library/src/scala/annotation/internal/$into.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ package scala.annotation.internal
77
* `T`. Hence, we don't need to use `.underlying` to go from an into type to its
88
* underlying type in the types of local parameters.
99
*/
10+
@preview
1011
class $into extends annotation.StaticAnnotation

library/src/scala/language.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ object language {
292292
* @see [[https://dotty.epfl.ch/docs/reference/experimental/into-modifier]]
293293
*/
294294
@compileTimeOnly("`into` can only be used at compile time in import statements")
295-
@deprecated("The into language import is no longer needed since the feature is now standard", since = "3.9")
295+
@deprecated("The into language import is no longer needed since the feature is now in preview", since = "3.8")
296296
object into
297297

298298
/** Experimental support for named tuples.

library/src/scala/runtime/stdLibPatches/language.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ object language:
9999
* @see [[https://dotty.epfl.ch/docs/reference/experimental/into-modifier]]
100100
*/
101101
@compileTimeOnly("`into` can only be used at compile time in import statements")
102-
@deprecated("The into language import is no longer needed since the feature is now standard", since = "3.9")
102+
@deprecated("The into language import is no longer needed since the feature is now in preview", since = "3.8")
103103
object into
104104

105105
/** Experimental support for named tuples.

tasty/src/dotty/tools/tasty/TastyFormat.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ Standard-Section: "ASTs" TopLevelStat*
228228
EXPORTED -- An export forwarder
229229
OPEN -- an open class
230230
INVISIBLE -- invisible during typechecking, except when resolving from TASTy
231-
TRACKED
232-
INTO -- a tracked class parameter / a dependent class
231+
TRACKED -- a tracked class parameter / a dependent class
232+
INTO -- a legal conversion target
233233
Annotation
234234
235235
Variance = STABLE -- invariant

tests/neg/into-inferred.check

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
-- [E007] Type Mismatch Error: tests/neg/into-inferred.scala:34:32 -----------------------------------------------------
2-
34 | val l1: List[into[Keyword]] = l :+ "then" :+ "else" // error
1+
-- [E007] Type Mismatch Error: tests/neg/into-inferred.scala:33:32 -----------------------------------------------------
2+
33 | val l1: List[into[Keyword]] = l :+ "then" :+ "else" // error
33
| ^^^^^^^^^^^^^^^^^^^^^
44
| Found: List[Conversion.into[Keyword] | String]
55
| Required: List[Conversion.into[Keyword]]
66
|
77
| longer explanation available when compiling with `-explain`
8-
-- Feature Warning: tests/neg/into-inferred.scala:22:43 ----------------------------------------------------------------
9-
22 | val ys: List[into[Keyword]] = List(ifKW, "then", "else") // warn // warn
8+
-- Feature Warning: tests/neg/into-inferred.scala:21:43 ----------------------------------------------------------------
9+
21 | val ys: List[into[Keyword]] = List(ifKW, "then", "else") // warn // warn
1010
| ^^^^^^
1111
| Use of implicit conversion given instance given_Conversion_String_Keyword in object Test should be enabled
1212
| by adding the import clause 'import scala.language.implicitConversions'
1313
| or by setting the compiler option -language:implicitConversions.
1414
| See the Scala docs for value scala.language.implicitConversions for a discussion
1515
| why the feature should be explicitly enabled.
16-
-- Feature Warning: tests/neg/into-inferred.scala:22:51 ----------------------------------------------------------------
17-
22 | val ys: List[into[Keyword]] = List(ifKW, "then", "else") // warn // warn
16+
-- Feature Warning: tests/neg/into-inferred.scala:21:51 ----------------------------------------------------------------
17+
21 | val ys: List[into[Keyword]] = List(ifKW, "then", "else") // warn // warn
1818
| ^^^^^^
1919
| Use of implicit conversion given instance given_Conversion_String_Keyword in object Test should be enabled
2020
| by adding the import clause 'import scala.language.implicitConversions'
2121
| or by setting the compiler option -language:implicitConversions.
2222
| See the Scala docs for value scala.language.implicitConversions for a discussion
2323
| why the feature should be explicitly enabled.
24-
-- Feature Warning: tests/neg/into-inferred.scala:35:42 ----------------------------------------------------------------
25-
35 | val l2: List[into[Keyword]] = l ++ List("then", "else") // warn // warn
24+
-- Feature Warning: tests/neg/into-inferred.scala:34:42 ----------------------------------------------------------------
25+
34 | val l2: List[into[Keyword]] = l ++ List("then", "else") // warn // warn
2626
| ^^^^^^
2727
| Use of implicit conversion given instance given_Conversion_String_Keyword in object Test should be enabled
2828
| by adding the import clause 'import scala.language.implicitConversions'
2929
| or by setting the compiler option -language:implicitConversions.
3030
| See the Scala docs for value scala.language.implicitConversions for a discussion
3131
| why the feature should be explicitly enabled.
32-
-- Feature Warning: tests/neg/into-inferred.scala:35:50 ----------------------------------------------------------------
33-
35 | val l2: List[into[Keyword]] = l ++ List("then", "else") // warn // warn
32+
-- Feature Warning: tests/neg/into-inferred.scala:34:50 ----------------------------------------------------------------
33+
34 | val l2: List[into[Keyword]] = l ++ List("then", "else") // warn // warn
3434
| ^^^^^^
3535
| Use of implicit conversion given instance given_Conversion_String_Keyword in object Test should be enabled
3636
| by adding the import clause 'import scala.language.implicitConversions'

tests/neg/into-inferred.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//> using options -feature
2-
import language.experimental.into
1+
//> using options -feature -preview
32
import Conversion.{into, underlying}
43

54
trait Token

tests/neg/into-override.check

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
-- [E120] Naming Error: tests/neg/into-override.scala:16:6 -------------------------------------------------------------
2-
16 |trait C[X] extends A[X]: // error
1+
-- [E120] Naming Error: tests/neg/into-override.scala:15:6 -------------------------------------------------------------
2+
15 |trait C[X] extends A[X]: // error
33
| ^
44
| Name clash between defined and inherited member:
5-
| def f(x: X): Unit in trait A at line 11 and
6-
| override def f(x: Conversion.into[X]): Unit in trait C at line 17
5+
| def f(x: X): Unit in trait A at line 10 and
6+
| override def f(x: Conversion.into[X]): Unit in trait C at line 16
77
| have the same type (x: Object): Unit after erasure.
88
|
99
| Consider adding a @targetName annotation to one of the conflicting definitions
1010
| for disambiguation.
1111
|
1212
| longer explanation available when compiling with `-explain`
13-
-- [E120] Naming Error: tests/neg/into-override.scala:19:6 -------------------------------------------------------------
14-
19 |class D[X] extends B[X], C[X] // error
13+
-- [E120] Naming Error: tests/neg/into-override.scala:18:6 -------------------------------------------------------------
14+
18 |class D[X] extends B[X], C[X] // error
1515
| ^
1616
| Name clash between inherited members:
17-
| override def f(x: X): Unit in trait B at line 14 and
18-
| override def f(x: Conversion.into[X]): Unit in trait C at line 17
17+
| override def f(x: X): Unit in trait B at line 13 and
18+
| override def f(x: Conversion.into[X]): Unit in trait C at line 16
1919
| have the same type (x: Object): Unit after erasure.
2020
|
2121
| Consider adding a @targetName annotation to one of the conflicting definitions
2222
| for disambiguation.
2323
|
2424
| longer explanation available when compiling with `-explain`
25-
-- [E120] Naming Error: tests/neg/into-override.scala:21:6 -------------------------------------------------------------
26-
21 |trait E[X] extends C[X]: // error
25+
-- [E120] Naming Error: tests/neg/into-override.scala:20:6 -------------------------------------------------------------
26+
20 |trait E[X] extends C[X]: // error
2727
| ^
2828
| Name clash between defined and inherited member:
29-
| override def f(x: Conversion.into[X]): Unit in trait C at line 17 and
30-
| override def f(x: X): Unit in trait E at line 22
29+
| override def f(x: Conversion.into[X]): Unit in trait C at line 16 and
30+
| override def f(x: X): Unit in trait E at line 21
3131
| have the same type (x: Object): Unit after erasure.
3232
|
3333
| Consider adding a @targetName annotation to one of the conflicting definitions

tests/neg/into-override.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
//> using options -Xfatal-warnings
1+
//> using options -Xfatal-warnings -preview
22

3-
import language.experimental.into
43
import Conversion.into
54

65
class Text(val str: String)

tests/pos/i23398.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//> using options -feature -Werror
2-
import scala.language.experimental.into
1+
//> using options -feature -Werror -preview
2+
33
import Conversion.into
44

55
case class Foo(x: Int)

0 commit comments

Comments
 (0)