Skip to content

Typechecker inferencing orphan type T #3538

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

Closed
rcano opened this issue Nov 23, 2017 · 2 comments
Closed

Typechecker inferencing orphan type T #3538

rcano opened this issue Nov 23, 2017 · 2 comments

Comments

@rcano
Copy link

rcano commented Nov 23, 2017

Code to reproduce it https://gist.github.com/rcano/14c1b3af9bec4b9dadbc7ba2fd097fd3
(Note, requires javafx which comes bundled with Oracle's JDK or you can install with to openjdk)

The error looks like this:

error when pickling type T
error when pickling type javafx.scene.control.ComboBox[T]
error when pickling tree javafx.scene.control.ComboBox[T]
error when pickling tree val cb: javafx.scene.control.ComboBox[T] = 
  Dsl.BorderPaneBuilder(this).right[javafx.scene.control.ComboBox[T]](
    Dsl.combobox[T](Test.this.planets: Planet*)
  )
error when pickling tree (planets: scala.collection.Seq[Planet] @scala.annotation.internal.Repeated())
   extends
 javafx.scene.layout.BorderPane() { $: Test => 
  private[this] val planets: scala.collection.Seq[Planet] @Repeated
  val cb: javafx.scene.control.ComboBox[T] = 
    Dsl.BorderPaneBuilder(this).right[javafx.scene.control.ComboBox[T]](
      Dsl.combobox[T](Test.this.planets: Planet*)
    )
  Test.this.cb.getSelectionModel().selectLast()
}
error when pickling tree @scala.annotation.internal.SourceFile(
  "/home/randa/Development/testdotty/src/main/scala/Main.scala"
) class Test(
  planets: scala.collection.Seq[Planet] @scala.annotation.internal.Repeated()
) extends javafx.scene.layout.BorderPane() { $: Test => 
  private[this] val planets: scala.collection.Seq[Planet] @Repeated
  val cb: javafx.scene.control.ComboBox[T] = 
    Dsl.BorderPaneBuilder(this).right[javafx.scene.control.ComboBox[T]](
      Dsl.combobox[T](Test.this.planets: Planet*)
    )
  this.cb.getSelectionModel().selectLast()
}
error when pickling tree package <empty> {
  import javafx.scene.Node
  import javafx.scene.control._
  import javafx.scene.layout._
  import Dsl._
  @scala.annotation.internal.SourceFile(
    "/home/randa/Development/testdotty/src/main/scala/Main.scala"
  ) class Test(
    planets: scala.collection.Seq[Planet] @scala.annotation.internal.Repeated()
  ) extends javafx.scene.layout.BorderPane() { $: Test => 
    private[this] val planets: scala.collection.Seq[Planet] @Repeated
    val cb: javafx.scene.control.ComboBox[T] = 
      Dsl.BorderPaneBuilder(this).right[javafx.scene.control.ComboBox[T]](
        Dsl.combobox[T](Test.this.planets: Planet*)
      )
    this.cb.getSelectionModel().selectLast()
  }
}

The orphan type T gets leaked even to the "presentation compiler" exposed through the language server.

@smarter
Copy link
Member

smarter commented Nov 23, 2017

Thanks for the report! I managed to reduce the testcase further:

class Inv[T]

class Test {
  implicit class Wrong(test: Test) {
    def right: Any = ???
  }
  implicit class Right(test: Test) {
    def right(node: Any): Any = ???
  }

  def inv[T](x: T): Inv[T] = ???

  this.right(inv(1))
}

@smarter
Copy link
Member

smarter commented Nov 23, 2017

this.right(inv(1)) is typechecked inside a FunProto#typedArgs, this is very reminiscent of #1460. In general the way FunProto deals with caches and contexts is very dubious, I tried to fix it in #2922 but that's not enough.

smarter added a commit to dotty-staging/dotty that referenced this issue Nov 23, 2017
Demonstrate that this caching is responsible for scala#3538.
@odersky odersky self-assigned this Nov 27, 2017
allanrenucci added a commit that referenced this issue Dec 18, 2017
Fix #3538: Better invalidation of typed arguments in FunProtos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants