scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.85k stars 1.06k forks source link

Pickling test fails for annotated types #15956

Open Linyxus opened 2 years ago

Linyxus commented 2 years ago

(taken from tests/pos/i15922.scala in #15948)

Compiler version

main

Minimized code

trait Cap:
  type M

class Id[X]

object Test:
  def withCap[X](op: Cap => X): X = ???

  class retains1(xs: Any*) extends annotation.StaticAnnotation

  def leaking1(c: Cap): Id[Cap @retains1(c)] = ??? // used to crash with orphan parameter on pickling
  def leaking2(c: Cap): Id[c.type] = ???

  val bad1 = withCap(leaking1)
  val bad2 = withCap(leaking2)

Output

Pickling test fails with -Xprint-types -Ytest-pickler -Yprint-pos -Yprint-pos-syms.

Expectation

It should pass the pickling test (i.e. the representation before and after pickling should be the same).

odersky commented 2 years ago

Yes I agree. If we fix that then we can also drop the exclude for i15922.scala. It would be great if someone could take a closer look here.

Linyxus commented 2 months ago

could be a duplicate of #20272