summaryrefslogtreecommitdiff
path: root/src/reflect
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #5068 from retronym/topic/jdk8ism2v2.12.0-M4Lukas Rytz2016-04-012-9/+23
|\ | | | | Accomodate and exploit new library, lang features JDK 8
| * At the end of a run, close macro runtime's classloaderJason Zaugg2016-03-302-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can only do this on 2.12.x, because URLClassLoader#close is new in JDK 7. Tested manually with the REPL and resident compilers. ``` % qscalac sandbox/macro.scala && (for i in 1 2; do echo sandbox/client.scala; done; printf '\n') | qscalac -Xresident -Ylog:all -Ydebug 2>&1 | grep "Closing macro runtime classloader" [log terminal] Closing macro runtime classloader [log terminal] Closing macro runtime classloader % qscalac sandbox/macro.scala && (for i in 1 2; do echo Macro.m; done; printf '\n') | qscala -Ylog:all -Ydebug 2>&1 | grep "Closing macro runtime classloader"; stty echo [log terminal] Closing macro runtime classloader [log terminal] Closing macro runtime classloader ``` Note: this doesn't close handles to JAR files held by the compiler classpath implementation, that will require changes elsewhere.
* | Merge pull request #5059 from lrytz/t9702Adriaan Moors2016-03-312-2/+4
|\ \ | | | | | | SI-9702 Fix backend crash with classOf[T] annotation argument
| * | SI-9702 Fix backend crash with classOf[T] annotation argumentLukas Rytz2016-03-302-2/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Bring back AbstractFunction parentAdriaan Moors2016-03-301-0/+1
| | | | | | | | | | Jason points out we still need it for bytecode efficiency, due to mixin forwarders.
* | LMF cannot instantiate SAM of trait with non-trait superclassAdriaan Moors2016-03-292-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Target FunctionN, not scala/runtime/java8/JFunction.Adriaan Moors2016-03-281-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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?)
* | SAM conversion can be disabled using `-Xsource:2.11`Adriaan Moors2016-03-263-1/+5
| | | | | | | | For completeness, `-Xsource:2.11 -Xexperimental` does enable it.
* | Refactor: simplify fallbackAfterVanillaAdapt.Adriaan Moors2016-03-261-8/+0
| | | | | | | | | | | | | | | | 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.
* | Soften sam restrictionsAdriaan Moors2016-03-262-16/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Track Function's SAM symbol & target type using an attachmentAdriaan Moors2016-03-262-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Additional SAM restrictions identified by JasonAdriaan Moors2016-03-261-6/+19
| | | | | | | | | | Also test roundtripping serialization of a lambda that targets a SAM that's not FunctionN (it should make no difference).
* | Treat `Function` literals uniformly, expecting SAM or FunctionN.Adriaan Moors2016-03-261-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Set the scene for Sammy.Adriaan Moors2016-03-262-0/+23
| | | | | | | | | | | | | | | | 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.)
* | Refactoring. Sweep Sammy's backyard.Adriaan Moors2016-03-261-0/+5
| |
* | Refactor typedFunction, rework synthesizeSAMFunction for sammyAdriaan Moors2016-03-262-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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.
* | SI-9415 Turn on SAM by defaultJason Zaugg2016-03-261-3/+1
| | | | | | | | | | | | | | | | | | | | 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.
* | Refactor. Extract mkLiteralUnit and mkUnitBlockAdriaan Moors2016-03-261-4/+7
| |
* | Remove dead code now that `genBCodeActive` is always true.Adriaan Moors2016-03-261-4/+0
| |
* | TypeHistory's toString time travels consistentlyAdriaan Moors2016-03-261-1/+4
|/ | | | | | | 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.
* Merge pull request #5047 from kmizu/resolve-several-warningsAdriaan Moors2016-03-221-1/+1
|\ | | | | Resolve several deprecation warnings
| * * Replace isPackage with hasPackageFlagKota Mizushima2016-03-171-1/+1
| |
* | Merge pull request #5043 from dongjoon-hyun/fix_typos_in_spec_and_commentsJason Zaugg2016-03-213-3/+3
|\ \ | | | | | | Fix some typos in `spec` documents and comments.
| * | Fix some typos in `spec` documents and comments.Dongjoon Hyun2016-03-153-3/+3
| |/
* / New trait encoding: use default methods, jettison impl classesJason Zaugg2016-03-1811-90/+18
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Merge pull request #4974 from szeiger/wip/patmat-outertestAdriaan Moors2016-03-142-41/+24
|\ | | | | More conservative optimization for unnecessary outer ref checks
| * Improved outer ref checking in pattern matches:Adriaan Moors2016-03-072-41/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* | Fix var spelling in WeakHashSetJanek Bogucki2016-03-091-6/+6
|/ | | | | WeakHashSet is internal so an exception was made against binary compatibility to allow the var to be made private.
* Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2016-02-251-13/+25
|\ | | | | | | | | | | | | | | | | | | | | 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.
| * Micro optimise Symbol#fullNameJason Zaugg2016-02-091-13/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #4958 from adriaanm/typerefrefactorAdriaan Moors2016-02-242-175/+176
|\ \ | | | | | | Simplify TypeRef hierarchy. baseType returns NoType, as needed for isSubtype. Also improves performance.
| * | thisInfo.parents also needs separate treatmentAdriaan Moors2016-02-121-1/+5
| | |
| * | Less distribution of logic across TypeRef subclassesAdriaan Moors2016-02-122-108/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | Towards understanding `TypeRef`'s `transformInfo`/`baseType`Adriaan Moors2016-02-101-94/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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) ```
* | | Merge pull request #4896 from retronym/topic/indy-all-the-thingsJason Zaugg2016-02-123-0/+15
|\ \ \ | |/ / |/| | Use invokedynamic for structural calls, symbol literals, lambda ser.
| * | Use invokedynamic for structural calls, symbol literals, lamba ser.Jason Zaugg2016-01-293-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #4868 from retronym/ticket/9542-comboJason Zaugg2016-02-102-22/+17
|\ \ \ | | | | | | | | SI-9542 Fix regression in value classes (served two ways)
| * | | SI-9542 Unify different reprs. of module type refsJason Zaugg2016-02-012-22/+17
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 remote-tracking branch 'origin/2.12.x' into ↵Jason Zaugg2016-02-042-8/+12
|\ \ \ | | | | | | | | | | | | merge/2.11.x-to-2.12.x-20160203
| * | | SI-9315 Desugar string concat to java.lang.StringBuilder ...Simon Ochsenreither2016-02-032-8/+12
| |/ / | | | | | | | | | | | | | | | ... 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.
* | | Merge commit 'bf599bc' into merge/2.11.x-to-2.12.x-20160203Jason Zaugg2016-02-031-2/+2
|\ \ \ | |/ / |/| / | |/ | | | | | | | | | | 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
| * Fix some simple extra wordsEitan Adler2016-01-171-2/+2
| | | | | | | | The the word 'the' is often used twice. Fix that.
* | Merge pull request #4735 from soc/SI-9437Lukas Rytz2016-01-261-0/+1
|\ \ | | | | | | SI-9437 Emit and support parameter names in class files
| * | SI-9437 Emit and support parameter names in class filesSimon Ochsenreither2016-01-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge remote-tracking branch 'upstream/2.12.x' into opt/elimBoxesLukas Rytz2016-01-2444-161/+159
|\| |
| * | SD-70 Don't share footnotes across multiple calls to universe.showRawLukas Rytz2016-01-192-26/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | Remove unused imports and other minor cleanupsSimon Ochsenreither2015-12-1838-89/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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".
| * | Merge pull request #4729 from retronym/topic-trait-defaults-moduleLukas Rytz2015-12-183-3/+3
| |\ \ | | | | | | | | Desugar module var and accessor in refchecks/lazyvals
| | * | Desugar module var and accessor in refchecks/lazyvalsJason Zaugg2015-10-083-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | Merge pull request #4265 from retronym/ticket/9110Lukas Rytz2015-12-181-1/+2
| |\ \ \ | | | | | | | | | | SI-9110 Pattern `O.C` must check `$outer eq O` for a top level O