8000 Merge pull request #8748 from dwijnand/class-based-on · scala/scala@32704bc · GitHub
[go: up one dir, main page]

Skip to content

Commit 32704bc

Browse files
authored
Merge pull request #8748 from dwijnand/class-based-on
Default true -Yrepl-{class-based,use-magic-imports}
2 parents 5575d98 + c4a69ee commit 32704bc

File tree

8 files changed

+28
-44
lines changed

8 files changed

+28
-44
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ trait ScalaSettings extends StandardScalaSettings with Warnings {
242242
val Ymacroexpand = ChoiceSetting ("-Ymacro-expand", "policy", "Control expansion of macros, useful for scaladoc and presentation compiler.", List(MacroExpand.Normal, MacroExpand.None, MacroExpand.Discard), MacroExpand.Normal)
243243
val YmacroFresh = BooleanSetting ("-Ymacro-global-fresh-names", "Should fresh names in macros be unique across all compilation units")
244244
val YmacroAnnotations = BooleanSetting ("-Ymacro-annotations", "Enable support for macro annotations, formerly in macro paradise.")
245-
val Yreplclassbased = BooleanSetting ("-Yrepl-class-based", "Use classes to wrap REPL snippets instead of objects")
246-
val YreplMagicImport = BooleanSetting ("-Yrepl-use-magic-imports", "In the code that wraps REPL snippets, use magic imports rather than nesting wrapper object/classes")
245+
val Yreplclassbased = BooleanSetting ("-Yrepl-class-based", "Use classes to wrap REPL snippets instead of objects") withDefault true
246+
val YreplMagicImport = BooleanSetting ("-Yrepl-use-magic-imports", "In the code that wraps REPL snippets, use magic imports rather than nesting wrapper object/classes") withDefault true
247247
val Yreploutdir = StringSetting ("-Yrepl-outdir", "path", "Write repl-generated classfiles to given output directory (use \"\" to generate a temporary dir)" , "")
248248
@deprecated("Unused setting will be removed", since="2.13")
249249
val Yreplsync = new BooleanSetting ("-Yrepl-sync", "Legacy setting for sbt compatibility, unused.").internalOnly()

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ Int
3535

3636
scala> :type protected lazy val f = 5
3737

38-
lazy val $result = $line16.$read.INSTANCE.$iw.$iw.f
39-
^
40-
<synthetic>:4: error: lazy value f cannot be accessed as a member of object $iw from object $eval in package
38+
lazy val $result = $line16.$read.INSTANCE.$iw.f
39+
^
40+
<synthetic>:4: error: lazy value f cannot 8000 be accessed as a member of INSTANCE.$iw from object $eval in package
4141
Access to protected lazy value f not permitted because
4242
enclosing object $eval in package $line16 is not a subclass of
43-
object $iw where target is defined
43+
class $iw where target is defined
4444

4545
(To diagnose errors in synthetic code, try adding `// show` to the end of your input.)
4646

test/files/run/repl-deadlock.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ import scala.tools.nsc.Settings
22
import scala.tools.partest.ReplTest
33

44
object Test extends ReplTest {
5-
override def transformSettings(s: Settings) = {
6-
s.Yreplclassbased.value = true // TODO: drop when it's default true, to assert it works out the box
7-
s
8-
}
9-
105
def code = """
116
|import scala.concurrent._
127
|import scala.concurrent.duration._

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,27 @@ repl-out-dir-run.obj
1515
$line2
1616
$eval$.class
1717
$eval.class
18-
$read$$iw$$iw$.class
19-
$read$$iw$.class
18+
$read$$iw.class
2019
$read$.class
2120
$read.class
2221
$line3
2322
$eval$.class
2423
$eval.class
25-
$read$$iw$$iw$.class
26-
$read$$iw$$iw$Bippy$.class
27-
$read$$iw$$iw$Bippy.class
28-
$read$$iw$.class
24+
$read$$iw$Bippy$.class
25+
$read$$iw$Bippy.class
26+
$read$$iw.class
2927
$read$.class
3028
$read.class
3129
$line4
3230
$eval$.class
3331
$eval.class
34-
$read$$iw$$iw$.class
35-
$read$$iw$.class
32+
$read$$iw.class
3633
$read$.class
3734
$read.class
3835
$line5
3936
$eval$.class
4037
$eval.class
41-
$read$$iw$$iw$.class
42-
$read$$iw$.class
38+
$read$$iw.class
4339
$read$.class
4440
$read.class
4541
$repl_$init.class

test/files/run/repl-trim-stack-trace.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ def f: Nothing
44

55
scala> f
66
java.lang.Exception: Uh-oh
7-
at .f(<console>:XX)
7+
at f(<console>:XX)
88
... ??? elided
99

1010
scala> def f = throw new Exception("")
1111
def f: Nothing
1212

1313
scala> f
1414
java.lang.Exception:
15-
at .f(<console>:XX)
15+
at f(<console>:XX)
1616
... ??? elided
1717

1818
scala> def f = throw new Exception
1919
def f: Nothing
2020

2121
scala> f
2222
java.lang.Exception
23-
at .f(<console>:XX)
23+
at f(<console>:XX)
2424
... ??? elided
2525

2626
scala> null.asInstanceOf

test/files/run/t5256d.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ scala> println(c)
1515
class A
1616

1717
scala> println(c.fullName)
18-
$line8.$read.$iw.$iw.$iw.$iw.A
18+
$line8.$read.$iw.A
1919

2020
scala> println(c.info)
2121
AnyRef {

test/files/run/t7747-repl.check

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -238,25 +238,18 @@ package $line10 {
238238
super.<init>;
239239
()
240240
};
241+
import $line7.$read.INSTANCE.$iw.BippyBups;
242+
import $line7.$read.INSTANCE.$iw.BippyBups;
243+
import $line8.$read.INSTANCE.$iw.PuppyPups;
244+
import $line8.$read.INSTANCE.$iw.PuppyPups;
245+
import $line9.$read.INSTANCE.$iw.Bingo;
246+
import $line9.$read.INSTANCE.$iw.Bingo;
241247
sealed class $iw extends _root_.java.io.Serializable {
242248
def <init>() = {
243249
super.<init>;
244250
()
245251
};
246-
import $line7.$read.INSTANCE.$iw.$iw.BippyBups;
247-
import $line7.$read.INSTANCE.$iw.$iw.BippyBups;
248-
import $line8.$read.INSTANCE.$iw.$iw.PuppyPups;
249-
import $line8.$read.INSTANCE.$iw.$iw.PuppyPups;
250-
import $line9.$read.INSTANCE.$iw.$iw.Bingo;
251-
import $line9.$read.INSTANCE.$iw.$iw.Bingo;
252-
sealed class $iw extends _root_.java.io.Serializable {
253-
def <init>() = {
254-
super.<init>;
255-
()
256-
};
257-
val res3 = List(BippyBups, PuppyPups, Bingo)
258-
};
259-
val $iw = new $iw.<init>
252+
val res3 = List(BippyBups, PuppyPups, Bingo)
260253
};
261254
val $iw = new $iw.<init>
262255
};
@@ -271,11 +264,11 @@ package $line10 {
271264

272265
package $line10 {
273266
object $eval {
274-
lazy val $result = $line10.$read.INSTANCE.$iw.$iw.res3
267+
lazy val $result = $line10.$read.INSTANCE.$iw.res3
275268
lazy val $print: _root_.java.lang.String = {
276-
$line10.$read.INSTANCE.$iw.$iw
269+
$line10.$read.INSTANCE.$iw
277270

278-
"" + "val res3: List[Product with java.io.Serializable]" + " = " + _root_.scala.runtime.ScalaRunTime.replStringOf($line10.$read.INSTANCE.$iw.$iw.res3, 1000)
271+
"" + "val res3: List[Product with java.io.Serializable]" + " = " + _root_.scala.runtime.ScalaRunTime.replStringOf($line10.$read.INSTANCE.$iw.res3, 1000)
279272

280273
}
281274
}}

test/files/run/t8843-repl-xlat.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ class Bippy
55
scala> $intp.reporter.withoutUnwrapping {
66
| println($intp.classLoader getResource "Bippy.class")
77
| }
8-
memory:(memory)/$line3/$read$$iw$$iw$Bippy.class
8+
memory:(memory)/$line3/$read$$iw$Bippy.class
99

1010
scala> $intp.reporter.withoutUnwrapping {
1111
| println(($intp.classLoader getResources "Bippy.class").nextElement)
1212
| }
13-
memory:(memory)/$line3/$read$$iw$$iw$Bippy.class
13+
memory:(memory)/$line3/$read$$iw$Bippy.class
1414

1515
scala> ($intp.classLoader classBytes "Bippy").nonEmpty
1616
val res2: Boolean = true

0 commit comments

Comments
 (0)
0