Skip to content

Crash when extending a type alias to a trait with implicit parameter #4837

Closed
@Medowhill

Description

@Medowhill

I found this issue while trying to write some tests for issue #4582. PR #4827 is related.

trait T[X]
type Foo[X, Y] = T[X]
class D[X] extends Foo[X, Unit]
trait T[X: Numeric]
type Foo[X] = T[X]
class D[X: Numeric] extends Foo[X]

Two above examples were compiled.

trait T[X: Numeric]
type Foo[X, Y] = T[X]
class D[X: Numeric] extends Foo[X, Unit]

However, this one resulted the following crash:

Exception in thread "main" java.lang.AssertionError: assertion failed: missing parameters for trait T from ($outer: C, implicit evidence$2: scala.math.Numeric) extends Object() with T {
  private implicit val evidence$2: scala.math.Numeric
  private val $outer: C
  private <accessor> def $outer(): C = this.$outer
  final def C$D$$$outer(): C = D.this.$outer()
} should have been caught in typer
	at scala.Predef$.assert(Predef.scala:219)
	at dotty.tools.dotc.transform.Mixin.nextArgument$1(Mixin.scala:209)
	at dotty.tools.dotc.transform.Mixin.$anonfun$transformTemplate$12(Mixin.scala:235)
	at scala.collection.TraversableLike$WithFilter.$anonfun$map$2(TraversableLike.scala:739)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:738)
	at dotty.tools.dotc.transform.Mixin.traitInits$1(Mixin.scala:217)
	at dotty.tools.dotc.transform.Mixin.$anonfun$transformTemplate$17(Mixin.scala:263)
	at scala.collection.immutable.List.flatMap(List.scala:335)
	at dotty.tools.dotc.transform.Mixin.transformTemplate(Mixin.scala:262)
	at dotty.tools.dotc.transform.Mixin.transformTemplate(Mixin.scala:98)
	at dotty.tools.dotc.transform.MegaPhase.goTemplate(MegaPhase.scala:922)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions