| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
SI-9045 Error on recursive ctor
|
| |
| |
| |
| | |
If the constructor invokes itself, say so.
|
| |
| |
| |
| |
| | |
Collapse conditionals into match for legible.
Yes, guards have scary eval order.
|
|\ \
| | |
| | | |
Remove legacy recursive classpath implementation
|
| | | |
|
| | | |
|
| | | |
|
|\ \ \
| |_|/
|/| | |
SD-140 inline the correct default method
|
| | |
| | |
| | |
| | |
| | | |
When inheriting multiple default methods, select the correct one to
inline. Implements method resolution according to the JVM spec.
|
| | |
| | |
| | |
| | | |
ArithmeticException (#5123)
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`withCurrentUnit` is designed to be called once per
compilation unit as it side effects by logging and updating
progress counters.
`GenBCode` was calling it more frequently (once per `ClassDef`.)
This is due to the somewhat convoluted internal architecture
of that phase, which is designed to support paralellism in
the future.
This commit factors out the internal part of `withCompilationUnit`
that modifies `currentUnit`, and calls that instead in the loop
over classes.
After this change:
```
% qscala -Ydebug
...
[running phase jvm on <console>] // only once
```
|
| |
| |
| |
| | |
Also adds a warning on junit test methods that compile as default
methods.
|
|\ \
| | |
| | | |
SI-9684 Deprecate JavaConversions
|
| |/
| |
| |
| |
| |
| |
| |
| |
| | |
Implicit conversions are now in package convert as ImplicitConversions,
ImplicitConversionsToScala and ImplicitConversionsToJava.
Deprecated WrapAsJava, WrapAsScala and the values in package object.
Improve documentation.
|
|/
|
|
|
|
|
|
|
|
|
| |
In any shift operation where the lhs is an Int (or smaller) and
the rhs is a Long, the result kind must be Int, and not Long.
This is important because the lhs must *not* be promoted to a
Long, as that causes an opcode for long shift to be emitted.
This uses an rhs modulo 64, instead of int shifts which use an
rhs module 32. Instead, the rhs must be downgraded to an Int.
The new behavior is consistent with the same operations in the
Java programming language.
|
|\
| |
| | |
Remove the duplicate implem of hash codes for numbers.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Previously, there were two separate implementations of hash
code for boxed number classes:
* One in Statics, used by the codegen of case class methods.
* One in ScalaRunTime + BoxesRunTime, used by everything else.
This commit removes the variant implemented in ScalaRunTime +
BoxesRunTime, and always uses Statics instead. We use Statics
because the one from ScalaRunTime causes an unnecessary module
load.
The entry point ScalaRunTime.hash() is kept, as deprecated,
for bootstrapping reasons.
|
|\ \
| | |
| | | |
Ensure ClassBTypes constructed from symbol and classfile are identical
|
| | |
| | |
| | |
| | |
| | | |
For some reason this was not the case, leading to spurious inliner
warnings (no inline info found for method O$lzycompute).
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
A super call (invokespecial) to a default method T.m is only allowed if
the interface T is a direct parent of the class. Super calls are
introduced for example in Mixin when generating forwarder methods:
trait T { override def clone(): Object = "hi" }
trait U extends T
class C extends U
The class C gets a forwarder that invokes T.clone(). During code
generation the interface T is added as direct parent to class C. Note
that T is not a (direct) parent in the frontend type of class C.
This commit stores interfaces that are added to a class during code
generation in the InlineInfo classfile attribute. This allows filtering
the interface list when constructing a ClassBType from a classfile.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The code was patched many times in the history and became a bit
scattered.
When emitting a virtual call, the receiver in the bytecode cannot just
be the method's owner (the class in which it is declared), because that
class may not be accessible at the callsite. Instead we use the type
of the receiver. This was basically done to fix
- aladdin bug 455 (9954eaf)
- SI-1430 (0bea2ab) - basically the same bug, slightly different
- SI-4283 (8707c9e) - the same for field reads
In this patch we extend the fix to field writes, and clean up the code.
This patch basically reverts 6eb55d4b, the fix for SI-4560, which was
rather a workaround than a fix. The underlying problem was that in some
cases, in a method invocation `foo.bar()`, the method `bar` was not
actually a member of `foo.tpe`, causing a NoSuchMethodErrors. The
issue was related to trait implementation classes. The idea of the fix
was to check, at code-gen time, `foo.tpe.member("bar")`, and if that
returns `NoSymbol`, use `barSym.owner`. With the new trait encoding
the underlying problem seems to be fixed - all tests still pass
(run/t4560.scala and run/t4560b.scala).
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
In most cases when a class inherits a concrete method from a trait we
don't need to generate a forwarder to the default method in the class.
t5148 is moved to pos as it compiles without error now. the error
message ("missing or invalid dependency") is still tested by t6440b.
|
|\ \ \
| |_|/
|/| | |
SI-6710 / PR 5072 follow-up: fix Unit.box / Unit.unbox
|
| |/
| |
| |
| |
| |
| |
| | |
The backend replaces .box / .unbox methods by corresponding invocations
to BoxesRunTime, but not for Unit.
This commit restores the body of `Unit.box` and `Unit.unbox`.
|
|/
|
|
| |
Because it was its only call site.
|
|\
| |
| | |
Cleanups related to the removal of trait impl classes
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The sbt command `generateSources` now generates both the AnyVal
sources and the tuple/function sources (previously done by `genprod`).
Source generation is part of the sbt build, the `scala.tools.cmd.gen`
package is removed from `scala-compiler`. This simplifies bootstrapping.
Generated sources are still in the same location and checked into git.
The shell scripts `tools/codegen` and `tools/codegen-anyvals` are
also removed. The ant build and the build scripts do not call these.
Regenerating sources is a manual step at the moment.
|
| | |
|
|/
|
|
|
|
|
|
|
| |
- Replaces the implementations of box/unbox in AnyVal companions by
`???`, the methods are only stubs, and the impls did not correspond
to the actual behavior. The doc comment already points to the actual
implementation in BoxesRunTime.
- Replaces the body of `getClass` from `null` to `???` and clarifies in
a comment why the overrides exist.
|
|\
| |
| | |
Accomodate and exploit new library, lang features JDK 8
|
| | |
|
|\ \
| | |
| | | |
SI-9702 Fix backend crash with classOf[T] annotation argument
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This commit fixes various issues with classOf literals and Java
annotations.
- Ensure that a Type within a ConstantType (i.e., a classOf literal)
is erased, so `classOf[List[Int]]` becomes `classOf[List]`.
- Ensure that no non-erased types are passed to `typeToBType` in the
backend. This happens for Java annotations: the annotation type and
`classOf` annotation arguments are not erased, the annotationInfos
of a symbol are not touched in the compiler pipeline.
- If T is an alias to a value class, ensure that `classOf[T]` erases
to the value class by calling `dealiasWiden` in erasure.
|
|\ \ \
| | | |
| | | | |
Unify treatment of built-in functions and SAMs
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Jason points out the recursion will be okay if
type checking the function inside the eta-expansion provides
fully determined argument types, as the result type is
not relevant for this phase of typedFunction.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
When recovering missing argument types for an
eta-expanded method value, rework the expected type
to a method type.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The body of `def delay[T](v: => T) = (v _): F0[T]`
becomes `() => v` during `typedEta`, and then uncurry
considers whether to strip the function wrapper since
`v` is known to be a `Function0` thunk. Stripping is sound
when the expected type is `Function0` for this expression,
but that's no longer a given, since we could be expecting any
nullary SAM.
Also sweep up a bit around `typedEta`.
Encapsulate the, erm, creative encoding of
`m _` as `Typed(m, Function(Nil, EmptyTree))`.
|
| | | |
| | | |
| | | |
| | | |
| | | | |
Jason points out we still need it for bytecode efficiency,
due to mixin forwarders.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Rather than in implementation of the abstract method in the
expanded anonymous class.
This leads to more more efficient use of the constant pool,
code shapes more amenable to SAM inlining, and is compatible
with the old behaviour of `-Xexperimental` in Scala 2.11,
which ScalaJS now relies upon.
Manual test:
```
scala> :paste -raw
// Entering paste mode (ctrl-D to finish)
package p1; trait T { val x = 0; def apply(): Any }; class DelambdafyInline { def t: T = (() => "") }
// Exiting paste mode, now interpreting.
scala> :javap -c p1.DelambdafyInline
Compiled from "<pastie>"
public class p1.DelambdafyInline {
public p1.T t();
Code:
0: new #10 // class p1/DelambdafyInline$$anonfun$t$1
3: dup
4: aload_0
5: invokespecial #16 // Method p1/DelambdafyInline$$anonfun$t$1."<init>":(Lp1/DelambdafyInline;)V
8: areturn
public final java.lang.Object p1$DelambdafyInline$$$anonfun$1();
Code:
0: ldc #22 // String
2: areturn
public p1.DelambdafyInline();
Code:
0: aload_0
1: invokespecial #25 // Method java/lang/Object."<init>":()V
4: return
}
scala> :javap -c p1.DelambdafyInline$$anonfun$t$1
Compiled from "<pastie>"
public final class p1.DelambdafyInline$$anonfun$t$1 implements p1.T,scala.Serializable {
public static final long serialVersionUID;
public int x();
Code:
0: aload_0
1: getfield #25 // Field x:I
4: ireturn
public void p1$T$_setter_$x_$eq(int);
Code:
0: aload_0
1: iload_1
2: putfield #25 // Field x:I
5: return
public final java.lang.Object apply();
Code:
0: aload_0
1: getfield #34 // Field $outer:Lp1/DelambdafyInline;
4: invokevirtual #37 // Method p1/DelambdafyInline.p1$DelambdafyInline$$$anonfun$1:()Ljava/lang/Object;
7: areturn
public p1.DelambdafyInline$$anonfun$t$1(p1.DelambdafyInline);
Code:
0: aload_1
1: ifnonnull 6
4: aconst_null
5: athrow
6: aload_0
7: aload_1
8: putfield #34 // Field $outer:Lp1/DelambdafyInline;
11: aload_0
12: invokespecial #42 // Method java/lang/Object."<init>":()V
15: aload_0
16: invokespecial #45 // Method p1/T.$init$:()V
19: return
}
scala> :quit
```
Adriaan is to `git blame` for `reflection-mem-typecheck.scala`.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
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.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Thus, rule out traits that have a constructor (which we use
as a proxy for having potentially side-effecting statements),
and create an anonymous subclass for them at compile time.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
LambdaMetaFactory can only properly instantiate Java interfaces
(with one abstract method, of course). A trait always compiles
to an interface, but a subclass that can be instantiated may
require mixing in further members, which LMF cannot do.
(Nested traits, traits with fields,... do not qualify.)
Traits that cannot be instantiated by LMF are still SAM targets,
we simply created anonymous subclasses as before.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
When a SAM type is specialized (i.e., a specialized type
parameter receives a specialized type argument), do not use
LambdaMetaFactory (expand during Uncurry instead).
This is an implementation restriction -- the current
specialization scheme is not amenable to using
LambdaMetaFactory to spin up subclasses. Since the generic
method is abstract, and the specialized ones are concrete,
specialization is rendered moot because we cannot implement
the specialized method with the lambda using LMF.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
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.
|