summaryrefslogtreecommitdiff
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #2439 from retronym/ticket/7369Adriaan Moors2013-04-271-11/+28
|\ | | | | SI-7369 Avoid spurious unreachable warnings in patterns
| * SI-7369 Avoid spurious unreachable warnings in patternsJason Zaugg2013-04-241-11/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unreachability analysis draws on the enumerated domain of types (e.g sealed subclasses + null, or true/false), and also looks at all stable identifier patterns tested for equality against the same 'slot' in a pattern. It was drawing the wrong conclusions about stable identifier patterns. Unlike the domain constants, two such values may hold the same value, so we can't assume that matching X precludes matching Y in the same slot in a subsequent case. For example: val X: Boolean = true; val Y: Boolean = true def m1(t1: Tuple1[Boolean]) = t1 match { case Tuple1(true) => case Tuple1(false) => case Tuple1(false) => // correctly unreachable } def m2(t1: Tuple1[Boolean]) = t1 match { case Tuple1(X) => case Tuple1(Y) => // spurious unreachable warning } // // Before // reachability, vars: V2: Boolean ::= true | false// Set(false, Y, X, true) // = x1._1 V1: (Boolean,) ::= null | ... // = x1 equality axioms: V2=true#4 \/ V2=false#5 /\ -V2=false#5 \/ -V2=Y#3 /\ -V2=false#5 \/ -V2=X#2 /\ -V2=false#5 \/ -V2=true#4 /\ -V2=Y#3 \/ -V2=X#2 /\ -V2=Y#3 \/ -V2=true#4 /\ -V2=X#2 \/ -V2=true#4 // // After // reachability, vars: V2: Boolean ::= true | false// Set(false, Y, X, true) // = x1._1 V1: (Boolean,) ::= null | ... // = x1 equality axioms: V2=true#4 \/ V2=false#5 /\ -V2=false#5 \/ -V2=true#4
* | Merge pull request #2392 from vigdorchik/ticket/si-7367Paul Phillips2013-04-262-27/+29
|\ \ | | | | | | SI-7367 scaladoc crash on constructing the model for annotations.
| * | SI-7367 scaladoc crash on constructing the model for annotations.Eugene Vigdorchik2013-04-252-27/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | Scaladoc only checks primary constructor when building annotation model. Here we instead find the constructor matching the annotation's symbol. Also change TreeFactory.makeTree to return TreeEntity rather than Option[TreeEntity] and force the caller check for EmptyTree.
* | | SI-6943 warn on value class miscomparison.Paul Phillips2013-04-241-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a very dangerous situation running around when you combine universal equality with value classes: // All over your code val x = "abc" if (x == "abc") ... // Hey let's make x a value class val x = new ValueClass("abc") // Uh-oh There was until now no warning when comparing a value class with something else. Now there is.
* | | Merge pull request #2420 from retronym/ticket/6675-2Jason Zaugg2013-04-235-10/+17
|\ \ \ | | | | | | | | SI-6675 Avoid spurious warning about pattern bind arity.
| * | | SI-6675 Avoid spurious warning about pattern bind arity.Jason Zaugg2013-04-215-10/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 692372ce, we added a warning (under -Xlint) when binding a `TupleN` in to a single pattern binder, which wasn't allowed before 2.10.0, and more often than not represents a bug. However, that warning overstretched, and warned even when using a Tuple Pattern to bind to the elements of such a value. This commit checks for this case, and avoids the spurious warnings. A new test case is added for this case to go with the existing test for SI-6675: $ ./tools/partest-ack 6675 % tests-with-matching-paths ... 3 % tests-with-matching-code ... 2 # 3 tests to run. test/partest --show-diff --show-log \ test/files/neg/t6675-old-patmat.scala \ test/files/neg/t6675.scala \ test/files/pos/t6675.scala \ "" Testing individual files testing: [...]/files/pos/t6675.scala [ OK ] Testing individual files testing: [...]/files/neg/t6675-old-patmat.scala [ OK ] testing: [...]/files/neg/t6675.scala [ OK ] All of 3 tests were successful (elapsed time: 00:00:03)
* | | | SI-7355 Handle spaces in paths in Windows batch files.Bjorn Regnell2013-04-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changed "%1%" and %2% to "%~1" and %~2 to allow spaces in paths by surrounding quotes according to advice at: http://stackoverflow.com/questions/473117/pass-path-with-spaces-as-parameter-to-bat-file http://ss64.com/nt/syntax-args.html
* | | | Merge pull request #2387 from vigdorchik/interactive_scaladocAdriaan Moors2013-04-221-2/+4
|\ \ \ \ | |_|_|/ |/| | | Interactive scaladoc: demand new typer run when done.
| * | | Interactive scaladoc: mark new typer run when done.Eugene Vigdorchik2013-04-171-2/+4
| | |/ | |/| | | | | | | | | | As of now, when backgroundCompile is in the same typer run as scaladoc-fetching logic, typer is confused with stale symbols.
* | | Merge pull request #2358 from adriaanm/ticket-7330Jason Zaugg2013-04-213-28/+30
|\ \ \ | | | | | | | | SI-7330 better error when pattern's not a value
| * | | SI-7330 better error when pattern isn't a valueAdriaan Moors2013-04-083-28/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Somehow an applied type managed to sneak past the type checker in pattern mode. Patterns must be values, though. `case C[_] =>` was probably meant to be `case _: C[_] =>` Advice is dispensed accordingly. (Generalizing the existing advice machinery.)
* | | | Merge pull request #2410 from paulp/pr/parameterized-implicitJason Zaugg2013-04-211-4/+5
|\ \ \ \ | | | | | | | | | | Quiet down overloaded implicit warning.
| * | | | Quiet down overloaded implicit warning.Paul Phillips2013-04-181-4/+5
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | Apparently implicit classes product both a method symbol and a module symbol, both of which are marked implicit, which left this warning code believing there was an overloaded implicit method.
* | | | Merge pull request #2408 from paulp/pr/fully-qualified-namePaul Phillips2013-04-191-9/+12
|\ \ \ \ | | | | | | | | | | Absolute path in error message.
| * | | | Absolute path in error message.Paul Phillips2013-04-171-9/+12
| |/ / / | | | | | | | | | | | | | | | | | | | | As soon as you have a directory called "language" lying around, you will appreciate why the advice given regarding SIP-18 should be "import scala.language..." not "import language..."
* | | | Merge pull request #2411 from retronym/ticket/7388Paul Phillips2013-04-191-1/+5
|\ \ \ \ | | | | | | | | | | SI-7388 Be more robust against cycles in error symbol creation.
| * | | | SI-7388 Be more robust against cycles in error symbol creation.Jason Zaugg2013-04-181-1/+5
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Symbol#toString` was triggering `CyclicReferenceError` (specifically, `accurateKindString` which calls `owner.primaryConstructor`.) The `toString` output is used when creating an error symbol to assign to the tree after an error (in this case, a non-existent access qualifier.) This commit catches the error, and falls back to just using the symbol's name.
* | | | Merge pull request #2402 from retronym/ticket/7377Paul Phillips2013-04-191-1/+6
|\ \ \ \ | | | | | | | | | | SI-7377 Fix retypechecking of patterns on case companion alias
| * | | | SI-7377 Fix retypechecking of patterns on case companion aliasJason Zaugg2013-04-171-1/+6
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some ancient code in Typers switches from PATTERNmode to EXPRmode when encountering `stableF(...)`. It just typechecks `stableF` and discards the arguments. To the best of Martin's recollection, this has something to do with the need to typecheck patterns rather late in the compiler, after `a.b` had been translated to `a.b()` in `Uncurry`. I'm not able to motivate this with tests using `-Xoldpatmat`; was there ever an even older pattern matcher that ran *after* uncurry? What changed in 2.10.1 to expose this wrinkle? dfbaaa17 fixed `TypeTree.copyAttrs` to copy the original tree. During the descent of `ResetAttrs`, sub-trees are duplicated before begin further transformed. Duplicating the `Match` in 2.10.0 would forget that the original tree of: pat = (a: Int)Foo(_) `----------` `- TypeTree((a: Int)Foo), with original Select(..., "FooAlias") The retypechecking would operate on the `MethodType`, rather than the `Select`, which was not considered a stable application. For 2.10.x, I've just tightened up the condition to only hit this if `args` is empty. I'm almost certain that the code can be removed altogether, and I'll do that when this is merged to master.
* | | | Merge pull request #2370 from retronym/ticket/7319-2Paul Phillips2013-04-192-18/+14
|\ \ \ \ | | | | | | | | | | SI-7319 Avoid unflushed error/warning buffers in startContext
| * | | | SI-7319 Clear error buffer during Typer reset.Jason Zaugg2013-04-152-18/+14
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Contexts share error/warning buffers with their children, and this also applies ot the shared `startContext`. That context flushes the buffers in `startContext` in `resetContexts`. It also removes `typerReportAnyContextErrors`, which appears to be an elaborate no-op. It is only ever passed a context `c` which is a direct child of `this.context`. So taking a buffered error out of `c` and reissuing it into `this.context` merely re-inserts into into the same error buffer. Consrast this with `silent`, which uses a child context with a fresh error buffer. SI-7319 Flush error buffer in typerReportAnyContextErrors. After this change, we no longer rely on the backstop in resetContexts introduced in the previous commit.
* | | | Merge pull request #2364 from vigdorchik/ticket/si-7329Paul Phillips2013-04-191-1/+5
|\ \ \ \ | |_|/ / |/| | | SI-7329 duplicate default getters for specialized parameters.
| * | | SI-7329 duplicate default getters for specialized parameters.Eugene Vigdorchik2013-04-071-1/+5
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default getter is generated with @specialized annotation if the type parameter corresponding to the type of the parameter is specialized. Consequently specialize pass tries to generate overloads. Rather than pruning overloads to exclude duplicates, let's notice that default getter specialization is not needed at all: - The dynamic scope of default getter doesn't include specialized method or class constructor. - generic default getter is called even when calling specialized method: object V { @specialized def foo[@specialized B](b: B = (??? : B)) = {} foo[Int]() } gives: invokevirtual Method V$.foo$default$1:()Ljava/lang/Object; invokestatic (unboxToInt) invokevirtual Method V$.foo$mIc$sp:(I)V
* | | Merge pull request #2383 from vigdorchik/ticket/si-6286Paul Phillips2013-04-141-20/+17
|\ \ \ | | | | | | | | SI-6286 IllegalArgumentException handling specialized method.
| * | | SI-6286 IllegalArgumentException handling specialized method.Eugene Vigdorchik2013-04-101-20/+17
| | |/ | |/| | | | | | | | | | | | | Specialize assigns SpecialOverride info to a specialized method even when there is a further specialization that should be forwarded to.
* / | SI-7360 Don't let a follow-up TypeError obscure the original error.Jason Zaugg2013-04-121-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | When supplementing a fatal error message with context (current compilation unit, tree, phase, etcetera), we must be cautious to not to trigger another error which will obscure the original one. Currently, `supplementErrorMessage` does its working a try catch that only catches `Exception`. But this fails to catch CyclicReferenceError (<: TypeError <: Throwable), as was seen in a recent mailing list post by Greg Meredith. This commit extends the catch clause.
* / SI-6386 typed existential type tree's original now have tpe setUladzimir Abramchuk2013-04-091-2/+10
|/ | | | | | | | | | | | | | | Tree reification fails for ExistentialTypeTree. The reason is that the tree passed for reification (see reifyTree at GetTrees.scala) must have not null tpe (see reifyBoundType at GenTrees.scala), which is not true in the case of ExistentialTypeTree. Why is it so? The tree passed to reifyTree was obtained in the reshape phase of reificationusing using original TypeTrees that reporesent pre- typer representation of a type. The problem is that original's tpe for ExistentialTypeTree is not set. So the solution to the issue is to create ExistentialTypeTree's original in a such way that is has actual tpe set.
* SI-7321 Memory leak in specialize on multiple compiler runs.Eugene Vigdorchik2013-04-041-16/+12
| | | | | | | | Currently the map is declared LinkedHashMap, which doesn't align with other caching maps that are cleared on every run. Linkedness is only needed to ensure deterministic order on the generated specialized classes. The same can be accomplished by sorting generated classes a-posteriori.
* Merge pull request #2298 from retronym/ticket/6900-3Paul Phillips2013-04-033-88/+23
|\ | | | | SI-6900 Tail call elimination + dependent method type crasher
| * SI-6900 Fix tailrec for dependent method typesJason Zaugg2013-04-021-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Uncurry's info transformer could generate a MethodType with cloned parameter symbols. This type was used for the LabelDef generated in the TailCalls phase. But, the RHS of the method still contains types that refer to the original parmameter symbol. Spurious type errors ensued. I've spent a good chunk of time pursuing a more principled fix, in which we keep the symbols in the tree in sync with those in the MethodType. You can relive the procession of false dawns: https://github.com/scala/scala/pull/2248 Ultimately that scheme was derailed by a mismatch between the type parameter `T` and the skolem `T&` in the example below. trait Endo[A] { def apply(a: => A): A } class Test { def foo[T] = new Endo[(T, Unit)] { def apply(v1: => (T, Unit)) = v1 // no bridge created } } Interestingly, by removing the caching in SingleType, I got past that problem. But I didn't characterize it further. This commit sets asides the noble goal of operating in the world of types, and sledgehammers past the crash by casting the arguments to and the result of the label jump generated in TailCalls.
| * Simplify interplay between Uncurry Info- and Tree-TransformersJason Zaugg2013-04-021-17/+10
| | | | | | | | | | | | | | | | | | | | Now, the InfoTransformer is responsible for erasing the path dependent types of formal parameters, at the same place where it flattens nested method types. This is preferable to having the tree transformer overwrite the result of the info transformer, as used to be the case after my previous work on SI-6135 / 493197fc.
| * Refactor existential related code out of types.Jason Zaugg2013-04-021-69/+1
| | | | | | | | | | | | | | For imminent reuse in the subsequent commit. The binary compatibility whitelist is updated to ignore these, as they live in reflect.internal.
* | Take the N^2 out of the compiler's TreeSet.Paul Phillips2013-04-031-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code responsible for this performance bug lives on somewhere in the combination of Iterator.single and Iterator.++ and is tracked by SI-7316. What this commit does is bypass the creation and composition of iterators entirely in favor of applying foreach to walking the tree. The important lesson of a bug like this: the occurrence depends on the existence of multiple implementations of basic structures like Trees. For each redundant implementation, scrutiny and testing are divided and "bug diversity" is increased. We should labor hard to structure collections in such a way that people have no good reason not to take advantage of the basic and hopefully battle-tested logic - especially when those people are us. I hope to remove util.TreeSet entirely. Until then, here is the impact of this commit on the time to compile a piece of generated test code. % time scalac3 ./target/generated/src.scala Mar 28 13:20:31 [running phase parser on src.scala] ... Mar 28 13:21:28 [running phase lazyvals on src.scala] Mar 28 13:21:28 [running phase lambdalift on src.scala] <-- WHOA Mar 28 13:25:05 [running phase constructors on src.scala] ... Mar 28 13:25:19 [running phase jvm on icode] 316.387 real, 438.182 user, 8.163 sys To this: 97.927 real, 211.015 user, 8.043 sys % time pscalac ./target/generated/src.scala Mar 28 13:18:47 [running phase parser on src.scala] ... Mar 28 13:19:44 [running phase lazyvals on src.scala] Mar 28 13:19:44 [running phase lambdalift on src.scala] Mar 28 13:19:46 [running phase constructors on src.scala] ... Mar 28 13:19:57 [running phase jvm on icode] 99.909 real, 223.605 user, 7.847 sys That's lambdalift dropping from 217 seconds to 2 seconds.
* | Merge pull request #2344 from retronym/ticket/7147Jason Zaugg2013-04-031-2/+9
|\ \ | |/ |/| SI-7147 Diagnostic for unexplained assertion in presentation compiler.
| * SI-7147 Diagnostic for unexplained assertion in presentation compiler.Jason Zaugg2013-04-021-2/+9
| | | | | | | | | | We don't have a reproducible test for this, so the best we can do is beef up the assertion to shine a little light on the problem.
* | Merge pull request #2319 from retronym/ticket/6793Paul Phillips2013-04-021-2/+9
|\ \ | |/ |/| SI-6793 Don't use super param accessors if inaccessible.
| * SI-6793 Don't use super param accessors if inaccessible.Jason Zaugg2013-03-261-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "Alias replacement" has been with us since 2005 (13c59adf9). Given: package a { class C1(val v0: String) class C2(v1: String) extends a.C1(v1) { v1 } } The reference to `v1` is rewritten as `C2.super.v0()`, and no field is generated in `C2`. (Oddly, this optimization doesn't seem to kick in if these classes are in the empty package. That's probably a distinct bug.) However, this rewriting is done without consideration of the accessibility of `v0` from `C2`. This commit disables this optimization if there if `v0` is not accessible.
* | Merge pull request #2321 from kzys/js-deferAdriaan Moors2013-04-012-16/+30
|\ \ | | | | | | Scaladoc: Load scripts at the bottom, and with a defer attribute
| * | Scaladoc: Load scripts at the bottom, and with a defer attributeKato Kazuyoshi2013-03-272-16/+30
| | | | | | | | | | | | | | | | | | | | | To improve latency on modern browsers (which supports defer) and old browsers: * https://www.webkit.org/blog/1395/running-scripts-in-webkit/ * http://developer.yahoo.com/blogs/ydn/posts/2007/07/high_performanc_5/
* | | Merge pull request #2292 from retronym/ticket/7285Adriaan Moors2013-03-271-1/+2
|\ \ \ | | | | | | | | SI-7285 Fix match analysis with nested objects
| * | | SI-7285 Fix match analysis with nested objects.Jason Zaugg2013-03-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fix for SI-6146 introduced `nestedMemberType` to enumerate sealed subtypes based on the (prefixed) type of the scrutinee and the symbols of its sealed subclasses. That method needed to widen `ThisType(modSym)`s to `ModuleTypeRef(modSym)` before calling `asSeenFrom`. However, this could lead to confused in the match analysis, which sees `ModuleTypeRef` as distinct from singleton types on the same modules (after all, they aren't =:=). Spurious warnings ensued. This commit makes two changes: - conditionally re-narrow the result of `asSeenFrom` in `nestedMemberType`. - present `a.b.SomeModule.type` as `SomeModule` in warnings emitted by the pattern matcher.
* | | | Merge pull request #2291 from retronym/ticket/7290Adriaan Moors2013-03-271-5/+15
|\ \ \ \ | |_|/ / |/| | | SI-7290 Discard duplicates in switchable alternative patterns.
| * | | SI-7290 Minor cleanups driven by review comments.Jason Zaugg2013-03-271-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | - make a def a val, we only need to compute it once - add a clarifying comment - only report the first duplicate
| * | | SI-7290 Discard duplicates in switchable alternative patterns.Jason Zaugg2013-03-231-3/+13
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | The pattern matcher must not allow duplicates to hit the backend when generating switches. It already eliminates then if they appear on different cases (with an unreachability warning.) This commit does the same for duplicated literal patterns in an alternative pattern: discard and warn.
* | | Merge pull request #2270 from retronym/ticket/7246-2Paul Phillips2013-03-251-14/+12
|\ \ \ | | | | | | | | SI-7246 Make $outer pointer elision Java aware
| * | | SI-7246 Make $outer pointer elision Java awareJason Zaugg2013-03-231-14/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In e0853b3, a space-saving optimization elided the outer pointer of inner classes if the the (protected) outer pointer of the immediate parent class was guaranteed to point to the same instance. But, this check failed to account for Java parent classes, which don't follow the Scala scheme. This commit disables the optimization in that case. The original test case in e0853b3 was anemic, I've fleshed it out to: - test the presense or absense of $outer pointers with Java reflection - test the optimization works in the presense of aliased and annotated aliased types. (The former worked already, the latter required a change to the implementation.) - Test the negative case when the prefixes don't line up and the subclass in fact needs its own $outer. This patch is based on work by Euguene Vigdorchik with some additions by Jason Zaugg.
* | | | Merge pull request #2306 from retronym/ticket/7299Paul Phillips2013-03-251-2/+8
|\ \ \ \ | | | | | | | | | | SI-7299 Improve error message for eta-expanding 23+ param method
| * | | | SI-7299 Improve error message for eta-expanding 23+ param methodJason Zaugg2013-03-251-2/+8
| | |_|/ | |/| | | | | | | | | | Before, we got `error: missing arguments for method f`.
* | | | Merge pull request #2257 from JamesIry/2.10.x_classfile_51Paul Phillips2013-03-255-2/+35
|\ \ \ \ | | | | | | | | | | Read version 51 (JDK 7) class files.