Skip to content

Commit f01ff56

Browse files
committed
Give explicit result types to all methods in scala.deriving.
They are public API. They should have explicit types.
1 parent 761f2a2 commit f01ff56

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

library/src/scala/deriving.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ object deriving {
3636
type MirroredType = this.type
3737
type MirroredElemTypes = EmptyTuple
3838
type MirroredElemLabels = EmptyTuple
39-
def fromProduct(p: scala.Product) = this
39+
def fromProduct(p: scala.Product): MirroredMonoType = this
4040
}
4141

4242
/** A proxy for Scala 2 singletons, which do not inherit `Singleton` directly */
@@ -45,7 +45,7 @@ object deriving {
4545
type MirroredType = value.type
4646
type MirroredElemTypes = EmptyTuple
4747
type MirroredElemLabels = EmptyTuple
48-
def fromProduct(p: scala.Product) = value
48+
def fromProduct(p: scala.Product): MirroredMonoType = value
4949
}
5050

5151
type Of[T] = Mirror { type MirroredType = T; type MirroredMonoType = T ; type MirroredElemTypes <: Tuple }
@@ -57,16 +57,16 @@ object deriving {
5757
class ArrayProduct(val elems: Array[AnyRef]) extends Product {
5858
def this(size: Int) = this(new Array[AnyRef](size))
5959
def canEqual(that: Any): Boolean = true
60-
def productElement(n: Int) = elems(n)
61-
def productArity = elems.length
60+
def productElement(n: Int): Any = elems(n)
61+
def productArity: Int = elems.length
6262
override def productIterator: Iterator[Any] = elems.iterator
63-
def update(n: Int, x: Any) = elems(n) = x.asInstanceOf[AnyRef]
63+
def update(n: Int, x: Any): Unit = elems(n) = x.asInstanceOf[AnyRef]
6464
}
6565

6666
/** The empty product */
6767
object EmptyProduct extends ArrayProduct(Array.emptyObjectArray)
6868

6969
/** Helper method to select a product element */
70-
def productElement[T](x: Any, idx: Int) =
70+
def productElement[T](x: Any, idx: Int): T =
7171
x.asInstanceOf[Product].productElement(idx).asInstanceOf[T]
7272
}

0 commit comments

Comments
 (0)