Skip to content

Commit 1c5cb39

Browse files
committed
Enforce new given syntax under -source future
It warned before, but did not error. However, the idea is that under -source future we should enforce the new rules that we have defined everywhere.
1 parent fc7ee52 commit 1c5cb39

14 files changed

+26
-32
lines changed

compiler/src/dotty/tools/dotc/config/MigrationVersion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enum MigrationVersion(val warnFrom: SourceVersion, val errorFrom: SourceVersion)
3131
case ImportRename extends MigrationVersion(future, future)
3232
case ParameterEnclosedByParenthesis extends MigrationVersion(future, future)
3333
case XmlLiteral extends MigrationVersion(future, future)
34-
case GivenSyntax extends MigrationVersion(future, never)
34+
case GivenSyntax extends MigrationVersion(future, future)
3535
case ImplicitParamsWithoutUsing extends MigrationVersion(`3.7`, future)
3636

3737
require(warnFrom.ordinal <= errorFrom.ordinal)

tests/warn/abstract-givens-new.scala renamed to tests/neg/abstract-givens-new.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class C:
44

55
trait T:
66
given Int is C // ok
7-
given intC: Int is C // warn
7+
given intC: Int is C // error
88
given intC2: (Int is C)() // ok
99
given intC3: Int is C {} // also ok
1010

tests/neg/context-bounds-migration-future.check

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,3 @@
44
| method foo does not take more parameters
55
|
66
| longer explanation available when compiling with `-explain`
7-
-- Warning: tests/neg/context-bounds-migration-future.scala:6:6 --------------------------------------------------------
8-
6 |given [T]: C[T] = C[T]()
9-
| ^
10-
| This old given syntax is no longer supported; use `=>` instead of `:`

tests/neg/context-bounds-migration-future.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class C[T]
44
def foo[X: C] = ()
55

6-
given [T]: C[T] = C[T]()
6+
given [T] => C[T] = C[T]()
77

88
def Test =
99
foo(C[Int]()) // error

tests/warn/old-givens.scala renamed to tests/neg/old-givens.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ trait Ord[T]:
55
class C[T]
66

77
trait T:
8-
given intC: C[Int] // warn
8+
given intC: C[Int] // error
99
given intC2: C[Int] () // OK
1010

11-
given [T]: Ord[T] with // warn // warn
11+
given [T]: Ord[T] with // error // error
1212
def compare(x: T, y: T): Boolean = ???
1313

14-
given [T](using Ord[T]): Ord[List[T]] with // warn // warn
14+
given [T](using Ord[T]): Ord[List[T]] with // error // error
1515
def compare(x: List[T], y: List[T]): Boolean = ???
1616

17-
def f[T: Ord : C]() = ??? // warn
17+
def f[T: Ord : C]() = ??? // error
1818

tests/pos/hylolib-deferred-given/AnyCollection.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ given anyCollectionIsCollection: [T] => (tIsValue: Value[T]) => Collection[AnyCo
4848
//given elementIsValue: Value[Element] = tIsValue
4949

5050
type Position = AnyValue
51-
given positionIsValue: Value[Position] = anyValueIsValue
51+
override given positionIsValue: Value[Position] = anyValueIsValue
5252

5353
extension (self: AnyCollection[T]) {
5454

tests/pos/hylolib-deferred-given/BitArray.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ given bitArrayIsCollection: Collection[BitArray] {
341341
//given elementIsValue: Value[Boolean] = booleanIsValue
342342

343343
type Position = BitArray.Position
344-
given positionIsValue: Value[BitArray.Position] = bitArrayPositionIsValue
344+
override given positionIsValue: Value[BitArray.Position] = bitArrayPositionIsValue
345345

346346
extension (self: BitArray) {
347347

tests/pos/hylolib-deferred-given/Collection.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trait Collection[Self] {
1010

1111
/** The type of a position in the collection. */
1212
type Position
13-
given positionIsValue: Value[Position]
13+
given positionIsValue: Value[Position] = compiletime.deferred
1414

1515
extension (self: Self) {
1616

tests/pos/hylolib-deferred-given/HyArray.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ given hyArrayIsCollection: [T] => (tIsValue: Value[T]) => Collection[HyArray[T]]
185185
//given elementIsValue: Value[T] = tIsValue
186186

187187
type Position = Int
188-
given positionIsValue: Value[Int] = intIsValue
188+
override given positionIsValue: Value[Int] = intIsValue
189189

190190
extension (self: HyArray[T]) {
191191

tests/pos/hylolib-deferred-given/Slice.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ given sliceIsCollection: [T] => (c: Collection[T]) => Collection[Slice[T]] {
3232
//given elementIsValue: Value[Element] = c.elementIsValue
3333

3434
type Position = c.Position
35-
given positionIsValue: Value[Position] = c.positionIsValue
35+
override given positionIsValue: Value[Position] = c.positionIsValue
3636

3737
extension (self: Slice[T]) {
3838

0 commit comments

Comments
 (0)