Skip to content

Commit ce973a2

Browse files
committed
Drop given as in instance definitions
1 parent c5dac5b commit ce973a2

File tree

157 files changed

+292
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+292
-281
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ object Parsers {
200200
def isBindingIntro: Boolean = {
201201
in.token match {
202202
case USCORE => true
203-
case IDENTIFIER | BACKQUOTED_IDENT => in.lookaheadIn(BitSet(COLON, ARROW))
203+
case IDENTIFIER | BACKQUOTED_IDENT => in.lookaheadIn(BitSet(ARROW))
204204
case LPAREN =>
205205
val lookahead = in.LookaheadScanner()
206206
lookahead.skipParens()
@@ -3401,9 +3401,10 @@ object Parsers {
34013401
checkExtensionParams(paramsStart, vparamss)
34023402

34033403
parseParams(isExtension = !hasGivenSig)
3404-
3404+
var oldSyntax = false
34053405
val parents =
34063406
if allowOldGiven && (!newStyle && in.token == FOR || isIdent(nme.as)) then
3407+
oldSyntax = true
34073408
// for the moment, accept both `delegate for` and `given as`
34083409
in.nextToken()
34093410
tokenSeparated(COMMA, constrApp)
@@ -3421,7 +3422,7 @@ object Parsers {
34213422
tokenSeparated(COMMA, constrApp)
34223423
else Nil
34233424

3424-
if allowOldGiven && vparamss.isEmpty then
3425+
if oldSyntax && vparamss.isEmpty then
34253426
vparamss = paramClauses(ofInstance = true)
34263427

34273428
val gdef =

tests/disabled/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Macros {
55

66
inline def foo(i: => Int): Int = ${ fooImpl('i) }
77
def fooImpl(i: Expr[Int]) given QuoteContext: Expr[Int] = {
8-
given as Toolbox = Toolbox.make(getClass.getClassLoader)
8+
given Toolbox = Toolbox.make(getClass.getClassLoader)
99
val y: Int = run(i)
1010
y
1111
}

tests/neg-custom-args/conditionalWarnings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
object Test {
44
@deprecated def foo = ???
55

6-
given as Conversion[String, Int] = _.length
6+
given Conversion[String, Int] = _.length
77

88
foo // error
99

tests/neg-custom-args/implicit-conversions.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ class B
33

44
object A {
55

6-
given as Conversion[A, B] {
6+
given Conversion[A, B] {
77
def apply(x: A): B = ???
88
}
99

10-
given as Conversion[B, A] {
10+
given Conversion[B, A] {
1111
def apply(x: B): A = ???
1212
}
1313
}
1414

1515
class C
1616

1717
object D {
18-
given as Conversion[A, C] {
18+
given Conversion[A, C] {
1919
def apply(x: A): C = ???
2020
}
2121
}

tests/neg-macros/quote-this.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class Foo {
1212
}
1313

1414
inline def i(): Unit = ${ Foo.impl[Any]('{
15-
given as QuoteContext = ???
15+
given QuoteContext = ???
1616
'this // error
1717
}) }
1818

1919
inline def j(that: Foo): Unit = ${ Foo.impl[Any]('{
20-
given as QuoteContext = ???
20+
given QuoteContext = ???
2121
'that // error
2222
}) }
2323

tests/neg-staging/quote-run-in-macro-1/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import given scala.quoted.autolift._
44

55
object Macros {
66

7-
given as Toolbox = Toolbox.make(getClass.getClassLoader)
7+
given Toolbox = Toolbox.make(getClass.getClassLoader)
88
inline def foo(i: => Int): Int = ${ fooImpl('i) }
99
def fooImpl(i: Expr[Int]) given QuoteContext: Expr[Int] = {
1010
val y: Int = run(i)

tests/neg-with-compiler/GenericNumLits/Even_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object Even {
2929
def fromDigits(digits: String) = evenFromDigits(digits)
3030
}
3131

32-
given as EvenFromDigits {
32+
given EvenFromDigits {
3333
override inline def fromDigits(digits: String) = ${
3434
evenFromDigitsImpl('digits)
3535
}

tests/neg/BigFloat/BigFloat_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ object BigFloat extends App {
5050
def fromDigits(digits: String) = apply(digits)
5151
}
5252

53-
given as BigFloatFromDigits {
53+
given BigFloatFromDigits {
5454
override inline def fromDigits(digits: String) = ${
5555
fromDigitsImpl('digits)
5656
}
5757
}
5858

5959
// Should be in StdLib:
6060

61-
given as Liftable[BigInt] {
61+
given Liftable[BigInt] {
6262
def toExpr(x: BigInt) =
6363
'{BigInt(${x.toString.toExpr})}
6464
}

tests/neg/GenericNumLits/Even_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object Even {
2929
def fromDigits(digits: String) = evenFromDigits(digits)
3030
}
3131

32-
given as EvenFromDigits {
32+
given EvenFromDigits {
3333
override inline def fromDigits(digits: String) = ${
3434
evenFromDigitsImpl('digits)
3535
}

tests/neg/cannot-reduce-summonFrom.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object Test {
66
}
77

88
{
9-
given as Int = 9
9+
given Int = 9
1010
bar()
1111
}
1212

0 commit comments

Comments
 (0)