Skip to content

@alpha has no effect over double definition error #7942

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
soronpo opened this issue Jan 9, 2020 · 1 comment · Fixed by #10149
Closed

@alpha has no effect over double definition error #7942

soronpo opened this issue Jan 9, 2020 · 1 comment · Fixed by #10149

Comments

@soronpo
Copy link
Contributor

soronpo commented Jan 9, 2020

minimized code

import scala.annotation.alpha
@alpha("fooString") def foo(ps: String*) : Unit = ???
@alpha("fooInt") def foo(ps: Int*) : Unit = ???
@alpha("fooAny") def foo(ps: Any*) : Unit = ???
Compilation output
Double definition:
def foo(ps: String*): Unit in package object main$package at line 4 and
def foo(ps: Int*): Unit in package object main$package at line 5
have the same type after erasure.
@alpha("fooAny") def foo(ps: Any*) : Unit = ???

Double definition:
def foo(ps: Int*): Unit in package object main$package at line 5 and
def foo(ps: Any*): Unit in package object main$package at line 6
have the same type after erasure.

see scastie: https://scastie.scala-lang.org/owQEIEShQayiRjUJ6Esk2w

expectation

Currently DummyImplicit is used as a workaround to create unique signatures after erasure.
@odersky mentioned that @alpha annotation could be used to avoid double definition error, however it does not seem to affect the compiler when it checks for double definitions.

@odersky odersky self-assigned this Jan 13, 2020
@odersky
Copy link
Contributor

odersky commented Jan 15, 2020

I tried to just remove the error condition but then we run into more trouble:

-- Error: i7942.scala:2:0 ------------------------------------------------------
2 |@alpha("fooString") def foo(ps: String*) : Unit = ???
  |^
  |cannot merge
  |  method foo of type (ps: Seq[Any]): Unit  and
  |  method foo of type (ps: Seq[Int]): Unit
  |they are both defined in package <empty> but have matching signatures
  |  (ps: Seq[Any]): Unit and
  |  (ps: Seq[Int]): Unit
  |as members of package object i7942$package
  |       
3 |@alpha("fooInt") def foo(ps: Int*) : Unit = ???
4 |@alpha("fooAny") def foo(ps: Any*) : Unit = ???

To fix this we need to change our way how we treat signatures. Since signatures are used for many different things this will require a lot of thought.

odersky added a commit to dotty-staging/dotty that referenced this issue Nov 4, 2020
odersky added a commit to dotty-staging/dotty that referenced this issue Nov 8, 2020
odersky added a commit to dotty-staging/dotty that referenced this issue Nov 10, 2020
michelou pushed a commit to michelou/scala3 that referenced this issue Nov 12, 2020
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants