Skip to content

Commit 7b58b34

Browse files
committed
Restrict DummyImplicit creation
- Make the implicit a val to avoid allocating instances for no reason. - Make the class itself final with a private constructor to guarantee that there is only one instance (the compiler could take this into account to shortcut implicit search).
1 parent 30728e8 commit 7b58b34

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/library/scala/DummyImplicit.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
package scala
1414

1515
/** A type for which there is always an implicit value. */
16-
class DummyImplicit
16+
final class DummyImplicit private ()
1717

1818
object DummyImplicit {
1919
/** An implicit value yielding a `DummyImplicit`. */
20-
implicit def dummyImplicit: DummyImplicit = new DummyImplicit
20+
implicit val dummyImplicit: DummyImplicit = new DummyImplicit
2121
}

0 commit comments

Comments
 (0)