Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/SourceVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ enum SourceVersion:
def isAtMost(v: SourceVersion) = stable.ordinal <= v.ordinal

object SourceVersion extends Property.Key[SourceVersion]:
def defaultSourceVersion = `3.5`
def defaultSourceVersion = `3.6`

/** language versions that may appear in a language import, are deprecated, but not removed from the standard library. */
val illegalSourceVersionNames = List("3.1-migration").map(_.toTermName)
Expand Down
14 changes: 2 additions & 12 deletions tests/neg/given-loop-prevention.check
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
2 changes: 0 additions & 2 deletions tests/neg/i20415.scala

This file was deleted.

14 changes: 0 additions & 14 deletions tests/neg/i6716.check

This file was deleted.

17 changes: 6 additions & 11 deletions tests/neg/i6716.scala
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 {}
}
30 changes: 7 additions & 23 deletions tests/neg/i7294.check
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this is the correct error to show. It should keep the following message:

-- [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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related issue: #20992

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`
2 changes: 1 addition & 1 deletion tests/neg/i7294.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package foo
trait Foo { def g(x: Any): Any }

inline given f[T <: Foo]: T = ??? match {
case x: T => x.g(10) // error // error
case x: T => x.g(10) // error
}

@main def Test = f
48 changes: 0 additions & 48 deletions tests/neg/looping-givens.check

This file was deleted.

11 changes: 0 additions & 11 deletions tests/neg/looping-givens.scala

This file was deleted.

2 changes: 2 additions & 0 deletions tests/pos/i20415.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Foo:
given ord: Ordering[Int] = summon[Ordering[Int]]
18 changes: 10 additions & 8 deletions tests/pos/i6716.scala
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)
}
7 changes: 3 additions & 4 deletions tests/pos/looping-givens.scala
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)
2 changes: 1 addition & 1 deletion tests/run/i6716.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings -source future
//> using options -Xfatal-warnings

trait Monad[T]:
def id: String
Expand Down