Skip to content

using dot notation for operator fails if operator defined in trait is in scope #8391

Closed
@robstoll

Description

@robstoll

minimized code

import scala.annotation.infix
import scala.annotation.alpha

trait MultiSet[T] {
  @alpha("intersection")
  def *(other: MultiSet[T]): MultiSet[T]
}

def test() = {
    val s1, s2: MultiSet[Int] = ???
    // comment out and the last statement fails with @alpha annotation "intersection" clashes with other definition is same scope
    //s1 * s2        
    //s1 * s2
    s1.*(s2)       
}

see for more details https://scastie.scala-lang.org/rnMia7lzSY2V9iLOya0w0Q

Note that it also happens if there is a top-level operator defined where the operator defined in the trait does not even need to be used (enough if it is in scope I guess)
see https://scastie.scala-lang.org/m40Jbs3nRMm3Dgb4RYRqcQ for more details.

Compilation output

@alpha annotation "foo" clashes with other definition is same scope

expectation

Should work

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions