| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
PR #2374 changed the behaviour of `typedSingletonTypeTree` in the
presence of an error typed reference tree. It incorrectly
returns the reference tree in case on an error. However, this is
a term tree, which is an inconsistent result with the input type
tree. Consequently, a `typedSelectInternal` later fails when
using this as the qualifier of a `SelectFromTypeTree`.
Both test cases enclosed show this symptom.
This commit:
- Returns `tree` rather than `refTyped` when `refTyped` is
error typed or when it isn't suitable as a stable prefix.
- Avoids issuing a cascading "not a stable prefix" error if the
`refTyped` is error typed.
- Adds an extra layer of defense in `typedSelectFromTypeTree`
to bail out quickly if the qualifier is error typed.
The last measure is not necessary to fix this bug.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Sealed abstract classes (like `List`) have a primary constructor, public
by default. It can never be called by external code but it shows up in
the scaladoc as a nice `new List()` construtor...
If a class is only abstract, the constructor is still useful because
people can subclass and call it. If it is only sealed (i.e. effectively final),
then it is the normal constructor of a final class. But sealed *and*
abstract makes documenting the constructor useless.
This should remove the misleading constructors of `List`, `Double`,
`Option` and others from the scaladoc.
|
|\
| |
| | |
SI-8922 REPL load -v
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Verbose mode causes the familiar prompt and
line echo so you can see what you just loaded.
The quit message is pushed up a level in the
process loop.
This has the huge payoff that if you start the
repl and immediately hit ctl-D, you don't have to
wait for the compiler to init (yawn) before you
get a shell prompt back.
|
|\ \
| | |
| | | |
Fix tests under -Ydelambdafy:method
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
the structure of Option.class generated by delambdafy:method is
slightly different. For example, lambdas declared within Option are
not emitted as nested classes, so under delambdafy:method there's no
inner class entry for anonfun classes.
The test failed because serializing a ClassTag involves serializing an
Option. Option did not have a `@SerialVersionUID`, and the classfile
generated by delambdafy:method has a different value.
The annotation is required on the parent class (Option) as well as the
subclasses (Some / None). De-serializing a Some will fail if Option
has a different SerialVersionUID.
Relates to SI-8576. We should probably have more SVUID annotations in
the library.
|
|\ \ \
| | | |
| | | | |
SI-8931 make generic signature consistent with interface list in classfiles
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
An optimization was introduced in 7a99c03 (SI-5278) to remove redundant
interfaces from the list of implemented interfaces in the bytecode.
However the same change was not propagated to the generic signature
of a class, which also contains a list of direct parent classes and
interfaces.
The JVM does not check the well-formedness of signatures at class
loading or linking (see ยง4.3.4 of jdk7 jvms), but other tools might
assume the number of implemented interfaces is the same whether one
asked for generic or erased interfaces.
It doesn't break reflection so nobody complained, but it does show:
scala> val c = classOf[Tuple1[String]]
c: Class[(String,)] = class scala.Tuple1
scala> c.getInterfaces // Product is gone
res0: Array[Class[_]] = Array(interface scala.Product1, interface
scala.Serializable)
scala> c.getGenericInterfaces // Product is back!
res1: Array[java.lang.reflect.Type] = Array(scala.Product1<T1>,
interface scala.Product, interface scala.Serializable)
This moves the optimization to erasure, for use in emitting the generic
signature, and the backend calls into it later for the list of
interfaces.
|
|\ \ \ \
| | | | |
| | | | | |
SI-7602 Avoid crash in LUBs with erroneous code
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
If a class contains a double defintion of a method that overrides
an interface method, LUBs could run into a spot where filtering
overloaded alternatives to those that match the interface method
fails to resolve to a single overload, which crashes the compiler.
This commit uses `filter` rather than `suchThat` to avoid the crash.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-7019 Fix crasher with private[this] extension methods
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
When we move the body of value class methods to the corresponding
extension method, we typecheck a forward method that remains
in the class. In order to allow access, this commit weakens the
access of `private[local]` extension methods to `private`.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-8947 Avoid cross talk between tag materializers and reify
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
As suggested in review:
- Use `abort` rather than `{error; EmptyTree} when we hit an
error in reification or tag materialization.
- Explicitly avoid adding the `MacroExpansionAttachment` to the
macro expansion if it an `EmptyTree`
- Emit a `-Xdev` warning if any other code paths find a way to
mutate attachments in places they shouldn't.
|
| | |/ / /
| |/| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
After a macro has been expanded, the expandee are expansion are
bidirectionally linked with tree attachments. Reify uses the back
reference to replace the expansion with the expandee in the reified
tree. It also has some special cases to replace calls to macros
defined in scala-compiler.jar with `Predef.implicitly[XxxTag[T]]`.
This logic lives in `Reshape`.
However, the expansion of a macro may be `EmptyTree`. This is the case
when a tag materializer macro fails. User defined macros could do the
also expand to `EmptyTree`. In the enclosed test case, the error
message that the tag materializer issued ("cannot materialize
class tag for unsplicable type") is not displayed as the typechecker
finds another means of making the surrounding expression typecheck.
However, the macro engine attaches a backreference to the materializer
macro on `EmpytyTree`!
Later, when `reify` reshapes a tree, every occurance of `EmptyTree`
will be replaced by a call to `implicitly`.
This commit expands the domain of `CannotHaveAttrs`, which is mixed
in to `EmptyTree`. It silently ignores all attempts to mutate
attachments.
Unlike similar code that discards mutations of its type and position,
I have refrained from issuing a developer warning in this case, as
to silence this I would need to go and add a special case at any
places adding attachments.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-8962 Fix regression with skolems in pattern translation
|
| | |/ / /
| |/| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
During the refactoring of error reporting in 258d95c7b15, the result
of `Context#reportError` was changed once we had switched to
using a `ThrowingReporter`, which is still the case in post
typer phase typechecking
This was enough to provoke a type error in the enclosed test.
Here's a diff of the typer log:
% scalac-hash 258d95~1 -Ytyper-debug sandbox/test.scala 2>&1 | tee sandbox/good.log
% scalac-hash 258d95 -Ytyper-debug sandbox/test.scala 2>&1 | tee sandbox/bad.log
% diff -U100 sandbox/{good,bad}.log | gist --filename=SI-8962-typer-log.diff
https://gist.github.com/retronym/3ccbe7e0791447d272a6
The test `Context#reportError` happens to be used when deciding
whether the type checker should be lenient when it hits a type error.
In lenient mode (see `adaptMismatchedSkolems`), it `adapt` retries
with after slackening the expected type by replacing GADT and
existential skolems with wildcard types. This is to accomodate
known type-incorrect trees generated by the pattern matcher.
This commit restores the old semantics of `reportError`, which means
it is `false` when a `ThrowingReporter` is being used.
For those still reading, here's some more details.
The trees of the `run2` example from the enclosed test. Notice that
after typechecking, `expr` has a type containing GADT skolems. The
pattern matcher assumes that calling the case field accessor `expr`
on the temporary val `x2 : Let[A with A]` containing the scrutinee
will result in a compatible expression, however this it does not.
Perhaps the pattern matcher should generate casts, rather than
relying on the typer to turn a blind eye.
```
[[syntax trees at end of typer]] // t8962b.scala
...
def run2[A](nc: Outer2[A,A]): Outer2[Inner2[A],A] = nc match {
case (expr: Outer2[Inner2[?A2 with ?A1],?A2 with ?A1])Let2[A with A]((expr @ _{Outer2[Inner2[?A2 with ?A1],?A2 with ?A1]}){Outer2[Inner2[?A2 with ?A1],?A2 with ?A1]}){Let2[A with A]} =>
(expr{Outer2[Inner2[?A2 with ?A1],?A2 with ?A1]}: Outer2[Inner2[A],A]){Outer2[Inner2[A],A]}
}{Outer2[Inner2[A],A]}
[[syntax trees at end of patmat]] // t8962b.scala
def run2[A](nc: Outer2[A,A]): Outer2[Inner2[A],A] = {
case <synthetic> val x1: Outer2[A,A] = nc{Outer2[A,A]};
case5(){
if (x1.isInstanceOf[Let2[A with A]])
{
<synthetic> val x2: Let2[A with A] = (x1.asInstanceOf[Let2[A with A]]: Let2[A with A]){Let2[A with A]};
{
val expr: Outer2[Inner2[?A2 with ?A1],?A2 with ?A1] = x2.expr{<null>};
matchEnd4{<null>}((expr{Outer2[Inner2[?A2 with ?A1],?A2 with ?A1]}: Outer2[Inner2[A],A]){Outer2[Inner2[A],A]}){<null>}
...
```
|
|\ \ \ \ \
| |/ / / /
|/| | | | |
SI-8960 Bring back the SerialVersionUID to anonymous function classes
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
In PR #1673 / 4267444, the annotation `SerialVersionId` was changed
from a `StaticAnnotation` to `ClassFileAnnotation` in order to enforce
annotation arguments to be constants. That was 2.11.0.
The ID value in the AnnotationInfo moved from `args` to `assocs`, but
the backend was not adjusted. This was fixed in PR #3711 / ecbc9d0 for
2.11.1.
Unfortunately, the synthetic AnnotationInfo that is added to anonymous
function classes still used the old constructor (`args` instead of
`assocs`), so extracting the value failed, and no field was added to
the classfile.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-6626 make @throws tags create links to exceptions
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
- there is no need for explicit links with [[ and ]]
- there is no need for explicit backquoting
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
In scaladoc, this turns exceptions in @throws tags into links
(when it can find the target exception), instead of just showing
the name.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-8898 javap -fun under new style lambdas
|
| | |_|_|/
| |/| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
To support both -Ydelambdafy strategies, look for both inline
(anonfun) and method (lambda) closure classes.
For method (lambda) style, use the anonfun method that is
invoked by the accessor.
Also, the output of javap must be captured eagerly for
filtering for the current target method.
If the user asks for a module, e.g., `Foo$`, don't yield
results for companion class, but for `Foo`, do yield
companion module results. Just because.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-6541 valid wildcard existentials for case-module-unapply
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Instead of letting the compiler infer the return type of case module
unapply methods, provide them explicitly.
This is enabled only under -Xsource:2.12, because the change is not
source compatible.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
The default value was NoScalaVersion before, because tryToSet (where
the default was supposed to be set) is not called at all if the option
is not specified.
The initial value of Xmigration is set to NoScalaVersion (which it was
before, the AnyScalaVersion argument was ignored). AnyScalaVersion
would be wrong, it would give a warning in `Map(1 -> "eis").values`
if the option was not specified. See tests.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
SI-8916 Clean up unused imports, values and variables
|
| | | | | | | |
|
| | |_|_|/ /
| |/| | | | |
|
|\ \ \ \ \ \
| |_|_|_|/ /
|/| | | | | |
SI-8711 ScalaVersion.unparse doesn't produce valid versions
|
| | |_|/ /
| |/| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
There is no dot between `major.minor.rev` and `-build` in a scala
version, yet that's what unparse returns for
```
// was "2.11.3.-SNAPSHOT"
ScalaVersion("2.11.3-SNAPSHOT").unparse
```
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-8893 Restore linear perf in TailCalls with nested matches
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
The iteration is only needed to side effect on `instructionList`
and `code.touched`. This commit uses an iterator and `foreach`,
rather than creating throwaway Arrays.
% time (for f in {1..200}; do echo test/files/pos/t8893.scala; done | qscalac -Xresident)
Before: 30s
After : 21s
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Compilation perfomance of the enclosed test regressed when the
new pattern matcher was introduced, specifically when the tail
call elimination phase was made aware of its tree shapes in cd3d34203.
The code added in that commit detects an application to a tail label
in order to treat recursive calls in the argument as in tail position.
If the transform of that argument makes no change, it falls
back to `rewriteApply`, which transforms the argument again
(although this time on a non-tail-position context.)
This commit avoids the second transform by introducing a flag
to `rewriteApply` to mark the arguments are pre-transformed.
I don't yet see how that fixes the exponential performance, as
on the surface it seems like a constant factor improvement.
But the numbers don't lie, and we can now compile the test
case in seconds, rather than before when it was running for
> 10 minutes.
This test case was based on a code pattern generated by the Avro
serializer macro in:
https://github.com/paytronix/utils-open/tree/release/2014/ernststavrosgrouper
The exponential performance in that context is visualed here:
https://twitter.com/dridus/status/519544110173007872
Thanks for @rmacleod2 for minimizing the problem.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Save the Trees!
When a subtransform is an identity, we must
strive to return the identical tree to enable the lazy part of
LazyTreeCopier. If we get this wrong in a leaf, all parents are
wastefully copied.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
I believe ClonedTailContext was added to avoid the need to
mutate the Boolean `ctx.tailPos`. All other calls are forwarded
to a delegate context.
This commit tries to find a delegate context with the right
value of `tailPos` to reuse that, rather than creating a
wrapper each time we need to flip that bit.
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Cache the member symbols for `Boolean.{||, &&}` per-run, rather
than look them up repeatedly.
Based on profiling the tail calls phase in the program below, which
was distilled by @rmacleod2 from the code generated by macros in
https://github.com/paytronix/utils-open/tree/release/2014/ernststavrosgrouper
Wall clock time went from 12s to 6.5s.
```scala
object Test {
def a(): Option[String] = Some("a")
def main(args: Array[String]) {
a() match {
case Some(b1) =>
a() match {
case Some(b2) =>
a() match {
case Some(b3) =>
a() match {
case Some(b4) =>
a() match {
case Some(b5) =>
a() match {
case Some(b6) =>
a() match {
case Some(b7) =>
a() match {
case Some(b8) =>
a() match {
case Some(b9) =>
a() match {
case Some(b10) =>
a() match {
case Some(b11) =>
a() match {
case Some(b12) =>
a() match {
case Some(b13) =>
a() match {
case Some(b14) =>
a() match {
case Some(b15) =>
a() match {
case Some(b16) =>
a() match {
case Some(b17) =>
a() match {
case Some(b18) =>
a() match {
case Some(b19) =>
a() match {
case Some(b20) =>
println("yay")
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
case None => None
}
}
}
```
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-8910 BitSet sometimes uses exponential memory.
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Because of an off-by-one error in scala.collection.mutable.BitSet, where a
function (ensureCapacity) is passed a list length instead of an index, when
^=, &=, |=, or &~= are passed BitSets with the same internal capacity as the
set the method is being invoked on, the size of the first BitSet is needlessly
doubled.
This patch simply changes the ensureCapacity calls to pass the last index of
the list, instead of the raw length. In addition, add documentation to
ensureCapacity to try and stop something similar from happening in the future.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
IntelliJ IDEA files for version 14
|
| | |_|/ /
| |/| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
The latest version of the Scala plugin for IntelliJ IDEA introduces
a new project structure
http://blog.jetbrains.com/scala/2014/10/30/scala-plugin-update-for-intellij-idea-14-rc-is-out/
Due to a bug (https://youtrack.jetbrains.com/issue/SCL-7753), you
currently need to install the latest nightly build from here:
http://confluence.jetbrains.com/display/SCA/Scala+Plugin+Nightly+Builds+for+Cassiopeia
The new format doesn't allow scala compiler options per-module, so
the `-sourcepath src/libarary` is used for all modules.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-8875 showCode should print all class constructor modifiers.
|
| | |/ / /
| |/| | |
| | | | |
| | | | |
| | | | | |
showCode used to print nothing when the only modifier was a change in
visibility scope (i.e. no flags but privateWithin is set).
|
|\ \ \ \ \
| |_|/ / /
|/| | | | |
fix typo. s/represenation/representation
|
| |/ / / |
|
|\ \ \ \
| | | | |
| | | | | |
SI-8943 Handle non-public case fields in pres. compiler
|
| | |/ /
| |/| |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
When a case class is type checked, synthetic methods are added,
such as the `hashCode`/`equals`, implementations of the `Product`
interface. At the same time, a case accessor method is added for
each non-public constructor parameter. This the accessor for a
parameter named `x` is named `x$n`, where `n` is a fresh suffix.
This is all done to retain universal pattern-matchability of
case classes, irrespective of access. What is the point of allowing
non-public parameters if pattern matching can subvert access? I
believe it is to enables private setters:
```
case class C(private var x: String)
scala> val x = new C("")
x: C = C()
scala> val c = new C("")
c: C = C()
scala> val C(x) = c
x: String = ""
scala> c.x
<console>:11: error: variable x in class C cannot be accessed in C
c.x
^
scala> c.x = ""
<console>:13: error: variable x in class C cannot be accessed in C
val $ires2 = c.x
^
<console>:10: error: variable x in class C cannot be accessed in C
c.x = ""
^
```
Perhaps I'm missing additional motivations.
If you think scheme sounds like a binary compatiblity nightmare,
you're right: https://issues.scala-lang.org/browse/SI-8944
`caseFieldAccessors` uses the naming convention to find the right
accessor; this in turn is used in pattern match translation.
The accessors are also needed in the synthetic `unapply` method
in the companion object. Here, we must tread lightly to avoid
triggering a typechecking cycles before; the synthesis of that method
is not allowed to force the info of the case class.
Instead, it uses a back channel, `renamedCaseAccessors` to see
which parameters have corresonding accessors.
This is pretty flaky: if the companion object is typechecked
before the case class, it uses the private param accessor directly,
which it happends to have access to, and which duly gets an
expanded name to allow JVM level access. If the companion
appears afterwards, it uses the case accessor method.
In the presentation compiler, it is possible to typecheck a source
file more than once, in which case we can redefine a case class. This
uses the same `Symbol` with a new type completer. Synthetics must
be re-added to its type.
The reported bug occurs when, during the second typecheck, an entry
in `renamedCaseAccessors` directs the unapply method to use `x$1`
before it has been added to the type of the case class symbol.
This commit clears corresponding entries from that map when we
detect that we are redefining a class symbol.
Case accessors are in need of a larger scale refactoring. But I'm
leaving that for SI-8944.
|
|\ \ \ \
| | | | |
| | | | | |
SI-8941 Idempotent presentation compilation of implicit classes
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
A retrospective test case which covers typechecking idempotency which
was introduced in 0b78a0196 / 148736c3df. It also tests the
implicit class handling, which was fixed in the previous commit.
It is difficult to test this using existing presentation compiler
testing infrastructure, as one can't control at which point during
the first typechecking the subesquent work item will be noticed.
Instead, I've created a test with a custom subclass of
`interactive.Global` that allows precise, deterministic control
of when this happens. It overrides `signalDone`, which is called
after each tree is typechecked, and watches for a defintion with
a well known name. At that point, it triggers a targetted typecheck
of the tree marked with a special comment.
It is likely that this approach can be generalized to a reusable
base class down the track. In particular, I expect that some of
the nasty interactive ScalaDoc bugs could use this single-threaded
approach to testing the presentation compiler.
|