Skip to content

VerifyError with implicit ClassTag in companion object #11208

New issue

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

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

Already on GitHub? Sign in to your account

Closed
hughsimpson opened this issue Jan 25, 2021 · 1 comment · Fixed by #12567
Closed

VerifyError with implicit ClassTag in companion object #11208

hughsimpson opened this issue Jan 25, 2021 · 1 comment · Fixed by #12567

Comments

@hughsimpson
Copy link

hughsimpson commented Jan 25, 2021

The following throws a VerifyError (Tested with 3.0.0-M3)

import scala.reflect.ClassTag

@main def run = println(Foo)

abstract class Bar[T](implicit val thisClassTag: ClassTag[T])

class Foo
object Foo extends Bar[Foo]

Alternatives tried:

  • Changing abstract class Bar[T](implicit val thisClassTag: ClassTag[T]) to abstract class Bar[T: ClassTag]{ val thisClassTag: ClassTag[T] = implicitly[ClassTag[T]] } works
  • Changing object Foo extends Bar[Foo] to object Foo extends Bar()(classTag[Foo]) works
  • Summoning an implicit of a different class works (only ClassTag specifically seems to be affected)
  • Using the ClassTag of anything other than the companion class works (object Foo extends Bar[Foo2] seems fine)
@griggt
Copy link
Contributor

griggt commented Jan 25, 2021

This example, reported as scala/bug#473, also throws a VerifyError at runtime with 3.0.0-M3 whereas in Scala 2 it is a compile error.

class Foo(implicit val foo: Foo)

object Test extends App {
  implicit object Bar extends Foo
  Bar.foo
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants