Skip to content

Weird Scala 2.13 Error: illegal trait super target found for method #12520

Closed
scala/scala
#9901
@cheeseng

Description

@cheeseng

reproduction steps

using Scala 2.13.7,

class Outcome
trait TestSuite { thisTestSuite =>
  protected trait NoArgTest extends (() => Outcome)
  protected def withFixture(test: NoArgTest): Outcome = {
    test()
  }
}
trait TestSuiteMixin { this: TestSuite =>
  protected def withFixture(test: NoArgTest): Outcome
}
trait TimeLimitedTests extends TestSuiteMixin { this: TestSuite =>
  abstract override def withFixture(test: NoArgTest): Outcome = super.withFixture(test)
}
trait AnyFunSuiteLike extends TestSuite { thisSuite => }
abstract class Test[C] extends AnyFunSuiteLike with TimeLimitedTests

problem

It got the following compiler error when compiles with Scala 2.13:

cheeseng@cheeseng-RAVEN:~/git/213-bug$ scalac Test.scala
Test.scala:15: error: illegal trait super target found for method withFixture required by trait TimeLimitedTests;
 found   : protected def withFixture: ((test: _1.NoArgTest): Outcome) forSome { val _1: [C]Test[C] } in trait TestSuite;
 expected: protected def withFixture: ((test: _1.NoArgTest): Outcome) forSome { val _1: [C]Test[C] } in trait TestSuiteMixin
abstract class Test[C] extends AnyFunSuiteLike with TimeLimitedTests

The same code compiles fine with Scala 3 and 2.12.

This is originally reported as ScalaTest issue here: scalatest/scalatest#2088

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions