Skip to content

Forced to restate type argument boundaries #1786

Open
@scabug

Description

@scabug

The below code shows a compiler flaw in that the wildcard "_" as value for a bounded type parameter either breaks the bound - as it result in Any - or doesn't (as id hoped it to be) evaluates to the bound.

class SomeClass(val intValue:Int)
class MyClass[T <: SomeClass](val myValue:T) 

def myMethod(i:MyClass[_]) {
   i.myValue.intValue/2      // << error i.myValue is of type Any
}

def myMethod(i:MyClass[_ <: SomeClass]) {
   i.myValue.intValue/2      // << works
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions