Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
smarter opened this issue Jul 4, 2015 · 0 comments

Comments

@smarter
Copy link
Member

smarter commented Jul 4, 2015

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.

smarter added a commit to smarter/dotty that referenced this issue Oct 1, 2015
When we need to avoid `A` in the class `A#B`, we can try to replace `A`
by a supertype. Previously, we only tried to replace `A#B` itself by a
supertype.

Fixes scala#711.
smarter added a commit to smarter/dotty that referenced this issue Oct 2, 2015
When we need to avoid `A` in the class `A#B`, we can try to replace `A`
by a supertype. Previously, we only tried to replace `A#B` itself by a
supertype.

Fixes scala#711.
smarter added a commit to smarter/dotty that referenced this issue Oct 2, 2015
When we need to avoid `A` in the class `A#B`, we can try to replace `A`
by a supertype. Previously, we only tried to replace `A#B` itself by a
supertype.

Fixes scala#711.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant