Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SI-9740 Repl import fix -Yrepl-class-based
Under `-Yrepl-class-based`, templating must follow the same scoping as under traditional object-based. The new test shows a typical case where two values of the same simple name must be imported in different scopes.
- Loading branch information
Showing
8 changed files
with
80 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
scala> case class K(s: String) | ||
defined class K | ||
|
||
scala> class C { implicit val k: K = K("OK?"); override def toString = s"C($k)" } | ||
defined class C | ||
|
||
scala> val c = new C | ||
c: C = C(K(OK?)) | ||
|
||
scala> import c.k | ||
import c.k | ||
|
||
scala> implicitly[K] | ||
res0: K = K(OK?) | ||
|
||
scala> val k = 42 | ||
k: Int = 42 | ||
|
||
scala> k // was K(OK?) | ||
res1: Int = 42 | ||
|
||
scala> :quit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
import scala.tools.partest.ReplTest | ||
import scala.tools.nsc.Settings | ||
|
||
//SI-9740 | ||
object Test extends ReplTest { | ||
override def transformSettings(s: Settings): Settings = { | ||
s.Yreplclassbased.value = true | ||
s | ||
} | ||
|
||
def code = | ||
""" | ||
case class K(s: String) | ||
class C { implicit val k: K = K("OK?"); override def toString = s"C($k)" } | ||
val c = new C | ||
import c.k | ||
implicitly[K] | ||
val k = 42 | ||
k // was K(OK?) | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +0,0 @@ | ||
#partest java6 | ||
Welcome to Scala | ||
Type in expressions for evaluation. Or try :help. | ||
|
||
scala> :javap -app MyApp$ | ||
public final void delayedEndpoint$MyApp$1(); | ||
Code: | ||
Stack=2, Locals=1, Args_size=1 | ||
0: getstatic #XX; //Field scala/Console$.MODULE$:Lscala/Console$; | ||
3: ldc #XX; //String Hello, delayed world. | ||
5: invokevirtual #XX; //Method scala/Console$.println:(Ljava/lang/Object;)V | ||
8: return | ||
LocalVariableTable: | ||
Start Length Slot Name Signature | ||
0 9 0 this LMyApp$; | ||
|
||
scala> :quit | ||
#partest java7 | ||
Welcome to Scala | ||
Type in expressions for evaluation. Or try :help. | ||
|
||
scala> :javap -app MyApp$ | ||
public final void delayedEndpoint$MyApp$1(); | ||
flags: ACC_PUBLIC, ACC_FINAL | ||
Code: | ||
stack=2, locals=1, args_size=1 | ||
0: getstatic #XX // Field scala/Console$.MODULE$:Lscala/Console$; | ||
3: ldc #XX // String Hello, delayed world. | ||
5: invokevirtual #XX // Method scala/Console$.println:(Ljava/lang/Object;)V | ||
8: return | ||
LocalVariableTable: | ||
Start Length Slot Name Signature | ||
0 9 0 this LMyApp$; | ||
LineNumberTable: | ||
line 5: 0 | ||
} | ||
|
||
scala> :quit | ||
#partest java8 | ||
Welcome to Scala | ||
Type in expressions for evaluation. Or try :help. | ||
|
||
scala> :javap -app MyApp$ | ||
public final void delayedEndpoint$MyApp$1(); | ||
descriptor: ()V | ||
flags: ACC_PUBLIC, ACC_FINAL | ||
Code: | ||
stack=2, locals=1, args_size=1 | ||
0: getstatic #XX // Field scala/Console$.MODULE$:Lscala/Console$; | ||
3: ldc #XX // String Hello, delayed world. | ||
5: invokevirtual #XX // Method scala/Console$.println:(Ljava/lang/Object;)V | ||
8: return | ||
LocalVariableTable: | ||
Start Length Slot Name Signature | ||
0 9 0 this LMyApp$; | ||
LineNumberTable: | ||
line 5: 0 | ||
} | ||
|
||
scala> :quit | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters