Skip to content

Extension methods and tuples don't mash #6734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Katrix opened this issue Jun 23, 2019 · 0 comments
Closed

Extension methods and tuples don't mash #6734

Katrix opened this issue Jun 23, 2019 · 0 comments
Assignees

Comments

@Katrix
Copy link
Contributor

Katrix commented Jun 23, 2019

minimized code

object Bug {

  def (ab: (A, B)) pipe2[A, B, Z](f: (A, B) => Z): Z = f(ab._1, ab._2)

  def (a: A) leftErr[A, B](b: B): A = (a, b).pipe2((a, b) => a) //Doesn't compile
  def (a: A) leftOk1[A, B](b: B): A = Tuple2(a, b).pipe2((a, b) => a) //Compiles
  def (a: A) leftOk2[A, B](b: B): A = {
    val t = (a, b)
    t.pipe2((a, b) => a) //Compiles
  }
}

Error:

[error] -- [E007] Type Mismatch Error: D:\DevProjects\Incubating\Squeal\squeal\src\main\scala\squeal\TupleBug.scala:7:50
[error] 7 |  def (a: A) leftErr[A, B](b: B): A = (a, b).pipe2((a, b) => a)
[error]   |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^
[error]   |                                      Found:    Any
[error]   |                                      Required: A

expectation

I would expect that all three would work. In most cases I can inline a val without any types without changing the behavior of the program.

@odersky odersky self-assigned this Jun 24, 2019
odersky added a commit to dotty-staging/dotty that referenced this issue Jul 1, 2019
Suppress interpolation in the middle of an ExtMethodApply. The reason is that
the ExtMethodApply has a WildcardType, which hides information about bound type
variables in the result type.
@odersky odersky closed this as completed in 8ddfbd6 Jul 2, 2019
odersky added a commit that referenced this issue Jul 2, 2019
Fix #6734: Suppress interpolation for extension methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants