Skip to content

Commit

Permalink
Work around limitation for JDK12+ about j.l.constant.Constable (#1941)
Browse files Browse the repository at this point in the history
`java.lang.constant.Constable` was introduced at JDK12 and is a
super trait of core boxed classes. This causes code like

    val seq = Seq(Double.box(1d), "")
    val elem = seq.head

to infer types that mention `Constable`: `seq` is of type
`Seq[Constable with ...]` and `elem` of type `Constable with ...`.
The latter erases to `Constable`, which results in linking errors.

It is unfortunately impossible to correctly implement `Constable`
in Scala Native, because it requires reflection, so the general
issue is not fixable.

This commit works around the issue in our own test suite, by
ascribing some values with explicit types, so that `Constable` does
not appear in erased types.
  • Loading branch information
catap committed Nov 5, 2020
1 parent 7607e56 commit b0ab3fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Expand Up @@ -830,7 +830,7 @@ class DefaultFormatterTest {
}

@Test def formatForGeneralConversionType_bB(): Unit = {
val triple = Array(
val triple: Array[Array[Object]] = Array(
Array(Boolean.box(false), "%3.2b", " fa"),
Array(Boolean.box(false), "%-4.6b", "false"),
Array(Boolean.box(false), "%.2b", "fa"),
Expand Down Expand Up @@ -891,7 +891,7 @@ class DefaultFormatterTest {
}

@Test def formatForGeneralConversionType_sS(): Unit = {
val triple = Array(
val triple: Array[Array[Object]] = Array(
Array(Boolean.box(false), "%2.3s", "fal"),
Array(Boolean.box(false), "%-6.4s", "fals "),
Array(Boolean.box(false), "%.5s", "false"),
Expand Down
4 changes: 2 additions & 2 deletions unit-tests/src/test/scala/java/util/FormatterUSTest.scala
Expand Up @@ -829,7 +829,7 @@ class FormatterUSTest {
}

@Test def formatForGeneralConversionType_bB(): Unit = {
val triple = Array(
val triple: Array[Array[Object]] = Array(
Array(Boolean.box(false), "%3.2b", " fa"),
Array(Boolean.box(false), "%-4.6b", "false"),
Array(Boolean.box(false), "%.2b", "fa"),
Expand Down Expand Up @@ -921,7 +921,7 @@ class FormatterUSTest {
}

@Test def formatForGeneralConversionType_sS(): Unit = {
val triple = Array(
val triple: Array[Array[Object]] = Array(
Array(Boolean.box(false), "%2.3s", "fal"),
Array(Boolean.box(false), "%-6.4s", "fals "),
Array(Boolean.box(false), "%.5s", "false"),
Expand Down

0 comments on commit b0ab3fb

Please sign in to comment.