Skip to content

Commit 6527e07

Browse files
committed
Revert exploratory changes to default REPL wrappers
Revert "Enable magic imports unconditionally to survey test results" This reverts commit b02f890. Revert "Enable -Yrepl-class-based to survey test failures" This reverts commit d64af1a.
1 parent d64af1a commit 6527e07

25 files changed

+77
-576
lines changed

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ trait ScalaSettings extends AbsScalaSettings
237237
val YmacroFresh = BooleanSetting ("-Ymacro-global-fresh-names", "Should fresh names in macros be unique across all compilation units")
238238
val Yreplsync = BooleanSetting ("-Yrepl-sync", "Do not use asynchronous code for repl startup")
239239
val Yreplclassbased = BooleanSetting ("-Yrepl-class-based", "Use classes to wrap REPL snippets instead of objects")
240+
val YreplMagicImport = BooleanSetting ("-Yrepl-use-magic-imports", "In the code the wraps REPL snippes, use magic imports to rather than nesting wrapper object/classes")
240241
val Yreploutdir = StringSetting ("-Yrepl-outdir", "path", "Write repl-generated classfiles to given output directory (use \"\" to generate a temporary dir)" , "")
241242
val YmethodInfer = BooleanSetting ("-Yinfer-argument-types", "Infer types for arguments of overridden methods.")
242243
val YdisableFlatCpCaching = BooleanSetting ("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")

src/repl/scala/tools/nsc/interpreter/IMain.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
7474
// Used in a test case.
7575
def showDirectory() = replOutput.show(out)
7676

77-
lazy val isClassBased: Boolean = true
78-
private[interpreter] lazy val useMagicImport: Boolean = true
77+
lazy val isClassBased: Boolean = settings.Yreplclassbased.value
78+
private[interpreter] lazy val useMagicImport: Boolean = settings.YreplMagicImport.value
7979

8080
private[nsc] var printResults = true // whether to print result lines
8181
private[nsc] var totalSilence = false // whether to print anything

test/files/run/macro-bundle-repl.check

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,17 @@ scala> import scala.reflect.macros.blackbox.Context
66
import scala.reflect.macros.blackbox.Context
77

88
scala> class Bar(val c: Context) { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl
9-
<console>:12: error: macro definition needs to be enabled
10-
by making the implicit value scala.language.experimental.macros visible.
11-
This can be achieved by adding the import clause 'import scala.language.experimental.macros'
12-
or by setting the compiler option -language:experimental.macros.
13-
See the Scaladoc for value scala.language.experimental.macros for a discussion
14-
why the feature needs to be explicitly enabled.
15-
class Bar(val c: Context) { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl
16-
^
9+
defined class Bar
10+
defined term macro bar: Unit
1711

1812
scala> bar
19-
<console>:14: error: not found: value bar
20-
bar
21-
^
2213

2314
scala> class Foo(val c: Context) { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
2415
defined class Foo
2516

2617
scala> def foo: Unit = macro Foo.impl
27-
<console>:14: error: macro bundles must be static
28-
def foo: Unit = macro Foo.impl
29-
^
18+
defined term macro foo: Unit
3019

3120
scala> foo
32-
<console>:14: error: not found: value foo
33-
foo
34-
^
3521

3622
scala> :quit

test/files/run/macro-repl-basic.check

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,15 @@ scala> object Macros {
3636
}; class Macros {
3737
def quux(x: Int): Int = macro Impls.quux
3838
}
39-
<console>:14: error: macro definition needs to be enabled
40-
by making the implicit value scala.language.experimental.macros visible.
41-
This can be achieved by adding the import clause 'import scala.language.experimental.macros'
42-
or by setting the compiler option -language:experimental.macros.
43-
See the Scaladoc for value scala.language.experimental.macros for a discussion
44-
why the feature needs to be explicitly enabled.
45-
def foo(x: Int): Int = macro Impls.foo
46-
^
47-
<console>:16: error: macro definition needs to be enabled
48-
by making the implicit value scala.language.experimental.macros visible.
49-
def bar(x: Int): Int = macro Impls.bar
50-
^
51-
<console>:18: error: macro definition needs to be enabled
52-
by making the implicit value scala.language.experimental.macros visible.
53-
def quux(x: Int): Int = macro Impls.quux
54-
^
39+
defined object Macros
40+
defined class Macros
5541

5642
scala>
5743

5844
scala> import Macros.Shmacros._
59-
<console>:13: error: not found: value Macros
60-
import Macros.Shmacros._
61-
^
45+
import Macros.Shmacros._
6246

6347
scala> println(foo(2) + Macros.bar(2) * new Macros().quux(4))
64-
<console>:14: error: not found: value foo
65-
println(foo(2) + Macros.bar(2) * new Macros().quux(4))
66-
^
67-
<console>:14: error: not found: value Macros
68-
println(foo(2) + Macros.bar(2) * new Macros().quux(4))
69-
^
70-
<console>:14: error: not found: type Macros
71-
println(foo(2) + Macros.bar(2) * new Macros().quux(4))
72-
^
48+
31
7349

7450
scala> :quit

test/files/run/macro-repl-dontexpand.check

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,12 @@ scala> def bar1(c: scala.reflect.macros.blackbox.Context) = ???
33
bar1: (c: scala.reflect.macros.blackbox.Context)Nothing
44

55
scala> def foo1 = macro bar1
6-
<console>:12: error: macro implementation reference has wrong shape. required:
7-
macro [<static object>].<method name>[[<type args>]] or
8-
macro [<macro bundle>].<method name>[[<type args>]]
9-
def foo1 = macro bar1
10-
^
6+
defined term macro foo1: Nothing
117

128
scala> def bar2(c: scala.reflect.macros.whitebox.Context) = ???
139
bar2: (c: scala.reflect.macros.whitebox.Context)Nothing
1410

1511
scala> def foo2 = macro bar2
16-
<console>:12: error: macro implementation reference has wrong shape. required:
17-
macro [<static object>].<method name>[[<type args>]] or
18-
macro [<macro bundle>].<method name>[[<type args>]]
19-
def foo2 = macro bar2
20-
^
12+
defined term macro foo2: Nothing
2113

2214
scala> :quit

test/files/run/macro-system-properties.check

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,12 @@ scala> object GrabContext {
99
def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
1010
def grab(): Unit = macro impl
1111
}
12-
<console>:19: error: macro implementation reference has wrong shape. required:
13-
macro [<static object>].<method name>[[<type args>]] or
14-
macro [<macro bundle>].<method name>[[<type args>]]
15-
def grab(): Unit = macro impl
16-
^
12+
defined object GrabContext
1713

1814
scala> object Test { class C(implicit a: Any) { GrabContext.grab } }
19-
<console>:15: error: not found: value GrabContext
20-
object Test { class C(implicit a: Any) { GrabContext.grab } }
21-
^
15+
defined object Test
2216

2317
scala> object Test { class C(implicit a: Any) { GrabContext.grab } }
24-
<console>:15: error: not found: value GrabContext
25-
object Test { class C(implicit a: Any) { GrabContext.grab } }
26-
^
18+
defined object Test
2719

2820
scala> :quit

test/files/run/repl-colon-type.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ scala> :type lazy val f = 5
3434
Int
3535

3636
scala> :type protected lazy val f = 5
37-
<console>:5: error: lazy value f cannot be accessed in INSTANCE.$iw
37+
<console>:5: error: lazy value f cannot be accessed in object $iw
3838
Access to protected lazy value f not permitted because
3939
enclosing object $eval in package $line13 is not a subclass of
40-
class $iw where target is defined
41-
lazy val $result = INSTANCE.f
42-
^
40+
object $iw where target is defined
41+
lazy val $result = f
42+
^
4343

4444
scala> :type def f = 5
4545
=> Int

test/files/run/repl-no-imports-no-predef.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,21 +175,21 @@ scala> 55 ; (x: scala.Int) => x + 1 ; () => ((5))
175175
<console>:12: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses
176176
55 ; (x: scala.Int) => x + 1 ;;
177177
^
178-
res30: () => Int = $Lambda$6544/1050942041@5302ef22
178+
res30: () => Int = <function0>
179179

180180
scala>
181181

182182
scala> () => 5
183-
res31: () => Int = $Lambda$6545/1676295269@33eff142
183+
res31: () => Int = <function0>
184184

185185
scala> 55 ; () => 5
186186
<console>:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses
187187
55 ;;
188188
^
189-
res32: () => Int = $Lambda$6546/1582681622@1c38b0a0
189+
res32: () => Int = <function0>
190190

191191
scala> () => { class X ; new X }
192-
res33: () => AnyRef = $Lambda$6549/2038305728@428804e0
192+
res33: () => AnyRef = <function0>
193193

194194
scala>
195195

test/files/run/repl-out-dir.check

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,31 @@ repl-out-dir-run.obj
1313
$line2
1414
$eval$.class
1515
$eval.class
16-
$read$$iw.class
16+
$read$$iw$$iw$.class
17+
$read$$iw$.class
1718
$read$.class
1819
$read.class
1920
$line3
2021
$eval$.class
2122
$eval.class
22-
$read$$iw$Bippy$.class
23-
$read$$iw$Bippy.class
24-
$read$$iw.class
23+
$read$$iw$$iw$.class
24+
$read$$iw$$iw$Bippy$.class
25+
$read$$iw$$iw$Bippy.class
26+
$read$$iw$.class
2527
$read$.class
2628
$read.class
2729
$line4
2830
$eval$.class
2931
$eval.class
30-
$read$$iw.class
32+
$read$$iw$$iw$.class
33+
$read$$iw$.class
3134
$read$.class
3235
$read.class
3336
$line5
3437
$eval$.class
3538
$eval.class
36-
$read$$iw.class
39+
$read$$iw$$iw$.class
40+
$read$$iw$.class
3741
$read$.class
3842
$read.class
3943
$repl_$init.class

test/files/run/repl-parens.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,21 @@ scala> 55 ; (x: Int) => x + 1 ; () => ((5))
5050
<console>:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses
5151
55 ; (x: Int) => x + 1 ;;
5252
^
53-
res11: () => Int = $Lambda$6705/1778997070@17df7cde
53+
res11: () => Int = <function0>
5454

5555
scala>
5656

5757
scala> () => 5
58-
res12: () => Int = $Lambda$6706/75596657@457092e2
58+
res12: () => Int = <function0>
5959

6060
scala> 55 ; () => 5
6161
<console>:11: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses
6262
55 ;;
6363
^
64-
res13: () => Int = $Lambda$6707/1795994857@65fa5379
64+
res13: () => Int = <function0>
6565

6666
scala> () => { class X ; new X }
67-
res14: () => AnyRef = $Lambda$6708/863796198@6a98e293
67+
res14: () => AnyRef = <function0>
6868

6969
scala>
7070

0 commit comments

Comments
 (0)