Skip to content

Order of the source files changes the compilation result #10634

Closed
@adpi2

Description

@adpi2

While compiling scala3doc I found surprising that the order of the source files change the compilation result.

Minimized code

I minimized it to 3 files.

// Context.scala
trait Context:
  type Symbol

trait SymOps[C <: Context](val c: C):
  extension (sym: c.Symbol):
    def getVisibility(): Int = 0
// Parser.scala
case class Parser(ctx: Context) extends BasicSupport
// BasicSupport.scala
trait BasicSupport:
  self: Parser =>

  object SymOps extends SymOps[ctx.type](ctx)
  export SymOps._

  def parse(sym: ctx.Symbol): Int =
    sym.getVisibility()

Output

BasicSupport.scala Context.scala Parser.scala compiles successfully.

But Parser.scala Context.scala BasicSupport.scala compiles in error:

[info] cannot take signature of (sym: Parser.this.SymOps.c.Symbol)(): Int
[error] -- [E008] Not Found Error: /home/piquerez/lampepfl/dotty-issue/src/main/scala/tasty/BasicSupport.scala:8:8 
[error] 8 |    sym.getVisibility()
[error]   |    ^^^^^^^^^^^^^^^^^
[error]   |    value getVisibility is not a member of BasicSupport.this.ctx.Symbol.
[error]   |    An extension method was tried, but could not be fully constructed:
[error]   |
[error]   |        sym
[error] one error found

Expectation

The order of the source files should not change the compilation result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions