| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
By default, scala-compiler.jar is in the bootclasspath, which gives us a
`null` when we call `classOf[IMain].getClassLoader`. That value is used
as the parent class loader of the classloader that evals code in the REPL.
Under JDK9, this breaks lookup of classes on the module path:
```
scala -J--add-modules=java.compiler -J--add-exports=jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED
Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 9-ea).
Type in expressions for evaluation. Or try :help.
scala> new com.sun.tools.javap.JavapTask();
java.lang.NoClassDefFoundError: com/sun/tools/javap/JavapTask
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:2948)
```
A workaround is to use `-nobootcp`.
This commit uses the system classloader as the parent in place of the null classloader
to make this work in both cases.
```
qscala -J--add-modules=java.compiler -J--add-exports=jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED
Welcome to Scala 2.12.2-20161208-165912-3de1c0c (Java HotSpot(TM) 64-Bit Server VM, Java 9-ea).
Type in expressions for evaluation. Or try :help.
scala> new com.sun.tools.javap.JavapTask();
res0: com.sun.tools.javap.JavapTask = com.sun.tools.javap.JavapTask@1f1cddf3
scala>
```
Note that the `:javap` command still requires `-nobootcp` because code in the REPL implements
an interface in a the `java.compiler` module.
|
|
|
|
|
|
|
| |
By marking the wrapper classes as sealed, the inliner will be
able to assume finality of defs introduces in the REPL without
requiring the user to mark them as `final`, which is an odd thing
to do in single line of REPL input.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The REPL has a long running instance of Global which outputs
classfiles by default to a VirtualDirectory. The inliner did not find
any of these class files when compiling calls to methods defined in
previous runs (ie, previous lines of input.)
This commit:
- Adds a hook to augment the classpath that the optimizer searches,
and uses this in the REPL to add the output directory
- Fixes the implementation of `findClassFile` in VirtualDirectory,
which doesn't seem to have been used in anger before. I've factored out
some common code into a new method on `AbstractFile`.
- Fixes a similar problem getSubDir reported by Li Haoyi
- Adds missing unit test coverage.
This also fixes a bug in REPL autocompletion for types defined
in packages >= 2 level deep (with the `:paste -raw` command).
I've added a test for this case.
|
| |
|
|
|
|
|
|
| |
just in time for Halloween. "boostrap" is definitely the most
adorable typo evah -- and one of the most common, too. but we don't
want to scare anybody.
|
|
|
|
|
|
|
|
|
|
| |
The paradigm is `def add(x: X): Unit = listBuffer += x`.
The value that is discarded is not new information.
Also cleans up the recent tweaks to help messaging.
Adds newlines in case they ask for multiple helps.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Essentially, we fuse mixin and lazyvals into the fields phase.
With fields mixing in trait members into subclasses, we
have all info needed to compute bitmaps, and thus we can
synthesize the synchronisation logic as well.
By doing this before erasure we get better signatures,
and before specialized means specialized lazy vals work now.
Mixins is now almost reduced to its essence: implementing
super accessors and forwarders. It still synthesizes
accessors for param accessors and early init trait vals.
Concretely, trait lazy vals are mixed into subclasses
with the needed synchronization logic in place, as do
lazy vals in classes and methods. Similarly, modules
are initialized using double checked locking.
Since the code to initialize a module is short,
we do not emit compute methods for modules (anymore).
For simplicity, local lazy vals do not get a compute method either.
The strange corner case of constant-typed final lazy vals
is resolved in favor of laziness, by no longer assigning
a constant type to a lazy val (see widenIfNecessary in namers).
If you explicitly ask for something lazy, you get laziness;
with the constant-typedness implicit, it yields to the
conflicting `lazy` modifier because it is explicit.
Co-Authored-By: Lukas Rytz <lukas@lightbend.com>
Fixes scala/scala-dev#133
Inspired by dotc, desugar a local `lazy val x = rhs` into
```
val x$lzy = new scala.runtime.LazyInt()
def x(): Int = {
x$lzy.synchronized {
if (!x$lzy.initialized) {
x$lzy.initialized = true
x$lzy.value = rhs
}
x$lzy.value
}
}
```
Note that the 2.11 decoding (into a local variable and a bitmap) also
creates boxes for local lazy vals, in fact two for each lazy val:
```
def f = {
lazy val x = 0
x
}
```
desugars to
```
public int f() {
IntRef x$lzy = IntRef.zero();
VolatileByteRef bitmap$0 = VolatileByteRef.create((byte)0);
return this.x$1(x$lzy, bitmap$0);
}
private final int x$lzycompute$1(IntRef x$lzy$1, VolatileByteRef bitmap$0$1) {
C c = this;
synchronized (c) {
if ((byte)(bitmap$0$1.elem & 1) == 0) {
x$lzy$1.elem = 0;
bitmap$0$1.elem = (byte)(bitmap$0$1.elem | 1);
}
return x$lzy$1.elem;
}
}
private final int x$1(IntRef x$lzy$1, VolatileByteRef bitmap$0$1) {
return (byte)(bitmap$0$1.elem & 1) == 0 ?
this.x$lzycompute$1(x$lzy$1, bitmap$0$1) : x$lzy$1.elem;
}
```
An additional problem with the above encoding is that the `lzycompute`
method synchronizes on `this`. In connection with the new lambda
encoding that no longer generates anonymous classes, captured lazy vals
no longer synchronize on the lambda object.
The new encoding solves this problem (scala/scala-dev#133)
by synchronizing on the lazy holder.
Currently, we don't exploit the fact that the initialized field
is `@volatile`, because it's not clear the performance is needed
for local lazy vals (as they are not contended, and as soon as
the VM warms up, biased locking should deal with that)
Note, be very very careful when moving to double-checked locking,
as this needs a different variation than the one we use for
class-member lazy vals. A read of a volatile field of a class
does not necessarily impart any knowledge about a "subsequent" read
of another non-volatile field of the same object. A pair of
volatile reads and write can be used to implement a lock, but it's
not clear if the complexity is worth an unproven performance gain.
(Once the performance gain is proven, let's change the encoding.)
- don't explicitly init bitmap in bytecode
- must apply method to () explicitly after uncurry
|
|\
| |
| | |
SI-8576 Minimal changes for `-Xcheckinit` compatibility
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As explained in https://issues.scala-lang.org/browse/SI-8576, I expect
serialization compatibility between builds with and without
`-Xcheckinit` to be unattainable. This commit contains some minor fixes
for issues discovered while running builds with `-Xcheckinit`:
- Add `@SerialVersionUID` to `scala.collection.immutable.Vector`, as
requested in SI-8576. Note that this does not make `Vector`
serialization compatible.
- Use lazy initialization for `global` in `PresentationCompilation`. It
used to access the uninitialized `self` variable (which seems to be
inconsequential in practice and only fails under `-Xcheckinit`).
We should consider using `Externalizable` instead of `Serializable` for
collections in 2.13 to make collection classes serialization compatible.
|
|\ \
| | |
| | | |
SI-8829 Defaultly scala -feature -deprecation
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
"Re-run with -deprecation" is not always appropriate.
REPL gets to customize the message. The API includes the
setting and its name, because reflect Settings do not
have names. (!)
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Turn on `-feature -deprecation` in REPL if neither option
is selected.
```
$ ./build/pack/bin/scala
Welcome to Scala 2.12.0-20160707-105953-4e564ef (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_92).
Type in expressions for evaluation. Or try :help.
scala> @deprecated("","") def f = 42
f: Int
scala> f toDouble
<console>:13: warning: postfix operator toDouble should be enabled
by making the implicit value scala.language.postfixOps visible.
This can be achieved by adding the import clause 'import scala.language.postfixOps'
or by setting the compiler option -language:postfixOps.
See the Scaladoc for value scala.language.postfixOps for a discussion
why the feature should be explicitly enabled.
f toDouble
^
<console>:13: warning: method f is deprecated:
f toDouble
^
res1: Double = 42.0
scala> :quit
$ scala
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_92).
Type in expressions for evaluation. Or try :help.
scala> @deprecated("","") def f = 42
f: Int
scala> f toDouble
warning: there was one deprecation warning; re-run with -deprecation for details
warning: there was one feature warning; re-run with -feature for details
res1: Double = 42.0
```
|
|/ |
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| | |
SBT tries to install its own SimpleReader (for some reason)
if it needs to create its own IMain.
Because Rube Goldberg needs to execute some postinit hooks,
don't let SBT do that.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If `-raw` is not supplied explicitly to REPL `:paste`,
see if the code text starts with `package` keyword or
else see if it parses to a named package (to cope with
leading commentary). In that case, take it as raw.
But parse only on suspect comment slash.
It's only worth parsing for a package if there's a chance
that package keyword is buried behind comments.
Small refactors to the `paste` object.
|
|\| |
|
| |
| |
| |
| | |
Text-based REPL pre-parses, so use the current label for errors.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Use a "label" for errors, so that script names are shown.
Position is still wrong for scripts in REPL.
Initial scripts are run with `ILoop.echo` and results printing
turned off, but reporter still enabled.
|
| |
| |
| |
| | |
Enable noisy modes only when interpreting user input.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The compiler is created on main thread and user input is read
on an aux thread (opposite to currently).
Fixes completion when `-i` is supplied.
Now `-i` means pasted and new option `-I` means line-by-line.
The temporary reader uses postInit to swap in the underlying
reader.
Completion is disabled for the temporary reader, rather than
blocking while it waits for a compiler. But manically hitting
tab is one way of knowing exactly when completion is live.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Refactor the ScriptEngine support to an adaptor atop the
IMain API.
Allow references to resolve to context attributes. (The
attributes must be defined at compilation time, though
they may resolve to updated values at evaluation time.)
This means that attributes are not bound statically in
REPL history. In particular, we forgo the trick of binding
attributes named "name: Type" as typed values.
Instead, an `x` bound in dynamic context is injected into
the script as a dynamic selection `$ctx.x` where `ctx`
performs the look-up in the script context.
When a compiled script is re-evaluated, a new instance of
the script class is created and defined symbols are
rebound.
The context stdout writer is handled with `Console.withOut`,
with bytes decoded using the default charset.
Compilation errors are thrown as ScriptException with the
first reported error.
This commit doesn't attempt dynamic selection from objects
in context. Currently, script must cast.
|
|\|
| |
| |
| |
| |
| |
| |
| |
| | |
merge/2.11.x-to-2.12.x-20160517
Conflicts:
build.sbt
test/files/run/repl-javap-app.check
test/files/run/repl-javap-app.scala
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| | |
When the repl is started with additional compiler flags that prevent implicits
being in scope (like -Yno-predef) the default message of implicits in scope
using :implicits stays the same.
This additional check will return the same message if predef is indeed in
scope and an adjusted message if Predef is not in scope.
|
|\ \
| | |
| | | |
Remove legacy recursive classpath implementation
|
| | | |
|
| | | |
|
|\ \ \
| |/ /
|/| /
| |/ |
|
| |
| |
| |
| |
| | |
Under `-Yrepl-class-based`, imports from historical `$read`
instances must be singleton-typed so that path-dependent types
remain so.
|
| |
| |
| |
| |
| | |
When constructing code text for compilation, the REPL
should prefer standard escape sequences, in case unicode
escapes are disabled.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Fix a batch of code inspection recommendations generated by IntelliJ 14.1.5.
Categories of fix,
Unnecessary public modifier in interface
Replace filter+size with count
Replace filter+nonEmpty with exists
Replace filter+headOption with find
Replace `if (x != null) Some(x) else None` with Option(x)
Replace getOrElse null with orNull
Drop redundant semicolons
Replace anon fun with PF
Replace anon fun with method
|
| |
| |
| |
| |
| |
| | |
Permit leading whitespace before `.` for continued selection.
This is just to handle pastes, which will typically include
indented text, and not to make dot-continuation especially robust.
|
| | |
|
| |
| |
| |
| |
| |
| | |
:require was re-incarnated in https://github.com/scala/scala/pull/4051,
it seems to be used by the spark repl. This commit makes it work when
using the flat classpath representation.
|
| |
| |
| |
| |
| |
| |
| | |
Implements VirtualDirectoryFlatClassPath, which is required for the
presentation compiler created for the repl's tab-completion.
Various minor cleanups in the flat classpath implementation.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- Language imports are preceding other imports
- Deleted empty file: InlineErasure
- Removed some unused private[parallel] methods in
scala/collection/parallel/package.scala
This removes hundreds of warnings when compiling with
"-Xlint -Ywarn-dead-code -Ywarn-unused -Ywarn-unused-import".
|
| | |
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Reusing parts of #4593, this commits adds two additional subprojects to
the sbt build:
- repl-jline, which is already used by the ant build, builds the part of
the REPL that depends on JLine. The actual JLine depenency is moved to
this project.
- repl-jline-shaded uses JarJar to create a shaded version of repl-jline
and jline.jar.
Unlike the ant build, this setup does not use any circular dependencies.
dist/mkBin puts all of quick/repl, quick/repl-jline and
quick/repl-jline-shaded onto the classpath of build-sbt/quick/bin/scala.
A future addition to the sbt build for building build-sbt/pack will have
to put the generated classfiles into the correct JARs, mirroring the old
structure.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
These seem to have been originally added as a basis for future
REPL work, for instance moving away from textual code generation
to using a custom typechecker to include definitions and imports from
previous lines in scope.
But until such work is started, lets remove the as-yet-uneeded
customizations in the name of simplicity.
(Original commits by Som Snytt, extended by Jason Zaugg to remove
the custom typer.)
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
there were merge conflicts in the Eclipse config that I resolved with
--ours. I invite @performantdata to submit a followup PR bringing the
Eclipse stuff into a good state on 2.12.x.
there was a test failure in
test/junit/scala/collection/mutable/OpenHashMapTest.scala
due to the 2.12 compiler emitting the field backing a
private var differently (with an unmangled name). Lukas
says the difference is expected, so I just updated the
code in the test.
there were no other merge conflicts.
% git log --decorate --oneline -1 origin/2.11.x | cat
ae5f0de (origin/HEAD, origin/2.11.x) Merge pull request #4791 from performantdata/issue/9508
% git log --decorate --oneline -1 origin/2.12.x | cat
c99e53e (HEAD -> 2.12.x, origin/2.12.x) Merge pull request #4797 from lrytz/M3-versions
% export MB=$(git merge-base 2.12.x origin/2.11.x)
% echo $MB
42cafa21f3c4a08c6dd34608278f810b6ec2886f
% git log --graph --oneline --decorate $MB...origin/2.11.x | cat
* ae5f0de (origin/HEAD, origin/2.11.x) Merge pull request #4791 from performantdata/issue/9508
|\
| * 08dca37 (origin/pull/4791) SI-9508 fix classpaths in Eclipse configuration
* | fe76232 Merge pull request #4798 from performantdata/issue/9513
|\ \
| * | 9c97a7f (origin/pull/4798) Suppress unneeded import.
| * | 30d704d Document some OpenHashMap internal methods.
| * | 1fb32fc SI-9513 decrement "deleted" count in OpenHashMap.put() when slot reused
| |/
* | 14f875c Merge pull request #4788 from dk14/patch-1
|\ \
| * | 42acd55 (origin/pull/4788) explicitly specify insertion-order feature in docs
| /
* | 68ce049 Merge pull request #4771 from som-snytt/issue/9492-here
|\ \
| * | f290962 (origin/pull/4771) SI-9492 Line trimming paste
| * | bc3589d SI-9492 REPL paste here doc
| /
* | 9834fc8 Merge pull request #4610 from todesking/spec-implicits-remove-obsolete
|\ \
| * | 46009b1 (origin/pull/4610) Add view/context-bound parameter ordering rule
| * | 6eba305 Spec: Implicit parameters with context/view bound is allowed since 2.10
| /
* | d792e35 Merge pull request #4789 from janekdb/2.11.x-param-names-predicates-operations
|\ \
| |/
|/|
| * b19a07e (origin/pull/4789) Rename forall, exists and find predicate and operator params.
|/
* 648c7a1 Merge pull request #4790 from SethTisue/issue/9501
|\
| * 40d12f1 (origin/pull/4790) SI-9501 link README to Scala Hacker Guide
* e0b5891 Merge pull request #4786 from performantdata/issue/9506
* 39acad8 (origin/pull/4786) SI-9506 suppress Scala IDE-generated files in the Eclipse project dirs
* 74dc364 SI-9506 suppress Scala IDE-generated files in the Eclipse project dirs
% git merge ae5f0de
Auto-merging src/repl/scala/tools/nsc/interpreter/ILoop.scala
Auto-merging src/library/scala/util/Either.scala
Auto-merging src/library/scala/runtime/Tuple3Zipped.scala
Auto-merging src/library/scala/runtime/Tuple2Zipped.scala
Auto-merging src/library/scala/collection/parallel/ParIterableLike.scala
Auto-merging src/library/scala/collection/immutable/ListMap.scala
Auto-merging src/library/scala/collection/TraversableLike.scala
Auto-merging src/eclipse/test-junit/.classpath
CONFLICT (content): Merge conflict in src/eclipse/test-junit/.classpath
Auto-merging src/eclipse/scaladoc/.classpath
CONFLICT (content): Merge conflict in src/eclipse/scaladoc/.classpath
Auto-merging src/eclipse/scala-compiler/.classpath
Auto-merging src/eclipse/repl/.classpath
CONFLICT (content): Merge conflict in src/eclipse/repl/.classpath
Auto-merging src/eclipse/partest/.classpath
CONFLICT (content): Merge conflict in src/eclipse/partest/.classpath
Auto-merging src/eclipse/interactive/.classpath
Auto-merging README.md
Automatic merge failed; fix conflicts and then commit the result.
% git checkout --ours src/eclipse/partest/.classpath
% git checkout --ours src/eclipse/repl/.classpath
% git checkout --ours src/eclipse/scaladoc/.classpath
% git checkout --ours src/eclipse/test-junit/.classpath
% git add -u
% emacs test/junit/scala/collection/mutable/OpenHashMapTest.scala
% git diff test/junit/scala/collection/mutable/OpenHashMapTest.scala | cat
...
- val field = m.getClass.getDeclaredField("scala$collection$mutable$OpenHashMap$$deleted")
+ val field = m.getClass.getDeclaredField("deleted")
...
% git add -u
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Use `-` stripmargin character to indicate trim (i.e.
remove leading indentation). `<<` looks more like
shift left, but is already the standard here doc sequence.
Indentation is often mangled by pasting, so trimming
normalizes lines for error messages. The entire paste
text was already trimmed as a whole.
`-Dscala.repl.here` provides a default end string, which
is unset unless specified.
```
scala> :pa <-
// Entering paste mode (ctrl-D to finish)
def g = 10
def f! = 27
--
// Exiting paste mode, now interpreting.
<console>:2: error: '=' expected but identifier found.
def f! = 27
^
```
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Simple here documentish syntax for REPL paste.
This makes it easier to paste a block of script
(as opposed to transcript).
It also means you won't accidentally ctl-D out
of the REPL and then out of SBT and then out of
the terminal window.
```
scala> :paste < EOF
// Entering paste mode (EOF to finish)
class C { def c = 42 }
EOF
// Exiting paste mode, now interpreting.
defined class C
scala> new C().c
res0: Int = 42
scala> :paste <| EOF
// Entering paste mode (EOF to finish)
|class D { def d = 42 }
EOF
// Exiting paste mode, now interpreting.
defined class D
scala> new D().d
res1: Int = 42
scala> :quit
```
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In the code:
```
s"${fooo<CURSOR"
```
The parser treats `fooo` as a interpolator ID for the quote that
we actually intend to end the interpolated string.
Inserting a space (in addition to `__CURSOR__` that we already
patch in to avoid parsing a partial identifier as a keyword),
solves this problem.
|
| |
| |
| |
| |
| | |
We kept it around behind an option in 2.11.x, but we can
jettison it in 2.12.x.
|