-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abf795c
commit aad6f7d
Showing
12 changed files
with
32 additions
and
135 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,4 @@ | ||
-- Error: tests/neg/given-loop-prevention.scala:10:36 ------------------------------------------------------------------ | ||
-- [E172] Type Error: tests/neg/given-loop-prevention.scala:10:36 ------------------------------------------------------ | ||
10 | given List[Foo] = List(summon[Foo]) // error | ||
| ^ | ||
| Result of implicit search for Foo will change. | ||
| Current result Baz.given_Foo will be no longer eligible | ||
| because it is not defined before the search position. | ||
| Result with new rules: No Matching Implicit. | ||
| 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 Baz.given_Foo comes earlier, | ||
| - use an explicit argument. | ||
| No given instance of type Foo was found for parameter x of method summon in object Predef |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,17 +1,12 @@ | ||
|
||
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 | ||
given Foo with {} | ||
given List[Foo] = List(summon[Foo]) // ok | ||
} | ||
|
||
object Test extends App { | ||
println(summon[Monad[Foo]].id) | ||
println(summon[Monad[Bar]].id) | ||
object Baz { | ||
@annotation.nowarn | ||
given List[Foo] = List(summon[Foo]) // error | ||
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,25 +1,9 @@ | ||
-- Error: tests/neg/i7294.scala:7:10 ----------------------------------------------------------------------------------- | ||
7 | case x: T => x.g(10) // error // error | ||
| ^ | ||
| Result of implicit search for scala.reflect.TypeTest[Nothing, T] will change. | ||
| Current result foo.f will be no longer eligible | ||
| because it is not defined before the search position. | ||
| Result with new rules: No Matching Implicit. | ||
| 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 foo.f comes earlier, | ||
| - use an explicit argument. | ||
| | ||
| where: T is a type in given instance f with bounds <: foo.Foo | ||
-- [E007] Type Mismatch Error: tests/neg/i7294.scala:7:18 -------------------------------------------------------------- | ||
7 | case x: T => x.g(10) // error // error | ||
| ^^^^^^^ | ||
| Found: Any | ||
| Required: T | ||
| | ||
| where: T is a type in given instance f with bounds <: foo.Foo | ||
-- [E007] Type Mismatch Error: tests/neg/i7294.scala:7:15 -------------------------------------------------------------- | ||
7 | case x: T => x.g(10) // error | ||
| ^ | ||
| Found: (x : Nothing) | ||
| Required: ?{ g: ? } | ||
| Note that implicit conversions were not tried because the result of an implicit conversion | ||
| must be more specific than ?{ g: [applied to (10) returning T] } | ||
| | ||
| longer explanation available when compiling with `-explain` |
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 was deleted.
Oops, something went wrong.
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 @@ | ||
class Foo: | ||
given ord: Ordering[Int] = summon[Ordering[Int]] |
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,16 @@ | ||
//> using options -Xfatal-warnings -source 3.4 | ||
|
||
trait Monad[T]: | ||
def id: String | ||
class Foo | ||
object Foo { | ||
given Monad[Foo] with { def id = "Foo" } | ||
} | ||
|
||
opaque type Bar = Foo | ||
object Bar { | ||
given Foo with {} | ||
given List[Foo] = List(summon[Foo]) // ok | ||
given Monad[Bar] = summon[Monad[Foo]] | ||
} | ||
|
||
object Baz { | ||
@annotation.nowarn | ||
given List[Foo] = List(summon[Foo]) // gives a warning, which is suppressed | ||
given Foo with {} | ||
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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import language.future | ||
|
||
class A | ||
class B | ||
|
||
given joint(using a: A, b: B): (A & B) = ??? | ||
|
||
def foo(using a: A, b: B) = | ||
given aa: A = summon // error | ||
given bb: B = summon // error | ||
given ab: (A & B) = summon // error | ||
given aa: A = summon // resolves to a | ||
given bb: B = summon // resolves to b | ||
given ab: (A & B) = summon // resolves to joint(aa, bb) |
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