Skip to content
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

Extensions are resolved even when the opaque type doesn't match #22320

Closed
hamzaremmal opened this issue Jan 8, 2025 · 0 comments · Fixed by #22321
Closed

Extensions are resolved even when the opaque type doesn't match #22320

hamzaremmal opened this issue Jan 8, 2025 · 0 comments · Fixed by #22321

Comments

@hamzaremmal
Copy link
Member

Compiler version

3.6.2

Minimized code

package a:
  opaque type System = Any
  opaque type SimulatedSystem <: System = System

  extension (system: System)
    def x: BigInt = ???
    def y: BigInt = ???
  end extension

  extension (system: SimulatedSystem)
    def z: BigInt = ???
  end extension

package b:
  import a.*
  def issue(system: System) =
    val x = system.x // ok
    val y = system.y // oK
    val z = system.z // ok...!!

Output

Compiles

Expectation

val z = system.z // ok...!!

This line shouldn't have been resolved and an error should have been expected here

Note

Changing a from a package to a package object or an object behaves correctly

@hamzaremmal hamzaremmal added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 8, 2025
@hamzaremmal hamzaremmal self-assigned this Jan 8, 2025
@hamzaremmal hamzaremmal added area:extension-methods and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 8, 2025
hamzaremmal added a commit to hamzaremmal/scala3 that referenced this issue Jan 8, 2025
@hamzaremmal hamzaremmal changed the title Extension are resolved even when the opaque type doesn't match Extensions are resolved even when the opaque type doesn't match Jan 8, 2025
bracevac pushed a commit to dotty-staging/dotty that referenced this issue Jan 19, 2025
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.

1 participant