Skip to content

Type avoidance does not take type parameter bounds in account and can produce invalid types #6205

Open
@smarter

Description

@smarter

Given:

class Contra[-T >: Null]

object Test {
  def foo = {
    class A

    new Contra[A]
  }
}

The inferred type of foo is Contra[Nothing], but this isn't a legal type (and indeed writing it down would produce a Type argument Nothing does not conform to lower bound Null error).
It seems that ApproximatingTypeMap#derivedAppliedType is missing logic to replace Ranges by types which are in bounds. Moreover, -Ycheck should be enhanced to detect this kind of bound violations.

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