Skip to content

ExplicitOuter crash with local class defined in val in trait if the local class extends a path-dependent class #1131

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 Feb 29, 2016 · 3 comments · Fixed by #1168

Comments

@smarter
Copy link
Member

smarter commented Feb 29, 2016

class Outer {
  class Inner
}

trait MustBeATrait {
  val o = new Outer
  val inner = new o.Inner {}
}

fails with assertion failed: asTerm called on not-a-Term val <none> somewhere in ExplicitOuter.
Stack trace: https://gist.github.com/smarter/992bb93f2d0f2705a6a6

@smarter
Copy link
Member Author

smarter commented Feb 29, 2016

Note that there's no crash if val inner = is removed or replaced by def inner =.

@smarter smarter changed the title Crash with anonymous path-dependent class in a trait ExplicitOuter crash with anonymous path-dependent class in a trait Feb 29, 2016
@smarter
Copy link
Member Author

smarter commented Feb 29, 2016

More info, if we print the ctx.log calls in ExplicitOuter:

computing outerpath to trait MustBeATrait from List(method <init>, method inner, method inner, class MustBeATrait, class MustBeATrait, module class <empty>, module class <root>, module class <root>, module class <root>, module class <root>, module class <root>, module class <root>, module class <root>, val <none>, val <none>, val <none>, val <none>)
outer to trait MustBeATrait of this: Outer.this.Inner{...}(this), looking for MustBeATrait$~$anon$$$outer in anonymous class Outer.this.Inner{...}
outer to trait MustBeATrait of this.MustBeATrait$~$anon$$$outer(): MustBeATrait, looking for MustBeATrait$$$outer in trait MustBeATrait
computing outerpath to anonymous class Outer.this.Inner{...} from List(class MustBeATrait, class MustBeATrait, class MustBeATrait, module class <empty>, module class <root>, module class <root>, module class <root>, module class <root>, module class <root>, module class <root>, module class <root>, val <none>, val <none>, val <none>, val <none>)
outer to anonymous class Outer.this.Inner{...} of this: MustBeATrait(MustBeATrait.this), looking for MustBeATrait$$$outer in trait MustBeATrait

The last two lines do not appear and there's no crash if we replace val inner = by def inner =

@smarter smarter changed the title ExplicitOuter crash with anonymous path-dependent class in a trait ExplicitOuter crash with local class defined in val in trait that extends a path-dependent class Feb 29, 2016
@smarter
Copy link
Member Author

smarter commented Feb 29, 2016

It also happens with non-anonymous local classes:

class Outer {
  class Inner
}

trait MustBeATrait {
  val o = new Outer
  val inner = {
    class A extends o.Inner
    new A
  }
}

@smarter smarter changed the title ExplicitOuter crash with local class defined in val in trait that extends a path-dependent class ExplicitOuter crash with local class defined in val in trait if the local class extends a path-dependent class Feb 29, 2016
DarkDimius referenced this issue Mar 14, 2016
Tweaks to ExplicitOuter and TreeTypeMap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants