Skip to content

Commit d64af1a

Browse files
committed
Enable -Yrepl-class-based to survey test failures
1 parent 9ac3039 commit d64af1a

21 files changed

+563
-52
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ 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 = settings.Yreplclassbased.value
77+
lazy val isClassBased: Boolean = true
7878
private[interpreter] lazy val useMagicImport: Boolean = true
7979

8080
private[nsc] var printResults = true // whether to print result lines

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,31 @@ 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-
defined class Bar
10-
defined term macro bar: Unit
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+
^
1117

1218
scala> bar
19+
<console>:14: error: not found: value bar
20+
bar
21+
^
1322

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

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

2031
scala> foo
32+
<console>:14: error: not found: value foo
33+
foo
34+
^
2135

2236
scala> :quit

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

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,39 @@ scala> object Macros {
3636
}; class Macros {
3737
def quux(x: Int): Int = macro Impls.quux
3838
}
39-
defined object Macros
40-
defined class Macros
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+
^
4155

4256
scala>
4357

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

4763
scala> println(foo(2) + Macros.bar(2) * new Macros().quux(4))
48-
31
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+
^
4973

5074
scala> :quit

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ 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-
defined term macro foo1: Nothing
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+
^
711

812
scala> def bar2(c: scala.reflect.macros.whitebox.Context) = ???
913
bar2: (c: scala.reflect.macros.whitebox.Context)Nothing
1014

1115
scala> def foo2 = macro bar2
12-
defined term macro foo2: Nothing
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+
^
1321

1422
scala> :quit

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@ 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-
defined object GrabContext
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+
^
1317

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

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

2028
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 object $iw
37+
<console>:5: error: lazy value f cannot be accessed in INSTANCE.$iw
3838
Access to protected lazy value f not permitted because
3939
enclosing object $eval in package $line13 is not a subclass of
40-
object $iw where target is defined
41-
lazy val $result = f
42-
^
40+
class $iw where target is defined
41+
lazy val $result = INSTANCE.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 = <function0>
178+
res30: () => Int = $Lambda$6544/1050942041@5302ef22
179179

180180
scala>
181181

182182
scala> () => 5
183-
res31: () => Int = <function0>
183+
res31: () => Int = $Lambda$6545/1676295269@33eff142
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 = <function0>
189+
res32: () => Int = $Lambda$6546/1582681622@1c38b0a0
190190

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

194194
scala>
195195

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ repl-out-dir-run.obj
1313
$line2
1414
$eval$.class
1515
$eval.class
16-
$read$$iw$.class
16+
$read$$iw.class
1717
$read$.class
1818
$read.class
1919
$line3
2020
$eval$.class
2121
$eval.class
22-
$read$$iw$.class
2322
$read$$iw$Bippy$.class
2423
$read$$iw$Bippy.class
24+
$read$$iw.class
2525
$read$.class
2626
$read.class
2727
$line4
2828
$eval$.class
2929
$eval.class
30-
$read$$iw$.class
30+
$read$$iw.class
3131
$read$.class
3232
$read.class
3333
$line5
3434
$eval$.class
3535
$eval.class
36-
$read$$iw$.class
36+
$read$$iw.class
3737
$read$.class
3838
$read.class
3939
$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 = <function0>
53+
res11: () => Int = $Lambda$6705/1778997070@17df7cde
5454

5555
scala>
5656

5757
scala> () => 5
58-
res12: () => Int = <function0>
58+
res12: () => Int = $Lambda$6706/75596657@457092e2
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 = <function0>
64+
res13: () => Int = $Lambda$6707/1795994857@65fa5379
6565

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

6969
scala>
7070

test/files/run/repl-term-macros.check

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,49 @@ scala> def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") }
1111
impl1: (c: scala.reflect.macros.blackbox.Context)c.Expr[Unit]
1212

1313
scala> def foo1: Unit = macro impl1
14-
defined term macro foo1: Unit
14+
<console>:14: error: macro implementation reference has wrong shape. required:
15+
macro [<static object>].<method name>[[<type args>]] or
16+
macro [<macro bundle>].<method name>[[<type args>]]
17+
def foo1: Unit = macro impl1
18+
^
1519

1620
scala> foo1
21+
<console>:14: error: not found: value foo1
22+
foo1
23+
^
1724

1825
scala>
1926

2027
scala> def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") }
2128
impl2: (c: scala.reflect.macros.blackbox.Context)()c.Expr[Unit]
2229

2330
scala> def foo2(): Unit = macro impl2
24-
defined term macro foo2: ()Unit
31+
<console>:14: error: macro implementation reference has wrong shape. required:
32+
macro [<static object>].<method name>[[<type args>]] or
33+
macro [<macro bundle>].<method name>[[<type args>]]
34+
def foo2(): Unit = macro impl2
35+
^
2536

2637
scala> foo2()
38+
<console>:14: error: not found: value foo2
39+
foo2()
40+
^
2741

2842
scala>
2943

3044
scala> def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
3145
impl3: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit]
3246

3347
scala> def foo3(x: Int)(y: Int): Unit = macro impl3
34-
defined term macro foo3: (x: Int)(y: Int)Unit
48+
<console>:14: error: macro implementation reference has wrong shape. required:
49+
macro [<static object>].<method name>[[<type args>]] or
50+
macro [<macro bundle>].<method name>[[<type args>]]
51+
def foo3(x: Int)(y: Int): Unit = macro impl3
52+
^
3553

3654
scala> foo3(2)(3)
55+
<console>:14: error: not found: value foo3
56+
foo3(2)(3)
57+
^
3758

3859
scala> :quit

0 commit comments

Comments
 (0)