summaryrefslogtreecommitdiff
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* SI-8369 resetAttrs now correctly accounts for skolemsEugene Burmako2014-03-071-1/+2
| | | | | resetAttrs (née resetLocalAttrs) has been oblivious to existence of skolems. Not anymore, which prevents us from reverting to the untyper nightmare.
* Merge pull request #3592 from densh/si/8281Eugene Burmako2014-03-031-1/+2
|\ | | | | SI-8281 check for unbound placeholder parameters in quasiquote parser
| * SI-8281 check for unbound placeholder parameters in quasiquote parserDenys Shabalin2014-02-281-1/+2
| |
* | SI-8332 implicit class param unquoting in quasiquotesDenys Shabalin2014-03-021-9/+14
| | | | | | | | | | | | A new api that simplifies handling of implicit parameters has been mistakingly supporting just methods parameters. This commit adds support for class parameters too.
* | Merge pull request #3596 from densh/si/8333Eugene Burmako2014-03-012-4/+6
|\ \ | | | | | | SI-8333 can't use modifiers if class is in a block
| * | SI-8333 can't use modifiers if class is in a blockDenys Shabalin2014-02-282-4/+6
| |/ | | | | | | | | | | Was caused by the ordering of parser cases. Need to check for definition first due to the fact that modifiers unquote looks like identifier from parser point of view.
* | Merge pull request #3593 from densh/si/8285Eugene Burmako2014-03-012-9/+7
|\ \ | | | | | | SI-8285 use correct kind of map for quasiquote positions
| * | SI-8285 use correct kind of map for quasiquote positionsDenys Shabalin2014-02-282-9/+7
| |/ | | | | | | | | | | | | Previously mutable.ListMap was used with assumption that it preserved order of inserted elements (but it doesn't). Surprisingly logic that assumed ordered elements worked mosly fine on unordered ones. I guess two bugs can cancel each other out.
* | Fix block construction/deconstruction asymmetryDenys Shabalin2014-02-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Deconstruction of blocks in case clauses uncovered asymmetry between construction and deconstruction of blocks: tree match { case cq"$pat => ..$cases" => cq"$pat => ..$cases" } Such an identity-like transformation used to produce an incorrect tree due to the fact that zero-element block was mistakingly associated with empty tree. Such association was used as a solution to block flatenning: val ab = q"a; b" q"..$ab; c" // ==> q"a; b; c" val a = q"a" q"..$a; c" // ==> q"a; c" val empty = q"" q"..$empty; c" // ==> q"c" This commit changes meaning of zero-element block to a be a synthetic unit instead. This is consistent with parsing of `{}`, cases, ifs and non-abstract empty-bodied methods. A local tweak to block flattenning is used to flatten empty tree as empty list instead.
* | SI-8275 allow to directly extract block contents of the case defDenys Shabalin2014-02-281-0/+2
|/ | | | | Due to the fact that blocks in cases are implicit one might expect to be able to extract its contents with `..$`.
* Selectively revert "SI-8315 Better debugging facility for ICode"Adriaan Moors2014-02-261-2/+4
| | | | | | This reverts commit 0561dd084b5f3c2678eb032a40b85cb25bb6d589, because appending the phase name to the icode filename breaks the windows build. Only doing it under -Ydebug.
* Merge pull request #3583 from adriaanm/t8197Adriaan Moors2014-02-252-15/+48
|\ | | | | SI-8197 clarify overloading resolution with default args
| * SI-8197 clarify overloading resolution with default argsAdriaan Moors2014-02-252-15/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit was co-authored with Lukas. His analysis is below. If there are multiple applicable alternatives, drop those that use default arguments. This is done indirectly by checking applicability based on arity. TODO: this `namesMatch` business is not spec'ed, and is the wrong fix for SI-4592. We should instead clarify what the spec means by "typing each argument with an undefined expected type". What does typing a named argument entail when we don't know what the valid parameter names are? (Since we're doing overload resolution, there are multiple alternatives that can define different names.) Luckily, the next step checks applicability to the individual alternatives, so it knows whether an assignment is: - a valid named argument - a well-typed assignment (which doesn't necessarily have type `Unit`!) - an error (e.g., rhs does not refer to a variable) I propose the following solution (as a TODO): check whether a named argument (when typing it in `doTypedApply`) could be interpreted as an assign; `infer.checkNames` should use the type of the well-typed assignment instead of `Unit`. Lukas's analysis: 990fa04 misunderstood the spec of overloading resolution with defaults. it should not discard applicable alternatives that define defaults, but only those that use defaults in the given invocation. bugs were shadowed because the refactoring used `alt.hasDefault` to check whether the alternative has some parameters with defaults, but this never worked. d5bb19f fixed that part by checking the flags of parameters, which fixed some but but un-shadowed others: ``` object t { def f(x: String = "") = 1; def f(x: Object) = 2 } scala> t.f("") // should return 1, but returns 2 after d5bb19f ``` The commit message of d5bb19f also mentions that its test "should fail to compile according to SI-4728", which is another misunderstanding. ``` class A; class B extends A object t { def f(x: A = null) = 1; def f(x: B*) = 2 } t.f() ``` This should return `2`: both alternatives are applicable, so the one that uses a default is eliminated, and we're left with the vararg one. SI-4728 is different in that it uses explicit parameters, `t.f(new B)` is ambiguous.
* | Merge pull request #3566 from adriaanm/t6455Grzegorz Kossakowski2014-02-251-1/+1
|\ \ | |/ |/| SI-6455 no longer rewrite .withFilter to .filter
| * SI-6455 under -Xfuture, don't rewrite .withFilter to .filterAdriaan Moors2014-02-241-1/+1
| | | | | | | | | | This has been deprecated for two major releases now, but `filter`'s still preferred over `withFilter` in the wild.
* | SI-8330: Mismatch in stack heightsGrzegorz Kossakowski2014-02-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | The SI-8233 / 9506d52 missed one case when we need to DROP a null from a stack: when unboxed Unit is an expected type. If we forgot to do that in a context where two branches were involved we could end up with unbalanced stack sizes. Let's fix that omission and a test covering that specific case to the original test for SI-8233. Fixes SI-8330.
* | Merge pull request #3559 from adriaanm/t1503Grzegorz Kossakowski2014-02-233-4/+55
|\ \ | | | | | | SI-1503 don't assume unsound type for ident/literal patterns
| * | SI-1503 don't assume unsound type for ident/literal patternsAdriaan Moors2014-02-193-4/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fix only kicks in under -Xfuture. We also warn under -Xlint. What type should a variable bound to the value matched by a pattern have? To avoid CCEs, it should be a type that's implied by the matching semantics of the pattern. Usually, the type implied by a pattern matching a certain value is the pattern's type, because pattern matching implies instance-of checks. However, Stable Identifier and Literal patterns are matched using `==`, which does not imply a type for the binder that binds the matched value. The change in type checking due to this fix is that programs that used to crash with a CCE (because we blindly cast to the type of the pattern, which a `==` check does not imply) now get a weaker type instead (and no cast). They may still type check, or they may not. To compensate for this fix, change `case x@Foo => x` to `case x: Foo.type => x`, if it's important that `x` have type `Foo.type`. See also: - SI-4577: matching of singleton type patterns uses `eq`, not `==` (so that the types are not a lie). - SI-5024: patmat strips unused bindings, but affects semantics
* | | Merge pull request #3571 from xeno-by/ticket/8321Adriaan Moors2014-02-233-16/+5
|\ \ \ | | | | | | | | SI-8321 bundles can't be whitebox
| * | | more clean up in the macro engineEugene Burmako2014-02-211-14/+3
| | | | | | | | | | | | | | | | | | | | Now when SI-7507 is fixed in starr, we can actually remove a workaround and make a 10 line reduction in the size of Resolvers.scala.
| * | | prohibits polymorphic bundlesEugene Burmako2014-02-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | It's not like they were inducing bugs, but I can't see how polymorphism can be useful for macro bundles, hence imho it's better to reduce the number of degrees of freedom of the system.
| * | | minor code cleanup in the macro engineEugene Burmako2014-02-212-3/+3
| | | |
* | | | Merge pull request #3574 from greenrd/SI-7962Adriaan Moors2014-02-231-3/+2
|\ \ \ \ | | | | | | | | | | SI-7962 Scalac runner does not work within Emacs's terminal
| * | | | SI-7962 Scalac runner does not work within Emacs's terminalRobin Green2014-02-221-3/+2
| |/ / / | | | | | | | | | | | | | | | | | | | | - Always set the env.emacs system property - scalac only cares about whether the system property has a non-empty value, not whether it is set or not. Fixes 7962
* | | | Merge pull request #3573 from retronym/ticket/8324Grzegorz Kossakowski2014-02-225-12/+12
|\ \ \ \ | | | | | | | | | | SI-8324 Fix regression in override checks for sealed classes
| * | | | SI-8324 Fix regression in override checks for sealed classesJason Zaugg2014-02-225-12/+12
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | adeffda25 changed `Symbol#isEffectivelyFinal` to help the optimizer by inferring finality within sealed class hierarchies. However, this change wasn't neccesarily welcome for other clients of that method. In the enclosed test case, we see that overriding checks in `RefChecks` regressed. This commit moves the enhanced version into a new method and selectively uses it in the optimizer (and the tail call optimizer).
* | | | Merge pull request #3572 from retronym/ticket/8197Adriaan Moors2014-02-221-1/+2
|\ \ \ \ | | | | | | | | | | SI-8197 Only consider immediate params for defaults, overloading
| * | | | SI-8197 Only consider immediate params for defaults, overloadingJason Zaugg2014-02-221-1/+2
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A recent commit fixed the behaviour of overloading with regards to discarding candiates that include default arguments. The old check was checking the wrong flag. But, the new code is actually checking all parameter lists for defaults, which led to a regression in scala-io, which is distilled in the enclosed test case. Applications are typechecked one parameter list at a time, so a holistic check for defaults doesn't seem to make sense; only defaults in the first parameter list ought to count.
* | | | Merge pull request #3567 from retronym/ticket/8315Jason Zaugg2014-02-222-3/+3
|\ \ \ \ | |/ / / |/| | | SI-8315 Fix crash in dead code elimination
| * | | SI-8315 Fix crash in dead code eliminationJason Zaugg2014-02-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It was a cache invalidation bug. We need to mark the Code as touched to invalidate the caches behind `predecessors` and `successors`.
| * | | SI-8315 Better debugging facility for ICodeJason Zaugg2014-02-201-3/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Suffix the phase name to avoid clobbering files. % qbin/scalac -Xprint-icode -Xprint:inline -Yinline -Ydead-code sandbox/test.scala 1>/dev/null 2>/dev/null % ls *.icode A$$anonfun$crash$1_icode.icode Listt_icode.icode A$$anonfun$crash$1_inliner.icode Listt_inliner.icode A_icode.icode Nill$_icode.icode A_inliner.icode Nill$_inliner.icode
* | | Merge pull request #3562 from adriaanm/t8197Jason Zaugg2014-02-211-1/+1
|\ \ \ | | | | | | | | SI-8197 Overload resolution should not consider default arguments
| * | | SI-8197 Overload resolution should not consider default argumentsAdriaan Moors2014-02-191-1/+1
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The spec says > Let B be the set of alternatives in A that are applicable (§6.6) > [...] It is an error if none of the members in B is applicable. If > there is one single applicable alternative, that alternative is > chosen. Otherwise, let C be the set of applicable alternatives which > don’t employ any default argument in the application to e1, ..., em. > It is again an error if C is empty. Otherwise, one chooses the most > specific alternative among the alternatives in C [...]. There are many ways to interpret this, but none of them involves excluding default getters, which is what the old code was doing. We now exclude all alternatives that define any default arguments. NOTE: according to SI-4728, this should fail to compile with an ambiguity error. The compiler has been accepting this program for all of 2.10.x, as far as I can tell, so let's not change that for 2.11.0-RC1...
* | | Merge pull request #3555 from adriaanm/rebase-3553Jason Zaugg2014-02-211-1/+1
|\ \ \ | | | | | | | | Small Predef cleanup
| * | | SI-7788 Avoid accidental shadowing of Predef.conformsAdriaan Moors2014-02-181-1/+1
| | |/ | |/| | | | | | | | | | | | | | | | Rename `conforms` to `$conforms` and put in a minimal backstop: pos/t7788.scala TODO: predicate the backwards compatibility shim for `Predef_conforms` on `-Xsource:2.10`
* | | Merge pull request #3558 from adriaanm/t4577Jason Zaugg2014-02-212-3/+3
|\ \ \ | | | | | | | | SI-4577 singleton type pattern test should use `eq`, not `==`
| * | | SI-4577 singleton type pattern test should use `eq`, not `==`Adriaan Moors2014-02-182-3/+3
| |/ / | | | | | | | | | | | | | | | I find it hard to imagine anyone is relying on `case x: foo.type =>` erroneously being compiled to `foo == x` instead of the spec'ed `foo eq x`, so let's finally fix this.
* | | Merge pull request #3564 from adriaanm/t6675Jason Zaugg2014-02-211-2/+2
|\ \ \ | | | | | | | | SI-6675 deprecation warning for auto-tupling in patterns
| * | | SI-6675 deprecation warning for auto-tupling in patternsAdriaan Moors2014-02-191-2/+2
| | |/ | |/| | | | | | | | | | NOTE: when the deprecation warning becomes an error, SI-6111 must become a `won't fix`
* | | Merge pull request #3569 from xeno-by/ticket/8316Jason Zaugg2014-02-203-5/+23
|\ \ \ | | | | | | | | SI-8316 SI-8318 SI-8248 reintroduces resetAllAttrs
| * | | SI-8316 SI-8318 SI-8248 reintroduces resetAllAttrsEugene Burmako2014-02-203-5/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unfortunately, due to the aforementioned bugs we have to delay our triumph over resetAllAttrs. Therefore, I'm rolling back the internal changes to scalac introduced in https://github.com/scala/scala/pull/3485. Our public reflection API interface in Scala 2.11 is still going to contain only resetLocalAttrs, but both the reifier and the label typechecker are too heavily addicted to resetAllAttrs to do away with it right now.
* | | | Merge pull request #3568 from densh/topic/qq-terminologyEugene Burmako2014-02-204-80/+80
|\ \ \ \ | |_|/ / |/| | | Fix quasiquote terminology to be consistent with Scheme
| * | | Fix quasiquote terminology to be consistent with SchemeDenys Shabalin2014-02-204-80/+80
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Rename cardinality into rank. Shorter word, easier to understand, more appropriate in our context. 2. Previously we called any dollar substitution splicing but this is not consistent with Scheme where splicing is substitution with non-zero rank. So now $foo is unquoting and ..$foo and ...$foo is unquote splicing or just splicing. Correspondingly splicee becomes unquotee. 3. Rename si7980 test into t7980
* / / SI-8306: handle SWITCH nodes with just default caseGrzegorz Kossakowski2014-02-191-1/+4
|/ / | | | | | | | | | | | | | | | | | | | | | | Handle properly SWITCH nodes that contain just a default case in optimizer (ConstantOptimization). SWITCH with just default case is expressed as a node with empty tags and exactly one label. We can handle such nodes easily by introducing a shortcut in logic that computes reachableLabels. Add a test case which triggers patmat to generate SWITCH node with just a default case. Fixes SI-8306.
* | Merge pull request #3452 from xeno-by/topic/palladium0Jason Zaugg2014-02-1943-200/+288
|\ \ | |/ |/| SI-8063 and its seventy friends
| * reverses SI-6484Eugene Burmako2014-02-181-24/+2
| | | | | | | | | | Unfortunately I have to revert b017629 because of SI-8303. There are projects (e.g. slick) that use typeOf in annotations, which effectively means bye-bye.
| * Merge remote-tracking branch 'origin/master' into topic/palladium0Eugene Burmako2014-02-174-85/+58
| |\
| * \ Merge remote-tracking branch 'origin/master' into topic/palladium0Eugene Burmako2014-02-1624-752/+807
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/compiler/scala/reflect/macros/compiler/Resolvers.scala src/compiler/scala/reflect/macros/contexts/Typers.scala src/compiler/scala/tools/reflect/ToolBoxFactory.scala src/reflect/scala/reflect/api/BuildUtils.scala
| * | | fixes compat for tree and type extractorsEugene Burmako2014-02-152-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When I removed XXXDef(...) and XXXType(...) methods from the public API, I put compatibility stubs in compat via implicit classes enriching XXXExtractor traits with apply methods. Unfortunately, this doesn't work, because if XXXDef or XXXType have any kind of an apply method left in the public API, then implicit classes won't even be considered when resolving calls to XXXDef(...) or XXXType(...). Therefore I had to put those removed methods back and adorn them with an implicit parameter that can only be resolved when "import compat._" is in place. Quite extravagant, yes, but goes along the lines with the design goals of the refactoring, which are: 1) Break source compatibility for users who are using methods that are now moved to internal in order to attract attention. 2) Provide an easy way to fix the breakage by importing compat._, which will pimp back all the missing APIs with deprecation warnings that are going to guide migration.
| * | | upgrades typingTransformEugene Burmako2014-02-151-0/+6
| | | | | | | | | | | | | | | | | | | | typingTransform and typingTransform's atOwner now work both with solitary trees and Tree+Symbol couples.