Skip to content

Commit

Permalink
Fix #18658: Handle varargs of generic types in JSExportsGen.
Browse files Browse the repository at this point in the history
When extracting the type of a varargs parameter, we have to go back
to before erasure. However, that gives us a non-erased type inside
as well. We need to re-erase that type to get something sensible
for the back-end.
  • Loading branch information
sjrd committed Oct 6, 2023
1 parent d788ef2 commit 44126aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ object JSSymUtils {
val list =
for ((name, info) <- paramNamesAndTypes) yield {
val v =
if (info.isRepeatedParam) Some(info.repeatedToSingle.widenDealias)
if (info.isRepeatedParam) Some(TypeErasure.erasure(info.repeatedToSingle))
else None
name -> v
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.scalajs.testsuite.jsinterop

import org.junit.Assert.*
import org.junit.Test

import scala.scalajs.js
import scala.scalajs.js.annotation.*

class NonNativeJSTypeTestScala3 {
@Test
def overloadWithVarargOfGenericType(): Unit = {
class OverloadWithVarargOfGenericType extends js.Object {
def overloaded(x: Int): Int = x
def overloaded(xs: (Int, Int)*): Int = xs.size
}

val obj = new OverloadWithVarargOfGenericType
assertEquals(5, obj.overloaded(5))
assertEquals(2, obj.overloaded((1, 2), (3, 4)))
}
}

0 comments on commit 44126aa

Please sign in to comment.