Skip to content

Unresolved symbols assertion during pickling when inlining def with result type with non-object prefix #5572

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
milessabin opened this issue Dec 5, 2018 · 4 comments

Comments

@milessabin
Copy link
Contributor

Compiling the following,

trait Foo {
  type Id[t] = t
  inline def foo[T](t: T) <: Id[T] =
    inline t match {
      case i: Int => (i+1).asInstanceOf[Id[T]]
      case _ => t
    }
}

object Bar extends Foo

object Test {
  Bar.foo(23)
}

Results in a compiler crash due to an assertion,

exception occurred while compiling tests/pos/inline-from-super.scala
java.lang.AssertionError: assertion failed: unresolved symbols: value Foo_this when pickling tests/pos/inline-from-super.scala while compiling tests/pos/inline-from-super.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: unresolved symbols: value Foo_this when pickling tests/pos/inline-from-super.scala

If we move the definition of Id out of the definition of Foo it compiles,

object Ext {
  type Id[t] = t
}
import Ext._

trait Foo {
  inline def foo[T](t: T) <: Id[T] =
    inline t match {
      case i: Int => (i+1).asInstanceOf[Id[T]]
      case _ => t
    }
}

object Bar extends Foo

object Test {
  Bar.foo(23)
}

It also compiles if we move the entire body of Foo into Bar,

object Bar {
  type Id[t] = t
  inline def foo[T](t: T) <: Id[T] =
    inline t match {
      case i: Int => (i+1).asInstanceOf[Id[T]]
      case _ => t
    }
}

object Test {
  Bar.foo(23)
}
@milessabin
Copy link
Contributor Author

I'm happy to take a swing at this. I'd be grateful for any pointers.

@odersky
Copy link
Contributor

odersky commented Dec 6, 2018

You get a more detailed message by turning -Ycheck:all (or just -Ycheck:front) on. The issue is that
there is a referenced symbol Foo_this that is not defined in the tree after typer. My guess is that this is due to Inliner.dropUnusedDefs not detecting a reference to Foo_this which would cause it to garbage collect the tree node. In the case it might be an owner of Id that is the undetected reference.

@milessabin milessabin assigned milessabin and unassigned odersky and nicolasstucki Dec 6, 2018
@milessabin
Copy link
Contributor Author

Thanks.

milessabin added a commit to milessabin/dotty that referenced this issue Dec 19, 2018
When dropping unused definitions during inlining we must also count
references to terms which are reachable via the types of RefTrees.

Fixes scala#5572.
@milessabin
Copy link
Contributor Author

PR here: #5646.

milessabin added a commit to milessabin/dotty that referenced this issue Dec 19, 2018
When dropping unused definitions during inlining we must also count
references to terms which are reachable via the types of RefTrees.

Fixes scala#5572.
nicolasstucki pushed a commit to dotty-staging/dotty that referenced this issue Jan 5, 2019
When dropping unused definitions during inlining we must also count
references to terms which are reachable via the types of RefTrees.

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

No branches or pull requests

3 participants