| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
Jason points out we still need it for bytecode efficiency,
due to mixin forwarders.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Also, drop AbstractFunction for parent of anonymous subclass of
function type that must have its class spun up at compile time
(rather than at linkage time by LambdaMetaFactory).
This revealed an old problem with typedTemplate, in which
parent types may be normalized at the level of trees,
while this change does not get propagated to the class's info
in time for the constructor to be located when we type check
the primary constructor.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We compile FunctionN to Java 8's idea of a function now,
so no need to target the artisanal JFunction and friends,
except when the function is specialized, as I don't yet
see how we can use LMF with the way specialization handles
FunctionN:
First, the working status quo -- the hand-crafted specialized
versions of JFunction0. Notice how `apply$mcB$sp` is looking
pretty SAMmy:
```
@FunctionalInterface
public interface JFunction0$mcB$sp extends JFunction0 {
@Override
public byte apply$mcB$sp();
@Override
default public Object apply() {
return BoxesRunTime.boxToByte(this.apply$mcB$sp());
}
}
```
Contrast this with our specialized standard FunctionN:
```
public interface Function0<R> {
public R apply();
default public byte apply$mcB$sp() {
return BoxesRunTime.unboxToByte(this.apply());
}
}
public interface Function0$mcB$sp extends Function0<Object> { }
```
The single abstract method in `Function0$mcB$sp` is `apply`, and
the method that would let us avoid boxing, if it were abstract,
is `apply$mcB$sp`...
TODO (after M4):
- do same for specialized functions (issues with boxing?)
- remove scala/runtime/java8/JFunction* (need new STARR?)
|
|
|
|
| |
For completeness, `-Xsource:2.11 -Xexperimental` does enable it.
|
|
|
|
|
|
|
|
| |
Trying to figure out if we can avoid adapting to SAM, and just
type them once and for all in typedFunction. Looks like overload
resolution requires SAM adaptation to happen in adapt.
Cleaned up while I was in the area.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some of the earlier proposals were too strongly linked to the
requirements of the Java 8 platform, which was problematic for
scala.js & friends.
Instead of ruling out SAM types that we can't compile to use
LambdaMetaFactory, expand those during compilation to anonymous
subclasses, instead of invokedynamic + LMF.
Also, self types rear their ugly heads again. Align `hasSelfType`
with the implementation suggested in `thisSym`'s docs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We cannot use the expected type to track whether a Function node
targets a SAM type, as the expected type may be erased (see test
for an example).
Thus, the type checker attaches a SAMFunction attachment to a
Function node when SAM conversion is performed in adapt. Ideally,
we'd move to Dotty's Closure AST, but that will need a
deprecation cycle.
Thanks to Jason for catching my mistake, suggesting the fix and
providing the test.
Both the sam method symbol and sam target type must be tracked,
as their relationship can be complicated (due to inheritance).
For example, the sam method could be defined in a superclass (T)
of the Function's target type (U).
```
trait T { def foo(a: Any): Any }
trait U extends T { def apply = ??? }
(((x: Any) => x) : U).foo("")
```
This removes some of the duplication in deriving the sam method
from the expected type, but some grossness (see TODO) remains.
|
|
|
|
|
| |
Also test roundtripping serialization of a lambda that targets a
SAM that's not FunctionN (it should make no difference).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
They both compile to INDY/MetaLambdaFactory, except when they
occur in a constructor call. (TODO: can we lift the ctor arg
expression to a method and avoid statically synthesizing
anonymous subclass altogether?)
Typers:
- no longer synthesize SAMs -- *adapt* a Function literal
to the expected (SAM/FunctionN) type
- Deal with polymorphic/existential sams (relevant tests:
pos/t8310, pos/t5099.scala, pos/t4869.scala) We know where
to find the result type, as all Function nodes have a
FunctionN-shaped type during erasure. (Including function
literals targeting a SAM type -- the sam type is tracked as
the *expected* type.)
Lift restriction on sam types being class types. It's enough
that they dealias to one, like regular instance creation
expressions.
Contexts:
- No longer need encl method hack for return in sam.
Erasure:
- erasure preserves SAM type for function nodes
- Normalize sam to erased function type during erasure,
otherwise we may box the function body from `$anonfun(args)`
to `{$anonfun(args); ()}` because the expected type for the
body is now `Object`, and thus `Unit` does not conform.
Delambdafy:
- must set static flag before calling createBoxingBridgeMethod
- Refactored `createBoxingBridgeMethod` to wrap my head around
boxing, reworked it to generalize from FunctionN's boxing
needs to arbitrary LMF targets.
Other refactorings: ThisReferringMethodsTraverser, TreeGen.
|
|
|
|
|
|
|
|
| |
Go beyond refactoring and introduce some hooks and patch some
holes that will become acute when we set Sammy loose.
Expanding sam requires class as first parent: `addObjectParent`.
(Tested in pos/sam_ctor_arg.scala, coming next.)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`typedFunction` uniformly recognizes Single Abstract Method types
and built-in `FunctionN` types, type checking literals regardless
of expected type.
`adapt` synthesizes an anonymous subclass of the SAM type, if
needed to meet the expected (non-`FunctionN`) type.
(Later, we may want to carry `Function` AST nodes with SAM types
through the whole pipeline until the back-end, and treat them
uniformly with built-in function types there too, emitting the
corresponding `invokedynamic` & `LambdaMetaFactory` bytecode.
Would be faster to avoid synthesizing all this code during type
checking...)
Refactor `typedFunction` for performance and clarity to avoid
non-local returns. A nice perk is that the error message for missing
argument types now indicates with `<error>` where they are missing
(see updated check file).
Allow pattern matching function literals when SAM type is expected
(SI-8429).
Support `return` in function body of SAM target type, by making the
synthetic `sam$body` method transparent to the `enclMethod` chain, so
that the `return` is interpreted in its original context.
A cleaner approach to inferring unknown type params of the SAM
method. Now that `synthesizeSAMFunction` operates on typed `Function`
nodes, we can take the types of the parameters and the body and
compare them against the function type that corresponds to the SAM
method's signature. Since we are reusing the typed body, we do need
to change owners for the symbols, and substitute the new method
argument symbols for the function's vparam syms.
Impl Notes:
- The shift from typing as a regular Function for SAM types was
triggered by limitation of the old approach, which deferred type
checking the body until it was in the synthetic SAM type
subclass, which would break if the expression was subsequently
retypechecked for implicit search. Other problems related to SAM
expansion in ctor args also are dodged now.
- Using `<:<`, not `=:=`, in comparing `pt`, as `=:=` causes
`NoInstance` exceptions when `WildcardType`s are encountered.
- Can't use method type subtyping: method arguments are in
invariant pos.
- Can't use STATIC yet, results in illegal bytecode. It would be a
better encoding, since the function body should not see members
of SAM class.
- This is all battle tested by running `synthesizeSAMFunction` on
all `Function` nodes while bootstrapping, including those where a
regular function type is expected. The only thing that didn't
work was regarding Function0 and the CBN transform, which breaks
outer path creation in lambdalift.
|
|
|
|
|
|
|
|
|
|
| |
Initial work to change settings and test by Svyatoslav Ilinskiy
Thanks!
To avoid cycles during overload resolution (which showed up
during bootstrapping), and to improve performance, I've guarded
the detection of SAM types in `isCompatible` to cases when the
LHS is potentially compatible.
|
| |
|
| |
|
|
|
|
|
|
|
| |
For each history entry, run the `Type`'s `toString` at the corresponding
phase, so that e.g., a method type's parameter symbols' `info`'s `toString`
runs at the phase corresponding to the type history we're turning into a
string.
|
|\
| |
| | |
Resolve several deprecation warnings
|
| | |
|
|\ \
| | |
| | | |
Fix some typos in `spec` documents and comments.
|
| |/ |
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Until now, concrete methods in traits were encoded with
"trait implementation classes".
- Such a trait would compile to two class files
- the trait interface, a Java interface, and
- the implementation class, containing "trait implementation methods"
- trait implementation methods are static methods has an explicit self
parameter.
- some methods don't require addition of an interface method, such as
private methods. Calls to these directly call the implementation method
- classes that mixin a trait install "trait forwarders", which implement
the abstract method in the interface by forwarding to the trait
implementation method.
The new encoding:
- no longer emits trait implementation classes or trait implementation
methods.
- instead, concrete methods are simply retained in the interface, as JVM 8
default interface methods (the JVM spec changes in
[JSR-335](http://download.oracle.com/otndocs/jcp/lambda-0_9_3-fr-eval-spec/index.html)
pave the way)
- use `invokespecial` to call private or particular super implementations
of a method (rather `invokestatic`)
- in cases when we `invokespecial` to a method in an indirect ancestor, we add
that ancestor redundantly as a direct parent. We are investigating alternatives
approaches here.
- we still emit trait fowrarders, although we are
[investigating](https://github.com/scala/scala-dev/issues/98) ways to only do
this when the JVM would be unable to resolve the correct method using its rules
for default method resolution.
Here's an example:
```
trait T {
println("T")
def m1 = m2
private def m2 = "m2"
}
trait U extends T {
println("T")
override def m1 = super[T].m1
}
class C extends U {
println("C")
def test = m1
}
```
The old and new encodings are displayed and diffed here: https://gist.github.com/retronym/f174d23f859f0e053580
Some notes in the implementation:
- No need to filter members from class decls at all in AddInterfaces
(although we do have to trigger side effecting info transformers)
- We can now emit an EnclosingMethod attribute for classes nested
in private trait methods
- Created a factory method for an AST shape that is used in
a number of places to symbolically bind to a particular
super method without needed to specify the qualifier of
the `Super` tree (which is too limiting, as it only allows
you to refer to direct parents.)
- I also found a similar tree shape created in Delambdafy,
that is better expressed with an existing tree creation
factory method, mkSuperInit.
|
|\
| |
| | |
More conservative optimization for unnecessary outer ref checks
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The old algorithm omitted necessary outer ref checks in some places.
This new one is more conservative. It only omits outer ref checks when
the expected type and the scrutinee type match up, or when the expected
type is defined in a static location. For this specific purpose the top
level of a method or other code block (which is not a trait or class
definition) is also considered static because it does not have a prefix.
This change comes with a spec update to clarify the prefix rule for type
patterns. The new wording makes it clear that the presence of a prefix
is to be interpreted in a *semantic* way, i.e. the existence of a prefix
determines the necessity for an outer ref check, no matter if the prefix
is actually spelled out *syntactically*. Note that the old outer ref
check implementation did not use the alternative interpretation of
requiring prefixes to be given syntactically. It never created an outer
ref check for a local class `C`, no matter if the pattern was `_: C`
or `_: this.C`, thus violating both interpretations of the spec.
There is now explicit support for unchecked matches (like
`case _: (T @unchecked) =>`) to suppress warnings for unchecked outer
refs. `@unchecked` worked before and was used for this purpose in
`neg/t7721` but never actually existed as a feature. It was a result of
a bug that prevented an outer ref check from being generated in the
first place if *any* annotation was used on an expected type in a type
pattern. This new version will still generate the outer ref check if an
outer ref is available but suppress the warning otherwise. Other
annotations on type patterns are ignored.
New tests are in `neg/outer-ref-checks`. The expected results of tests
`neg/t7171` and `neg/t7171b` have changed because the compiler now
tries to generate additional outer ref checks that were not present
before (which was a bug).
|
|/
|
|
|
| |
WeakHashSet is internal so an exception was made against binary
compatibility to allow the var to be made private.
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
merge/2.11.x-to-2.12.x-20160225
Conflicts:
scripts/jobs/integrate/bootstrap
src/build/maven/scala-actors-pom.xml
test/files/pos/t3420.flags
Conflicts were trivial to resolve.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The old approach of recursively calling `fullNameAsName`
creates a lot of garbage for intermediate results, in
addition to needless interning of those results into
the name table.
This commit instead creates a string buffer of the
correct capacity and writes the component names
directly into this.
I compared old and new approaches and this shows a 2x
speedup.
```
scala> val th = ichi.bench.Thyme.warmed(verbose = print)
th: ichi.bench.Thyme = ichi.bench.Thyme@1643e817
scala> val w_old = th.Warm(sym.fullNameAsNameOld('.'))
w_old: th.Warm[$r.intp.global.Name] = ichi.bench.Thyme$Warm@7a8d001b
scala> val w_new = th.Warm(sym.fullNameAsName('.'))
w_new: th.Warm[$r.intp.global.Name] = ichi.bench.Thyme$Warm@1ec14586
scala> th.pbenchOffWarm("", x => println(x))(w_old, 10, "old")(w_new, 10, "new")
Benchmark comparison (in 4.084 s)
old vs new
Significantly different (p ~= 0)
Time ratio: 0.53572 95% CI 0.51618 - 0.55525 (n=20)
old 64.54 ns 95% CI 62.41 ns - 66.67 ns
new 34.57 ns 95% CI 34.04 ns - 35.11 ns
res3: $r.intp.global.Name = scala.collection.parallel.mutable.ParSeq
```
It is still expensive enough that we should still consider
caching. The call to full name in `classBTypeFromSymbol`
in the new backed is a prime candidate for optimization.
|
|\ \
| | |
| | | |
Simplify TypeRef hierarchy. baseType returns NoType, as needed for isSubtype. Also improves performance.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Redeem myself for e1c732db44 -- hopefully.
I inlined `thisInfo` (== `sym.info`), and made sure to use `relativeInfo`
wherever prefix and args influence the result of the query that we're
delegating to the underlying type. For type aliases, use `normalize`
for `baseClasses` and `decls`, since `relativeInfo` breaks the gnarly SI-8177.
I think normalize is okay for aliases, as the prefix should not matter
when computing base classes, and infos for the members in `decls`
are given the `asSeenFrom` treatment individually downstream.
(It's a tight rope between rewriting too many symbols and maintaining correctness.
Documented the trade-off in the code.)
Renamed the unimaginative `transform` to `relativize`, which, although everything
is relative, hopefully says a bit more about its usage than `transform`.
Removed a lot of over-factoring in the TypeRef hierarchy. Ultimately, we need
to reduce the number of TypeRef subclasses further, I think. It's really hard
to follow what's going on.
Removed the `thisInfo` cache, since `sym.info` and `relativeInfo` are both cached.
Made the cache invalidation hooks a bit more OO-y.
Compare `Symbol`s with `eq` -- they don't define an `equals` method.
Also, don't recurse in isSubtype when a `baseType` results in `NoType`.
This happens a lot and is cheap to check, so I posit (without proof),
that it's better for performance (and clarity) to check before recursing.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
By reducing excessive factoring, we can save an extraneous call
to `asSeenFrom`, and hopefully in a following commit figure out
a bigger problem with `baseType` that is causing wrong subtyping results.
This commit is a pure refactoring, save for the dropped ASF call,
which is explained below.
To motivate the following change to `relativeInfo`:
```
private[Types] def relativeInfo = /*trace(s"relativeInfo(${safeToString}})")*/{
if (relativeInfoPeriod != currentPeriod) {
- val memberInfo = pre.memberInfo(sym)
- relativeInfoCache = transformInfo(memberInfo)
+ relativeInfoCache = memberInfoInstantiated
```
Let's consolidate the two removed line in this new method:
```
def memberInfoInstantiated = transformInfo(pre.memberInfo(sym))
```
To understand what `transformInfo` does, take these helpers spread over
various `*TypeRef` traits, and consolidate them:
```
- def asSeenFromOwner(tp: Type) = tp.asSeenFrom(pre, sym.owner)
// regular type refs:
- def transformInfo(tp: Type): Type = appliedType(asSeenFromOwner(tp), args)
// for no-args type refs:
- override def transformInfo(tp: Type): Type = appliedType(asSeenFromOwner(tp), dummyArgs)
```
By removing the dynamic dispatch, we get the following method
(given `require(args0 ne Nil, this)` in `ArgsTypeRef`,
and `args eq Nil` by construction in `NoArgsTypeRef` ):
```
def transformInfo(tp: Type) =
appliedType(tp.asSeenFrom(pre, sym.owner), if (args.isEmpty) dummyArgs else args)
```
Inlining `memberInfo`, which is defined as:
```
def memberInfo(sym: Symbol): Type = {
require(sym ne NoSymbol, this)
sym.info.asSeenFrom(this, sym.owner)
}
```
gives us:
```
def memberInfoInstantiated = transformInfo(sym.info.asSeenFrom(pre, sym.owner))
```
Inlining `transformInfo` as reworked above:
```
def memberInfoInstantiated =
appliedType(sym.info.asSeenFrom(pre, sym.owner).asSeenFrom(pre, sym.owner),
if (args.isEmpty) dummyArgs else args)
```
Whoops! One `asSeenFrom` should do...
```
+ final protected def memberInfoInstantiated: Type =
+ appliedType(sym.info.asSeenFrom(pre, sym.owner), if (args.isEmpty) dummyArgs else args)
```
|
|\ \ \
| |/ /
|/| | |
Use invokedynamic for structural calls, symbol literals, lambda ser.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The previous encodings created static fields in the enclosing class
to host caches. However, this isn't an option once emit code in default
methods of interfaces, as Java interfaces don't allow private static
fields.
We could continue to emit fields, and make them public when added to
traits.
Or, as chosen in this commit, we can emulate a call-site specific
static field by using invokedynamic: when the call site is linked,
our bootstrap methid can perform one-time computation, and we can
capture the result in the CallSite.
To implement this, I've allowed encoding of arbitrary invokedynamic
calls in ApplyDynamic.
The encoding is:
ApplyDynamic(
NoSymbol.newTermSymbol(TermName("methodName")).setInfo(invokedType)
Literal(Constant(bootstrapMethodSymbol)) :: (
Literal(Constant(staticArg0)) :: Literal(Constant(staticArgN)) :: Nil
) :::
(dynArg0 :: dynArgN :: Nil)
)
So far, static args may be `MethodType`, numeric or string literals, or
method symbols, all of which can be converted to constant pool entries.
`MethodTypes` are transformed to the erased JVM type and are converted
to descriptors as String constants.
I've taken advantage of this for symbol literal caching and
for the structural call site cache.
I've also included a test case that shows how a macro could target this
(albeit using private APIs) to cache compiled regexes.
I haven't managed to use this for LambdaMetafactory yet, not sure
if the facility is general enough.
|
|\ \ \
| | | |
| | | | |
SI-9542 Fix regression in value classes (served two ways)
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The new unit test shows failures in transitivity of subtyping
and type equivalence, which boil down the the inconsistent
handling of the semantically equivalent:
ThisType(pre, ModuleClass)
ModuleTypeRef(pre, ModuleClass)
SingleType(pre, Module)
This commit:
- adds a case to `normalizePlus` to unwrap a `ThisType` to
a `ModuleTypeRef`
- Use `normalizePlus` more widely during subtype comparison
- refactor `fourthTry` (part of `isSubType`) to remove code
that becomes obviated by the use of `normalizePlus`.
This fixes the regression in the extension methods phase which
was triggered by https://github.com/scala/scala/pull/4749.
We can also fix that regression by tweaking the extension methods
phase itself to emit the `ThisType` representation of the owner
of the value class, as before.
I plan to demonstrate the two approaches to fixing the regression
on separate branches, and the propose that the merged result of these
two is useds.
|
|\ \ \
| | | |
| | | |
| | | | |
merge/2.11.x-to-2.12.x-20160203
|
| |/ /
| | |
| | |
| | |
| | |
| | | |
... instead of scala.collection.mutable.StringBuilder to benefit from
JVM optimizations. Unfortunately primitives are already boxed in erasure
when they end up in this part of the backend.
|
|\ \ \
| |/ /
|/| /
| |/
| |
| |
| |
| |
| | |
Conflicts:
src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala
src/compiler/scala/tools/nsc/transform/Constructors.scala
src/compiler/scala/tools/nsc/typechecker/Contexts.scala
src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala
src/scaladoc/scala/tools/nsc/doc/html/resource/lib/jquery.layout.js
|
| |
| |
| |
| | |
The the word 'the' is often used twice. Fix that.
|
|\ \
| | |
| | | |
SI-9437 Emit and support parameter names in class files
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
JEP 118 added a MethodParameters attribute to the class file spec which
holds the parameter names of methods when compiling Java code with
`javac -parameters`.
We emit parameter names by default now.
|
|\| | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Before this commit, multiple invocations of universe.showRaw used a
shared weak map that caches footnotes. If the two printed objects
have equal components printed as footnotes, e.g., an equal TypeRef,
the result of the second invocation depends on whether the object
has been collected (and removed from the weak map) or not.
See https://github.com/scala/scala-dev/issues/70#issuecomment-171701671
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
- 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".
|
| |\ \
| | | |
| | | | |
Desugar module var and accessor in refchecks/lazyvals
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Rather than leaving it until mixin.
The broader motivation is to simplify the mixin phase of the
compiler before we get rid of implementatation classes in
favour of using JDK8 default interface methods.
The current code in mixin is used for both lazy val and modules,
and puts the "slow path" code that uses the monitor into a
dedicated method (`moduleName$lzyCompute`). I tracked this
back to a3d4d17b77. I can't tell from that commit whether the
performance sensititivity was related to modules or lazy vals,
from the commit message I'd say the latter.
As the initialization code for a module is just a constructor call,
rather than an arbitraryly large chunk of code for a lazy initializer,
this commit opts to inline the `lzycompute` method.
During refchecks, mixin module accessors are added to classes, so
that mixed in and defined modules are translated uniformly. Trait
owned modules get an accessor method with an empty body (that shares
the module symbol), but no module var.
Defer synthesis of the double checked locking idiom to the lazyvals
phase, which gets us a step closer to a unified translation of
modules and lazy vals.
I had to change the `atOwner` methods to to avoid using the
non-existent module class of a module accessor method as the
current owner. This fixes a latent bug. Without this change,
retypechecking of the module accessor method during erasure crashes
with an accessibility error selecting the module var.
In the process, I've tweaked a tree generation utility method
to wvoid synthesizing redundant blocks in module desugaring.
|
| |\ \ \
| | | | |
| | | | | |
SI-9110 Pattern `O.C` must check `$outer eq O` for a top level O
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
The outer check was not being generated when the prefix was a
top level module. The enclosed test shows that we in fact must
synthesize the outer check in that case.
Perhaps the bug was introduced by neglecting to consider that
a module can inherit member classes.
|
| |\ \ \ \
| | |/ / /
| |/| | /
| | | |/
| | |/| |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
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
|
| |\| | |
|