diff --git a/src/compiler/scala/tools/nsc/PipelineMain.scala b/src/compiler/scala/tools/nsc/PipelineMain.scala index 06adc05f8cc6..ccc151454594 100644 --- a/src/compiler/scala/tools/nsc/PipelineMain.scala +++ b/src/compiler/scala/tools/nsc/PipelineMain.scala @@ -77,7 +77,7 @@ class PipelineMainClass(argFiles: Seq[Path], pipelineSettings: PipelineMain.Pipe } } - implicit val executor = ExecutionContext.fromExecutor(new java.util.concurrent.ForkJoinPool(parallelism), t => handler.uncaughtException(Thread.currentThread(), t)) + implicit val executor: ExecutionContext = ExecutionContext.fromExecutor(new java.util.concurrent.ForkJoinPool(parallelism), t => handler.uncaughtException(Thread.currentThread(), t)) def changeExtension(p: Path, newExtension: String): Path = { val fileName = p.getFileName.toString val changedFileName = fileName.lastIndexOf('.') match { diff --git a/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala b/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala index 2557867ea966..9fd8343ea7ce 100644 --- a/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala +++ b/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala @@ -54,7 +54,8 @@ trait AnalyzerPlugins { self: Analyzer with splain.SplainData => /** * Let analyzer plugins change the types assigned to definitions. For definitions that have * an annotated type, the assigned type is obtained by typing that type tree. Otherwise, the - * type is inferred by typing the definition's righthand side. + * type is inferred by typing the definition's righthand side, or from the overridden + * member under `-Xsource:3`. * * In order to know if the type was inferred, you can query the `wasEmpty` field in the `tpt` * TypeTree of the definition (for DefDef and ValDef). diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 2521ce0b4c40..4516290ac952 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -21,6 +21,7 @@ import scala.annotation.tailrec import scala.reflect.runtime.ReflectionUtils import scala.reflect.macros.runtime.AbortMacroException import scala.util.control.{ControlThrowable, NonFatal} +import scala.tools.nsc.Reporting.WarningCategory import scala.tools.nsc.util.stackTraceString import scala.reflect.io.NoAbstractFile import scala.reflect.internal.util.NoSourceFile @@ -153,7 +154,7 @@ trait ContextErrors extends splain.SplainErrors { MacroIncompatibleEngineError("macro cannot be expanded, because it was compiled by an incompatible macro engine", internalMessage) /** The implicit not found message from the annotation, and whether it's a supplement message or not. */ - def NoImplicitFoundAnnotation(tree: Tree, param: Symbol): (Boolean, String) = { + def NoImplicitFoundAnnotation(tree: Tree, param: Symbol): (Boolean, String) = param match { case ImplicitNotFoundMsg(msg) => (false, msg.formatParameterMessage(tree)) case _ => @@ -167,7 +168,6 @@ trait ContextErrors extends splain.SplainErrors { true -> supplement } } - } def NoImplicitFoundError(tree: Tree, param: Symbol)(implicit context: Context): Unit = { val (isSupplement, annotationMsg) = NoImplicitFoundAnnotation(tree, param) @@ -186,6 +186,26 @@ trait ContextErrors extends splain.SplainErrors { issueNormalTypeError(tree, if (errMsg.isEmpty) defaultErrMsg else errMsg) } + private def InferredImplicitErrorImpl(tree: Tree, inferred: Type, cx: Context, isTyper: Boolean): Unit = { + def err(): Unit = { + val msg = + s"Implicit definition ${if (currentRun.isScala3) "must" else "should"} have explicit type${ + if (!inferred.isErroneous) s" (inferred $inferred)" else "" + }" + if (currentRun.isScala3) ErrorUtils.issueNormalTypeError(tree, msg)(cx) + else cx.warning(tree.pos, msg, WarningCategory.Other) + } + val sym = tree.symbol + // Defer warning field of class until typing getter (which is marked implicit) + if (sym.isImplicit) { + if (!sym.isLocalToBlock) { + err() + } + } + else if (!isTyper && sym.isField && !sym.isLocalToBlock) + sym.updateAttachment(FieldTypeInferred) + } + trait TyperContextErrors { self: Typer => @@ -1049,6 +1069,8 @@ trait ContextErrors extends splain.SplainErrors { def MacroAnnotationTopLevelModuleBadExpansion(ann: Tree) = issueNormalTypeError(ann, "top-level object can only expand into an eponymous object") + def InferredImplicitError(tree: Tree, inferred: Type, cx: Context): Unit = + InferredImplicitErrorImpl(tree, inferred, cx, isTyper = true) } /** This file will be the death of me. */ @@ -1077,7 +1099,7 @@ trait ContextErrors extends splain.SplainErrors { object InferErrorGen { - implicit val contextInferErrorGen = getContext + implicit val contextInferErrorGen: Context = getContext object PolyAlternativeErrorKind extends Enumeration { type ErrorType = Value @@ -1282,7 +1304,7 @@ trait ContextErrors extends splain.SplainErrors { object NamerErrorGen { - implicit val contextNamerErrorGen = context + implicit val contextNamerErrorGen: Context = context object SymValidateErrors extends Enumeration { val ImplicitConstr, ImplicitNotTermOrClass, ImplicitAtToplevel, @@ -1400,6 +1422,9 @@ trait ContextErrors extends splain.SplainErrors { issueNormalTypeError(tree, name.decode + " " + msg) } } + + def InferredImplicitError(tree: Tree, inferred: Type, cx: Context): Unit = + InferredImplicitErrorImpl(tree, inferred, cx, isTyper = false) } trait ImplicitsContextErrors { diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 8236d9cb7b0a..4943a4f37aa6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -18,6 +18,7 @@ import scala.collection.mutable import symtab.Flags._ import scala.reflect.internal.util.ListOfNil import scala.tools.nsc.Reporting.WarningCategory +import scala.util.chaining._ /** This trait declares methods to create symbols and to enter them into scopes. * @@ -1122,13 +1123,16 @@ trait Namers extends MethodSynthesis { * assigns the type to the tpt's node. Returns the type. */ private def assignTypeToTree(tree: ValOrDefDef, defnTyper: Typer, pt: Type): Type = { - val rhsTpe = tree match { - case ddef: DefDef if tree.symbol.isTermMacro => defnTyper.computeMacroDefType(ddef, pt) - case _ => defnTyper.computeType(tree.rhs, pt) - } tree.tpt.defineType { if (currentRun.isScala3 && !pt.isWildcard && pt != NoType && !pt.isErroneous) pt - else dropIllegalStarTypes(widenIfNecessary(tree.symbol, rhsTpe, pt)) + else { + val rhsTpe = tree match { + case ddef: DefDef if tree.symbol.isTermMacro => defnTyper.computeMacroDefType(ddef, pt) + case _ => defnTyper.computeType(tree.rhs, pt) + } + dropIllegalStarTypes(widenIfNecessary(tree.symbol, rhsTpe, pt)) + .tap(InferredImplicitError(tree, _, context)) + } }.setPos(tree.pos.focus) tree.tpt.tpe } @@ -1160,9 +1164,7 @@ trait Namers extends MethodSynthesis { private def templateSig(templ: Template): Type = { val clazz = context.owner - val parentTrees = typer.typedParentTypes(templ) - val pending = mutable.ListBuffer[AbsTypeError]() parentTrees foreach { tpt => val ptpe = tpt.tpe @@ -1383,7 +1385,6 @@ trait Namers extends MethodSynthesis { * * If the result type is missing, assign a MethodType to `meth` that's constructed using this return type. * This allows omitting the result type for recursive methods. - * */ val resTpFromOverride = if (!inferResTp || overridden == NoSymbol || overridden.isOverloaded) resTpGiven @@ -1442,7 +1443,7 @@ trait Namers extends MethodSynthesis { val resTp = { // When return type is inferred, we don't just use resTpFromOverride -- it must be packed and widened. - // Here, C.f has type String: + // Here, C.f has type String (unless -Xsource:3): // trait T { def f: Object }; class C extends T { def f = "" } // using resTpFromOverride as expected type allows for the following (C.f has type A): // trait T { def f: A }; class C extends T { implicit def b2a(t: B): A = ???; def f = new B } @@ -1704,63 +1705,58 @@ trait Namers extends MethodSynthesis { } } - private def valDefSig(vdef: ValDef) = { + private def valDefSig(vdef: ValDef): Type = { val ValDef(_, _, tpt, rhs) = vdef - val result = - if (tpt.isEmpty) { - if (rhs.isEmpty) { - MissingParameterOrValTypeError(tpt) - ErrorType - } else { - // enterGetterSetter assigns the getter's symbol to a ValDef when there's no underlying field - // (a deferred val or most vals defined in a trait -- see Field.noFieldFor) - val isGetter = vdef.symbol hasFlag ACCESSOR - - val pt = { - val valOwner = owner.owner - // there's no overriding outside of classes, and we didn't use to do this in 2.11, so provide opt-out - - if (!valOwner.isClass) WildcardType - else { - // normalize to getter so that we correctly consider a val overriding a def - // (a val's name ends in a " ", so can't compare to def) - val overridingSym = if (isGetter) vdef.symbol else vdef.symbol.getterIn(valOwner) + def inferredValTpt: Type = { + // enterGetterSetter assigns the getter's symbol to a ValDef when there's no underlying field + // (a deferred val or most vals defined in a trait -- see Field.noFieldFor) + val isGetter = vdef.symbol hasFlag ACCESSOR + + val pt: Type = { + val valOwner = owner.owner + if (!valOwner.isClass) WildcardType + else { + // normalize to getter so that we correctly consider a val overriding a def + // (a val's name ends in a " ", so can't compare to def) + val overridingSym = if (isGetter) vdef.symbol else vdef.symbol.getterIn(valOwner) - // We're called from an accessorTypeCompleter, which is completing the info for the accessor's symbol, - // which may or may not be `vdef.symbol` (see isGetter above) - val overridden = safeNextOverriddenSymbol(overridingSym) + // We're called from an accessorTypeCompleter, which is completing the info for the accessor's symbol, + // which may or may not be `vdef.symbol` (see isGetter above) + val overridden = safeNextOverriddenSymbol(overridingSym) - if (overridden == NoSymbol || overridden.isOverloaded) WildcardType - else valOwner.thisType.memberType(overridden).resultType - } - } + if (overridden == NoSymbol || overridden.isOverloaded) WildcardType + else valOwner.thisType.memberType(overridden).resultType + } + } - def patchSymInfo(tp: Type): Unit = - if (pt ne WildcardType) // no patching up to do if we didn't infer a prototype - vdef.symbol setInfo (if (isGetter) NullaryMethodType(tp) else tp) + def patchSymInfo(tp: Type): Unit = + if (pt ne WildcardType) // no patching up to do if we didn't infer a prototype + vdef.symbol.setInfo { if (isGetter) NullaryMethodType(tp) else tp } - patchSymInfo(pt) + patchSymInfo(pt) - // derives the val's result type from type checking its rhs under the expected type `pt` - // vdef.tpt is mutated, and `vdef.tpt.tpe` is `assignTypeToTree`'s result - val tptFromRhsUnderPt = assignTypeToTree(vdef, typer, pt) + // derives the val's result type from type checking its rhs under the expected type `pt` + // vdef.tpt is mutated, and `vdef.tpt.tpe` is `assignTypeToTree`'s result + val tptFromRhsUnderPt = assignTypeToTree(vdef, typer, pt) - // need to re-align with assignTypeToTree, as the type we're returning from valDefSig (tptFromRhsUnderPt) - // may actually go to the accessor, not the valdef (and if assignTypeToTree returns a subtype of `pt`, - // we would be out of synch between field and its accessors), and thus the type completer won't - // fix the symbol's info for us -- we set it to tmpInfo above, which may need to be improved to tptFromRhsUnderPt - if (!isGetter) patchSymInfo(tptFromRhsUnderPt) + // need to re-align with assignTypeToTree, as the type we're returning from valDefSig (tptFromRhsUnderPt) + // may actually go to the accessor, not the valdef (and if assignTypeToTree returns a subtype of `pt`, + // we would be out of synch between field and its accessors), and thus the type completer won't + // fix the symbol's info for us -- we set it to tmpInfo above, which may need to be improved to tptFromRhsUnderPt + if (!isGetter) patchSymInfo(tptFromRhsUnderPt) - tptFromRhsUnderPt - } + tptFromRhsUnderPt + } + val result: Type = + if (tpt.isEmpty) { + if (rhs.isEmpty) { MissingParameterOrValTypeError(tpt); ErrorType } + else inferredValTpt } else { val tptTyped = typer.typedType(tpt) context.unit.transformed(tpt) = tptTyped tptTyped.tpe } - // println(s"val: $result / ${vdef.tpt.tpe} / ") - pluginsTypeSig(result, typer, vdef, if (tpt.isEmpty) WildcardType else result) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index e1eed2b88345..d44e41bc8b34 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2164,7 +2164,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper } /** Analyze the super constructor call to record information used later to compute parameter aliases */ - def analyzeSuperConsructor(meth: Symbol, vparamss: List[List[ValDef]], rhs: Tree): Unit = { + def analyzeSuperConstructor(meth: Symbol, vparamss: List[List[ValDef]], rhs: Tree): Unit = { val clazz = meth.owner debuglog(s"computing param aliases for $clazz:${clazz.primaryConstructor.tpe}:$rhs") val pending = ListBuffer[AbsTypeError]() @@ -2346,7 +2346,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper } } - val tparams1 = ddef.tparams mapConserve typedTypeDef + val tparams1 = ddef.tparams.mapConserve(typedTypeDef) val vparamss1 = ddef.vparamss.mapConserve(_.mapConserve(typedValDef)) warnTypeParameterShadow(tparams1, meth) @@ -2386,9 +2386,9 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper if (meth.isClassConstructor && !isPastTyper && !meth.owner.isSubClass(AnyValClass) && !meth.isJava) { // There are no supercalls for AnyVal or constructors from Java sources, which - // would blow up in analyzeSuperConsructor; there's nothing to be computed for them anyway. + // would blow up in analyzeSuperConstructor; there's nothing to be computed for them anyway. if (meth.isPrimaryConstructor) - analyzeSuperConsructor(meth, vparamss1, rhs1) + analyzeSuperConstructor(meth, vparamss1, rhs1) else checkSelfConstructorArgs(ddef, meth.owner) } @@ -2415,13 +2415,18 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper if (meth.isStructuralRefinementMember) checkMethodStructuralCompatible(ddef) - if (meth.isImplicit && !meth.isSynthetic) meth.paramss match { - case List(param) :: _ if !param.isImplicit => - checkFeature(ddef.pos, currentRun.runDefinitions.ImplicitConversionsFeature, meth.toString) - case _ => + if (meth.isImplicit) { + if (!meth.isSynthetic) meth.paramss match { + case List(param) :: _ if !param.isImplicit => + checkFeature(ddef.pos, currentRun.runDefinitions.ImplicitConversionsFeature, meth.toString) + case _ => + } + if (meth.isGetter && !meth.isLocalToBlock && meth.accessed.hasAttachment[FieldTypeInferred.type]) { + meth.accessed.removeAttachment[FieldTypeInferred.type] + InferredImplicitError(ddef, meth.accessed.tpe.resultType, context) + } } } - treeCopy.DefDef(ddef, typedMods, ddef.name, tparams1, vparamss1, tpt1, rhs1) setType NoType } finally { currentRun.profiler.afterTypedImplDef(meth) diff --git a/src/manual/scala/tools/docutil/ManPage.scala b/src/manual/scala/tools/docutil/ManPage.scala index 853c17b94c0b..cfd9844629f2 100644 --- a/src/manual/scala/tools/docutil/ManPage.scala +++ b/src/manual/scala/tools/docutil/ManPage.scala @@ -24,7 +24,7 @@ object ManPage { case class Emph(contents: AbstractText) extends AbstractText case class Mono(contents: AbstractText) extends AbstractText case class Quote(contents: AbstractText) extends AbstractText - implicit def str2text(str: String) = Text(str) + implicit def str2text(str: String): Text = Text(str) case class Definition(term: AbstractText, description: AbstractText) case class DefinitionList(definitions: Definition*) extends AbstractText @@ -37,14 +37,14 @@ object ManPage { case class CodeSample(text: String) extends Paragraph case class BlockQuote(text: AbstractText) extends Paragraph implicit def text2para(text: AbstractText): Paragraph = TextParagraph(text) - implicit def str2para(str: String) = text2para(str2text(str)) + implicit def str2para(str: String): Paragraph = text2para(str2text(str)) case class BulletList(items: AbstractText*) extends Paragraph case class NumberedList(items: AbstractText*) extends Paragraph case class TitledPara(title: String, text: AbstractText) extends Paragraph case class EmbeddedSection(section: Section) extends Paragraph - implicit def section2Para(section: Section) = EmbeddedSection(section) + implicit def section2Para(section: Section): EmbeddedSection = EmbeddedSection(section) case class Section(title: String, paragraphs: Paragraph*) diff --git a/src/partest/scala/tools/partest/CompilerTest.scala b/src/partest/scala/tools/partest/CompilerTest.scala index f45846848d83..8114d071c460 100644 --- a/src/partest/scala/tools/partest/CompilerTest.scala +++ b/src/partest/scala/tools/partest/CompilerTest.scala @@ -12,6 +12,7 @@ package scala.tools.partest +import scala.language.implicitConversions import scala.reflect.runtime.{universe => ru} import scala.tools.nsc._ @@ -46,7 +47,7 @@ abstract class CompilerTest extends DirectTest { if (sym eq NoSymbol) NoType else appliedType(sym, compilerTypeFromTag(t)) } - implicit def mkMkType(sym: Symbol) = new MkType(sym) + implicit def mkMkType(sym: Symbol): MkType = new MkType(sym) def allMembers(root: Symbol): List[Symbol] = { def loop(seen: Set[Symbol], roots: List[Symbol]): List[Symbol] = { diff --git a/src/partest/scala/tools/partest/nest/Instance.scala b/src/partest/scala/tools/partest/nest/Instance.scala index 7c0827e99a05..21da651e7031 100644 --- a/src/partest/scala/tools/partest/nest/Instance.scala +++ b/src/partest/scala/tools/partest/nest/Instance.scala @@ -28,5 +28,5 @@ trait Instance extends Spec { def residualArgs = parsed.residualArgs // only args which were not options or args to options type OptionMagic = Opt.Instance - protected implicit def optionMagicAdditions(name: String) = new Opt.Instance(programInfo, parsed, name) + protected implicit def optionMagicAdditions(name: String): Opt.Instance = new Opt.Instance(programInfo, parsed, name) } diff --git a/src/partest/scala/tools/partest/nest/Reference.scala b/src/partest/scala/tools/partest/nest/Reference.scala index f068c7d785f6..ecf07319f8a5 100644 --- a/src/partest/scala/tools/partest/nest/Reference.scala +++ b/src/partest/scala/tools/partest/nest/Reference.scala @@ -45,7 +45,7 @@ trait Reference extends Spec { final def apply(args: String*): ThisCommandLine = creator(propertyArgs ++ args flatMap expandArg) type OptionMagic = Opt.Reference - protected implicit def optionMagicAdditions(name: String) = new Opt.Reference(programInfo, options, name) + protected implicit def optionMagicAdditions(name: String): Opt.Reference = new Opt.Reference(programInfo, options, name) } object Reference { diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala index 5484b5dc8b94..ccddabe77feb 100644 --- a/src/partest/scala/tools/partest/package.scala +++ b/src/partest/scala/tools/partest/package.scala @@ -18,6 +18,7 @@ import java.util.concurrent.{Callable, ExecutorService} import scala.concurrent.duration.Duration import scala.io.Codec import scala.jdk.CollectionConverters._ +import scala.language.implicitConversions import scala.tools.nsc.util.Exceptional package object partest { @@ -123,8 +124,6 @@ package object partest { implicit def temporaryPath2File(x: Path): File = x.jfile implicit def stringPathToJavaFile(path: String): File = new File(path) - implicit lazy val implicitConversions = scala.language.implicitConversions - def fileSeparator = java.io.File.separator def pathSeparator = java.io.File.pathSeparator diff --git a/src/reflect/scala/reflect/api/Internals.scala b/src/reflect/scala/reflect/api/Internals.scala index 1478f55f897f..3e2f5f4fe736 100644 --- a/src/reflect/scala/reflect/api/Internals.scala +++ b/src/reflect/scala/reflect/api/Internals.scala @@ -1098,7 +1098,7 @@ trait Internals { self: Universe => trait CompatApi { /** @see [[CompatToken]] */ @deprecated("compatibility with Scala 2.10 EOL", "2.13.0") - implicit val token = new CompatToken + implicit val token: CompatToken = new CompatToken /** Scala 2.10 compatibility enrichments for BuildApi. */ @deprecated("compatibility with Scala 2.10 EOL", "2.13.0") diff --git a/src/reflect/scala/reflect/internal/StdAttachments.scala b/src/reflect/scala/reflect/internal/StdAttachments.scala index 6045c42adec3..2aefc327cca2 100644 --- a/src/reflect/scala/reflect/internal/StdAttachments.scala +++ b/src/reflect/scala/reflect/internal/StdAttachments.scala @@ -149,4 +149,7 @@ trait StdAttachments { /** Marks a Typed tree with Unit tpt. */ case object TypedExpectingUnitAttachment def explicitlyUnit(tree: Tree): Boolean = tree.hasAttachment[TypedExpectingUnitAttachment.type] + + /** For `val i = 42`, marks field as inferred so accessor (getter) can warn if implicit. */ + case object FieldTypeInferred extends PlainAttachment } diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 5a07f3ccd75c..336cb5cfbdca 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -1464,15 +1464,13 @@ trait Trees extends api.Trees { override def removeAttachment[T: ClassTag]: this.type = attachmentWarning() private def attachmentWarning(): this.type = {devWarning(s"Attempt to mutate attachments on $self ignored"); this} - private def requireLegal(value: Any, allowed: Any, what: String) = ( - if (value != allowed) { + private def requireLegal(value: Any, allowed: Any, what: String): Unit = + if (value != allowed && this != pendingSuperCall) { log(s"can't set $what for $self to value other than $allowed") if (settings.isDebug && settings.isDeveloper) - (new Throwable).printStackTrace + new Throwable(s"can't set $what for $self to value other than $allowed").printStackTrace } - ) - override def traverse(traverser: Traverser): Unit = - () + override def traverse(traverser: Traverser): Unit = () } case object EmptyTree extends TermTree with CannotHaveAttrs { diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala index ead2054e9092..b4d932c591d9 100644 --- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala +++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala @@ -78,6 +78,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse => this.InterpolatedString this.RootSelection this.TypedExpectingUnitAttachment + this.FieldTypeInferred this.noPrint this.typeDebug // inaccessible: this.posAssigner diff --git a/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala index 73639213cc6f..5208ae1797a5 100644 --- a/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala +++ b/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala @@ -34,7 +34,7 @@ trait MemberHandlers { val front = if (leadingPlus) "+ " else "" front + (xs map string2codeQuoted mkString " + ") } - private implicit def name2string(name: Name) = name.toString + private implicit def name2string(name: Name): String = name.toString /** A traverser that finds all mentioned identifiers, i.e. things * that need to be imported. It might return extra names. diff --git a/src/repl/scala/tools/nsc/interpreter/Power.scala b/src/repl/scala/tools/nsc/interpreter/Power.scala index bf0996559a2e..0d65f8bcf5f5 100644 --- a/src/repl/scala/tools/nsc/interpreter/Power.scala +++ b/src/repl/scala/tools/nsc/interpreter/Power.scala @@ -264,7 +264,7 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re trait Implicits1 { // fallback - implicit def replPrinting[T](x: T)(implicit pretty: Prettifier[T] = Prettifier.default[T]) = + implicit def replPrinting[T](x: T)(implicit pretty: Prettifier[T] = Prettifier.default[T]): PrettifierClass[T] = new SinglePrettifierClass[T](x) } trait Implicits2 extends Implicits1 { @@ -288,7 +288,7 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re implicit def replPrettifier[T] : Prettifier[T] = Prettifier.default[T] implicit def replTypeApplication(sym: Symbol): RichSymbol = new RichSymbol(sym) - implicit def replInputStream(in: InputStream)(implicit codec: Codec) = new RichInputStream(in) + implicit def replInputStream(in: InputStream)(implicit codec: Codec): RichInputStream = new RichInputStream(in) implicit def replEnhancedURLs(url: URL)(implicit codec: Codec): RichReplURL = new RichReplURL(url)(codec) } diff --git a/src/repl/scala/tools/nsc/interpreter/ReplVals.scala b/src/repl/scala/tools/nsc/interpreter/ReplVals.scala index 2e485d2ac787..1213c99c117f 100644 --- a/src/repl/scala/tools/nsc/interpreter/ReplVals.scala +++ b/src/repl/scala/tools/nsc/interpreter/ReplVals.scala @@ -47,13 +47,17 @@ class StdReplVals(final val intp: IMain) extends ReplVals { import intp.global.Symbol private val tagFn = ReplVals.mkCompilerTypeFromTag[intp.global.type](global) - implicit def mkCompilerTypeFromTag(sym: Symbol) = tagFn(sym) + implicit def mkCompilerTypeFromTag(sym: Symbol): ATFT[global.type] = tagFn(sym) } final lazy val replImplicits = new ReplImplicits def typed[T <: analyzer.global.Tree](tree: T): T = typer.typed(tree).asInstanceOf[T] } +trait ATFT[G <: Global] { + def apply[M](implicit m1: ru.TypeTag[M]): G#Type + def apply[M1, M2](implicit m1: ru.TypeTag[M1], m2: ru.TypeTag[M2]): G#Type +} object ReplVals { /** Latest attempt to work around the challenge of foo.global.Type @@ -72,7 +76,7 @@ object ReplVals { def compilerTypeFromTag(t: ApiUniverse # WeakTypeTag[_]): Global#Type = definitions.compilerTypeFromTag(t) - class AppliedTypeFromTags(sym: Symbol) { + class AppliedTypeFromTags(sym: Symbol) extends ATFT[T] { def apply[M](implicit m1: ru.TypeTag[M]): Type = if (sym eq NoSymbol) NoType else appliedType(sym, compilerTypeFromTag(m1).asInstanceOf[Type]) diff --git a/src/scaladoc/scala/tools/nsc/doc/Uncompilable.scala b/src/scaladoc/scala/tools/nsc/doc/Uncompilable.scala index df9b5c679ffb..6494a3d49008 100644 --- a/src/scaladoc/scala/tools/nsc/doc/Uncompilable.scala +++ b/src/scaladoc/scala/tools/nsc/doc/Uncompilable.scala @@ -29,7 +29,7 @@ trait Uncompilable { import global.definitions.{ AnyRefClass, AnyRefTpe } import global.rootMirror.RootClass - private implicit def translateName(name: Global#Name) = + private implicit def translateName(name: Global#Name): global.Name = if (name.isTypeName) newTypeName("" + name) else newTermName("" + name) val WaitNames = List("scala", "AnyRef", "wait") diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala index e571649454a8..cbc0b53960f5 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala +++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala @@ -114,7 +114,7 @@ case class ScalaSig(majorVersion: Int, minorVersion: Int, table: Seq[Int ~ ByteC def parseEntry(index: Int) = applyRule(ScalaSigParsers.parseEntry(ScalaSigEntryParsers.entry)(index)) - implicit def applyRule[A](parser: ScalaSigParsers.Parser[A]) = ScalaSigParsers.expect(parser)(this) + implicit def applyRule[A](parser: ScalaSigParsers.Parser[A]): A = ScalaSigParsers.expect(parser)(this) override def toString = "ScalaSig version " + majorVersion + "." + minorVersion + { for (i <- 0 until table.size) yield "" + i + ":\t" + parseEntry(i) // + "\n\t" + getEntry(i) @@ -165,7 +165,8 @@ object ScalaSigEntryParsers extends RulesWithState with MemoisableRules { def parseEntry[A](parser: EntryParser[A])(index: Int) = (toEntry(index) -~ parser) - implicit def entryType(code: Int) = key filter (_ == code) + type R = scala.tools.scalap.scalax.rules.Rule[ScalaSigEntryParsers.S, ScalaSigEntryParsers.S, Int, Nothing] + implicit def entryType(code: Int): R = key.filter(_ == code) val index = read(_.index) val key = read(_.entryType) diff --git a/test/async/jvm/toughtype.scala b/test/async/jvm/toughtype.scala index 939d0647e985..9587afa35f19 100644 --- a/test/async/jvm/toughtype.scala +++ b/test/async/jvm/toughtype.scala @@ -199,7 +199,7 @@ package scala.async.run.toughtype { } object FunDep { - implicit def `Something to do with List`[W, S, R](implicit funDep: FunDep[W, S, R]) = + implicit def `Something to do with List`[W, S, R](implicit funDep: FunDep[W, S, R]): FunDep[W,List[S],W] = new FunDep[W, List[S], W] { def method(w: W, l: List[S]) = async { val it = l.iterator diff --git a/test/files/jvm/future-spec/main.scala b/test/files/jvm/future-spec/main.scala index 411a6333992f..dda7cfbb4e47 100644 --- a/test/files/jvm/future-spec/main.scala +++ b/test/files/jvm/future-spec/main.scala @@ -17,9 +17,10 @@ object Test { } trait Features { - implicit def implicitously = scala.language.implicitConversions - implicit def reflectively = scala.language.reflectiveCalls - implicit def postulously = scala.language.postfixOps + import languageFeature._ + implicit def implicitously: implicitConversions = scala.language.implicitConversions + implicit def reflectively: reflectiveCalls = scala.language.reflectiveCalls + implicit def postulously: postfixOps = scala.language.postfixOps } @@ -40,7 +41,9 @@ trait MinimalScalaTest extends Output with Features with Vigil { if (throwables.nonEmpty) println(buffer.toString) } - implicit def stringops(s: String) = new { + type Ops = AnyRef{def should[U](snippets: => U): U; def in[U](snippet: => U): scala.collection.mutable.IndexedSeq[_ >: Char with Throwable] with scala.collection.mutable.AbstractSeq[_ >: Char with Throwable] with scala.collection.mutable.Growable[Char with Throwable] with java.io.Serializable} + + implicit def stringops(s: String): Ops = new { def should[U](snippets: => U) = { bufferPrintln(s + " should:") @@ -62,7 +65,8 @@ trait MinimalScalaTest extends Output with Features with Vigil { } - implicit def objectops(obj: Any) = new { + type OOps = AnyRef{def mustBe(other: Any): Unit; def mustEqual(other: Any): Unit} + implicit def objectops(obj: Any): OOps = new { def mustBe(other: Any) = assert(obj == other, s"$obj is not $other") def mustEqual(other: Any) = mustBe(other) diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index 3acf90e25db0..2e9430f729c4 100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -87,6 +87,8 @@ scala> case class Bar(n: Int) class Bar scala> implicit def foo2bar(foo: Foo) = Bar(foo.n) + ^ + warning: Implicit definition should have explicit type (inferred Bar) warning: 1 feature warning; for details, enable `:setting -feature` or `:replay -feature` def foo2bar(foo: Foo): Bar diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index d8eafde41b16..3633582cb376 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -1055,7 +1055,7 @@ class ExecutionContextPrepare extends TestBase { delegate.reportFailure(t) } - implicit val ec = new PreparingExecutionContext + implicit val ec: ExecutionContext = new PreparingExecutionContext def testOnComplete(): Unit = once { done => diff --git a/test/files/neg/implicit-log.scala b/test/files/neg/implicit-log.scala index f77085e3c2af..7af20610f64d 100644 --- a/test/files/neg/implicit-log.scala +++ b/test/files/neg/implicit-log.scala @@ -37,8 +37,8 @@ object Test1579 { class Query[E](val value: E) class Invoker(q: Any) { val foo = null } - implicit def unwrap[C](q: Query[C]) = q.value - implicit def invoker(q: Query[Column]) = new Invoker(q) + implicit def unwrap[C](q: Query[C]): C = q.value + implicit def invoker(q: Query[Column]): Invoker = new Invoker(q) val q = new Query(new Column) q.foo @@ -50,9 +50,9 @@ object Test1625 { def unwrap() = x } - implicit def byName[A](x: => A) = new Wrapped(x) + implicit def byName[A](x: => A): Wrapped = new Wrapped(x) - implicit def byVal[A](x: A) = x + implicit def byVal[A](x: A): A = x def main(args: Array[String]) = { diff --git a/test/files/neg/implicits.check b/test/files/neg/implicits.check index 2eb03eb5f3db..6bcdf6c81285 100644 --- a/test/files/neg/implicits.check +++ b/test/files/neg/implicits.check @@ -16,4 +16,11 @@ implicits.scala:47: error: type mismatch; implicits.scala:59: error: could not find implicit value for parameter x: Nothing foo { ^ +implicits.scala:34: warning: Implicit definition should have explicit type (inferred T) + implicit def select[T](t: HSome[T,_]) = t.head + ^ +implicits.scala:35: warning: Implicit definition should have explicit type (inferred L) + implicit def selectTail[L](t: HSome[_,L]) = t.tail + ^ +2 warnings 4 errors diff --git a/test/files/neg/override-final-implicit.check b/test/files/neg/override-final-implicit.check index d46efa1acb52..d5e546078794 100644 --- a/test/files/neg/override-final-implicit.check +++ b/test/files/neg/override-final-implicit.check @@ -1,5 +1,9 @@ +override-final-implicit.scala:6: warning: Implicit definition should have explicit type (inferred Test.this.FooExtender) + override implicit def FooExtender(foo: String) = super.FooExtender(foo) + ^ override-final-implicit.scala:6: error: cannot override final member: final implicit def FooExtender(foo: String): Test.this.FooExtender (defined in class Implicits) override implicit def FooExtender(foo: String) = super.FooExtender(foo) ^ +1 warning 1 error diff --git a/test/files/neg/private-implicit-class.check b/test/files/neg/private-implicit-class.check index 31ddc9a023ab..1578f9102325 100644 --- a/test/files/neg/private-implicit-class.check +++ b/test/files/neg/private-implicit-class.check @@ -1,4 +1,8 @@ private-implicit-class.scala:6: error: method BarExtender in class ImplicitsPrivate cannot be accessed as a member of ImplicitsPrivate from class TestPrivate override implicit def BarExtender(bar: Int) = super.BarExtender(bar) // error ^ +private-implicit-class.scala:6: warning: Implicit definition should have explicit type + override implicit def BarExtender(bar: Int) = super.BarExtender(bar) // error + ^ +1 warning 1 error diff --git a/test/files/neg/t1038.scala b/test/files/neg/t1038.scala index 367022965b99..2cc45a190eea 100644 --- a/test/files/neg/t1038.scala +++ b/test/files/neg/t1038.scala @@ -4,5 +4,6 @@ object Y { val a = new X import a._ implicit val b : Int = 1 + @annotation.nowarn implicit val c = 2 } diff --git a/test/files/neg/t2206.check b/test/files/neg/t2206.check index 5ea5570f9a90..75c5e19c58e5 100644 --- a/test/files/neg/t2206.check +++ b/test/files/neg/t2206.check @@ -2,4 +2,8 @@ t2206.scala:10: error: value f is not a member of o.A Note: implicit method ax is not applicable here because it comes after the application point and it lacks an explicit result type a.f() ^ +t2206.scala:13: warning: Implicit definition should have explicit type (inferred o.AX) + implicit def ax(a: A) = new AX + ^ +1 warning 1 error diff --git a/test/files/neg/t2421b.check b/test/files/neg/t2421b.check index 7c714f1c9bd7..644395fc6a12 100644 --- a/test/files/neg/t2421b.check +++ b/test/files/neg/t2421b.check @@ -1,4 +1,8 @@ t2421b.scala:12: error: could not find implicit value for parameter aa: Test.F[Test.A] f ^ +t2421b.scala:10: warning: Implicit definition should have explicit type (inferred Test.F[X]) + implicit def b[X <: B] = new F[X]() + ^ +1 warning 1 error diff --git a/test/files/neg/t2866.scala b/test/files/neg/t2866.scala index 2f464593d30c..d80822349244 100644 --- a/test/files/neg/t2866.scala +++ b/test/files/neg/t2866.scala @@ -1,7 +1,7 @@ // for 2.7.x compatibility object A { - implicit val one = 1 + implicit val one: Int = 1 } object Test { diff --git a/test/files/neg/t3006.check b/test/files/neg/t3006.check index b8dea080a766..e2358b0f0dd9 100644 --- a/test/files/neg/t3006.check +++ b/test/files/neg/t3006.check @@ -3,4 +3,8 @@ t3006.scala:8: error: type mismatch; required: Int println(A(3) + "H") ^ +t3006.scala:6: warning: Implicit definition should have explicit type (inferred Test.Foo) + implicit def aToFoo(x: A) = new Foo(x); + ^ +1 warning 1 error diff --git a/test/files/neg/t3346c.check b/test/files/neg/t3346c.check index 10c96eeb6cdb..4b18680e493d 100644 --- a/test/files/neg/t3346c.check +++ b/test/files/neg/t3346c.check @@ -1,4 +1,4 @@ -t3346c.scala:60: error: value bar is not a member of Either[Int,String] +t3346c.scala:65: error: value bar is not a member of Either[Int,String] did you mean map? eii.bar ^ diff --git a/test/files/neg/t3346c.scala b/test/files/neg/t3346c.scala index 59584e0a6168..287c91bdf2ca 100644 --- a/test/files/neg/t3346c.scala +++ b/test/files/neg/t3346c.scala @@ -1,3 +1,5 @@ +import annotation._ + object Test extends App { // // An attempt to workaround scala/bug#2712, foiled by scala/bug#3346 @@ -32,15 +34,18 @@ object Test extends App { } + @nowarn implicit def ToTCValue[M[_], A](ma: M[A])(implicit M0: TC[M]) = new TCValue[M, A] { - implicit val M = M0 + implicit val M: TC[M] = M0 val self = ma } implicit def ToTCValueBin1[M[_, _], A, B](ma: M[A, B])(implicit M0: TC[({type λ[α]=M[A, α]})#λ]): TCValue[({type λ[α] = M[A, α]})#λ, B] = new TCValue[({type λ[α]=M[A, α]})#λ, B] { + @nowarn implicit val M = M0 val self = ma } implicit def ToTCValueBin2[M[_, _], A, B](ma: M[A, B])(implicit M0: TC[({type λ[α]=M[α, B]})#λ]): TCValue[({type λ[α]=M[α, B]})#λ, A] = new TCValue[({type λ[α]=M[α, B]})#λ, A] { + @nowarn implicit val M = M0 val self = ma } diff --git a/test/files/neg/t3346i.check b/test/files/neg/t3346i.check index b1b5a140e8f9..dafa0b861e24 100644 --- a/test/files/neg/t3346i.check +++ b/test/files/neg/t3346i.check @@ -4,4 +4,20 @@ t3346i.scala:28: error: value a is not a member of Test.A[T] t3346i.scala:29: error: value a is not a member of Test.A[Nothing] (new A[Nothing]).a ^ +t3346i.scala:16: warning: Implicit definition should have explicit type (inferred Implicit1[T]) + implicit def implicit1[T <: Intermediate[_, _]](implicit b: Implicit2[T]) = new Implicit1[T](b) + ^ +t3346i.scala:18: warning: Implicit definition should have explicit type (inferred Implicit2[T]) + implicit def implicit2alt1[T <: Intermediate[_ <: String, _]](implicit c: Implicit3[T]) = new Implicit2[T](c) + ^ +t3346i.scala:19: warning: Implicit definition should have explicit type (inferred Implicit2[T]) + implicit def implicit2alt2[T <: Intermediate[_ <: Double, _]](implicit c: Implicit3[T]) = new Implicit2[T](c) + ^ +t3346i.scala:21: warning: Implicit definition should have explicit type (inferred Implicit3[T]) + implicit def implicit3alt1[T <: Intermediate[_, _ <: Int]] = new Implicit3[T]() + ^ +t3346i.scala:22: warning: Implicit definition should have explicit type (inferred Implicit3[T]) + implicit def implicit3alt2[T <: Intermediate[_ <: Double, _ <: AnyRef],X] = new Implicit3[T]() + ^ +5 warnings 2 errors diff --git a/test/files/neg/t4271.check b/test/files/neg/t4271.check index 402a7b9b7acb..d89d07f420a7 100644 --- a/test/files/neg/t4271.check +++ b/test/files/neg/t4271.check @@ -8,4 +8,23 @@ t4271.scala:11: error: value -> is not a member of Int did you mean >>>? 3 -> 5 ^ +t4271.scala:3: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def Ensuring[A](x: A) = Donotuseme + ^ +t4271.scala:4: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def doubleWrapper(x: Int) = Donotuseme + ^ +t4271.scala:5: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def floatWrapper(x: Int) = Donotuseme + ^ +t4271.scala:6: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def intWrapper(x: Int) = Donotuseme + ^ +t4271.scala:7: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def longWrapper(x: Int) = Donotuseme + ^ +t4271.scala:8: warning: Implicit definition should have explicit type (inferred foo.Donotuseme.type) + implicit def ArrowAssoc[A](x: A) = Donotuseme + ^ +6 warnings 3 errors diff --git a/test/files/neg/t4457_1.check b/test/files/neg/t4457_1.check index a16bb1ff8b1b..4d65bc39c1e0 100644 --- a/test/files/neg/t4457_1.check +++ b/test/files/neg/t4457_1.check @@ -4,4 +4,20 @@ and method aFunc in object ImplicitConvAmbiguity2 of type [A](a: ImplicitConvAm match argument types (Float) val x = aFunc(4F) ^ +t4457_1.scala:11: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.NE[Float]) + implicit def conv1(i: Float) = new NE[Float] + ^ +t4457_1.scala:12: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[java.util.TooManyListenersException]) + implicit def conv3(op: AA[java.util.TooManyListenersException]) = new N[java.util.TooManyListenersException] + ^ +t4457_1.scala:13: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[Float]) + implicit def conv4(op: AA[Float]) = new N[Float] + ^ +t4457_1.scala:14: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.NZ[Float]) + implicit def conv7(i: Float) = new NZ[Float] + ^ +t4457_1.scala:15: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[java.util.GregorianCalendar]) + implicit def conv5(e: BB[java.util.GregorianCalendar]) = new N[java.util.GregorianCalendar] + ^ +5 warnings 1 error diff --git a/test/files/neg/t4457_2.check b/test/files/neg/t4457_2.check index b1310f74ed50..d0be6d48ef38 100644 --- a/test/files/neg/t4457_2.check +++ b/test/files/neg/t4457_2.check @@ -10,4 +10,20 @@ and method aFunc in object ImplicitConvAmbiguity2 of type [A](a: ImplicitConvAm match argument types (Float) bFunc(aFunc(4F)) ^ +t4457_2.scala:11: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.NE[Float]) + implicit def conv1(i: Float) = new NE[Float] + ^ +t4457_2.scala:12: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[java.util.TooManyListenersException]) + implicit def conv3(op: AA[java.util.TooManyListenersException]) = new N[java.util.TooManyListenersException] + ^ +t4457_2.scala:13: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[Float]) + implicit def conv4(op: AA[Float]) = new N[Float] + ^ +t4457_2.scala:14: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.NZ[Float]) + implicit def conv7(i: Float) = new NZ[Float] + ^ +t4457_2.scala:15: warning: Implicit definition should have explicit type (inferred ImplicitConvAmbiguity2.N[java.util.GregorianCalendar]) + implicit def conv5(e: BB[java.util.GregorianCalendar]) = new N[java.util.GregorianCalendar] + ^ +5 warnings 2 errors diff --git a/test/files/neg/t4568.check b/test/files/neg/t4568.check index 3582e24b188a..604948e41b47 100644 --- a/test/files/neg/t4568.check +++ b/test/files/neg/t4568.check @@ -1,4 +1,8 @@ t4568.scala:8: error: recursive method isSubListOf needs result type case h :: t => y.contains(h) && (t.isSubListOf(y.drop(y.indexOf(h) + 1))) ^ +t4568.scala:2: warning: Implicit definition should have explicit type (inferred SubList.SubListable[A]) + implicit def sublistable[A](x: List[A]) = new SubListable(x) + ^ +1 warning 1 error diff --git a/test/files/neg/t4889.check b/test/files/neg/t4889.check index 96e9b7528e67..e643dd1ffc05 100644 --- a/test/files/neg/t4889.check +++ b/test/files/neg/t4889.check @@ -1,4 +1,8 @@ t4889.scala:19: error: could not find implicit value for parameter ma1: t4889.MatrixAdder[Int,[S]t4889.SparseMatrix[S]] m1.foo ^ +t4889.scala:14: warning: Implicit definition should have explicit type (inferred t4889.MatrixAdder[S,R]) + implicit def adderImplicit[S, R[s] <: Matrix[s, R]] = new MatrixAdder[S, R] { + ^ +1 warning 1 error diff --git a/test/files/neg/t5265a.check b/test/files/neg/t5265a.check new file mode 100644 index 000000000000..f788868ec4b0 --- /dev/null +++ b/test/files/neg/t5265a.check @@ -0,0 +1,18 @@ +t5265a.scala:7: warning: Implicit definition should have explicit type (inferred T[String]) + implicit val tsMissing = new T[String] {} // warn val in trait + ^ +t5265a.scala:20: warning: Implicit definition should have explicit type (inferred T[String]) + implicit val tsChild = new T[String] {} // warn because inferred from RHS + ^ +t5265a.scala:22: warning: Implicit definition should have explicit type (inferred Int) + implicit private[this] val pChild = 42 // also warn + ^ +t5265a.scala:27: warning: Implicit definition should have explicit type (inferred Int) + implicit private[this] val y = 42 // also warn + ^ +t5265a.scala:25: warning: Implicit definition should have explicit type (inferred T[String]) + implicit val tsD = new T[String] {} // warn val in class + ^ +error: No warnings can be incurred under -Werror. +5 warnings +1 error diff --git a/test/files/neg/t5265a.scala b/test/files/neg/t5265a.scala new file mode 100644 index 000000000000..80b127e1adeb --- /dev/null +++ b/test/files/neg/t5265a.scala @@ -0,0 +1,32 @@ +// scalac: -Werror +trait T[A] + +class C[A: T] + +trait Missing { + implicit val tsMissing = new T[String] {} // warn val in trait + def f = new C[String] +} +trait Local { + def f = { + implicit val tsLocal = new T[String] {} // nowarn because local + new C[String] + } +} +trait Parent { + def t: T[String] +} +trait Child extends Parent { + implicit val tsChild = new T[String] {} // warn because inferred from RHS + def f = new C[String] + implicit private[this] val pChild = 42 // also warn +} +class D { + implicit val tsD = new T[String] {} // warn val in class + def f = new C[String] + implicit private[this] val y = 42 // also warn +} +class X extends Missing +trait Z { + val z = 42 +} diff --git a/test/files/neg/t5265b.check b/test/files/neg/t5265b.check new file mode 100644 index 000000000000..97f96fd82be1 --- /dev/null +++ b/test/files/neg/t5265b.check @@ -0,0 +1,4 @@ +t5265b.scala:7: error: Implicit definition must have explicit type (inferred T[String]) + implicit val tsMissing = new T[String] {} // warn val in trait + ^ +1 error diff --git a/test/files/neg/t5265b.scala b/test/files/neg/t5265b.scala new file mode 100644 index 000000000000..19512c3c9180 --- /dev/null +++ b/test/files/neg/t5265b.scala @@ -0,0 +1,22 @@ +// scalac: -Werror -Xlint -Xsource:3 +trait T[A] + +class C[A: T] + +trait Missing { + implicit val tsMissing = new T[String] {} // warn val in trait + def f = new C[String] +} +trait Local { + def f = { + implicit val tsLocal = new T[String] {} // nowarn because local + new C[String] + } +} +trait Parent { + def tsChild: T[String] +} +trait Child extends Parent { + implicit val tsChild = new T[String] {} // nowarn because inferred from overridden + def f = new C[String] +} diff --git a/test/files/neg/t5728.check b/test/files/neg/t5728.check index 7a80af2af06d..72a0c0273005 100644 --- a/test/files/neg/t5728.check +++ b/test/files/neg/t5728.check @@ -1,4 +1,8 @@ t5728.scala:3: error: implicit classes must accept exactly one primary constructor parameter implicit class Foo ^ +t5728.scala:5: warning: Implicit definition should have explicit type (inferred Test.Foo) + implicit def Foo = new Foo + ^ +1 warning 1 error diff --git a/test/files/neg/t6436.check b/test/files/neg/t6436.check index 27f4466572e5..2d74aa8c2a78 100644 --- a/test/files/neg/t6436.check +++ b/test/files/neg/t6436.check @@ -7,4 +7,11 @@ Note that implicit conversions are not applicable because they are ambiguous: are possible conversion functions from StringContext to ?{def q: ?} println(q"a") ^ +t6436.scala:2: warning: Implicit definition should have explicit type (inferred AnyRef{def q: Nothing}) + implicit def foo1(ctx: StringContext) = new { def q = ??? } + ^ +t6436.scala:3: warning: Implicit definition should have explicit type (inferred AnyRef{def q: Nothing}) + implicit def foo2(ctx: StringContext) = new { def q = ??? } + ^ +2 warnings 1 error diff --git a/test/files/neg/t6436b.check b/test/files/neg/t6436b.check index be9b17a4e387..8e33d7bb134a 100644 --- a/test/files/neg/t6436b.check +++ b/test/files/neg/t6436b.check @@ -7,4 +7,11 @@ Note that implicit conversions are not applicable because they are ambiguous: are possible conversion functions from StringContext to ?{def q: ?} println(StringContext("a").q()) ^ +t6436b.scala:2: warning: Implicit definition should have explicit type (inferred AnyRef{def q: Nothing}) + implicit def foo1(ctx: StringContext) = new { def q = ??? } + ^ +t6436b.scala:3: warning: Implicit definition should have explicit type (inferred AnyRef{def q: Nothing}) + implicit def foo2(ctx: StringContext) = new { def q = ??? } + ^ +2 warnings 1 error diff --git a/test/files/neg/t6567.check b/test/files/neg/t6567.check index 5ae946a4c1ac..552f4cbd48df 100644 --- a/test/files/neg/t6567.check +++ b/test/files/neg/t6567.check @@ -1,3 +1,6 @@ +t6567.scala:8: warning: Implicit definition should have explicit type (inferred B) + implicit def a2b(a: A) = new B + ^ t6567.scala:10: warning: Suspicious application of an implicit view (Test.this.a2b) in the argument to Option.apply. Option[B](a) ^ @@ -6,5 +9,5 @@ t6567.scala:12: warning: Suspicious application of an implicit view (Test.this.a ^ warning: 1 feature warning; re-run with -feature for details error: No warnings can be incurred under -Werror. -3 warnings +4 warnings 1 error diff --git a/test/files/neg/t6667.check b/test/files/neg/t6667.check index 1fe4a15e593e..7a1da161e592 100644 --- a/test/files/neg/t6667.check +++ b/test/files/neg/t6667.check @@ -1,13 +1,17 @@ -t6667.scala:8: error: ambiguous implicit values: +t6667.scala:9: error: ambiguous implicit values: both value inScope1 in object Test of type C and value inScope2 in object Test of type C match expected type C implicitly[C]: Unit // C.companion was used; whereas the ambiguity should abort the implicit search. ^ -t6667.scala:9: error: ambiguous implicit values: +t6667.scala:10: error: ambiguous implicit values: both value inScope1 in object Test of type C and value inScope2 in object Test of type C match expected type C implicitly[C] // ambiguity reported, rather than falling back to C.companion ^ +t6667.scala:3: warning: Implicit definition should have explicit type (inferred C) + implicit def companion = new C + ^ +1 warning 2 errors diff --git a/test/files/neg/t6667.scala b/test/files/neg/t6667.scala index fb857ebd3322..1db377d30bef 100644 --- a/test/files/neg/t6667.scala +++ b/test/files/neg/t6667.scala @@ -4,7 +4,8 @@ object C { } object Test { - implicit val inScope1, inScope2 = new C + implicit val inScope1: C = new C + implicit val inScope2: C = new C implicitly[C]: Unit // C.companion was used; whereas the ambiguity should abort the implicit search. implicitly[C] // ambiguity reported, rather than falling back to C.companion } diff --git a/test/files/neg/t692.check b/test/files/neg/t692.check index 670495f6467d..42e2a1b8f2c6 100644 --- a/test/files/neg/t692.check +++ b/test/files/neg/t692.check @@ -16,4 +16,8 @@ t692.scala:14: error: class Foo takes type parameters t692.scala:19: error: class Foo takes type parameters class Bar[A <: Foo](implicit tpeA : Type[A]) extends Foo; ^ +t692.scala:11: warning: Implicit definition should have explicit type (inferred test3.this.FooType) + implicit def typeOfFoo = FooType(); + ^ +1 warning 6 errors diff --git a/test/files/neg/t712.check b/test/files/neg/t712.check index fc8f7824f2c7..606e41f04d92 100644 --- a/test/files/neg/t712.check +++ b/test/files/neg/t712.check @@ -1,4 +1,11 @@ t712.scala:10: error: overloaded method coerce needs result type implicit def coerce(p : ParentImpl) = p.self; ^ +t712.scala:3: warning: Implicit definition should have explicit type (inferred A.this.Node) + implicit def coerce(n : NodeImpl) = n.self; + ^ +t712.scala:10: warning: Implicit definition should have explicit type + implicit def coerce(p : ParentImpl) = p.self; + ^ +2 warnings 1 error diff --git a/test/files/neg/t7131.check b/test/files/neg/t7131.check index c66f1b4f927c..86df78172b9c 100644 --- a/test/files/neg/t7131.check +++ b/test/files/neg/t7131.check @@ -4,4 +4,11 @@ t7131.scala:21: error: type mismatch; Note: implicit method convertToSimpleMappable is not applicable here because it comes after the application point and it lacks an explicit result type x.value.map(f) ^ +t7131.scala:28: warning: Implicit definition should have explicit type (inferred ObservableValue.TraversableMappable[T,Container]) + implicit def convertToTraversableMappable[T, Container[X] <: Traversable[X]](x: ObservableValue[Container[T]]) = + ^ +t7131.scala:43: warning: Implicit definition should have explicit type (inferred ObservableValue.NestedMappable[T,Container]) + implicit def convertToSimpleMappable[T, Container[X] <: ObservableValue.HasMap[X, Container]](x: ObservableValue[Container[T]]) = + ^ +2 warnings 1 error diff --git a/test/files/neg/t7212.check b/test/files/neg/t7212.check new file mode 100644 index 000000000000..8f1fe20edcb4 --- /dev/null +++ b/test/files/neg/t7212.check @@ -0,0 +1,16 @@ +t7212.scala:8: error: type mismatch; + found : Object + required: String + val s: String = k.f + ^ +t7212.scala:14: error: type mismatch; + found : Object + required: String + val s: String = f.f + ^ +t7212.scala:21: error: type mismatch; + found : Object + required: String + val s: String = w.f + ^ +3 errors diff --git a/test/files/neg/t7212.scala b/test/files/neg/t7212.scala new file mode 100644 index 000000000000..5dd16a6c8091 --- /dev/null +++ b/test/files/neg/t7212.scala @@ -0,0 +1,22 @@ + +// scalac: -Xsource:3 + +trait T { def f: Object } +class K extends T { def f = "" } +object K { + val k = new K + val s: String = k.f +} + +class F extends T { val f = "" } +object F { + val f = new F + val s: String = f.f +} + +trait V extends T { var f = "" } +class W extends V +object W { + val w = new W + val s: String = w.f +} diff --git a/test/files/neg/t729.check b/test/files/neg/t729.check index 050772cf84b9..7680b2fdfa4b 100644 --- a/test/files/neg/t729.check +++ b/test/files/neg/t729.check @@ -3,4 +3,11 @@ t729.scala:20: error: type mismatch; required: ScalaParserAutoEdit.this.NodeImpl(in trait ScalaParserAutoEdit) val yyy : NodeImpl = link.from; ^ +t729.scala:3: warning: Implicit definition should have explicit type (inferred Parser.this.Node) + implicit def coerce(n : NodeImpl) = n.self; + ^ +t729.scala:14: warning: Implicit definition should have explicit type (inferred ScalaParserAutoEdit.this.Node) + implicit def coerce(node : NodeImpl) = node.self; + ^ +2 warnings 1 error diff --git a/test/files/neg/t8322.check b/test/files/neg/t8322.check index 6c3f9a5e53ce..bc56230cd385 100644 --- a/test/files/neg/t8322.check +++ b/test/files/neg/t8322.check @@ -13,4 +13,11 @@ t8322.scala:19: error: type mismatch; required: scala.util.Either[?,?] Right(0).right.flatMap(_ => new String()) ^ +t8322.scala:15: warning: Implicit definition should have explicit type (inferred Writes[Seq[E]]) + implicit def rw[E] = Writes[Seq[E]] { _ => "" } + ^ +t8322.scala:17: warning: Implicit definition should have explicit type + implicit def wr[E] = jw(implicitly, implicitly) + ^ +2 warnings 3 errors diff --git a/test/files/pos/t7212.scala b/test/files/pos/t7212.scala index 1c1a3f07a2c2..4b53c034ff1f 100644 --- a/test/files/pos/t7212.scala +++ b/test/files/pos/t7212.scala @@ -13,3 +13,14 @@ class C extends B { override def f: Option[String] = Some("goodbye, cruel world") override def remove(): Unit = println("removed! (not really)") } + +trait T { def f: Object } +class K extends T { def f = "" } +object K { + val k = new K + val s: Any = k.f +} + +trait U extends T { def f = "" } +trait V { var v: Any } +trait W extends V { var v = "" } diff --git a/test/files/run/Meter.scala b/test/files/run/Meter.scala index 9fa8a7babd7d..7ef9d247e1ba 100644 --- a/test/files/run/Meter.scala +++ b/test/files/run/Meter.scala @@ -23,7 +23,7 @@ package a { def apply(x: Double): Meter = new Meter(x) - implicit val boxings = new BoxingConversions[Meter, Double] { + implicit val boxings: BoxingConversions[Meter, Double] = new BoxingConversions[Meter, Double] { def box(x: Double) = new Meter(x) def unbox(m: Meter) = m.underlying } @@ -35,7 +35,7 @@ package a { override def toString = unbox.toString+"ft" } object Foot { - implicit val boxings = new BoxingConversions[Foot, Double] { + implicit val boxings: BoxingConversions[Foot, Double] = new BoxingConversions[Foot, Double] { def box(x: Double) = new Foot(x) def unbox(m: Foot) = m.unbox } diff --git a/test/files/run/MeterCaseClass.scala b/test/files/run/MeterCaseClass.scala index 8c15bbb6d30b..1f40dc5e7dbc 100644 --- a/test/files/run/MeterCaseClass.scala +++ b/test/files/run/MeterCaseClass.scala @@ -20,7 +20,7 @@ package a { private[a] trait MeterArg - implicit val boxings = new BoxingConversions[Meter, Double] { + implicit val boxings: BoxingConversions[Meter, Double] = new BoxingConversions[Meter, Double] { def box(x: Double) = new Meter(x) def unbox(m: Meter) = m.underlying } @@ -32,7 +32,7 @@ package a { override def toString = unbox.toString+"ft" } object Foot { - implicit val boxings = new BoxingConversions[Foot, Double] { + implicit val boxings: BoxingConversions[Foot, Double] = new BoxingConversions[Foot, Double] { def box(x: Double) = new Foot(x) def unbox(m: Foot) = m.unbox } diff --git a/test/files/run/idempotency-lazy-vals.scala b/test/files/run/idempotency-lazy-vals.scala index 8688add3e699..236e1516137c 100644 --- a/test/files/run/idempotency-lazy-vals.scala +++ b/test/files/run/idempotency-lazy-vals.scala @@ -7,7 +7,7 @@ object Test extends App { val lazee = reify { class C { lazy val x = 2 - implicit lazy val y = 3 + implicit lazy val y: Int = 3 } val c = new C() import c._ diff --git a/test/files/run/impconvtimes.scala b/test/files/run/impconvtimes.scala index 477a16a8903d..d377685a9c77 100644 --- a/test/files/run/impconvtimes.scala +++ b/test/files/run/impconvtimes.scala @@ -9,7 +9,7 @@ object Test { def *(newUnit: Unit) = Measure(scalar, newUnit) } - implicit def double2Measure(scalar: Double) = + implicit def double2Measure(scalar: Double): Measure = Measure(scalar, NoUnit) diff --git a/test/files/run/implicits.scala b/test/files/run/implicits.scala index 5681a9d484dc..fbc8536c041b 100644 --- a/test/files/run/implicits.scala +++ b/test/files/run/implicits.scala @@ -2,7 +2,7 @@ import scala.language.implicitConversions object A { object B { - implicit def int2string(x: Int) = "["+x.toString+"]" + implicit def int2string(x: Int): String = "["+x.toString+"]" } } diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala index 46367cd1a307..a126bd813d46 100644 --- a/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala +++ b/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala @@ -1,6 +1,6 @@ import scala.language.experimental.macros object Test extends App { - implicit val x = 42 + implicit val x: Int = 42 def foo(implicit x: Int): Unit = macro Impls.foo foo } diff --git a/test/files/run/macro-implicit-decorator/Test_2.scala b/test/files/run/macro-implicit-decorator/Test_2.scala index bfcb57986997..88c60d91b09f 100644 --- a/test/files/run/macro-implicit-decorator/Test_2.scala +++ b/test/files/run/macro-implicit-decorator/Test_2.scala @@ -5,9 +5,9 @@ class CustomClass trait MyTC[A] object MyTC { - implicit val forInt = new MyTC[Int] {} - implicit def forList[A](implicit a: Derivation[MyTC[A]]) = new MyTC[List[A]] {} - implicit def forCustomClass(implicit a: Derivation[MyTC[List[Boolean]]]) = new MyTC[CustomClass] {} + implicit val forInt: MyTC[Int] = new MyTC[Int] {} + implicit def forList[A](implicit a: Derivation[MyTC[A]]): MyTC[List[A]] = new MyTC[List[A]] {} + implicit def forCustomClass(implicit a: Derivation[MyTC[List[Boolean]]]): MyTC[CustomClass] = new MyTC[CustomClass] {} } object Test extends App { diff --git a/test/files/run/reflection-implicit.scala b/test/files/run/reflection-implicit.scala index a6e939322ad5..1e104d1e5809 100644 --- a/test/files/run/reflection-implicit.scala +++ b/test/files/run/reflection-implicit.scala @@ -3,7 +3,7 @@ import scala.language.implicitConversions import scala.reflect.runtime.universe._ class C { - implicit val v = new C + implicit val v: C = new C implicit def d(x: C)(implicit c: C): Int = ??? implicit class X(val x: Int) } diff --git a/test/files/run/repl-class-based-implicit-import.check b/test/files/run/repl-class-based-implicit-import.check index 9ad75cba7540..85d97a78c1fd 100644 --- a/test/files/run/repl-class-based-implicit-import.check +++ b/test/files/run/repl-class-based-implicit-import.check @@ -2,7 +2,7 @@ scala> def showInt(implicit x: Int) = println(x) def showInt(implicit x: Int): Unit -scala> object IntHolder { implicit val myInt = 5 } +scala> object IntHolder { implicit val myInt: Int = 5 } object IntHolder scala> import IntHolder.myInt diff --git a/test/files/run/repl-class-based-implicit-import.scala b/test/files/run/repl-class-based-implicit-import.scala index 9153c8e08f7f..133c99969f66 100644 --- a/test/files/run/repl-class-based-implicit-import.scala +++ b/test/files/run/repl-class-based-implicit-import.scala @@ -11,7 +11,7 @@ object Test extends ReplTest { def code = """ |def showInt(implicit x: Int) = println(x) - |object IntHolder { implicit val myInt = 5 } + |object IntHolder { implicit val myInt: Int = 5 } |import IntHolder.myInt |showInt |class A; showInt diff --git a/test/files/run/repl-no-imports-no-predef-power.check b/test/files/run/repl-no-imports-no-predef-power.check index 64c4b37b92e2..52140e1b5c2c 100644 --- a/test/files/run/repl-no-imports-no-predef-power.check +++ b/test/files/run/repl-no-imports-no-predef-power.check @@ -11,7 +11,6 @@ warning: 1 deprecation (since 2.11.0); for details, enable `:setting -deprecatio val res0: $r.global.noSelfType.type = private val _ = _ scala> val tp = ArrayClass[scala.util.Random] // magic with tags -warning: 1 feature warning; for details, enable `:setting -feature` or `:replay -feature` val tp: $r.global.Type = Array[scala.util.Random] scala> tp.memberType(Array_apply) // evidence diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index 64c4b37b92e2..52140e1b5c2c 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -11,7 +11,6 @@ warning: 1 deprecation (since 2.11.0); for details, enable `:setting -deprecatio val res0: $r.global.noSelfType.type = private val _ = _ scala> val tp = ArrayClass[scala.util.Random] // magic with tags -warning: 1 feature warning; for details, enable `:setting -feature` or `:replay -feature` val tp: $r.global.Type = Array[scala.util.Random] scala> tp.memberType(Array_apply) // evidence diff --git a/test/files/run/sip23-implicit-resolution.scala b/test/files/run/sip23-implicit-resolution.scala index 5d83f89c43b1..beef7ae73e9f 100644 --- a/test/files/run/sip23-implicit-resolution.scala +++ b/test/files/run/sip23-implicit-resolution.scala @@ -4,11 +4,11 @@ object Test extends App { def mkAssoc[K, V0](k: K, v0: V0): Assoc[k.type] { type V = V0 } = new Assoc[k.type] {type V = V0 ; val v = v0} def lookup[K](k: K)(implicit a: Assoc[k.type]): a.V = a.v - implicit def firstAssoc = mkAssoc(1, "Panda!") - implicit def secondAssoc = mkAssoc(2, "Kitty!") + implicit def firstAssoc: Assoc[1] { type V = String } = mkAssoc(1, "Panda!") + implicit def secondAssoc: Assoc[2] { type V = String } = mkAssoc(2, "Kitty!") - implicit def ageAssoc = mkAssoc("Age", 3) - implicit def nmAssoc = mkAssoc("Name", "Jane") + implicit def ageAssoc: Assoc["Age"] { type V = Int } = mkAssoc("Age", 3) + implicit def nmAssoc: Assoc["Name"] { type V = String } = mkAssoc("Name", "Jane") assert(lookup(1) == "Panda!") assert(lookup(2) == "Kitty!") diff --git a/test/files/run/t2316_run.scala b/test/files/run/t2316_run.scala index 19d326f57f1a..2a17886aea46 100644 --- a/test/files/run/t2316_run.scala +++ b/test/files/run/t2316_run.scala @@ -1,7 +1,7 @@ case class T1(source: String) object T1 { - implicit def T1FromT2(implicit t2: T2) = new T1(t2.source) + implicit def T1FromT2(implicit t2: T2): T1 = new T1(t2.source) } case class T2(source: String) @@ -10,7 +10,7 @@ object A { def requireT1(implicit t1: T1) = t1 object B1 { - implicit val t2_b1 = new T2("from B1") + implicit val t2_b1: T2 = new T2("from B1") requireT1 } diff --git a/test/files/run/t2514.scala b/test/files/run/t2514.scala index 0bf716e8bbf6..6a58c8f63c36 100644 --- a/test/files/run/t2514.scala +++ b/test/files/run/t2514.scala @@ -2,9 +2,8 @@ import scala.language.{ implicitConversions, postfixOps, reflectiveCalls } -object Test -{ - implicit def x[A](a: A) = new { def xx = a } +object Test { + implicit def x[A](a: A): AnyRef{def xx: A} = new { def xx = a } def main(args: Array[String]): Unit = { val r1 = 12 xx; diff --git a/test/files/run/t2866.scala b/test/files/run/t2866.scala index c1583e91ace9..7c65e3c406bd 100644 --- a/test/files/run/t2866.scala +++ b/test/files/run/t2866.scala @@ -1,7 +1,7 @@ // for 2.7.x compatibility object A { - implicit val one = 1 + implicit val one: Int = 1 } object Test extends App { diff --git a/test/files/run/t3346d.scala b/test/files/run/t3346d.scala index 118318dee67d..261028dea3a9 100644 --- a/test/files/run/t3346d.scala +++ b/test/files/run/t3346d.scala @@ -11,7 +11,7 @@ object Test extends App { def create(v: A): Basket[A,B] } - implicit val bf = new BasketFactory[Int,TARInt] { + implicit val bf: BasketFactory[Int,TARInt] = new BasketFactory[Int,TARInt] { def create(v: Int): Basket[Int,TARInt] = new Basket[Int, TARInt]{} } diff --git a/test/files/run/t3346e.scala b/test/files/run/t3346e.scala index 8f75eb97edd3..66bba85818f6 100644 --- a/test/files/run/t3346e.scala +++ b/test/files/run/t3346e.scala @@ -47,9 +47,9 @@ class FilterMapFixed[A, Repr <% IterableOps[A, Iterable, _]](a: Repr) { } object MyEnhancements { - implicit def toQS[Coll](a: Coll) = new QuickSort(a) - implicit def toFM[Coll](a: Coll) = new FilterMap(a) - implicit def toFM2[A, Repr <% IterableOps[A, Iterable, _]](a: Repr) = new FilterMapFixed(a) + implicit def toQS[Coll](a: Coll): QuickSort[Coll] = new QuickSort(a) + implicit def toFM[Coll](a: Coll): FilterMap[Coll] = new FilterMap(a) + implicit def toFM2[A, Repr <% IterableOps[A, Iterable, _]](a: Repr): FilterMapFixed[A,Repr] = new FilterMapFixed(a) } object Test extends App { diff --git a/test/files/run/t3346f.scala b/test/files/run/t3346f.scala index 4799ca2ca9a5..b2dc16de5bfd 100644 --- a/test/files/run/t3346f.scala +++ b/test/files/run/t3346f.scala @@ -4,11 +4,11 @@ import scala.language.reflectiveCalls object Test extends App { trait Foo[A] implicit def fooString: Foo[String] = null - implicit def value[A](implicit foo: Foo[A]) = 5 + implicit def value[A](implicit foo: Foo[A]): Int = 5 println(implicitly[Int]) - implicit def conversion[A](x: Int)(implicit foo: Foo[A]) = new { + implicit def conversion[A](x: Int)(implicit foo: Foo[A]): AnyRef{def aMethod: Int} = new { def aMethod = 5 } println(1.aMethod) diff --git a/test/files/run/t3346h.check b/test/files/run/t3346h.check deleted file mode 100644 index 587be6b4c3f9..000000000000 --- a/test/files/run/t3346h.check +++ /dev/null @@ -1 +0,0 @@ -x diff --git a/test/files/run/t3346h.scala b/test/files/run/t3346h.scala index 642b7cf58505..3e94e25df7ed 100644 --- a/test/files/run/t3346h.scala +++ b/test/files/run/t3346h.scala @@ -3,7 +3,7 @@ import scala.language.implicitConversions object Test extends App { trait Fundep[T, U] { def u(t: T): U } class C { def y = "x" } - implicit val FundepStringC = new Fundep[String, C]{ def u(t: String) = new C } + implicit val FundepStringC: Fundep[String,C] = new Fundep[String, C]{ def u(t: String) = new C } implicit def foo[T, U](x: T)(implicit y: Fundep[T, U]): U = y.u(x) - println("x".y) + assert("x".y == "x") } diff --git a/test/files/run/t3346j.scala b/test/files/run/t3346j.scala index 719d11819af4..bfacb6d0e17a 100644 --- a/test/files/run/t3346j.scala +++ b/test/files/run/t3346j.scala @@ -5,7 +5,7 @@ import scala.reflect.runtime.universe._ object Test extends App { class A[T] class B[T] - implicit def foo[T: TypeTag](a: A[T])(implicit b: B[T]) = new { def baz = typeOf[T] } + implicit def foo[T: TypeTag](a: A[T])(implicit b: B[T]): AnyRef{def baz: reflect.runtime.universe.Type} = new { def baz = typeOf[T] } implicit def bar[T <: Int]: B[T] = new B[T]() println(new A[Int]().baz) } diff --git a/test/files/run/t5080.scala b/test/files/run/t5080.scala index acb6167f4652..8d0d04fd60ec 100644 --- a/test/files/run/t5080.scala +++ b/test/files/run/t5080.scala @@ -11,7 +11,7 @@ object Test extends App { override def toString = value.toString; } - implicit def conversions(x: Value) = new { + implicit def conversions(x: Value): AnyRef { def toInt: Int } = new { def toInt = x match { case Num(n) => n diff --git a/test/files/run/t5276_2b.scala b/test/files/run/t5276_2b.scala index 9cc789ec22c8..eb3d744befa4 100644 --- a/test/files/run/t5276_2b.scala +++ b/test/files/run/t5276_2b.scala @@ -4,7 +4,7 @@ import scala.tools.reflect.Eval object Test extends App { reify { class C { - implicit lazy val x = 2 + implicit lazy val x: Int = 2 def y = implicitly[Int] } diff --git a/test/files/run/t5565.scala b/test/files/run/t5565.scala index 9ced87ca21a7..3c9ed24003af 100644 --- a/test/files/run/t5565.scala +++ b/test/files/run/t5565.scala @@ -1,7 +1,9 @@ +import scala.annotation.nowarn import scala.language.reflectiveCalls import scala.language.implicitConversions object Test extends App { + @nowarn // the inferred type includes the default arg, which can't be written explicitly implicit def doubleWithApproxEquals(d: Double) = new { def ~==(v: Double, margin: Double = 0.001): Boolean = math.abs(d - v) < margin @@ -10,3 +12,11 @@ object Test extends App { assert(math.abs(-4.0) ~== (4.0, 0.001)) assert(math.abs(-4.0) ~== 4.0) } +/* +was: +Exception in thread "main" java.lang.IllegalAccessError: tried to access field illegal_access_error_test_case$.reflParams$Cache2 from class illegal_access_error_test_case$delayedInit$body + at illegal_access_error_test_case$delayedInit$body.(illegal_access_error_test_case.scala:8) + at illegal_access_error_test_case$.(illegal_access_error_test_case.scala:1) + at illegal_access_error_test_case$.(illegal_access_error_test_case.scala) + at illegal_access_error_test_case.main(illegal_access_error_test_case.scala) + */ diff --git a/test/files/run/t6290.scala b/test/files/run/t6290.scala index 9d05db0d1885..4a5ac1cf4d14 100644 --- a/test/files/run/t6290.scala +++ b/test/files/run/t6290.scala @@ -1,4 +1,5 @@ object Test { - implicit val foo = language.dynamics + import languageFeature._ + implicit val foo: dynamics = language.dynamics def main(args: Array[String]): Unit = () } diff --git a/test/files/run/t6327.scala b/test/files/run/t6327.scala index 4a2f6c3ee88f..7ebba247b871 100644 --- a/test/files/run/t6327.scala +++ b/test/files/run/t6327.scala @@ -7,8 +7,8 @@ object Test extends App { case class R[+T](s: String) { def x() = println(s) } // Implicits in contention; StringR is nested to avoid ambiguity - object R { implicit val StringR = R[String]("A") } - implicit val Default = R[Any]("B") + object R { implicit val StringR: R[String] = R[String]("A") } + implicit val Default: R[Any] = R[Any]("B") class B() extends Dynamic { def selectDynamic[T](f: String)(implicit r: R[T]): Unit = r.x() diff --git a/test/files/run/t657.scala b/test/files/run/t657.scala index d7f882b4342a..882c9bf3fb71 100644 --- a/test/files/run/t657.scala +++ b/test/files/run/t657.scala @@ -4,7 +4,7 @@ import scala.language.{ implicitConversions } abstract class BaseList { type Node <: BaseNodeImpl - implicit def convertNode(ni : BaseNodeImpl) = ni.asInstanceOf[Node]; + implicit def convertNode(ni : BaseNodeImpl): Node = ni.asInstanceOf[Node]; abstract class BaseNodeImpl } abstract class LinkedList extends BaseList { @@ -33,7 +33,7 @@ trait Matcher extends PrecedenceParser { trait NodeImpl4 extends super.NodeImpl3 type Matchable <: Node with MatchableImpl0 - implicit def convertMatchable(m : MatchableImpl0) = m.asInstanceOf[Matchable] + implicit def convertMatchable(m : MatchableImpl0): Matchable = m.asInstanceOf[Matchable] trait MatchableImpl0 extends NodeImpl4 { override def chop : Node = { Console.println("passed"); super.chop; diff --git a/test/files/run/t8564.scala b/test/files/run/t8564.scala index 6d7d1178c4a0..6ffaa75938e2 100644 --- a/test/files/run/t8564.scala +++ b/test/files/run/t8564.scala @@ -13,8 +13,8 @@ object Test extends App { def lookup(k: String)(implicit assoc: Assoc[k.type]): assoc.V = assoc.value - implicit def nameAssoc = mkAssoc("Name", "Mary") - implicit def ageAssoc = mkAssoc("Age", 23) + implicit def nameAssoc: Assoc["Name"] { type V = String } = mkAssoc("Name", "Mary") + implicit def ageAssoc: Assoc["Age"] { type V = Int } = mkAssoc("Age", 23) assert((lookup("Name"): String) == "Mary") assert((lookup("Age"): Int) == 23) diff --git a/test/files/run/tcpoly_parseridioms.scala b/test/files/run/tcpoly_parseridioms.scala index 38455f05eebb..6144fb30dba0 100644 --- a/test/files/run/tcpoly_parseridioms.scala +++ b/test/files/run/tcpoly_parseridioms.scala @@ -103,8 +103,8 @@ trait ParserIdioms extends Parsers with Idioms { // TODO: how can parserIdiom(curry2(_)) be omitted? def expr: Parser[Expr] = parserIdiomFun(curry2(Plus)) <| num <> num |> - implicit def curry2[s, t, u](fun: (s, t) => u)(a: s)(b: t) = fun(a, b) - implicit def curry3[r, s, t, u](fun: (r, s, t) => u)(a: r)(b: s)(c: t) = fun(a, b, c) + implicit def curry2[s, t, u](fun: (s, t) => u)(a: s)(b: t): u = fun(a, b) + implicit def curry3[r, s, t, u](fun: (r, s, t) => u)(a: r)(b: s)(c: t): u = fun(a, b, c) } object Test extends ParserIdioms with App { diff --git a/test/junit/scala/io/SourceTest.scala b/test/junit/scala/io/SourceTest.scala index 0c4a996d1c9f..593b990d0413 100644 --- a/test/junit/scala/io/SourceTest.scala +++ b/test/junit/scala/io/SourceTest.scala @@ -10,7 +10,7 @@ import java.io.{Console => _, _} class SourceTest { - private implicit val `our codec` = Codec.UTF8 + private implicit val `our codec`: Codec = Codec.UTF8 private val charSet = Codec.UTF8.charSet.name private def sampler = """ diff --git a/test/junit/scala/reflect/internal/util/AbstractFileClassLoaderTest.scala b/test/junit/scala/reflect/internal/util/AbstractFileClassLoaderTest.scala index c57ca039a144..0248aebdb990 100644 --- a/test/junit/scala/reflect/internal/util/AbstractFileClassLoaderTest.scala +++ b/test/junit/scala/reflect/internal/util/AbstractFileClassLoaderTest.scala @@ -10,11 +10,11 @@ class AbstractFileClassLoaderTest { import scala.reflect.io._ import scala.io.Source - import scala.io.Codec.UTF8 + import scala.io.Codec, Codec.UTF8 import scala.reflect.io.Streamable import java.net.{ URLClassLoader, URL } - implicit def `we love utf8` = UTF8 + implicit def `we love utf8`: Codec = UTF8 implicit class `abs file ops`(f: AbstractFile) { def writeContent(s: String): Unit = Streamable.closing(f.bufferedOutput)(os => os write s.getBytes(UTF8.charSet)) } diff --git a/test/macro-annot/run/scopes/scopes_2.scala b/test/macro-annot/run/scopes/scopes_2.scala index 451931c14ee8..783c729aef1f 100644 --- a/test/macro-annot/run/scopes/scopes_2.scala +++ b/test/macro-annot/run/scopes/scopes_2.scala @@ -2,7 +2,7 @@ object Test extends App { def assertEquals(a: Any, b: Any): Unit = { assert(a == b, s"$a != $b") } - implicit val x = 42 + implicit val x: Int = 42 @explorer object C // @Test def toplevel: Unit = diff --git a/test/scalacheck/scala/collection/mutable/MutableTreeMap.scala b/test/scalacheck/scala/collection/mutable/MutableTreeMap.scala index 5b06a35725be..b81e9de6fcf6 100644 --- a/test/scalacheck/scala/collection/mutable/MutableTreeMap.scala +++ b/test/scalacheck/scala/collection/mutable/MutableTreeMap.scala @@ -31,8 +31,8 @@ trait Generators { } yield mutable.TreeMap(keys zip values: _*) } - implicit def arbRedBlackTree[A: Arbitrary: Ordering, B: Arbitrary] = Arbitrary(genRedBlackTree[A, B]) - implicit def arbTreeMap[A: Arbitrary: Ordering, B: Arbitrary] = Arbitrary(genTreeMap[A, B]) + implicit def arbRedBlackTree[A: Arbitrary: Ordering, B: Arbitrary]: Arbitrary[RB.Tree[A, B]] = Arbitrary(genRedBlackTree[A, B]) + implicit def arbTreeMap[A: Arbitrary: Ordering, B: Arbitrary]: Arbitrary[mutable.TreeMap[A, B]] = Arbitrary(genTreeMap[A, B]) } object RedBlackTreeProperties extends Properties("mutable.RedBlackTree") with Generators { @@ -218,7 +218,7 @@ object MutableTreeMapProjectionProperties extends Properties("mutable.TreeMapPro type K = String type V = Int - implicit val ord = implicitly[Ordering[K]] + implicit val ord: Ordering[K] = implicitly[Ordering[K]] def in(key: K, from: Option[K], until: Option[K]) = from.fold(true)(_ <= key) && until.fold(true)(_ > key) diff --git a/test/scalacheck/scala/collection/mutable/MutableTreeSet.scala b/test/scalacheck/scala/collection/mutable/MutableTreeSet.scala index 39a44ae453e7..1e3b2a359c21 100644 --- a/test/scalacheck/scala/collection/mutable/MutableTreeSet.scala +++ b/test/scalacheck/scala/collection/mutable/MutableTreeSet.scala @@ -117,7 +117,7 @@ object MutableTreeSetProperties extends Properties("mutable.TreeSet") { object MutableTreeSetProjectionProperties extends Properties("mutable.TreeSetProjection") { type K = String - implicit val ord = implicitly[Ordering[K]] + implicit val ord: Ordering[K] = implicitly[Ordering[K]] def in(key: K, from: Option[K], until: Option[K]) = from.fold(true)(_ <= key) && until.fold(true)(_ > key) diff --git a/test/scalacheck/scala/reflect/quasiquotes/ArbitraryTreesAndNames.scala b/test/scalacheck/scala/reflect/quasiquotes/ArbitraryTreesAndNames.scala index 19032a2d0fb7..bc6e6089c231 100644 --- a/test/scalacheck/scala/reflect/quasiquotes/ArbitraryTreesAndNames.scala +++ b/test/scalacheck/scala/reflect/quasiquotes/ArbitraryTreesAndNames.scala @@ -267,8 +267,8 @@ trait ArbitraryTreesAndNames { def genTreeIsTypeWrapped(size: Int) = for(tit <- genTreeIsType(size)) yield TreeIsType(tit) - implicit val liftTreeIsTerm = Liftable[TreeIsTerm] { _.tree } - implicit val liftTreeIsType = Liftable[TreeIsType] { _.tree } + implicit val liftTreeIsTerm: Liftable[TreeIsTerm] = Liftable[TreeIsTerm] { _.tree } + implicit val liftTreeIsType: Liftable[TreeIsType] = Liftable[TreeIsType] { _.tree } implicit def treeIsTerm2tree(tit: TreeIsTerm): Tree = tit.tree implicit def treeIsType2tree(tit: TreeIsType): Tree = tit.tree diff --git a/test/scalacheck/treemap.scala b/test/scalacheck/treemap.scala index 83fb586b5192..1df3424c2064 100644 --- a/test/scalacheck/treemap.scala +++ b/test/scalacheck/treemap.scala @@ -12,7 +12,7 @@ object TreeMapTest extends Properties("TreeMap") { keys <- listOf(arbitrary[A]) values <- listOfN(keys.size, arbitrary[B]) } yield TreeMap(keys zip values: _*) - implicit def arbTreeMap[A : Arbitrary : Ordering, B : Arbitrary] = Arbitrary(genTreeMap[A, B]) + implicit def arbTreeMap[A : Arbitrary : Ordering, B : Arbitrary]: Arbitrary[TreeMap[A, B]] = Arbitrary(genTreeMap[A, B]) property("foreach/iterator consistency") = forAll { (subject: TreeMap[Int, String]) => val it = subject.iterator diff --git a/test/scaladoc/run/diagrams-base.check b/test/scaladoc/run/diagrams-base.check index 619c56180bb9..ec9c6d6a74f2 100644 --- a/test/scaladoc/run/diagrams-base.check +++ b/test/scaladoc/run/diagrams-base.check @@ -1 +1,10 @@ +newSource:10: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.diagrams.T) + object E { implicit def eToT(e: E) = new T } + ^ +newSource:18: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.diagrams.E) + object X { implicit def xToE(x: X) = new E} + ^ +newSource:21: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.diagrams.E) + object Z { implicit def zToE(z: Z) = new E} + ^ Done. diff --git a/test/scaladoc/run/diagrams-filtering.check b/test/scaladoc/run/diagrams-filtering.check index 619c56180bb9..6f40b2c32793 100644 --- a/test/scaladoc/run/diagrams-filtering.check +++ b/test/scaladoc/run/diagrams-filtering.check @@ -1 +1,7 @@ +newSource:30: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.diagrams.T) + implicit def eToT(e: E) = new T + ^ +newSource:31: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.diagrams.A) + implicit def eToA(e: E) = new A { } + ^ Done. diff --git a/test/scaladoc/run/implicits-ambiguating.check b/test/scaladoc/run/implicits-ambiguating.check index 619c56180bb9..f716066eb126 100644 --- a/test/scaladoc/run/implicits-ambiguating.check +++ b/test/scaladoc/run/implicits-ambiguating.check @@ -1 +1,7 @@ +newSource:70: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.ambiguating.X[T]) + implicit def AtoX[T](a: A[T]) = new X[T] + ^ +newSource:71: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.ambiguating.Z[T]) + implicit def AtoZ[T](a: A[T]) = new Z[T] + ^ Done. diff --git a/test/scaladoc/run/implicits-base.check b/test/scaladoc/run/implicits-base.check index 619c56180bb9..e5f9afca6ebf 100644 --- a/test/scaladoc/run/implicits-base.check +++ b/test/scaladoc/run/implicits-base.check @@ -1 +1,19 @@ +newSource:36: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.EnrichedA[V]) + implicit def enrichA0[V](a: A[V]) = new EnrichedA(a) + ^ +newSource:37: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.NumericA[ZBUR]) + implicit def enrichA1[ZBUR: Numeric](a: A[ZBUR]) = new NumericA[ZBUR](a) + ^ +newSource:38: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.IntA) + implicit def enrichA2(a: A[Int]) = new IntA(a) + ^ +newSource:39: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.GtColonDoubleA) + implicit def enrichA3(a: A[T] forSome { type T <: Double }) = new GtColonDoubleA(a) + ^ +newSource:42: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.MyNumericA[Z]) + implicit def enrichA6[Z: MyNumeric](a: A[Z]) = new MyNumericA[Z](a) + ^ +newSource:44: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.base.ManifestA[H] with scala.test.scaladoc.implicits.base.MyTraversableOps[H]) + implicit def enrichA7[H <: Double : Manifest](a: A[H]) = new ManifestA[H](a) with MyTraversableOps[H] { def convToTraversableOps(x: H): H = sys.error("no") } + ^ Done. diff --git a/test/scaladoc/run/implicits-chaining.check b/test/scaladoc/run/implicits-chaining.check index 619c56180bb9..9cbfe46b4ac1 100644 --- a/test/scaladoc/run/implicits-chaining.check +++ b/test/scaladoc/run/implicits-chaining.check @@ -1 +1,16 @@ +newSource:22: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.Implicit1[T]) + implicit def implicit1[T <: Intermediate[_, _]](implicit b: Implicit2[T]) = new Implicit1[T](b) + ^ +newSource:24: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.Implicit2[T]) + implicit def implicit2alt1[T <: Intermediate[_ <: String, _]](implicit c: Implicit3[T]) = new Implicit2[T](c) + ^ +newSource:25: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.Implicit2[T]) + implicit def implicit2alt2[T <: Intermediate[_ <: Double, _]](implicit c: Implicit3[T]) = new Implicit2[T](c) + ^ +newSource:27: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.Implicit3[T]) + implicit def implicit3alt1[T <: Intermediate[_, _ <: Int]] = new Implicit3[T]() + ^ +newSource:28: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.Implicit3[T]) + implicit def implicit3alt2[T <: Intermediate[_ <: Double, _ <: AnyRef],X] = new Implicit3[T]() + ^ Done. diff --git a/test/scaladoc/run/implicits-known-type-classes.check b/test/scaladoc/run/implicits-known-type-classes.check index 619c56180bb9..225b60e6cfe3 100644 --- a/test/scaladoc/run/implicits-known-type-classes.check +++ b/test/scaladoc/run/implicits-known-type-classes.check @@ -1 +1,49 @@ +newSource:13: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[Numeric[T]]) + implicit def convertNumeric [T: Numeric] (a: A[T]) = new B(implicitly[Numeric[T]]) + ^ +newSource:14: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[Integral[T]]) + implicit def convertIntegral [T: Integral] (a: A[T]) = new B(implicitly[Integral[T]]) + ^ +newSource:15: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[Fractional[T]]) + implicit def convertFractional [T: Fractional] (a: A[T]) = new B(implicitly[Fractional[T]]) + ^ +newSource:16: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[Manifest[T]]) + implicit def convertManifest [T: Manifest] (a: A[T]) = new B(implicitly[Manifest[T]]) + ^ +newSource:17: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[reflect.ClassManifest[T]]) + implicit def convertClassManifest [T: ClassManifest] (a: A[T]) = new B(implicitly[ClassManifest[T]]) + ^ +newSource:18: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[OptManifest[T]]) + implicit def convertOptManifest [T: OptManifest] (a: A[T]) = new B(implicitly[OptManifest[T]]) + ^ +newSource:19: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.reflect.ClassTag[T]]) + implicit def convertClassTag [T: ClassTag] (a: A[T]) = new B(implicitly[ClassTag[T]]) + ^ +newSource:20: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[reflect.runtime.universe.TypeTag[T]]) + implicit def convertTypeTag [T: TypeTag] (a: A[T]) = new B(implicitly[TypeTag[T]]) + ^ +newSource:29: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.K[T]]) + implicit def convertK [T: K] (a: A[T]) = new B(implicitly[K[T]]) + ^ +newSource:30: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.L[T]]) + implicit def convertL [T: L] (a: A[T]) = new B(implicitly[L[T]]) + ^ +newSource:31: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.M[T]]) + implicit def convertM [T: M] (a: A[T]) = new B(implicitly[M[T]]) + ^ +newSource:32: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.N[T]]) + implicit def convertN [T: N] (a: A[T]) = new B(implicitly[N[T]]) + ^ +newSource:33: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.O[T]]) + implicit def convertO [T: O] (a: A[T]) = new B(implicitly[O[T]]) + ^ +newSource:34: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.P[T]]) + implicit def convertP [T: P] (a: A[T]) = new B(implicitly[P[T]]) + ^ +newSource:35: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.Q[T]]) + implicit def convertQ [T: Q] (a: A[T]) = new B(implicitly[Q[T]]) + ^ +newSource:36: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.typeclasses.B[scala.test.scaladoc.implicits.typeclasses.A.R[T]]) + implicit def convertR [T: R] (a: A[T]) = new B(implicitly[R[T]]) + ^ Done. diff --git a/test/scaladoc/run/implicits-shadowing.check b/test/scaladoc/run/implicits-shadowing.check index 619c56180bb9..59ba86b25cef 100644 --- a/test/scaladoc/run/implicits-shadowing.check +++ b/test/scaladoc/run/implicits-shadowing.check @@ -1 +1,4 @@ +newSource:63: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.implicits.shadowing.Z[T]) + implicit def AtoZ[T](a: A[T]) = new Z[T] + ^ Done. diff --git a/test/scaladoc/run/implicits-var-exp.check b/test/scaladoc/run/implicits-var-exp.check index 619c56180bb9..9cc519cab9e0 100644 --- a/test/scaladoc/run/implicits-var-exp.check +++ b/test/scaladoc/run/implicits-var-exp.check @@ -1 +1,7 @@ +newSource:8: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.variable.expansion.C) + implicit def aToC(a: A) = new C + ^ +newSource:9: warning: Implicit definition should have explicit type (inferred scala.test.scaladoc.variable.expansion.E with scala.test.scaladoc.variable.expansion.F) + implicit def aToE(a: A) = new E with F + ^ Done. diff --git a/test/tasty/neg/src-2/TestCtxFns_fail.scala b/test/tasty/neg/src-2/TestCtxFns_fail.scala index 150ec4a209bc..c1db5e1d1585 100644 --- a/test/tasty/neg/src-2/TestCtxFns_fail.scala +++ b/test/tasty/neg/src-2/TestCtxFns_fail.scala @@ -9,7 +9,7 @@ object TestCtxFns { def puts[T](t: T): Unit = logs += t.toString } - implicit val ctx = new TestContext + implicit val ctx: TestContext = new TestContext def test1: Unit = { puts(23)(ctx)