Open Katrix opened 4 years ago
Hi all,
I have another sample that I doesn't work as expected. I'm not sure if my code is syntactically correct (tuple map expects [A] => A => F[A]
) and I provide a [A] => A => Numeric[A] ?=> A
(I use numeric in tuple and F[_] is Identity in my case)
type Inc = [A] => A => Numeric[A] ?=> A
val inc: Inc = [A] => (a: A) => (ev: Numeric[A]) ?=> ev.plus(a, ev.one)
def pair[B: Numeric, C: Numeric](b: B, c: C, inc: Inc): (B, C) = (inc(b), inc(c))
pair(1, 2.0, inc) // This works (2, 3.0)
(1, 2.0).map(inc) // Should return (2, 3.0) but got Exception during compilation (see below)
[error] (Compile / compileIncremental) java.lang.AssertionError: assertion failed: orphan parameter reference: TypeParamRef(A)
[error] Total time: 1 s, completed 6 déc. 2021 à 09:29:18
sbt:Scala 3 playground> compile
[info] compiling 1 Scala source to .../target/scala-3.1.0/classes ...
error when pickling type A
error when pickling type Numeric[A]
error when pickling type (Numeric[A]) ?=> scala$ContextFunction1$$R
error when pickling type [scala$ContextFunction1$$R] =>> (Numeric[A]) ?=> scala$ContextFunction1$$R
error when pickling tree ([scala$ContextFunction1$$R] =>> (Numeric[A]) ?=> scala$ContextFunction1$$R)
error when pickling tree Tuple2.apply[Double, Double](1.0d, 2.0d).map[
([scala$ContextFunction1$$R] =>> (Numeric[A]) ?=> scala$ContextFunction1$$R)
]
error when pickling tree Tuple2.apply[Double, Double](1.0d, 2.0d).map[
([scala$ContextFunction1$$R] =>> (Numeric[A]) ?=> scala$ContextFunction1$$R)
](playground.inc)
...
another example without Context function
scalaVersion := "3.1.3-RC1-bin-20220404-ad2553d-NIGHTLY"
class A {
class B
}
object Main {
def x[C](f : [a <: A] => (a1: a) => a1.B => C): Unit = ()
x([a <: A] => (a1: a) => (b: a1.B) => b)
}
Minimized code
Expectation
This should work, as the polymorphic function still needs a value, it's just not shown to the user.