Skip to content

The approximation of path-dependent classes in TypeAssigner#avoid is too imprecise #711

Closed
@smarter

Description

@smarter
class Outer {
  class Inner
}
object Test {
  def test = {
    // works
    val a: Outer#Inner = {
      val o = new Outer
      new o.Inner: Outer#Inner
    }


    // error: type mismatch:
    // found   : Object
    // required: Outer#Inner
    //    val b: Outer#Inner = {
    //                         ^
    val b: Outer#Inner = {
      val o = new Outer
      new o.Inner
    }
  }
}

The approximation is done in TypeAssigner#avoid:

        case tp: TypeRef if (forbidden contains tp.symbol) || toAvoid(tp.prefix) =>
           //...

Instead of approximating the class o.Inner by its parent class Object, it should approximate it by its supertypeOuter#Inner.

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