Skip to content

Structural type parameter bounds do not work as expected #4377

Open
@scabug

Description

@scabug
scala> trait Op { type Cap }
defined trait Op

scala> def f[O <: Op] = implicitly[O <:< Op { type Cap = O#Cap }]
<console>:8: error: could not find implicit value for parameter e: <:<[O,Op{type Cap = O#Cap}]
       def f[O <: Op] = implicitly[O <:< Op { type Cap = O#Cap }]
                                  ^

or, without implicits

scala> def f[C, O <: Op { type Cap = C }] {}
f: [C,O <: Op{type Cap = C}]=> Unit

scala> def g[O <: Op] = f[O#Cap, O]
<console>:9: error: type arguments [O#Cap,O] do not conform to method f's type parameter bounds [C,O <: Op{type Cap = C}]
       def g[O <: Op] = f[O#Cap, O]
                         ^

But the following actually works!

scala> def g[O <: Op { type Cap = Int }] = f[O#Cap, O]
g: [O <: Op{type Cap = Int}]=> Unit

Tested on 2.8.1 and 2.10.0.r24524-b20110321020039

See https://groups.google.com/d/msg/scala-user/WIjt66A74Kk/CFQUf1NyD3oJ for another example.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions