Gabriel95 / scalafx

Automatically exported from code.google.com/p/scalafx
Other
0 stars 0 forks source link

Cannot create TableColumn using default constructor #40

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If you try to instantiate a TableColumn using a default constructor, for 
instance:

new TableColumn[Person, String]()

or

new TableColumn[Person, String] {
      text = "First Name"
}

you get an exception:

  error: polymorphic expression cannot be instantiated to expected type;
  found   : [S, T]javafx.scene.control.TableColumn[Nothing,Nothing]
  required: javafx.scene.control.TableColumn[proscalafx.ch05.model.Person,String]
  Note: Nothing <: proscalafx.ch05.model.Person (and [S, T]javafx.scene.control.TableColumn[Nothing,Nothing] <: javafx.scene.control.TableColumn[Nothing,Nothing]), but Java-defined class TableColumn is invariant in type S.
  You may wish to investigate a wildcard type such as `_ <: proscalafx.ch05.model.Person`. (SLS 3.2.10)
  Note: Nothing <: String (and [S, T]javafx.scene.control.TableColumn[Nothing,Nothing] <: javafx.scene.control.TableColumn[Nothing,Nothing]), but Java-defined class TableColumn is invariant in type T.
  You may wish to investigate a wildcard type such as `_ <: String`. (SLS 3.2.10)

to avoid exception you have to use non-default constructor, for instance:

new TableColumn[Person, String]("First Name")

Original issue reported on code.google.com by jpsacha on 26 Feb 2013 at 12:58

GoogleCodeExporter commented 8 years ago

Original comment by jpsacha on 26 Feb 2013 at 2:04