-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct Java signature for value classes appearing in type arguments (#…
…20463) As suggested in #10846 the fix to this issue should be to port scala/scala#8127 to scala3 I started by adding the same tests as in the scala2 PR and then tried to find the place where to do the fix by adding some log traces. Unfortunately I am still pretty lost because this is my first time looking at the compiler code. Any tips where this needs to be fixed are very welcome. Meanwhile a few questions: * The scala2 fix was done in `src/compiler/scala/tools/nsc/transform/Erasure.scala`, should I do the fix for scala3 in `compiler/src/dotty/tools/dotc/transform/Erasure.scala` as well? * I think I need to do the fix around `ErasedValueType`, either when it is created (in `TypeErasure#eraseDerivedValueClass`) or when it is used (in `Erasure#unbox`). Please also send me any pointers besides https://dotty.epfl.ch/docs/contributing/index.html regarding compiler contributions
- Loading branch information
Showing
4 changed files
with
45 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
public class C_2 { | ||
String hi = A.foo().head(); | ||
String hy = A.bar().head(); | ||
String hy = A.bar().head().s(); | ||
String hj = A.baz("").head(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
i10846.V: scala.Option<i10846.V> | ||
i10846.U: scala.Option<i10846.U> | ||
i10846.W: scala.Option<i10846.W<scala.Function1<java.lang.Object, java.lang.String>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// scalajs: --skip | ||
|
||
package i10846 { | ||
final class V(val x: Int) extends AnyVal | ||
object V { def get: Option[V] = null } | ||
|
||
final class U(val y: String) extends AnyVal | ||
object U { def get: Option[U] = null } | ||
|
||
final class W[T](val z: T) extends AnyVal | ||
object W { def get: Option[W[Int => String]] = null } | ||
} | ||
|
||
|
||
object Test extends scala.App { | ||
def check[T](implicit tt: reflect.ClassTag[T]): Unit = { | ||
val companion = tt.runtimeClass.getClassLoader.loadClass(tt.runtimeClass.getName + '$') | ||
val get = companion.getMethod("get") | ||
assert(get.getReturnType == classOf[Option[_]]) | ||
println(s"${tt.runtimeClass.getName}: ${get.getGenericReturnType}") | ||
} | ||
|
||
import i10846._ | ||
|
||
check[V] | ||
check[U] | ||
check[W[_]] | ||
} |