Skip to content

Implicit conversion does not work for mix-in types #10671

@Atry

Description

@Atry
Welcome to Scala 2.12.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_152).
Type in expressions for evaluation. Or try :help.

scala> type A = {
     |   def self: Option[String]
     | }
defined type alias A

scala> type B = {
     |   def self: Option[AnyRef]
     | }
defined type alias B

scala> def convert(ab: A with B) = ab.ensuring { _.isInstanceOf[AnyRef] }
<console>:13: error: value ensuring is not a member of A with B
       def convert(ab: A with B) = ab.ensuring { _.isInstanceOf[AnyRef] }
                                      ^

Note that ensuring is an extension method defined in Predef

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