sourcecode icon indicating copy to clipboard operation
sourcecode copied to clipboard

sourcecode.Name is incorrect when used as an implicit constructor arg on an abstract class

Open fizzy33 opened this issue 9 years ago • 1 comments

The following fails

scala> abstract class Foo(implicit val name: sourcecode.Name)
defined class Foo

scala> val x = new Foo {}
x: Foo = $anon$1@b6bdc65

scala> x.name
res0: sourcecode.Name = Name($anon)

Here is a pull request with a unit test https://github.com/lihaoyi/sourcecode/pull/18

fizzy33 avatar Sep 12 '16 22:09 fizzy33

I'm seeing this behavior in 0.1.7.

abstract class Foo(implicit val name: sourcecode.Name) { override val toString: String = name.value }
val x = new Foo {}  // x: Foo = $anon
x.name  // res1: sourcecode.Name = Name($anon)

ryan-williams avatar Jun 29 '19 18:06 ryan-williams