Skip to content

Fix #9091: Drop deprecated extension method syntax #9093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 1 addition & 5 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3320,11 +3320,7 @@ object Parsers {
mods1 = mods1.withAddedAnnotation(infixAnnot)
val tparams =
if in.token == LBRACKET then
if mods1.is(Extension) then
if leadingTparams.isEmpty then
deprecationWarning("type parameters in extension methods should be written after `def`")
else
syntaxError("no type parameters allowed here")
if mods1.is(Extension) then syntaxError("no type parameters allowed here")
typeParamClause(ParamOwner.Def)
else leadingTparams
val vparamss = paramClauses() match
Expand Down
2 changes: 1 addition & 1 deletion tests/init/crash/i5606.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object Test extends App {

def (f: A => B) `$`[A, B](a: A): B = f(a)
def [A, B](f: A => B) `$` (a: A): B = f(a)

assert((((a: Int) => a.toString()) `$` 10) == "10")

Expand Down
8 changes: 4 additions & 4 deletions tests/neg/i6662.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
opaque type Opt[A >: Null] = A

inline def (x: Opt[A]) nonEmpty[A >: Null]: Boolean = x.get != null // error: Implementation restriction
inline def (x: Opt[A]) isEmpty[A >: Null]: Boolean = x.get == null // error: Implementation restriction
inline def (x: Opt[A]) isDefined[A >: Null]: Boolean = x.nonEmpty // error: Implementation restriction
inline def (x: Opt[A]) get[A >: Null]: A = Opt.unOpt(x) // error: Implementation restriction
inline def [A >: Null](x: Opt[A]) nonEmpty: Boolean = x.get != null // error: Implementation restriction
inline def [A >: Null](x: Opt[A]) isEmpty: Boolean = x.get == null // error: Implementation restriction
inline def [A >: Null](x: Opt[A]) isDefined: Boolean = x.nonEmpty // error: Implementation restriction
inline def [A >: Null](x: Opt[A]) get: A = Opt.unOpt(x) // error: Implementation restriction

object Opt
{
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i6762b.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ type Liftable
given Liftable = ???

implicit object ExprOps {
def (x: T).toExpr[T](using Liftable): Expr[T] = ???
def [T](x: T).toExpr(using Liftable): Expr[T] = ???
}
2 changes: 1 addition & 1 deletion tests/neg/i6779.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type G[T]
type Stuff
given Stuff = ???

def (x: T).f[T](using Stuff): F[T] = ???
def [T](x: T).f(using Stuff): F[T] = ???


def g1[T](x: T): F[G[T]] = x.f(using summon[Stuff]) // error
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i7438.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type Tr[+A]
inline def (tr: Tr[A]).map[A, B](f: A => B): Tr[B] = ???
inline def [A, B](tr: Tr[A]).map(f: A => B): Tr[B] = ???

def (d: Double).func: None.type => Some[Double] = ???

Expand Down
4 changes: 2 additions & 2 deletions tests/pos/i6565.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class Err
type Lifted[A] = Err | A

def point[O](o: O): Lifted[O] = o
def (o: Lifted[O]) map [O, U] (f: O => U): Lifted[U] = ???
def (o: Lifted[O]) flatMap [O, U] (f: O => Lifted[U]): Lifted[U] = ???
def [O, U](o: Lifted[O]).map(f: O => U): Lifted[U] = ???
def [O, U](o: Lifted[O]).flatMap(f: O => Lifted[U]): Lifted[U] = ???

val error: Err = Err()

Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/i6772/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object Macros {
def mImpl()(using QuoteContext): Expr[Any] =
List(Expr(1), Expr(2), Expr(3)).toExprOfList

def (list: List[Expr[T]]).toExprOfList[T](using Type[T], QuoteContext): Expr[List[T]] = '{
def [T](list: List[Expr[T]]).toExprOfList(using Type[T], QuoteContext): Expr[List[T]] = '{
val buff = List.newBuilder[T]
${ Expr.block(list.map(v => '{ buff += $v }), '{ buff.result() }) }
}
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/reflect-sourceCode/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import scala.quoted._

object api {
inline def (x: => T) reflect[T] : String =
inline def [T](x: => T).reflect: String =
${ reflImpl('x) }

private def reflImpl[T](x: Expr[T])(implicit qctx: QuoteContext): Expr[String] = {
Expand Down