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
This is a followup of a discussion on gitter with @Blaisorblade and @smarter regarding the documentation of "Structural Types".
The two main issue with the documentation are :
to be a bit misleading regarding the fact that current implementation still "reflection-based". dotty structural types allow for other implementations but right now we only have the reflection-based one
not emphasize enough that in most cases importing scala.reflect.Selectable.reflectiveSelectable is sufficient for Scala2 code.
Regarding point 2 @smarter suggested to make the reflective stuff enabled by default with -language:Scala2 to allow cross-compilation.
That seemed to be fine but they are issues with Scala 2 code :
//import is not enought to make Scala2 code compile with dottyimportscala.reflect.Selectable.reflectiveSelectableobjectStructural {
classExample1 {
deftext():String="example"
}
valexample1:Example1=newExample1valexample3: { deftext():String } = example1
valres:String= example3.text
}
example3.text has not the same type with Scala 2 "String" and with dotty "() => String"
This is easy to fix manually using def text instead of def text()
I would have been happy to open a PR to improve the documentation but too many uncertainties still remain in order to do so.
The text was updated successfully, but these errors were encountered:
and that the example in this issue should compile with -language:Scala2,rewrite.
We can minimize it like in #4026
importscala.reflect.Selectable.reflectiveSelectable//should not be needed in Scala2 modeclassTest {
deftest(x: { defget():Int }):Int= x.get
}
Is this also an other issue or just not implemented yet ?
Clarify migration path from Scala2 for "Structural Types" would be summed up then by : will the reflective stuff will be enabled by default in Scala 2 mode ?
Given the age of the issue, documentation changes and the presence of new migration guide, I think it's safe to close this issue. If there's a problem with the migration guide, please open a new issue.
This is a followup of a discussion on gitter with @Blaisorblade and @smarter regarding the documentation of "Structural Types".
The two main issue with the documentation are :
Regarding point 2 @smarter suggested to make the reflective stuff enabled by default with -language:Scala2 to allow cross-compilation.
That seemed to be fine but they are issues with Scala 2 code :
example3.text has not the same type with Scala 2 "String" and with dotty "() => String"
This is easy to fix manually using def text instead of def text()
I would have been happy to open a PR to improve the documentation but too many uncertainties still remain in order to do so.
The text was updated successfully, but these errors were encountered: