From 1c03d45b1649bb8307c09ebfd2bcb3b9efe50dad Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 12 Dec 2016 09:42:29 +0100 Subject: Fix #1784: allow to omit types for local implicit vals --- compiler/src/dotty/tools/dotc/typer/Namer.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/typer/Namer.scala') diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index b8fe46745..e02e90df1 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -998,11 +998,17 @@ class Namer { typer: Typer => lhsType // keep constant types that fill in for a non-constant (to be revised when inline has landed). else inherited else { - if (sym is Implicit) { - val resStr = if (mdef.isInstanceOf[DefDef]) "result " else "" - ctx.error(s"${resStr}type of implicit definition needs to be given explicitly", mdef.pos) + def missingType(modifier: String) = { + ctx.error(s"${modifier}type of implicit definition needs to be given explicitly", mdef.pos) sym.resetFlag(Implicit) + } + if (sym is Implicit) + mdef match { + case _: DefDef => missingType("result") + case _: ValDef if sym.owner.isType => missingType("") + case _ => + } lhsType orElse WildcardType } } -- cgit v1.2.3