-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn given loop prevention on for -source future (#19392)
Drop the experimental language import. I believe everybody agrees that this is a desirable improvement, and type inference and implicit search have traditionally been in the realm of the compiler implementers. Experimental language imports have to live forever (albeit as deprecated once the feature is accepted as standard). So they are rather heavyweight and it is unergonomic to require them for smallish improvements to type inference. The new road map is as follows: - In 3.4: warning if behavior would change in the future. - In 3.5: error if behavior would change in the future - In 3.future (at the earliest 3.6): new behavior.
- Loading branch information
Showing
13 changed files
with
103 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
-- Error: tests/neg/i15474.scala:6:39 ---------------------------------------------------------------------------------- | ||
6 | given c: Conversion[ String, Int ] = _.toInt // error | ||
| ^ | ||
| Result of implicit search for ?{ toInt: ? } will change. | ||
| Current result Test2.c will be no longer eligible | ||
| because it is not defined before the search position. | ||
| Result with new rules: augmentString. | ||
| To opt into the new rules, use the `experimental.givenLoopPrevention` language import. | ||
| Result of implicit search for ?{ toInt: ? } will change. | ||
| Current result Test2.c will be no longer eligible | ||
| because it is not defined before the search position. | ||
| Result with new rules: augmentString. | ||
| To opt into the new rules, compile with `-source future` or use | ||
| the `scala.language.future` language import. | ||
| | ||
| To fix the problem without the language import, you could try one of the following: | ||
| - use a `given ... with` clause as the enclosing given, | ||
| - rearrange definitions so that Test2.c comes earlier, | ||
| - use an explicit conversion, | ||
| - use an import to get extension method into scope. | ||
| This will be an error in Scala 3.5 and later. | ||
| To fix the problem without the language import, you could try one of the following: | ||
| - use a `given ... with` clause as the enclosing given, | ||
| - rearrange definitions so that Test2.c comes earlier, | ||
| - use an explicit conversion, | ||
| - use an import to get extension method into scope. | ||
| This will be an error in Scala 3.5 and later. | ||
-- Error: tests/neg/i15474.scala:12:56 --------------------------------------------------------------------------------- | ||
12 | given Ordering[Price] = summon[Ordering[BigDecimal]] // error | ||
| ^ | ||
| Result of implicit search for Ordering[BigDecimal] will change. | ||
| Current result Prices.Price.given_Ordering_Price will be no longer eligible | ||
| because it is not defined before the search position. | ||
| Result with new rules: scala.math.Ordering.BigDecimal. | ||
| To opt into the new rules, use the `experimental.givenLoopPrevention` language import. | ||
| Result of implicit search for Ordering[BigDecimal] will change. | ||
| Current result Prices.Price.given_Ordering_Price will be no longer eligible | ||
| because it is not defined before the search position. | ||
| Result with new rules: scala.math.Ordering.BigDecimal. | ||
| To opt into the new rules, compile with `-source future` or use | ||
| the `scala.language.future` language import. | ||
| | ||
| To fix the problem without the language import, you could try one of the following: | ||
| - use a `given ... with` clause as the enclosing given, | ||
| - rearrange definitions so that Prices.Price.given_Ordering_Price comes earlier, | ||
| - use an explicit argument. | ||
| This will be an error in Scala 3.5 and later. | ||
| To fix the problem without the language import, you could try one of the following: | ||
| - use a `given ... with` clause as the enclosing given, | ||
| - rearrange definitions so that Prices.Price.given_Ordering_Price comes earlier, | ||
| - use an explicit argument. | ||
| This will be an error in Scala 3.5 and later. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
-- Error: tests/neg/i6716.scala:12:39 ---------------------------------------------------------------------------------- | ||
12 | given Monad[Bar] = summon[Monad[Foo]] // error | ||
| ^ | ||
| Result of implicit search for Monad[Foo] will change. | ||
| Current result Bar.given_Monad_Bar will be no longer eligible | ||
| because it is not defined before the search position. | ||
| Result with new rules: Foo.given_Monad_Foo. | ||
| To opt into the new rules, use the `experimental.givenLoopPrevention` language import. | ||
| Result of implicit search for Monad[Foo] will change. | ||
| Current result Bar.given_Monad_Bar will be no longer eligible | ||
| because it is not defined before the search position. | ||
| Result with new rules: Foo.given_Monad_Foo. | ||
| To opt into the new rules, compile with `-source future` or use | ||
| the `scala.language.future` language import. | ||
| | ||
| To fix the problem without the language import, you could try one of the following: | ||
| - use a `given ... with` clause as the enclosing given, | ||
| - rearrange definitions so that Bar.given_Monad_Bar comes earlier, | ||
| - use an explicit argument. | ||
| This will be an error in Scala 3.5 and later. | ||
| To fix the problem without the language import, you could try one of the following: | ||
| - use a `given ... with` clause as the enclosing given, | ||
| - rearrange definitions so that Bar.given_Monad_Bar comes earlier, | ||
| - use an explicit argument. | ||
| This will be an error in Scala 3.5 and later. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//> using options -Xfatal-warnings | ||
|
||
class Foo | ||
|
||
object Bar { | ||
given Foo with {} | ||
given List[Foo] = List(summon[Foo]) // ok | ||
} | ||
|
||
object Baz { | ||
@annotation.nowarn | ||
given List[Foo] = List(summon[Foo]) // gives a warning, which is suppressed | ||
given Foo with {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//> using options -Xfatal-warnings -source 3.4 | ||
|
||
class Foo | ||
|
||
object Bar { | ||
given Foo with {} | ||
given List[Foo] = List(summon[Foo]) // ok | ||
} | ||
|
||
object Baz { | ||
@annotation.nowarn | ||
given List[Foo] = List(summon[Foo]) // gives a warning, which is suppressed | ||
given Foo with {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import language.experimental.givenLoopPrevention | ||
import language.future | ||
|
||
class A | ||
class B | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters