-
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.
Avoid generating given definitions that loop
- Loading branch information
Showing
12 changed files
with
161 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- Error: tests/neg/i15474.scala:16:56 --------------------------------------------------------------------------------- | ||
16 | given Ordering[Price] = summon[Ordering[BigDecimal]] // error | ||
| ^ | ||
| Warning: result of implicit search for Ordering[BigDecimal] will change. | ||
| current result: given instance given_Ordering_Price in object Price | ||
| result with -source future: object BigDecimal in object Ordering |
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,6 @@ | ||
-- Error: tests/neg/i6716.scala:12:39 ---------------------------------------------------------------------------------- | ||
12 | given Monad[Bar] = summon[Monad[Foo]] // error | ||
| ^ | ||
| Warning: result of implicit search for Monad[Foo] will change. | ||
| current result: given instance given_Monad_Bar in object Bar | ||
| result with -source future: object given_Monad_Foo in object Foo |
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,18 @@ | ||
//> using options -Xfatal-warnings | ||
|
||
trait Monad[T]: | ||
def id: String | ||
class Foo | ||
object Foo { | ||
given Monad[Foo] with { def id = "Foo" } | ||
} | ||
|
||
opaque type Bar = Foo | ||
object Bar { | ||
given Monad[Bar] = summon[Monad[Foo]] // error | ||
} | ||
|
||
object Test extends App { | ||
println(summon[Monad[Foo]].id) | ||
println(summon[Monad[Bar]].id) | ||
} |
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,20 @@ | ||
//> using options -Xfatal-warnings | ||
import scala.language.implicitConversions | ||
import language.future | ||
|
||
object Test1: | ||
given c: Conversion[ String, Int ] with | ||
def apply(from: String): Int = from.toInt // was error, now avoided | ||
|
||
object Test2: | ||
given c: Conversion[ String, Int ] = _.toInt // now avoided, was loop not detected, could be used as a fallback to avoid the warning. | ||
|
||
object Prices { | ||
opaque type Price = BigDecimal | ||
|
||
object Price{ | ||
given Ordering[Price] = summon[Ordering[BigDecimal]] // was error, now avoided | ||
} | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
4 | ||
5 |
File renamed without changes.
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,2 @@ | ||
Foo | ||
Foo |
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,20 @@ | ||
//> using options -Xfatal-warnings | ||
|
||
import language.future | ||
|
||
trait Monad[T]: | ||
def id: String | ||
class Foo | ||
object Foo { | ||
given Monad[Foo] with { def id = "Foo" } | ||
} | ||
|
||
opaque type Bar = Foo | ||
object Bar { | ||
given Monad[Bar] = summon[Monad[Foo]] // error | ||
} | ||
|
||
object Test extends App { | ||
println(summon[Monad[Foo]].id) | ||
println(summon[Monad[Bar]].id) | ||
} |