Skip to content

Bug with scala.js return type check and intersection types #9892

Closed
@oyvindberg

Description

@oyvindberg

Minimized code

import scala.scalajs.js
@js.native
trait ObjectConstructor {
  def assign[T, U](target: T, source: U): T with U = js.native
}

Output

[error] -- Error: /home/olvind/.cache/scalablytyped/ScalablyTyped/s/std/src/main/scala/typings/std/ObjectConstructor.scala:30:6 
[error] 30 |  def assign[T, U](target: T, source: U): T with U = js.native
[error]    |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |The type of assign must be explicitly specified because it is JS native.

Expectation

Should compile.

Notes:

  • Works in scala 2
  • Tested with 0.28.0-bin-20200925-f4528ce-NIGHTLY
  • annotated return type of T & U compiles
  • T and U could be concrete types and still trigger the error. I have several examples with concrete types, this was just the smallest
  • I also saw this for vals
  • It might not actually be relevant given the above, but I thought I should mention this was just fixed, Bad interaction between package objects, Nothing, type parameters #9717

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions