Open scabug opened 9 years ago
Imported From: https://issues.scala-lang.org/browse/SI-9004?orig=1 Reporter: @OlegYch Affected Versions: 2.10.4, 2.11.4 See #6904
@retronym said: Here's another encoding which works:
def f[R](a: AA[R]): Option[a.R] = Some(1).map(_ => a.r)
@retronym said:
object Main {
trait AA[RR] { type R = RR; def r: R }
def test1(a: AA[B] forSome { type B }) = {
val f = () => a.r
// The tree a.r is given the type `a.R` which normalizes
// to B', where B' is a distinct symbol ("captured existential skolem")
// to substitute for the reference to an existential skolem of B.
//
// inference of the result type of the function computes the
// packed type of tree `a.r` to make sure that terms and types
// local to the body of the function don't leak into its result
// type. The captured existential skolem is considered to be local
// so it is abstracted to its upper bound, Any.
f: (() => a.R)
// The workaround is to annotate the function type, rather than
// relying in inference.
val g: (() => a.R) () => a.r
()
}
// typer debug trace: http://rawgit.com/retronym/d5aeaf8e0a4a2e6eef4b/raw/out.html
}
@retronym said: I think I might have a solution: https://github.com/retronym/scala/tree/ticket/9004
I'll see if that change is at odds with the test suite. Assuming it is sound, we'll have to hide it behind -Xsource:2.12.
@retronym said: :*(
Two failing tests on that branch:
test/partest \
/Users/jason/code/scala3/test/files/pos/t8023.scala \
/Users/jason/code/scala3/test/files/neg/t5378.scala
@retronym said (edited on Jan 27, 2015 2:52:42 AM UTC): Another test case that crashes under my proposed fix:
object Test {
def foo1[A1] = new { private type A2 = A1 ; def bar: A2 = ??? }
// def foo2[A1] = new { type A2 = A1 ; def bar: A2 = ??? }
def f1: Int = foo1[Int].bar
// def f2: Int = foo2[Int].bar
}
@retronym said: