Skip to content

Issue with a nullary extension method and covariance #7458

Closed
@flomebul

Description

@flomebul

minimized code

type Tr[+V, +O <: V]
def (tr: Tr[V, O]) sl[V, O <: V]: Tr[V, O] = ???
def as[V, O <: V](tr: Tr[V, O]) : Tr[V, O] = tr.sl

An error is found by the compiler whine none is expected

-- [E007] Type Mismatch Error: ABug.scala:5:45 ---------------------------------
5 |def as[V, O <: V] (tr: Tr[V, O]): Tr[V, O] = tr.sl
  |                                             ^^
  |                       Found:    queries.Tr[V, V]
  |                       Required: queries.Tr[V, O]
  |                       
  |                       where:    O is a type in method as with bounds <: V
  |                                 V is a type in method as with bounds >: O
  |                       
  |                       Constraint(
  |                        uninstVars = ;
  |                        constrained types = 
  |                        bounds = 
  |                        ordering = 
  |                       )
  |                       Subtype trace:

For information, the issue disappears if I replace nullary method by parameterless

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions