Skip to content

Type mismatch error involving type member #3058

Closed
@pweisenburger

Description

@pweisenburger

When compiling the following code:

trait C[T] { type U }

object C { type Aux[X, Y] = C[X] { type U = Y } }


def a: C[Int] { type U = Int } = ???

def b[T](c: C[T]): C[T] { type U = c.U } = ???


def test[T, U](c: C.Aux[T, U]) = ???

test(b(a))

Dotty produces the following compiler error:

[E007] Type Mismatch Error
test(b(a))
     ^^^^
     found:    C[Int]{U = Int}
     required: C'.Aux[Int, U']

     where:    C  is a trait
               C' is a object
               U  is a type in trait C with bounds 
               U' is a type variable which is an alias of (param)1#U

There should be no type mismatch. Splitting the last expression like val x = b(a); test(x) works.

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