| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
| |
`scala.color` now has 3 states: `true`, `false` and `auto`
(the default). `auto` allows colors if not on windows and if the shell
is interactive (as in, both stdin and stdout are a tty).
The autodetect works as expected when run via SBT too, and it can always
be overriden on the CLI or via JAVA_OPTS.
|
|\
| |
| | |
SI-9881 Fix ImportHandler's reporting of importedNames and importedSymbols
|
| | |
|
|\ \
| | |
| | | |
SI-10133 Require escaped single quote char lit
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Instead of indenting source code to make messages
align on output, let the reporter add indentation,
only if the source is the console (and not a pastie
or a loaded file).
Previously, syntax errors were not indented.
```
$ skala
Welcome to Scala 2.12.2-20170108-010722-939abf1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_111).
Type in expressions for evaluation. Or try :help.
scala> 'abc'
<console>:1: error: unclosed character literal (or use " for string literal "abc")
'abc'
^
scala> :quit
$ scala
Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_111).
Type in expressions for evaluation. Or try :help.
scala> 'abc'
<console>:1: error: unclosed character literal
'abc'
^
```
|
|\ \
| | |
| | | |
More groundwork for JDK 9 support
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The addition of this method in `CharBuffer`
CharBuffer position(int newPosition)
renders an ambiguity in:
```
scala> (b: java.nio.CharBuffer) => b.position
<console>:12: error: ambiguous reference to overloaded definition,
both method position in class CharBuffer of type (x$1: Int)java.nio.CharBuffer
and method position in class Buffer of type ()Int
match expected type ?
(b: java.nio.CharBuffer) => b.position
```
Manually applying the empty params avoids this.
|
|/ /
| |
| |
| |
| |
| | |
The old EOL is EOL. Use `println()` when feasible and obvious.
Minor cleanup of surrounding code.
|
|\ \
| | |
| | | |
SI-10130 Ignore extra parse warnings
|
| |/
| |
| |
| |
| |
| | |
Don't emit warnings when parsing to test for
complete input. The warnings will show up
in the templated code.
|
|/
|
|
|
|
| |
Support command completions with a completer that
delegates to a colon command completer, which
either completes the command or completes a filename.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|