Skip to content

List(1,2,3,4).contains("hello") compiles #10831

@pjrt

Description

@pjrt

This seems to be an issue in the inference of types since the following also compiles:

trait K[A] { def f[A1 >: A](a2: A1): Boolean = false } 
val x = new K[Int]{} 
x.f("Hello") // compiles
x.f[String]("Hello") // does not

When [A1 >: A] is used in a function though, it works as expected:

def f[A, A1 >: A](a: A)(a1: A1): Unit = () 
f(1)("hello") // does not compile

So it seems [A1 >: A] is unsafe when used in methods where A is defined at the trait/class level.

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