Skip to content

Add prototype conversion with dependent functions support #8523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions tests/pos/conversion-function-prototype.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package scala


object ConversionFunction {

opaque type ConversionFunction[+F <: Nothing => Any] = F

def apply[F <: Nothing => Any](f: F): ConversionFunction[F] = f
def get[F <: Nothing => Any](using f: ConversionFunction[F]): F = f

}

type ConversionFunction[+F <: Nothing => Any] =
ConversionFunction.ConversionFunction[F]

object Test {

{
given ConversionFunction[Int => String] = ConversionFunction(_.toString)
// val a: String = 3
val a: String = ConversionFunction.get[3 => String].apply(3)
}

trait X {
type T
def t: T
}
val x: X = ???

{
given ConversionFunction[(x: X) => x.T] = ConversionFunction((x: X) => x.t)
// val a: x.T = x
val a: x.T = ConversionFunction.get[(x: X) => x.T].apply(x)
}

{
given ConversionFunction[(x: X) => x.T] = ConversionFunction(_.t)
// val a: x.T = x
val a: x.T = ConversionFunction.get[(x: X) => x.T].apply(x)
}

}