summaryrefslogtreecommitdiff
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* SI-10069 Fix code gen errors with array updates, NothingJason Zaugg2016-12-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Crashes in ASM or VerifyErrors used to occur when assigning an expression of type Nothing to an element of a primitive array. This commit adapts the RHS of the assignment to the element type to correct this. `adapt` contains logic to insert an `ATHROW` of the slot of type `Nothing$`, which makes everything line up. The subsequent array stores become dead code and are dropped later on in code gen, so the test case compiles to: public void foo0(double[]); Code: 0: bipush 42 2: istore_2 3: aload_1 4: iconst_0 5: aload_0 6: invokevirtual #30 // Method throwExpected:()Lscala/runtime/Nothing$; 9: athrow I found a similar bug in the emission of primitive unboxing and fixed that too.
* Merge pull request #5449 from som-snytt/issue/9953Lukas Rytz2016-11-161-1/+1
|\ | | | | SI-9953 Any Any aborts warn on equals
| * SI-9953 Any Any aborts warn on equalsSom Snytt2016-10-071-1/+1
| | | | | | | | | | | | | | Don't warn about equals if any `Any` is involved. cf SI-8965 The condition for warning is that both types lub to a supertype of Object.
* | Merge pull request #5440 from som-snytt/issue/9944Lukas Rytz2016-11-161-2/+11
|\ \ | | | | | | SI-9944 Scan after interp expr keeps CR
| * | SI-9944 Scan after interp expr keeps CRSom Snytt2016-10-011-2/+11
| | | | | | | | | | | | | | | | | | In an interpolated expression `s"""${ e }"""`, the scanner advances input past the RBRACE. If a multiline string as shown, get the next raw char, because CR is significant.
* | | Merge pull request #5513 from SethTisue/compiler-rootdocLukas Rytz2016-11-161-6/+1
|\ \ \ | | | | | | | | improve top-level compiler/reflect doc text
| * | | improve top-level compiler/reflect doc textSeth Tisue2016-11-081-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | this shows up at http://www.scala-lang.org/api/2.12.0/scala-compiler/ ideally there'd be something better here, but we should at least not link to egregiously outdated stuff
* | | | Merge pull request #5534 from lrytz/t10059Lukas Rytz2016-11-161-1/+1
|\ \ \ \ | | | | | | | | | | SI-10059 reset the `DEFERRED` flag for Java varargs forwarders
| * | | | SI-10059 reset the `DEFERRED` flag for Java varargs forwardersLukas Rytz2016-11-161-1/+1
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an abstract method is annotated `@varargs`, make sure that the generated synthetic Java varargs method does not have the `DEFERRED` flag (`ACC_ABSTRACT` in bytecode). The flag lead to an NPE in the code generator, because the ASM framework leaves certain fields `null` for abstract methods (`localVariables` in this case). Interestingly this did not crash in 2.11.x: the reason is that the test whether to emit a method body or not has changed in the 2.12 backend (in c8e6050). val isAbstractMethod = [..] methSymbol.isDeferred [..] // 2.11 val isAbstractMethod = rhs == EmptyTree // 2.12 So in 2.11, the varargs forwarder method was actually left abstract in bytecode, leading to an `AbstractMethodError: T.m([I)I` at run-time.
* | | | Merge pull request #5384 from som-snytt/issue/9915Seth Tisue2016-11-141-2/+6
|\ \ \ \ | | | | | | | | | | SI-9915 Utf8_info are modified UTF8
| * | | | SI-9915 Utf8_info are modified UTF8Som Snytt2016-10-201-2/+6
| | |_|/ | |/| | | | | | | | | | | | | | | | | | Use DataInputStream.readUTF to read CONSTANT_Utf8_info. This fixes reading embedded null char and supplementary chars.
* | | | Typo and spelling correctionsJanek Bogucki2016-11-115-5/+5
| | | |
* | | | Merge pull request #5460 from som-snytt/issue/6978Jason Zaugg2016-11-101-1/+1
|\ \ \ \ | | | | | | | | | | SI-6978 No linting of Java parens
| * | | | SI-6978 No linting of Java parensSom Snytt2016-10-151-1/+1
| |/ / / | | | | | | | | | | | | | | | | Don't lint overriding of nullary by non-nullary when non-nullary is Java-defined. They can't help it.
* | | | Merge pull request #5486 from som-snytt/issue/6734-synthsJason Zaugg2016-11-101-3/+18
|\ \ \ \ | | | | | | | | | | SI-6734 Synthesize companion near case class
| * | | | SI-6734 CommentSom Snytt2016-10-311-1/+2
| | | | |
| * | | | SI-6734 Synthesize companion near case classSom Snytt2016-10-271-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tweak the "should I synthesize now" test for case modules, so that the tree is inserted in the same tree as the case class.
* | | | | Fix returns from within finalizersLukas Rytz2016-11-093-13/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a return in a finalizer was reached through a return within the try block, the backend ignored the return in the finalizer: try { try { return 1 } finally { return 2 } } finally { println() } This expression should evaluate to 2 (it does in 2.11.8), but in 2.12.0 it the result is 1. The Scala spec is currently incomplete, it does not say that a finalizer should be exectuted if a return occurs within a try block, and it does not specify what happens if also the finally block has a return. So we follow the Java spec, which basically says: if the finally blocks completes abruptly for reason S, then the entire try statement completes abruptly with reason S. An abrupt termination of the try block for a different reason R is discarded. Abrupt completion is basically returning or throwing.
* | | | | SI-10032 Fix code gen with returns in nested try-finally blocksLukas Rytz2016-11-081-7/+38
| |_|/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Return statements within `try` or `catch` blocks need special treatement if there's also a `finally` try { return 1 } finally { println() } For the return, the code generator emits a store to a local and a jump to a "cleanup" version of the finally block. There will be 3 versions of the finally block: - One reached through a handler, if the code in the try block throws; re-throws at the end - A "cleanup" version reached from returns within the try; reads the local and returns the value at the end - One reached for ordinary control flow, if there's no return and no exception within the try If there are multiple enclosing finally blocks, a "cleanup" version is emitted for each of them. The nested ones jump to the enclosing ones, the outermost one reads the local and returns. A global variable `shouldEmitCleanup` stores whether cleanup versions are required for the curren finally blocks. By mistake, this variable was not reset to `false` when emitting a `try-finally` nested within a `finally`: try { try { return 1 } finally { println() } // need cleanup version } finally { // need cleanup version try { println() } finally { println() } // no cleanup version needed! } In this commit we ensure that the variable is reset when emitting nested `try-finally` blocks.
* | | | Merge pull request #5469 from adriaanm/java-scan-tailrecAdriaan Moors2016-11-042-24/+44
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | No StackOverflowError in Java doc comment scanning Fixes SI-10020 SI-10027
| * | | | Factor out some more into ScaladocScannerAdriaan Moors2016-10-191-1/+1
| | | | |
| * | | | DocScanner has doc-comment scanning hooks.Adriaan Moors2016-10-192-22/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Align the Scala and Java doc comment scanning methods a bit. The Scala one especially had gotten a bit messy, with regular block comments being kind of accumulated, but never actually registered as DocComments.
| * | | | Keep `skipBlockComment` tail recursiveAdriaan Moors2016-10-191-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid StackOverflow on big comments. Simplify `ScaladocJavaUnitScanner` while in there. TODO: Do same for `ScaladocUnitScanner`?
* | | | | Merge pull request #5482 from lrytz/sd248-frontendLukas Rytz2016-10-282-136/+135
|\ \ \ \ \ | | | | | | | | | | | | Frontend fixes for scala-dev#248
| * | | | | Address review commentsLukas Rytz2016-10-282-34/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tighten some types (Symbol -> ClassSymbol / ModuleSymbol), use NonFatal instead of catching Throwable. Also don't run the classfile parser enteringPhase(phaseBeforeRefchecks) anymore. This was added in 0ccdb15 but seems no longer required.
| * | | | | For scala classfiles, only parse the scala signature annotationLukas Rytz2016-10-281-24/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Skipping other annotations not only saves some cycles / GC, but also prevents some spurious warnings / errors related to cyclic dependencies when parsing annotation arguments refering to members of the class.
| * | | | | Minor style cleanups, no changes in logicLukas Rytz2016-10-271-4/+4
| | | | | |
| * | | | | Classfile parser and unpickler require class and module symbol argumentsLukas Rytz2016-10-272-30/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In SymbolLoaders, when seeing a classfile `Foo.class`, we always (unconditionally) create 3 symbols: a class, a module and a module class. Some symbols get invalidated later (`.exists`). Until now, the classfile parser (and unpickler) received the "root" symbol as argument, which is the symbol whose type is being completed. This is either the class symbol or the module symbol. The classfile parser would then try to lookup the other symbol through `root.companionClass` or `root.companionModule`. Howver, this lookup can fail. One example is scala-dev#248: when a type alias (in a package object) shadows a class symbol, `companionClass` will fail. The implementations of the classfile parser / unpickler assume that both the `clazz` and the `staticModule` symbols are available. This change makes sure that they are always passed in explicitly. Before this patch, in the example of scala-dev#248, the `classRoot` of the unpickler was NoSymbol. This caused a bug when unpickling the module class symbol, causing a second module class symbol to be created mistakingly. The next commit cleans up this logic, more details there. This second symbol would then cause the crash in the backend because it doesn't have an `associatedFile`, therefore `isCoDefinedWith` would spuriously return `true`.
| * | | | | Clean up cross-check in classfile parser, remove unnecessary assignmentLukas Rytz2016-10-271-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One of the first entries in the classfile is the class name. The classfile parser performs a cross-check by looking up the class sybmol corresponding to that name and ensures it's the same as `clazz`, the class symbol that the parser currently populates. Since 322c980 ("Another massive IDE checkin"), if at the time of the check `clazz` but the lookup returns some class, the `clazz` field is assigned. The commit following this one makes sure `clazz` is never NoSymbol, so the assignment can safely be removed.
| * | | | | Clean up lookup class by name in the classfile parserLukas Rytz2016-10-271-46/+26
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was a piece of logic essentially duplicating getClassByName in Mirrors (split up a fully qualified class name by ".", look up pieces). That piece of code was added in 0ce0ad5 to fix one example in SI-2464. However, since 020053c (2012, 2.10) that code was broken: the line ss = name.subName(0, start) should be ss = name.subName(start, name.length).toTypeName As a result, the code would always create a stub symbol. Returning a stub seems to be the right thing to do anyway, and the fact that we were doing so during two major releases is a good proof.
* | | | | Merge pull request #5276 from som-snytt/issue/9750Seth Tisue2016-10-261-27/+17
|\ \ \ \ \ | |/ / / / |/| | | | SI-9750 scala.util.Properties.isJavaAtLeast works with JDK9
| * | | | SI-9750 Remove isJavaAtLeast from util.StackTracingSom Snytt2016-07-291-27/+17
| | | | | | | | | | | | | | | | | | | | | | | | | Formatting suppressed exceptions required reflection for platform compatibility. No longer, since Java 8 is assumed. Minor tidying.
* | | | | assorted typo fixes, cleanup, updating of commentsSeth Tisue2016-10-244-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | just in time for Halloween. "boostrap" is definitely the most adorable typo evah -- and one of the most common, too. but we don't want to scare anybody.
* | | | | SI-9516 remove now-unneeded codeSeth Tisue2016-10-241-3/+3
| | | | | | | | | | | | | | | | | | | | now that STARR includes the relevant fix
* | | | | Merge pull request #5466 from dragos/issue/remove-println-SI-8717Lukas Rytz2016-10-211-4/+4
|\ \ \ \ \ | | | | | | | | | | | | Replace println with log calls in BrowsingLoaders
| * | | | | Replace println with log calls in BrowsingLoadersIulian Dragos2016-10-191-4/+4
| | |/ / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | This alternative symbol loader is used in the presentation compiler and may generate output even when the compiler should be silent. See SI-8717 for more context, even though this does not really fix the ticket.
* | | | | Merge pull request #5393 from som-snytt/issue/nowarn-thistype-discardLukas Rytz2016-10-213-16/+10
|\ \ \ \ \ | | | | | | | | | | | | No warn when discarding r.f(): r.type
| * | | | | No warn when discarding r.f(): r.typeSom Snytt2016-09-103-16/+10
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The paradigm is `def add(x: X): Unit = listBuffer += x`. The value that is discarded is not new information. Also cleans up the recent tweaks to help messaging. Adds newlines in case they ask for multiple helps.
* | | | | Merge pull request #5439 from som-snytt/issue/fields-fieldwidthSeth Tisue2016-10-201-7/+7
|\ \ \ \ \ | | | | | | | | | | | | Shorten fields phase description
| * | | | | Don't clip descrip when -YdebugSom Snytt2016-09-301-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -Ydebug is supposed to show everything about the phases, including full description (if otherwise clipped) and any phases that are not "enabled" by options.
| * | | | | Shorten fields phase descriptionSom Snytt2016-09-301-1/+1
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Makes fields fit the field width, which is fitting. `s/including/add` seems sufficient. Possibly, "synthesize" is an extravagance for "add", but "add" is used previously in that column. Resolve, load, translate, add, synthesize, replace, erase, move, eliminate, remove, generate. Would love to learn a word that says what typer does, if the word "type" is too redundant or overloaded, besides the food metaphor. Also "meat-and-potatoes" implies basic, simple, not fussy or fancy. There are many devices, like the heart or a Ferrari engine, that are fundamental without being unfussy.
* | | | | Merge 2.11.x into 2.12.xAdriaan Moors2016-10-181-5/+13
|\ \ \ \ \ | |_|/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix conflict in #5453: ``` - def help: String = { + override def help: String = { ```
| * | | | Merge pull request #5453 from som-snytt/issue/9832-2.11Adriaan Moors2016-10-181-5/+13
| |\ \ \ \ | | | | | | | | | | | | SI-9832 -Xlint:help shows default
| | * | | | SI-9832 -Xlint:help shows defaultSom Snytt2016-10-111-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conclude help method with the default list. Extra words are supplied for underscore.
| * | | | | Merge pull request #5345 from milessabin/topic/si-7046-backportAdriaan Moors2016-10-184-11/+48
| |\ \ \ \ \ | | | | | | | | | | | | | | [nomerge] Partial fix for SI-7046
| | * | | | | Partial fix for SI-7046Miles Sabin2016-08-154-11/+48
| | |/ / / /
| * | | | | Merge pull request #5341 from milessabin/topci/si-9760-backportAdriaan Moors2016-10-181-1/+0
| |\ \ \ \ \ | | | | | | | | | | | | | | SI-9760 Fix for higher-kinded GADT refinement
| | * | | | | SI-9760 Fix for higher-kinded GADT refinementMiles Sabin2016-08-151-1/+0
| | |/ / / /
| * | | | | Merge pull request #5218 from retronym/ticket/9806Jason Zaugg2016-10-181-2/+2
| |\ \ \ \ \ | | |/ / / / | |/| | | | SI-9806 Fix incorrect codegen with optimizer, constants, try/catch
| | * | | | SI-9806 Fix incorrect codegen with optimizer, constants, try/catchJason Zaugg2016-06-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The constant optimizer phase performs abstract interpretation of the icode representation of the progam in order to eliminate dead code. For each basic block, the possible and impossible states of each local variable is computed for both a normal and an exceptional exit. A bug in this code incorrectly tracked state for exception exits. This appears to have been an oversight: the new state was computed at each instruction, but it was discarded rather than folded through the intepreter.