You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// unfortunately // opaque type Fix[F[_]] = F[Fix[F]]// won't work (no recursion in opaque type), but this implementation is safe, but scary due to asInstanceOfobjectFixImpl {
typeFix[F[_]]
inlinedeffix[F[_]](f: F[Fix[F]]):Fix[F] = f.asInstanceOf[Fix[F]]
inlinedefunfix[F[_]](f: Fix[F]):F[Fix[F]] = f.asInstanceOf[F[Fix[F]]]
}
importFixImpl._typeOrNull[A<:AnyRef] =A|Null// List[A] = null | (A, null) | (A, (A, null)) | (A, (A, (A, null))) | ...opaquetypeList[A] =Fix[[X] =>>OrNull[(A, X)]]
objectList {
defempty[A]:List[A] = fix(null)
}
givenListOps {
def (head: A) ::[A](self: List[A]):List[A] =
fix((head, self))
}
In the repl, I can use :: the first time, but not the second time:
scala> List.empty[Int]
val res0: List[Int] = null
scala> 1 :: res0
val res1: List[Int] = (1,null)
scala> 1 :: res0
1 |1 :: res0
| ^^^^^^^
| value :: is not a member of List[Int] - did you mean res0.==?
expectation
Notice, the first time I use :: it works, the second time with the exact same syntax, it fails.
As top-level in a named or empty package, if List is opaque:
scala> { import i7182._
| 42 :: res0
| }
2 |42 :: res0
| ^^^^^^^
| value :: is not a member of i7182.List[Int].
| An extension method was tried, but could not be fully constructed:
|
| i7182.::[A](res0)
That is after deleting the disallowed inline and writing :: as extension.
I remember that top level opaque means opaque in the package object, but it's not obvious why compilation fails.
I've tried to reproduce this issue during the Spree, and have the same conclusions as @som-snytt above. Putting the example in an object body and removing the inlines, fixes it. The bug has been probably fixed along the way, but should be checked again as soon as #12748#9879 is fixed.
minimized code
In the repl, I can use
::
the first time, but not the second time:expectation
Notice, the first time I use
::
it works, the second time with the exact same syntax, it fails.seems possibly related to #7181
The text was updated successfully, but these errors were encountered: