Skip to content

Not all implicits should be able to influence type inference #7454

@scabug

Description

@scabug

As discussed in http://groups.google.com/group/scala-internals/browse_thread/thread/90927a689028dfe4

import scala.reflect.{ClassTag, classTag}
import scala.reflect.runtime.universe.{TypeTag, typeTag}

class C

object Test extends App {
  implicit val cctag: ClassTag[C] = ClassTag[C](classOf[C])
  def foo[T: ClassTag](xs: T*) = println(classTag[T])
  foo(1, 2)
  foo()

  implicit val cttag: TypeTag[C] = { val cttag = "shadow cttag"; typeTag[C] }
  def bar[T: TypeTag](xs: T*) = println(typeTag[T])
  bar(1, 2)
  bar()
}
10:15 ~/Projects/Kepler_5923/sandbox (ticket/5923)$ sr
Int
C
TypeTag[Int]
TypeTag[C]

Whereas one would expect the second and the fourth line to print Nothing and TypeTag[Nothing].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions