Copilot commented on code in PR #2218:
URL: https://github.com/apache/pekko/pull/2218#discussion_r2347169048


##########
actor/src/main/scala/org/apache/pekko/japi/Throwables.scala:
##########
@@ -49,4 +49,15 @@ object Throwables {
    * or false if it is to be considered non-fatal
    */
   def isFatal(throwable: Throwable): Boolean = !isNonFatal(throwable)
+
+  /**
+   * Throws the given `Throwable`, without requiring the caller to declare it 
in a `throws` clause.
+   * @param t the `Throwable` to throw
+   * @throws T the type of the `Throwable` to throw

Review Comment:
   The `@throws T` documentation is incorrect. The method throws the actual 
`Throwable` instance `t`, not a type `T`. This should be `@throws t the 
`Throwable` instance to throw` or similar.
   ```suggestion
      * @throws t the `Throwable` instance to throw
   ```



##########
actor/src/main/scala/org/apache/pekko/japi/Throwables.scala:
##########
@@ -49,4 +49,15 @@ object Throwables {
    * or false if it is to be considered non-fatal
    */
   def isFatal(throwable: Throwable): Boolean = !isNonFatal(throwable)
+
+  /**
+   * Throws the given `Throwable`, without requiring the caller to declare it 
in a `throws` clause.
+   * @param t the `Throwable` to throw
+   * @throws T the type of the `Throwable` to throw
+   * @return never returns normally, but has return type `R` to allow usage in 
expressions
+   * @since 2.0.0
+   */
+  def sneakyThrow[T <: Throwable, R](t: Throwable): R = {
+    throw t.asInstanceOf[T]

Review Comment:
   The `asInstanceOf[T]` cast is unnecessary and potentially unsafe. Since `t` 
is already a `Throwable`, it should be thrown directly as `throw t`. The cast 
doesn't provide any benefit and could mask type issues.
   ```suggestion
       throw t
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org
For additional commands, e-mail: notifications-h...@pekko.apache.org

Reply via email to