Skip to content

Extension methods shouldn't create extension methods for Scala2x defined symbols #387

Closed
@DarkDimius

Description

@DarkDimius

Scala2x has extmethods phase before pickler, so extension methods are picked, and unpicked by dotty.
Ie dotty has already unpickled for RichInt$

    public final Range until$extension0(int $this, int end)
    public final Range until$extension1(int $this, int end, int step)

And it additionally creates(in ExtensionMethods.transform)

denot1: final def until$extension1:
  ($this: scala.runtime.RichInt)(end: Int)scala.collection.immutable.Range
denot1: final def until$extension0:
  ($this: scala.runtime.RichInt)(end: Int, step: Int)scala.collection.immutable.Range

Note that as dotty chose different suffix number, we don't have any assertions broken, no name clashes, as methods just become overloaded from the middle of pipeline. This is a bug, as target methods don't actually exists.

@smarter I guess that's the bug you are experiencing.
A sidenote: Current scheme seems to rely on stable order of definitions in class. This reveals problem with separate compilation of value classes, as overloading a method in a value class seems to be a binary incompatible change. This could be solved if we somehow persist reference to an appropriate extension method, eg in annotation on forwarder method.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions