summaryrefslogtreecommitdiff
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | | | Merge pull request #3169 from som-snytt/issue/4841-plugin-cpJason Zaugg2013-12-123-52/+77
|\ \ \ \ \ \ \ | |_|_|_|/ / / |/| | | | | | Plugins get a class path
| * | | | | | SI-4841 Plugins get a class pathSom Snytt2013-12-063-52/+77
| | |_|_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let -Xplugin specify a class path (or multiple of them). Each entry can be a jar or dir, and the first entry to supply a plugin descriptor defines the plugin to load. If no plugin is found on the path, then issue a warning if `-Xdev`. This honors the legacy silent treatment (which scala-ide tests for). In the proposed scheme, each plugin gets a class loader so that plugins are isolated from each other. Presumably, if compiler plugins were a rich ecosystem, in which shared dependencies were required in incompatible versions, this would have become a requirement by now. (Updated with a `DirectTest` that uses two plugins, but keeping the following as documentation.) Partest can't do multiple plugins yet, but this is what it looks like: ``` skalac -Xplugin:sample.jar:useful.jar:util,needful.jar:another.jar:util,needful.jar:util:exploded -Xplugin-require:sample,another,other foo.scala skalac -Xplugin:sample.jar:useful.jar:util,needful.jar:another.jar:util,needful.jar:util:exploded -Xplugin-require:sample,other -Xplugin-disable:another foo.scala skalac -Xplugin:sample.jar:useful.jar:util,sample.jar:useful.jar:util -Xplugin-require:sample foo.scala ``` The manual test shows three plugins with various permutations of jars and dirs. The manual test demonstrates that plugins only see classes on their class path: ``` Initializing test.plugins.SamplePlugin needful.Needful? Failure(java.lang.ClassNotFoundException: needful.Needful) useful.Useful? Success(class useful.Useful) Initializing more.plugins.AnotherPlugin needful.Needful? Success(class needful.Needful) useful.Useful? Failure(java.lang.ClassNotFoundException: useful.Useful) Initializing other.plugins.OtherPlugin ``` Disabling a plugin results in a message instead of silent suppression: ``` Disabling plugin another ``` The duplicate plugin class test must still be honored: ``` Ignoring duplicate plugin sample (test.plugins.SamplePlugin) Initializing test.plugins.SamplePlugin needful.Needful? Failure(java.lang.ClassNotFoundException: needful.Needful) useful.Useful? Success(class useful.Useful) ``` If the path is bad, then missing classes will report which plugin induced the error: ``` Error: class not found: util/Probe required by test.plugins.SamplePlugin Error: class not found: util/Probe required by more.plugins.AnotherPlugin Initializing other.plugins.OtherPlugin needful.Needful? Success(class needful.Needful) useful.Useful? Failure(java.lang.ClassNotFoundException: useful.Useful) error: Missing required plugin: sample error: Missing required plugin: another two errors found ```
* | | | | | Address minor pull request feedback pointsDen Shabalin2013-12-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Use (x1, x2): (T1, T2) instead of (x1: T1, x2: T2) 2. More detailed error message for improper function argument 3. Fix typo 4. Completely remove LiftableClass symbol from definitions
* | | | | | Introduce support for Unliftable for QuasiquotesDen Shabalin2013-12-102-6/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unliftable is a type class similar to existing Liftable that lets users to extract custom data types out of trees with the help of straightforward type ascription syntax: val q“foo.bar(${baz: Baz})” = ... This will use Unliftable[Baz] to extract custom data type Baz out of a tree nested inside of the another tree. A simpler example would be extracting of constant values: val q”${x: Int} + ${y: Int}” = q”1 + 2”
* | | | | | Refactor Holes and Reifiers slices of Quasiquotes cakeDen Shabalin2013-12-103-239/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit performs a number of preliminary refactoring needed to implement unliftable: 1. Replace previous inheritance-heavy implementation of Holes with similar but much simpler one. Holes are now split into two different categories: ApplyHole and UnapplyHole which correspondingly represent information about holes in construction and deconstruction quasiquotes. 2. Make Placeholders extract holes rather than their field values. This is required to be able to get additional mode-specific information from holes (e.g. only ApplyHoles have types). 3. Bring ApplyReifier & UnapplyReifier even closer to the future where there is just a single base Reifier with mode parameter. Along the way a few bugs were fixed: 1. SI-7980 SI-7996 fail with nice error on bottom types splices 2. Use asSeenFrom instead of typeArguments in parseCardinality. This fixes a crash if T <:< Iterable[Tree] but does not itself have any type arguments. 3. Fix spurious error message on splicing of Lists through Liftable[List[T]]
* | | | | | Provide a way for unapply macro to obtain a list of subpattensDen Shabalin2013-12-101-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces internal attachment that allows unapply macros to be aware of their sub patterns and tweak their expansion depending on that info. At the moment this is not possible due to the way pattern macros are expanded: case MacroPat(inner1, inner2) => ... During type checking this will expand as MacroPat.unapply(<unapply-dummy>) Meaning that macro can’t see inner1 and inner2 in it’s macroApplication. To circumvent this we attach that info as an attachment to the dummy.
* | | | | | Move Liftable into the Universe cake; add additional standard LiftablesDen Shabalin2013-12-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we believed that having Liftable outside of the Universe will bring some advantages but it turned out this wasn’t worth it. Due to infectious nature of path dependent types inside of the universe one had to cast a lot. A nice example of what I’m talking about is a change in trait ArbitraryTreesAndNames. Additionally a number of standard Liftables is added for types that are available through Predef and/or default scala._ import: Array, Vector, List, Map, Set, Option, Either, TupleN.
* | | | | | SI-6842 Make splicing less sensitive to precise types of treesDen Shabalin2013-12-101-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously trees that represent parameters, case clauses and type variables had strictly defined ValDef, TypeDef and CaseDef types which caused problems in compositionality. Now this checks are moved to runtime so it's possible to pass a tree that is CaseDef but has Tree type.
* | | | | | SI-8009 Ensure that Idents preserve isBackquoted propertyDen Shabalin2013-12-101-0/+2
| | | | | |
* | | | | | SI-8016 Ensure that q”..$xs” is equivalent to q”{..$xs}”Den Shabalin2013-12-102-1/+10
| | | | | |
* | | | | | SI-8008 Make q”f(..$xs)” only match trees with Apply nodeDen Shabalin2013-12-101-3/+0
| |/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously it also matched other nodes but returned Nil as value of xs. This behavior was added for sake of consistentcy with q”f[..$ts]”. On the other hand q”f[..$Nil]” == q”f” but q”f(..$Nil)” == q”f()” not q”f”. Due to this deconstruction/construction symmetry was broken. On the other hand applications also have q"f(...$xss)" option which is infact similar to q"f[..$ts]". Splicing Nil into it also results in q"f".
* | | | | Merge pull request #3246 from xeno-by/topic/compile-time-onlyJason Zaugg2013-12-101-28/+16
|\ \ \ \ \ | | | | | | | | | | | | streamlines refchecking undesired symbol properties
| * | | | | streamlines refchecking undesired symbol propertiesEugene Burmako2013-12-091-28/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unifies `checkDeprecated`, `checkMigration` and `checkCompileTimeOnly` into a single centralized point of reference that is now consistently called from `checkTypeRef`, `transformIdent` and `transformSelect`.
* | | | | | deprecates macro def return type inferenceEugene Burmako2013-12-103-4/+24
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the new focus on quasiquotes in macro implementations, we now have to change the way how inference of macro def return types works. Previously, if the return type of a macro def wasn’t specified, we looked into the signature of its macro impl, took its return type (which could only be c.Expr[T]) and then assigned T to be the return type of the macro def. We also had a convenient special case which inferred Any in case when the body of the macro impl wasn’t an expr. That avoided reporting spurious errors if the macro impl had its body typed incorrectly (because in that case we would report a def/impl signature mismatch anyway) and also provided a convenience by letting macro impls end with `???`. However now we also allow macro impls to return c.Tree, which means that we are no longer able to do any meaningful type inference, because c.Tree could correspond to tree of any type. Unfortunately, when coupled with the type inference special case described above, this means that the users who migrate from exprs to quasiquotes are going to face an unpleasant surprise. If they haven’t provided explicit return types for their macro defs, those types are going to be silently inferred as `Any`! This commit plugs this loophole by prohibiting type inference from non-expr return types of macro impls (not counting Nothing). Moreover, it also deprecates c.Expr[T] => T inference in order to avoid confusion when switching between exprs and quasiquotes.
* | | | | Merge pull request #3225 from som-snytt/issue/8013-interp-nowarnAdriaan Moors2013-12-081-6/+15
|\ \ \ \ \ | |/ / / / |/| | | | SI-8013 Nowarn on macro str interpolation
| * | | | SI-8013 Nowarn on macro str interpolationSom Snytt2013-12-041-6/+15
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When warning about stray "foo $bar" under `-Xlint`, which may be missing an interpolator id, suppress the warning if we're in the middle of a macro expansion, since we have no useful heuristic to apply to the expanded tree. The test for whether the string is part of an expanded tree is to check all open macros for an expanded tree that contains the literal tree under scrutiny. (This is deemed more paranoid than looking for a macro application that is an enclosing position.)
* | | | Merge pull request #3216 from xeno-by/topic/macro-error-messagesAdriaan Moors2013-12-032-10/+26
|\ \ \ \ | | | | | | | | | | better error messages for various macro definition errors
| * | | | better error messages for various macro definition errorsEugene Burmako2013-12-032-10/+26
| |/ / /
* | | | Merge pull request #3202 from retronym/topic/function1-tuplenAdriaan Moors2013-12-035-8/+51
|\ \ \ \ | | | | | | | | | | Diminished Tuple Confusion
| * | | | Better error messages for common Function/Tuple mistakesJason Zaugg2013-12-015-8/+51
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Firstly, for `((a, b) => c): (Tuple2[A, B] => C)`, we currently just offer "missing parameter type." Is something of a rite of passage to know that you need `{ case (...)}` This commit stops short DWIM, but does offer a diagnostic to guide the user towards the supported way of destructuring a `Tuple` in the sole argument of a `Function1`. Secondly, another (less common?) way one might try to write a function to destructure a single tuple argument is: (((a, b)) => c) The parser now matches offers a specific error message for this, and points out the alternatives. In both cases, we avoid offering syntactically invalid alternatives, by detecting names that aren't valid as variable-patterns, and falling back to generic "paramN" in the error message. A handly utility function to sequence a list of options is liberated from the pattern matcher for broader use.
* | | | SI-8023 Address review comments around typedHigherKindedTypeJason Zaugg2013-12-031-18/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Make `WildCardType` kind polymorphic - Factory methods for expected kinds. They are still just `Type`-s, though. - Check if the type parameter is initialized, rather than its owner. - Take advantage of these to cleanup `typedAppliedTypeTree` TODO: is this comment totally accurate? If so, should we refactor `Kind.FromParams(tparams)` to `Kind.Arity(tparams.length)`? // @M: kind-arity checking is done here and in adapt, // full kind-checking is in checkKindBounds (in Infer)
* | | | SI-8023 Fix symbol-completion-order type var pattern bugJason Zaugg2013-12-021-7/+15
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removing the `isComplete` check altogether leads to cycles in, for instatnce, F-bound type parameters: trait LSO[+A, +Repr <: LSO[A, Repr]] // error: illegal cyclic reference involving type Repr But, I believe that we can (and must) eagerly initialize the type parameter symbols if we are typechecking a pattern. While this appeared to regress in 2.11.x, but the problem was in fact dormant and was merely uncovered in the fix for SI-7756, 3df1d77fc.
* | | Merge pull request #3197 from retronym/merge/2.10.x-positions-to-masterJason Zaugg2013-11-261-4/+14
|\ \ \ | | | | | | | | Merge 2.10.x, and PR #3196, to master
| * | | Merge remote-tracking branch 'origin/pr/3196' into ↵Jason Zaugg2013-11-261-4/+14
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | merge/2.10.x-positions-to-master Conflicts: src/compiler/scala/tools/nsc/typechecker/Typers.scala test/files/neg/applydynamic_sip.check - Changes two calls from `.endOrPoint` to `.point`. The latter is safe in master for both `Range`- and `OffsetPosition`s - Updates checkfiles with unrelated position changes (constructors)
| | * | SI-8005 Fixes NoPositon error for updateDynamic callsSimon Schaefer2013-11-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously there occurred a NoPosition error when one asks for position information in the AST because no positions were set to the trees created during the transformation for updateDynamic calls. This commit applies range positions to the trees in order to being able to highlight them inside of the scala-ide.
| | * | SI-8004 Resolve NoPosition error for applyDynamicNamed method callSimon Schaefer2013-11-261-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, there were no positions created for the tuples that are generated while doing the transformation for an applyDynamicNamed call. This led to an NoPosition error in scalac when one tries to show position information in the AST. Furthermore, this simplifies semantic highlighting in the scala-ide because no position information for color ranges have to be created anymore.
| | * | SI-7463,SI-8003 Correct wrong position for {select,apply}Dynamic callsSimon Schaefer2013-11-261-1/+4
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new positions are range positions that directly refer to the beginning and the end of the method calls in the sources instead of simply point to the beginning of the expression. This allows the scala-ide to semantically highlight select- and applyDynamic method calls, because it has only to traverse the tree and apply the color ranges to the given position ranges. This also fixes the position marker of an error messages related to a wrong Dynamic method signature.
| | * Merge pull request #3166 from skyluc/issue/completion-import-object-7280-210Jason Zaugg2013-11-225-37/+100
| | |\ | | | | | | | | Backport of
| | | * [nomaster] SI-7280 Scope completion not returning members provided by importsLuc Bourlier2013-11-211-25/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Updates localeContext() to return the best context possible when there are none directly associated with the given position. It happens when an expression cannot be successfully typed, as no precise ContextTree covers the expression location, or if the position is not inside any expression. Adds corresponding tests (cherry picked from commit 3028327e2a2b553b12ee45519413515c8aa0865f)
| | | * [nomaster] Test infrastructure for scope completionJason Zaugg2013-11-214-12/+60
| | | | | | | | | | | | | | | | | | | | | | | | Adds a new marker /*_*/ to trigger scope completion test. Original type completion test oracles update for the tweaked output (cherry picked from commit 9c7c66ff7907e3ab814f0f4375eeaf6cdd230d5e)
| | * | SI-7915 Corrected range positions created during default args expansionMirco Dotta2013-11-191-3/+6
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tree created during expansion of default arguments contained trees with the wrong type of positions. Let's discuss this with an example. Below is the tree generated for the `foo` method in the test class included in this commit. Before this commit: ``` [54:94]def foo(): [58]Unit = <70:90>{ [70:79]<artifact> val qual$1: [70]Bar = [70:79][70:79][70:79]new [74:77]Bar(); [80]<artifact> val x$1: [80]Int = [80]qual$1.bar$default$1; <70:90><70:83>qual$1.bar([80]x$1) } ``` Now: ``` [54:99]def foo(): [58]Unit = <70:95>{ <70:84><artifact> val qual$1: [70]Bar = [70:84][70:84][70:84]new [74:77]Bar(); [85]<artifact> val x$1: [85]Int = [85]qual$1.bar$default$1; <70:95>[84:88]qual$1.bar([85]x$1) } ``` Here are the list of changes: * The synthetic `qual$1` has a transparent position, instead of a range position. * The new Select tree (i.e., `qual$1.bar`) should always have a range position, because `selected` (i.e., the called method) is always visible in the source (in fact, this is the whole point of the fix, we need a range position or hyperlinking request from the Scala IDE won't work). * The Block that contains the expanded default arguments is forced to have a transparent position, as it never exist in the original source. The tricky part of the fix is the position assigned to the new Select tree, which needs to respect the range position's invariants. In the specific case, we ought to make sure that range positions don't overlap. Therefore, the position assigned to the new Select tree is computed by intersecting the original Select position (i.e., `baseFun`'s position) and the original qualifier's position (i.e., `qual`'s position). If you take a closer look at the range positions assigned in the tree after this commit, you'll notice that the range position of the `qual$1`'s rhs (i.e., [70:84]), and `qual$1.bar` (i.e., [84:88]) might seem to overlap, because the former ends where the latter begins. However, this not the case because of the range position's invariant 2, which states: > Invariant 2: in a range position, start <= point < end Hence, the above two positions aren't overlapping as far as the compiler is concerned. One additional aspect (that may look like a detail) is that we make sure to never generate a position such that its start is after its end. This is why we take the position with the smallest end point. Furthermore, calling `withStart` would turn any position in a range position, which isn't desiderable in general (and, even worse, this can lead to generation of invalid positions - bad offsets - if the computation is performed on offset positions). Hence, the position's computation is only performed when both `baseFun` and `qual` positions are range positions. Indeed, I expect this to be always the case if the compiler is started with -Yrangepos. (cherry picked from commit 3009a525b58a4c7865ff524899b85518884ee5f7)
| | * Merge pull request #3110 from xeno-by/topic/7776-backportEugene Burmako2013-11-081-2/+6
| | |\ | | | | | | | | [backport] SI-7776 post-erasure signature clashes are now macro-aware
| | | * [backport] SI-7776 post-erasure signature clashes are now macro-awareEugene Burmako2013-11-081-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | "double definition: macro this and method that have same type after erasure" This error doesn't make sense when macros are involved, because macros expand at compile-time, where we're not affected by erasure. Moreover, macros produce no bytecode, which means that we're safe from VerifyErrors.
| | * | Merge pull request #3105 from retronym/ticket/completionGrzegorz Kossakowski2013-11-081-2/+7
| | |\ \ | | | |/ | | |/| Fix completion after application with implicit arguments
| | | * Fix completion after application with implicit argumentsJason Zaugg2013-11-061-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `List(1, 2, 3).map(f).<ctrl-space>` now works; before the tree had the type `(bf: CanBuildFrom[...]):...` and did not contribute completions from the result type. This commit checks if the tree has an implicit method type, and typechecks it as a qualifier. That is enough to get to `adaptToImplicitMethod` in the type checker, infer the implicit arguments, and compute the final result type accordingly.
* | | | Merge pull request #3189 from retronym/ticket/8002Jason Zaugg2013-11-262-1/+11
|\ \ \ \ | | | | | | | | | | private access for local companions
| * | | | SI-8002 private access for local companionsJason Zaugg2013-11-242-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We go through similar gymnastics to make companion implicits work for local class/object pairings, so we ought to be consistent when it comes to access
* | | | | SI-7984 Issue unchecked warning for type aliasesJason Zaugg2013-11-261-5/+7
| |/ / / |/| | | | | | | | | | | | | | | | | | | - Dealias pattern types before launching the CheckabilityChecker - Sharpen the error messages to explain that the dealiased type is the expansion of the alias.
* | | | Merge pull request #3178 from retronym/ticket/7872Adriaan Moors2013-11-251-0/+2
|\ \ \ \ | | | | | | | | | | SI-7872 Plug a variance exploit in refinement types
| * | | | SI-7872 Plug a variance exploit in refinement typesJason Zaugg2013-11-231-0/+2
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refinement types are collapsed to a TypeTree with an original during type checking; this was enough to evade variance validation in refchecks. This commit: - validates the original of `TypeTree`s in refchecks - changes VarianceValidator to recurse into: - the originals of `TypeTree`s - `TypTree` (to cover, e.g. `CompoundTypeTree` / `SelectFromTypeTree`) It also finds an unreported variance violation in an existing test case, variances.scala. This looks to be legitimate.
* | | | Merge pull request #3130 from retronym/ticket/7967-2Adriaan Moors2013-11-251-2/+3
|\ \ \ \ | | | | | | | | | | SI-7967 Account for type aliases in self-type checks
| * | | | SI-7967 Account for type aliases in self-type checksJason Zaugg2013-11-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These eluded the check for "illegal inheritance; self-type does not conform" as AliasTypeRef doesn't forward `typeOfThis`. This commit dealiases before calling `typeOfThis`. That seems to be the most localised change. Without the dealias, we had: parent.tpe = TypeRef(pre, sym = AliasTypeSymbol("CC"), Nil) parent.tpe.typeOfThis = parent.tpe.transform(sym.typeOfThis) = CC After: parent.tpe.dealias = TypeRef(pre, sym = ClassSymbol("C"), Nil) parent.tpe.dealias.typeOfThis = C with B
* | | | | Merge pull request #3165 from retronym/ticket/uncurry-tidy-2Adriaan Moors2013-11-252-95/+56
|\ \ \ \ \ | | | | | | | | | | | | Unifying -Ydelambdafy:{inline, method}
| * | | | | Refactor away duplication between -Ydelambdafy:{inline,method}Jason Zaugg2013-11-232-64/+47
| | | | | |
| * | | | | Substitute new parameter symbols into lambda bodyJason Zaugg2013-11-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, new synthetic parameter symbols were created for the apply method parameters, but only used in its `MethodType`. The `ValDef` trees of the function, along with their symbols, were used directly as the parameter trees of the apply method. % cat sandbox/test.scala object Test { (x: Int) => { (y: Int) => ??? } } % scalac-hash v2.10.3 -Xprint:typer,uncurry -uniqid ../scala2/sandbox/test.scala | egrep 'syntax|\bx' [info] v2.10.3 => /Users/jason/usr/scala-v2.10.3-0-g88b5d19 [[syntax trees at end of typer]] // test.scala ((x#12152: Int#351) => x#12152)#12151 [[syntax trees at end of uncurry]] // test.scala final def apply#15952(x#12152: Int#351): Int#351 = x#12152 This approach dates back a long way: c64152bc3. @odersky tells me it was most likely due to insufficent substitution/cloning machinery at the time. % qbin/scalac -Xprint:typer,uncurry -uniqid ../scala2/sandbox/test.scala | egrep 'syntax|\bx' [[syntax trees at end of typer]] // test.scala ((x#13685: Int#1760) => x#13685)#13671 [[syntax trees at end of uncurry]] // test.scala final def apply#13959(x#13960: Int#1760): Int#1760 = x#13960 To make this work, I had to fix a problem in symbol substition; this was commited in the previous commit. In the enclosed test, at Uncurry, the symbol of the nested class `N` had a `ClassInfoType`, which listed as a parent `M[a.C]`. When we substituted the new method parameter symbol `a` for the eponymous function parameter symbol, this was not touched.
| * | | | | Tidy up the Uncurry component of delambdafyJason Zaugg2013-11-171-42/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Use tree factories that accept symbols and encapsulate ValDef creation - Use `gen.mkForwarder` to handle the conditional addition of `: _*` for varargs functions. We don't need to predicate this on `etaExpandKeepsStar`; the only place that need to do that is EtaExpansion.
* | | | | | Merge pull request #3137 from xeno-by/topic/implicit-macros-invalidate-on-errorAdriaan Moors2013-11-221-0/+2
|\ \ \ \ \ \ | | | | | | | | | | | | | | correctly fails implicit search for invalid implicit macros
| * | | | | | correctly fails implicit search for invalid implicit macrosEugene Burmako2013-11-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was a rare corner case when implicit search wouldn’t discard an invalid implicit macro (e.g. the one with mismatching macro impl or the one with macro impl defined in the same compilation run) during typechecking the corresponding candidate in typedImplicit1. This is now fixed.
* | | | | | | Merge pull request #3160 from retronym/ticket/7983Adriaan Moors2013-11-221-17/+12
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Fix implicit divergence regression
| * | | | | | | Account for a variation of package types in Implicit Divergence.Jason Zaugg2013-11-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While debugging pos/t7983.scala, I noticed that: complexity(scala.type): 1 complexity(Int): 2 The intent of the code is that top level classes should have a complexity of one. This commit restores that for cases when we see the prefix type as a ThisType, rather than a SingleType. I can't construct a test case in which this small difference is observable in the divergence checks.