Skip to content

Commit

Permalink
fix wrong return type for as
Browse files Browse the repository at this point in the history
looks like I forgot to rename the type variable when renaming T to TSub
  • Loading branch information
robstoll committed Apr 4, 2024
1 parent 5922c7e commit 238ffd6
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/main/scala/com/tegonal/scala/commons/anyExtensions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,13 @@ extension [T](self: T) {
* @return The receiver object cast to [[TSub]]
* @since 0.1.0
*/
inline def as[TSub <: T]: T = ${ asImpl[TSub, T]('self) }
inline def as[TSub <: T]: TSub = ${ asImpl[TSub, T]('self) }
}

@nowarn
private def asImpl[T, U >: T](x: Expr[U])(using Type[T], Type[U], Quotes): Expr[T] = {
import quotes.reflect.TypeRepr

val sym = TypeRepr.of[T].typeSymbol
val code = Expr(x.show)

emitWarningIfUnableToTypeCheckEntirely[T]
val isPrimitive = Expr(Type.of[T] match {
case '[Boolean] | '[Char] | '[Byte] | '[Short] | '[Int] | '[Long] | '[Float] | '[Double] => true
Expand Down

0 comments on commit 238ffd6

Please sign in to comment.