diff options
author | Martin Odersky <odersky@gmail.com> | 2014-02-02 18:55:47 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-02-02 18:56:47 +0100 |
commit | 4886d7cb538f9a073827c78671d1890be787c0a5 (patch) | |
tree | 654c02b484be36b885d27677f7ca9328912d5087 /src | |
parent | 19c8cb1bca7a07395446a0cceaab137e5af2c8c5 (diff) | |
download | dotty-4886d7cb538f9a073827c78671d1890be787c0a5.tar.gz dotty-4886d7cb538f9a073827c78671d1890be787c0a5.tar.bz2 dotty-4886d7cb538f9a073827c78671d1890be787c0a5.zip |
Relaxing check that implicits must have explicit return type
Now this is required only for members of a template. Local statements can still have implicits with no result type. (Maybe we need to get back on this).
Also, changed Dotty itself and tests to adhere to the new restriction.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/printing/PlainPrinter.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Implicits.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 4 |
7 files changed, 10 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index cfc7db1c3..0f1d1010a 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -274,7 +274,7 @@ object desugar { else Nil // For an implicit class C[Ts](p11: T11, ..., p1N: T1N) ... (pM1: TM1, .., pMN: TMN), the method - // synthetic implicit C[Ts](p11: T11, ..., p1N: T1N) ... (pM1: TM1, ..., pMN: TMN) = + // synthetic implicit C[Ts](p11: T11, ..., p1N: T1N) ... (pM1: TM1, ..., pMN: TMN): C[Ts] = // new C[Ts](p11, ..., p1N) ... (pM1, ..., pMN) = val implicitWrappers = if (mods is Implicit) { @@ -283,7 +283,7 @@ object desugar { if (mods is Case) ctx.error("implicit classes may not case classes", cdef.pos) DefDef(Modifiers(Synthetic | Implicit), name.toTermName, - tparams, vparamss, TypeTree(), creatorExpr) :: Nil + tparams, vparamss, classTypeRef, creatorExpr) :: Nil } else Nil diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index d82826277..1d78eaf02 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -477,7 +477,7 @@ object Contexts { object Context { /** Implicit conversion that injects all printer operations into a context */ - implicit def toPrinter(ctx: Context) = ctx.printer + implicit def toPrinter(ctx: Context): Printer = ctx.printer /** implicit conversion that injects all ContextBase members into a context */ implicit def toBase(ctx: Context): ContextBase = ctx.base @@ -487,7 +487,7 @@ object Contexts { /** Info that changes on each compiler run */ class RunInfo(initctx: Context) extends ImplicitRunInfo { - implicit val ctx = initctx + implicit val ctx: Context = initctx } /** Initial size of superId table */ diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 92d9b7748..9604e1531 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -16,7 +16,7 @@ import config.Printers._ /** Provides methods to compare types. */ class TypeComparer(initctx: Context) extends DotClass { - implicit val ctx = initctx + implicit val ctx: Context = initctx val state = ctx.typerState import state.constraint diff --git a/src/dotty/tools/dotc/printing/PlainPrinter.scala b/src/dotty/tools/dotc/printing/PlainPrinter.scala index a2e7b21e8..71c255c17 100644 --- a/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -10,7 +10,7 @@ import java.lang.Integer.toOctalString import scala.annotation.switch class PlainPrinter(_ctx: Context) extends Printer { - protected[this] implicit val ctx = _ctx + protected[this] implicit val ctx: Context = _ctx protected def maxToTextRecursions = 100 diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index 68ec9273a..ddd37a885 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -274,7 +274,7 @@ trait ImplicitRunInfo { self: RunInfo => * abstract types are eliminated. */ object liftToClasses extends TypeMap { - private implicit val ctx = liftingCtx + private implicit val ctx: Context = liftingCtx def apply(tp: Type) = tp match { case tp: TypeRef if tp.symbol.isAbstractOrAliasType => val pre = tp.prefix diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 8e0b44b05..d67579408 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -378,7 +378,7 @@ class Namer { typer: Typer => class ClassCompleter(cls: ClassSymbol, original: TypeDef)(ictx: Context) extends Completer(original)(ictx) { withDecls(newScope) - protected implicit val ctx = localContext(cls) + protected implicit val ctx: Context = localContext(cls) val TypeDef(_, name, impl @ Template(constr, parents, self, body)) = original diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 58522ddb3..8498e5e54 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -862,7 +862,7 @@ class Typer extends Namer with Applications with Implicits { val ValDef(mods, name, tpt, rhs) = vdef val mods1 = typedModifiers(mods) val tpt1 = typedType(tpt) - if (sym is Implicit) checkImplicitTptNonEmpty(vdef) + if ((sym is Implicit) && sym.owner.isType) checkImplicitTptNonEmpty(vdef) val rhs1 = rhs match { case Ident(nme.WILDCARD) => rhs withType tpt1.tpe case _ => typedExpr(rhs, tpt1.tpe) @@ -877,7 +877,7 @@ class Typer extends Namer with Applications with Implicits { val tparams1 = tparams mapconserve (typed(_).asInstanceOf[TypeDef]) val vparamss1 = vparamss nestedMapconserve (typed(_).asInstanceOf[ValDef]) if (sym is Implicit) { - checkImplicitTptNonEmpty(ddef) + if (sym.owner.isType) checkImplicitTptNonEmpty(ddef) checkImplicitParamsNotSingletons(vparamss1) } val tpt1 = typedType(tpt) |