summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker
Commit message (Collapse)AuthorAgeFilesLines
* Allow user-defined `[un]apply` in case companionAdriaan Moors2017-04-051-24/+75
| | | | | | | | | | | | | Don't emit a synthetic `apply` (or `unapply`) when it would clash with an existing one. This allows e.g., a `private apply`, along with a `case class` with a `private` constructor. We have to retract the synthetic method in a pretty roundabout way, as we need the other methods and the owner to be completed already. Unless we have to complete the synthetic `apply` while completing the user-defined one, this should not be a problem. If this does happen, this implies there's a cycle in computing the user-defined signature and the synthetic one, which is not allowed.
* Make ImplicitInfo hashCode consistent with equals.Miles Sabin2017-04-031-1/+4
|
* Merge pull request #5643 from som-snytt/issue/8417Adriaan Moors2017-03-222-18/+20
|\ | | | | SI-8417 Check adapts of each param section
| * SI-8417 Check adapts of each param sectionSom Snytt2017-02-202-18/+20
| | | | | | | | | | | | | | Previously, adaptations like auto-tupling were checked only on the last param section of an application. This commit runs the sanity check always.
* | Merge pull request #5622 from edmundnoble/extra-errsAdriaan Moors2017-03-023-24/+46
|\ \ | | | | | | Improved error messages for identically named, differently prefixed types
| * | Match error lengthsEdmund Noble2017-02-071-2/+5
| | |
| * | Improved error messages for identically named, differently prefixed typesEdmund Noble2016-12-313-24/+43
| | |
* | | SI-10207 Error before update conversionSom Snytt2017-02-261-5/+6
| | | | | | | | | | | | | | | | | | Gaze deeper for errors before committing to conversion of assignment to update. The error buried in the transformed tree escapes notice of retypechecking and leaks to backend.
* | | Merge pull request #5708 from szeiger/issue/si10194Lukas Rytz2017-02-211-7/+7
|\ \ \ | | | | | | | | SI-10194: Fix abstract type resolution for overloaded HOFs
| * | | SI-10194: Fix abstract type resolution for overloaded HOFsStefan Zeiger2017-02-211-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | Types in the applicable overload alternatives need to be seen from the respective owners of the individual alternative, not from the target’s owner (which can be a subtype of the types that define the methods).
* | | | Merge pull request #5700 from retronym/ticket/10154-refactorLukas Rytz2017-02-212-20/+29
|\ \ \ \ | | | | | | | | | | Refactor lookupCompanion
| * | | | Refactor implementation of lookupCompanionJason Zaugg2017-02-192-20/+29
| | |_|/ | |/| | | | | | | | | | | | | | - Check for module class up front to use sourceModule - Consolidate most of the logic in Contexts
* | | | Merge pull request #5640 from optimizely/repl-import-handlerAdriaan Moors2017-02-201-2/+5
|\ \ \ \ | |/ / / |/| | | SI-9881 Fix ImportHandler's reporting of importedNames and importedSymbols
| * | | Fix ImportHandler's reporting of importedNames and importedSymbolsHao Xia2017-01-111-2/+5
| | |/ | |/|
* | | Merge branch '2.12.x' into merge-2.11.x-to-2.12.x-20170214Seth Tisue2017-02-174-42/+43
|\ \ \ | | |/ | |/|
| * | Merge pull request #5546 from som-snytt/issue/9636Adriaan Moors2017-02-161-32/+24
| |\ \ | | | | | | | | SI-9636 More precise error pos on apply inference
| | * | SI-9636 More precise error pos on apply inferenceSom Snytt2016-12-201-32/+24
| | |/ | | | | | | | | | | | | If a method type arg is inferred Any, warn about the function and not the innocent arg.
| * | Merge pull request #5662 from teldosas/SI-9675Adriaan Moors2017-02-161-1/+1
| |\ \ | | | | | | | | SI-9675 warn about non-sensible equals in anonymous functions
| | * | Add warning about non-sensible equals in anonymous functionsteldosas2017-02-011-1/+1
| | |/
| * | Merge pull request #5587 from lrytz/t10072Adriaan Moors2017-02-161-4/+0
| |\ \ | | | | | | | | SI-10072 cast Function nodes to environment in specialization
| | * | SI-10072 cast Function nodes to environment in specializationLukas Rytz2016-12-071-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit basically make sure the fix for SI-5284 works correctly when a Function node reaches specialization (`-Ydealmbdafy:method` and IndyLambda are default in 2.12.x). To understand it, best read the excellent description in b29c01b. The code that's removed in this commit was added in 13ea590. It prevented `castType` from being invoked on the `Function` node, which is exactly what is needed here. It's also what happens under `-Ydelambdafy:inline`, the `new anonfun()` tree is being casted from `(Int, Int) => Int` to `(Int, A) => Int`.
| * | | Merge pull request #5542 from retronym/ticket/10066Adriaan Moors2017-02-161-5/+18
| |\ \ \ | | | | | | | | | | SI-10066 Fix crash in erroneous code with implicits, dynamic
| | * | | SI-10066 Fix crash in erroneous code with implicits, dynamicJason Zaugg2016-11-181-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The compiler support in the typechecker for `scala.Dynamic` is very particular about the `Context` in which it is typechecked. It looks at the `tree` in the enclosing context to find the expression immediately enclosing the dynamic selection. See the logic in `dyna::mkInvoke` for the details. This commit substitutes the result of `resetAttrs` into the tree of the typer context before continuing with typechecking.
* | | | | Merge commit '0965028809' into merge-2.11.x-to-2.12.x-20170214Seth Tisue2017-02-161-1/+1
|\ \ \ \ \
| * | | | | SI-1459 two bridges for impl of java generic vararg methodAdriaan Moors2017-01-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A Scala method that implements a generic, Java-defined varargs method, needs two bridges: - to convert the collections for the repeated parameters (VBRIDGE) - to bridge the generics gap (BRIDGE) Refchecks emits the varargs "bridges", and erasure takes care of the other gap. Because a VBRIDGE was also an ARTIFACT, it was wrongly considered inert with respect to erasure, because `OverridingPairs` by default excluded artifacts. Removed the artifact flag from those VBRIDGES, so that they qualify for a real bridge. It would also work to include VBRIDGE methods that are artifacts in BridgesCursor.
* | | | | | Merge commit '36967321c7' into merge-2.11.x-to-2.12.x-20170214Seth Tisue2017-02-161-2/+3
|\| | | | | | |/ / / / |/| | | |
| * | | | SI-9331 Fix canEqual for case classes with HK type paramsJason Zaugg2017-01-091-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Time for the courage of our convictions: follow the advice of my TODO comment from SI-8244 / f62e280825 and fix `classExistentialType` once and for all. This is the change in the generated `canEquals` method in the test case; we no longer get a kind conformance error. ``` --- sandbox/old.log 2015-05-27 14:31:27.000000000 +1000 +++ sandbox/new.log 2015-05-27 14:31:29.000000000 +1000 @@ -15,7 +15,7 @@ case _ => throw new IndexOutOfBoundsException(x$1.toString()) }; override <synthetic> def productIterator: Iterator[Any] = runtime.this.ScalaRunTime.typedProductIterator[Any](Stuff.this); - <synthetic> def canEqual(x$1: Any): Boolean = x$1.$isInstanceOf[Stuff[Proxy[PP]]](); + <synthetic> def canEqual(x$1: Any): Boolean = x$1.$isInstanceOf[Stuff[_ <: [PP]Proxy[PP]]](); override <synthetic> def hashCode(): Int = ScalaRunTime.this._hashCode(Stuff.this); override <synthetic> def toString(): String = ScalaRunTime.this._toString(Stuff.this); override <synthetic> def equals(x$1: Any): Boolean = x$1 match { @@ -38,9 +38,3 @@ } } ``` I also heeded my own advice to pass in a prefix to this method.
* | | | | Merge pull request #5654 from retronym/ticket/10154Adriaan Moors2017-02-141-1/+2
|\ \ \ \ \ | | | | | | | | | | | | SI-10154 Fix implicit search regression for term-owned objects
| * | | | | SI-10154 Fix implicit search regression for term-owned objectsJason Zaugg2017-01-201-1/+2
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A recent change to fix lookup of companion implicits of term-owned classes (#5550) caused a regression in the enclosed test case. The previous approach of calling `Scope#lookup(companionName)` was replaced by a lookup of the scope entry of the original name followed by a narrower search lookup for the companion name, to ensure that it was a true companion, and not just a same-named module from defined at a different nested scope. However, module class symbols are not themselves entered into scopes, so the first part of the new scheme fails. We need to add a special case modules here. I've chosen to just call `.sourceModule` on module classes. For module classes in the current run (all term owned symbols will fall into this category), this amounts to using the value of the field `ModuleClassSymbol#module`.
* | | | | Correct the AbstractVar error messageJon Pretty2017-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The error currently reads "only classes can have declared but undefined members", which isn't true on two counts: traits can have them, and concrete classes cannot. This corrects the error message to read "only traits and abstract classes can have declared but undefined members".
* | | | | SI-8685 Warn on deprecated case ctorSom Snytt2017-01-161-0/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The narrow use case in the ticket was just to warn on `C.apply` when the constructor has been deprecated. Someone added code to warn after the apply is rewritten, but it wasn't checking the constructor (and the tree was checked before but not after transform).
* | | | Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2016-12-201-17/+43
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | merge/2.11.x-to-2.12.x-20161220 Conflicts: bincompat-backward.whitelist.conf build.xml src/compiler/scala/tools/nsc/typechecker/Typers.scala src/library/scala/collection/immutable/NumericRange.scala
| * | | SI-9834 Show expansion of update on errorSom Snytt2016-11-251-3/+4
| | | |
| * | | SI-9834 Improve error on failed op=Som Snytt2016-11-251-16/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If rewriting `x += y` fails to typecheck, emit error messages for both the original tree and the assignment. If rewrite is not attempted because `x` is a val, then say so. The error message at `tree.pos` is updated with the additional advice. SI-8763 Crash in update conversion When there are already errors, don't attempt mechanical rewrites.
| * | | Merge pull request #5345 from milessabin/topic/si-7046-backportAdriaan Moors2016-10-183-11/+35
| |\ \ \ | | | | | | | | | | [nomerge] Partial fix for SI-7046
| | * | | Partial fix for SI-7046Miles Sabin2016-08-153-11/+35
| | | | |
| * | | | SI-9760 Fix for higher-kinded GADT refinementMiles Sabin2016-08-151-1/+0
| |/ / /
* | | | SI-10068 Only permit elidable methodsSom Snytt2016-12-141-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In refchecks, check that symbol with `@elidable` is a method. When eliding in uncurry, doublecheck. The check is enabled under `-Xsource:2.13`.
* | | | Merge pull request #5558 from larsrh/topic/deprecated-y-flagsAdriaan Moors2016-12-132-5/+3
|\ \ \ \ | | | | | | | | | | Remove deprecated -Y flags
| * | | | remove deprecated compiler flag "-Yinfer-by-name"Lars Hupel2016-12-011-4/+2
| | | | | | | | | | | | | | | | | | | | This was slated for removal in 2.12.
| * | | | remove deprecated compiler flag "-Yeta-expand-keeps-star"Lars Hupel2016-12-011-1/+1
| | |_|/ | |/| | | | | | | | | | This was slated for removal in 2.12.
* | | | Merge pull request #5550 from retronym/ticket/3772Lukas Rytz2016-12-122-5/+26
|\ \ \ \ | | | | | | | | | | SI-3772 Fix detection of term-owned companions
| * | | | Refactor companion lookup methods after code reviewJason Zaugg2016-11-291-1/+1
| | | | |
| * | | | SI-3772 Fix detection of term-owned companionsJason Zaugg2016-11-292-5/+26
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Companion detection consults the scopes of enclosing Contexts during typechecking to avoid the cycles that would ensue if we had to look at into the info of enclosing class symbols. For example, this used to typecheck: object CC { val outer = 42 } if ("".isEmpty) { case class CC(c: Int) CC.outer } This logic was not suitably hardened to find companions in exactly the same nesting level. After fixing this problem, a similar problem in `Namer::inCurrentScope` could be solved to be more selective about synthesizing a companion object. In particular, if a manually defined companion trails after the case class, don't create an addiotional synthetic comanpanion object.
* | | | Compiler support for JEP-193 VarHandle polymorphic signaturesJason Zaugg2016-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | VarHandles bring a host of new "polymorphic signature" methods to the Java 9 standard library. This commit updates the way we detect such methods to look at the absense/presense of the `PolymorphicSignature` annotation, so as to include these (and any future additions.) When we see applications of such methods, we disable adaptation of argument and return types. Tested manually with JDK9-ea: ``` Welcome to Scala 2.12.2-20161208-165912-3de1c0c (Java HotSpot(TM) 64-Bit Server VM, Java 9-ea). Type in expressions for evaluation. Or try :help. scala> import java.lang.invoke._, scala.runtime.IntRef import java.lang.invoke._ import scala.runtime.IntRef scala> val varHandle = MethodHandles.lookup().in(classOf[IntRef]).findVarHandle(classOf[IntRef], "elem", classOf[Int]); varHandle: java.lang.invoke.VarHandle = java.lang.invoke.VarHandleInts$FieldInstanceReadWrite@7112ce6 scala> varHandle.getAndSet(ref, 1): Int res5: Int = 0 scala> varHandle.getAndSet(ref, 1): Int res6: Int = 1 ``` Inspecting bytecode shows the absense of box/unboxing: ``` object Test { import java.lang.invoke._, scala.runtime.IntRef val varHandle = MethodHandles.lookup().in(classOf[IntRef]).findVarHandle(classOf[IntRef], "elem", classOf[Int]); def main(args: Array[String]): Unit = { val i : Int = varHandle.getAndSet(IntRef.zero, 1) } } ``` ``` public void main(java.lang.String[]); Code: 0: aload_0 1: invokevirtual #28 // Method varHandle:()Ljava/lang/invoke/VarHandle; 4: invokestatic #34 // Method scala/runtime/IntRef.zero:()Lscala/runtime/IntRef; 7: iconst_1 8: invokevirtual #40 // Method java/lang/invoke/VarHandle.getAndSet:(Lscala/runtime/IntRef;I)I 11: istore_2 12: return ```
* | | | Merge pull request #5570 from adriaanm/t10075Adriaan Moors2016-12-052-5/+8
|\ \ \ \ | |_|/ / |/| | | SI-10075 propagate annotations to lazy val's underlying field
| * | | SI-10075 annotations go to lazy val's underlying fieldAdriaan Moors2016-12-052-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This likely regressed in #5294. Review feedback from retronym: - Tie annotation triaging a bit closer together durban kindly provided initial version of test/files/run/t10075.scala And pointed out you must force `lazy val`, since `null`-valued field is serializable regardless of its type. Test test/files/run/t10075b courtesy of retronym
* | | | Merge pull request #5284 from milessabin/topic/si-7046Adriaan Moors2016-11-303-13/+35
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SI-7046 reflection doesn't see all knownDirectSubclasses This appears to do the right thing in the most typical scenarios in which `knownDirectSubclasses` would be used. The missing 5% is that subclasses defined in local scopes might not be seen by `knownDirectSubclasses` (see `Local` and `Riddle` in the test below). In mitigation, though, it is almost certain that a local subclass would represent an error in any scenario where `knownDirectSubclasses` might be used. Errors for such situations are reported by recording (via a symbol attachment) that `knownDirectSubclasses` has been called and reporting an error if any additional children are added subsequently. Despite these limitations and caveats, I believe that this represents a huge improvement over the status quo, and would eliminate 100% of the failures that I've seen in practice with people using shapeless for type class derivation.
| * | | | Partial fix for SI-7046Miles Sabin2016-11-283-13/+35
| | | | |
* | | | | Merge pull request #5376 from milessabin/topic/clean-experimentalAdriaan Moors2016-11-301-1/+1
|\ \ \ \ \ | |_|/ / / |/| | | | Clean up of code guarded by bare -Xexperimental