Skip to content
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

Imported names are not respected when defining classes in REPL with -Yrepl-class-based #9880

Closed
scabug opened this issue Aug 6, 2016 · 3 comments
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Aug 6, 2016

The following snippet illustrates the problem with -Yrepl-class-based:

$ scala -Yrepl-class-based
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_92).
Type in expressions for evaluation. Or try :help.

scala> import java.util.Date
import java.util.Date

scala> class Test(date: Date) // show
class $read extends Serializable {
  def <init>() = {
    super.<init>;
    ()
  };
  class $iw extends Serializable {
    def <init>() = {
      super.<init>;
      ()
    };
    class $iw extends Serializable {
      def <init>() = {
        super.<init>;
        ()
      };
      class Test extends scala.AnyRef {
        <paramaccessor> private[this] val date: Date = _;
        def <init>(date: Date) = {
          super.<init>;
          ()
        }
      }
    };
    val $iw = new $iw.<init>
  };
  val $iw = new $iw.<init>
}
object $read extends scala.AnyRef {
  def <init>() = {
    super.<init>;
    ()
  };
  val INSTANCE = new $read.<init>
}
<console>:11: error: not found: type Date
       class Test(date: Date) // show
                        ^

Without -Yrepl-class-based it works as expected:

$ scala
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_92).
Type in expressions for evaluation. Or try :help.

scala> import java.util.Date
import java.util.Date

scala> class Test(date: Date) // show
object $read extends scala.AnyRef {
  def <init>() = {
    super.<init>;
    ()
  };
  object $iw extends scala.AnyRef {
    def <init>() = {
      super.<init>;
      ()
    };
    import java.util.Date;
    object $iw extends scala.AnyRef {
      def <init>() = {
        super.<init>;
        ()
      };
      class Test extends scala.AnyRef {
        <paramaccessor> private[this] val date: Date = _;
        def <init>(date: Date) = {
          super.<init>;
          ()
        }
      }
    }
  }
}
defined class Test
@scabug
Copy link
Author

scabug commented Aug 6, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9880?orig=1
Reporter: @jasonxh
Affected Versions: 2.11.8, 2.12.0-M5

@scabug
Copy link
Author

scabug commented Aug 7, 2016

@jasonxh said:
After some digging, this seems to be caused by a deeper problem in how ImportHandler keeps track of importedNames. See [SI-9881]. We need to either fix that bug or remove the check on importedNames when computing imports (which may have undesirable consequences).

@som-snytt
Copy link

see the other ticket

@som-snytt som-snytt closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants