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

class defined with paste mode mismatches #9734

Closed
scabug opened this Issue Apr 5, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Apr 5, 2016

This bug only exists with the flag -Yrepl-class-based:

#  scala -Yrepl-class-based
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_60).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :pa
// Entering paste mode (ctrl-D to finish)

case class Data(i: Int)
val d = Data(1)

// Exiting paste mode, now interpreting.

defined class Data
d: Data = Data(1)

scala> val d2: Data = d
<console>:14: error: type mismatch;
 found   : Data
 required: Data
       val d2: Data = d
                      ^

scala>
@scabug

This comment has been minimized.

Copy link
Author

scabug commented Apr 5, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9734?orig=1
Reporter: Wenchen Fan (cloud)
Affected Versions: 2.11.7
Other Milestones: 2.12.0-M5

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Apr 5, 2016

Wenchen Fan (cloud) said:
cc [~rxin]

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Apr 5, 2016

@som-snytt said:
Minimization of a sort:

import $line3.$read.INSTANCE.$iw.$iw.D;
val $line3$read = $line3.$read.INSTANCE;
import $line3$read.$iw.$iw.d;
val x: D = d

or

package badinterp {

  class read { case class D(i: Int) }
  object read { val instance = new read }

  object Test extends App {
    import badinterp.read.instance.D
    val instance = badinterp.read.instance
    //val instance: read.instance.type = read.instance  // works
    val x: D = instance.D(42)
    Console println x
  }
}
@scabug

This comment has been minimized.

Copy link
Author

scabug commented Apr 5, 2016

@som-snytt said:
I would have added, Fixed in Ammonite, but I didn't actually try it out.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Apr 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment