aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #2267 from dotty-staging/fix-constant-lazy-valsDmitry Petrashko2017-04-191-0/+14
|\ | | | | Fix #2266: Do not replace constant type lazy vals with constant.
| * Fix constant type val value inline in constructors.Nicolas Stucki2017-04-161-0/+14
| |
* | Alternative fixMartin Odersky2017-04-181-2/+6
| | | | | | | | | | Special case HKApply only. This is simpler and potentially more efficient.
* | Dealias before type erasingMartin Odersky2017-04-181-2/+2
|/ | | | | | ... and likewise for taking a signature. The previous case worked in all cases except when faced with an alias like `type Id[T] = T`. In that case, it would disregard the argument and erase to Object.
* Merge pull request #2209 from dotty-staging/fix-#2152odersky2017-04-133-3/+8
|\ | | | | Fix #2152: Instantiate dependent result type parameters
| * Alternative fixMartin Odersky2017-04-111-4/+5
| | | | | | | | | | | | The original fix made run/hmap-covariant fail because a type variable representing a dependent result parameter was instantiated. Trying something else now.
| * Fix #2152: Instantiate dependent result type parametersMartin Odersky2017-04-113-2/+6
| | | | | | | | | | | | | | #2152 shows that dependent result type parameters can end up in the types of terms, so we have to eliminate them. If we don't we get orphan parameters in pickling. Fix method name and comment
* | Revert <: Product requierment in pattern matchingOlivier Blanvillain2017-04-131-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The change in question broke the following pattern, commonly used in name based pattern matching: ```scala object ProdEmpty { def _1: Int = ??? def _2: String = ??? def isEmpty = true def get = this } ``` This type define both `_1` and `get` + `isEmpty` (but is not <: Product). After #1938, `ProdEmpty` became eligibles for both product and name based pattern. Because "in case of ambiguities, *Product Pattern* is preferred over *Name Based Pattern*", isEmpty wouldn't be used, breaking the scalac semantics.
* | SI-9915 Utf8_info are modified UTF8Guillaume Martres2017-04-111-2/+6
| | | | | | | | | | | | | | | | | | Adapted from scalac commit 3c5990ce5839f4bdfca8fed7f2c415a72f6a8bd8 by Som Snytt: Use DataInputStream.readUTF to read CONSTANT_Utf8_info. This fixes reading embedded null char and supplementary chars.
* | SI-7455 Drop dummy param for synthetic access constructorGuillaume Martres2017-04-111-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adapted from scalac commit 050b4c951c838699c2fe30cbf01b63942c63a299 by Jason Zaugg: Java synthesizes public constructors in private classes to allow access from inner classes. The signature of that synthetic constructor (known as a "access constructor") has a dummy parameter appended to avoid overloading clashes. javac chooses the type "Enclosing$1" for the dummy parameter (called the "access constructor tag") which is either an existing anonymous class or a synthesized class for this purpose. In OpenJDK, this transformation is performed in: langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java (Incidentally, scalac would just emits a byte-code public constructor in this situation, rather than a private constructor / access constructor pair.) Scala parses the signature of the access contructor, and drops the $outer parameter, but retains the dummy parameter. This causes havoc when it tries to parse the bytecode for that anonymous class; the class file parser doesn't have the enclosing type parameters of Vector in scope and crash ensues. In any case, we shouldn't allow user code to see that constructor; it should only be called from within its own compilation unit. This commit drops the dummy parameter from access constructor signatures in class file parsing.
* | SI-2464 Resiliance against missing InnerClass attributesGuillaume Martres2017-04-111-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adapted from scalac commit 2a19cd56258884e25f26565d7b865cc2ec931b23 by Jason Zaugg, but without the testing infrastructure added: A classfile in the wild related to Vaadin lacked the InnerClasses attribute. As such, our class file parser treated a nested enum class as top-level, which led to a crash when trying to find its linked module. More details of the investigation are available in the JIRA comments. The test introduces a new facility to rewrite classfiles. This commit turns this situation into a logged warning, rather than crashing. Code by paulp, test by yours truly.
* | Merge pull request #2191 from dotty-staging/sync-classpath-scalacGuillaume Martres2017-04-112-21/+33
|\ \ | |/ |/| Fix #2186: Synchronize classpath handling with Scala 2.12
| * Fix #2186: Synchronize classpath handling with Scala 2.12Guillaume Martres2017-04-112-21/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is a very crude port of the classpath handling as it exists in the 2.12.x branch of scalac (hash: 232d95a198c94da0c6c8393624e83e9b9ac84e81), this replaces the existing Classpath code that was adapted from scalac years ago. This code was written by Grzegorz Kossakowski, MichaƂ Pociecha, Lukas Rytz, Jason Zaugg and other scalac contributors, many thanks to them! For more information on this implementation, see the description of the PR that originally added it to scalac: https://github.com/scala/scala/pull/4060 Changes made to the copied code to get it to compile with dotty: - Rename scala.tools.nsc.util.ClassPath to dotty.tools.io.ClassPath - Rename scala.tools.nsc.classpath.* to dotty.tools.dotc.classpath.* - Replace "private[nsc]" by "private[dotty]" - Changed `isClass` methods in FileUtils to skip Scala 2.11 implementation classes (needed until we stop being retro-compatible with Scala 2.11) I also copied PlainFile.scala from scalac to get access to `PlainNioFile`.
* | Fix #2219: Fix type applications on WildcardTypeGuillaume Martres2017-04-111-1/+1
|/ | | | | | | Previously we just returned the unapplied WildcardType which is incorrect if the WildcardType is bounded. The proper thing to do is to do the type application on the bounds of the WildcardType and wrap the result in a WildcardType.
* Merge pull request #1938 from dotty-staging/named-based-patmatFelix Mulder2017-04-111-12/+3
|\ | | | | Change case class desugaring and decouple Products and name-based-pattern-matching
| * Move isProductSubType to Applications & rename to canProductMatchOlivier Blanvillain2017-04-111-3/+0
| |
| * Decouple Product and pattern-matchingOlivier Blanvillain2017-04-061-10/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Product pattern use to: - have a `<: Product` requirement - compute the arity of a pattern by looking at `N` in a `ProductN` superclass. This commit changes `<: Product`, instead we look for a `_1` member. The arity is determined by inspecting `_1` to `_N` members instead. --- Here another attempt to formalize Dotty's pattern-matching (base on #1805). This covers the *Extractor Patterns* [section of the spec](https://www.scala-lang.org/files/archive/spec/2.12/08-pattern-matching.html#extractor-patterns). Dotty support 4 different extractor patterns: Boolean Pattern, Product Pattern, Seq Pattern and Name Based Pattern. Boolean Pattern - Extractor defines `def unapply(x: T): Boolean` - Pattern-matching on exactly `0` patterns Product Pattern - Extractor defines `def unapply(x: T): U` - `N > 0` is the maximum number of consecutive (parameterless `def` or `val`) `_1: P1` ... `_N: PN` members in `U` - Pattern-matching on exactly `N` patterns with types `P1, P2, ..., PN` Seq Pattern - Extractor defines `def unapplySeq(x: T): U` - `U` has (parameterless `def` or `val`) members `isEmpty: Boolean` and `get: S` - `S <: Seq[V]` - Pattern-matching on any number of pattern with types `V, V, ..., V` Name Based Pattern - Extractor defines `def unapply(x: T): U` - `U` has (parameterless `def` or `val`) members `isEmpty: Boolean` and `get: S` - If there is exactly `1` pattern, pattern-matching on `1` pattern with type `S` - Otherwise fallback to Product Pattern on type `U` In case of ambiguities, *Product Pattern* is preferred over *Name Based Pattern*.
| * Generate synthetic productElement/productArity methods above 22Olivier Blanvillain2017-04-061-0/+1
| |
* | Better documentation of sharable structures in Names, NameKindsMartin Odersky2017-04-112-1/+5
| |
* | Adapt isPackageObject to semantic namingMartin Odersky2017-04-112-3/+4
| | | | | | | | Used a hardcoded string before, which caused test failures.
* | Fix pickling/unpickling of namesMartin Odersky2017-04-113-3/+12
| | | | | | | | | | Running the test suite with the pickling printer on showed up two more problems which are fixed in this commit.
* | Fix rebase breakageMartin Odersky2017-04-114-22/+6
| |
* | Make extension method names semanticMartin Odersky2017-04-112-8/+26
| |
* | Lazy entering of names with internal $'s in package scopesMartin Odersky2017-04-115-51/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Names with internal $'s are entered in package scopes only if - we look for a name with internal $'s. - we want to know all the members of a package scope This optimization seems to be fairly effective. The typical range of package scopes that need $-names is between 0 and 20%. The optimization seems to improve execution time of all unit tests by about 3%. Also. drop the inheritance from Iterable to Scope. The reason is that we now need a context parameter for toList and other Iterable operations which makes them impossible to fit into the Iterable framework.
* | Scope refactoringMartin Odersky2017-04-113-56/+31
| | | | | | | | | | | | Since we now have separate package-scopes, it's easier to have them take into account the special role played by the scala package. So we can drop the funky logic of `makeScalaSpecial`.
* | Avoid setter in NameMartin Odersky2017-04-112-2/+2
| | | | | | | | and fix a bug in TreeUnpickler
* | Fix and activate package scopesMartin Odersky2017-04-114-14/+33
| | | | | | | | Prevviously they were actually unused.
* | Introduce mangled methodMartin Odersky2017-04-114-6/+13
| | | | | | | | Mangled is like toSimpleName, except that it keeps the term/type distinction.
* | Keep package member names mangledMartin Odersky2017-04-116-11/+31
| | | | | | | | | | | | | | | | | | Once we start using unencoded operators internally, we will face the problem that one cannot decode realiably a class file filename. We therefore turn things around, keeping members of package scopes in mangled and encoded form. This is compensated by (1) mangling names for lookup of such members and (2) when unpickling from Scala 2 info or Tasty, comparing mangled names when matching a read class or module object against a root.
* | Simplify classfile parser "own name" checkingMartin Odersky2017-04-111-12/+5
| | | | | | | | | | | | | | Simplifies the test that the class represented by a classfile is the class logically referenced by the file. The simplification is needed if we want to populate package scopes with unmangled classnames.
* | Don't unmangle names in ClassfileParserMartin Odersky2017-04-111-13/+12
| | | | | | | | | | Classfile parsing is about JVM-level names, not Scala level ones. So it is more consistent to use mangled names throughout.
* | Memoize toSimpleNameMartin Odersky2017-04-111-1/+6
| | | | | | | | | | | | | | toSimpleName is called a lot from the backend, so it makes sense to memoize it. It would be even better to communicate with the backend using strings, because then we would not have to enter all these simple names in the name table.
* | Bugfix in stripModuleClassSuffixMartin Odersky2017-04-111-2/+2
| |
* | Further simplification for NameMartin Odersky2017-04-116-33/+16
| |
* | Merge likeTyped and likeKinded into likeSpacedMartin Odersky2017-04-112-23/+19
| |
* | Names are no longer SeqsMartin Odersky2017-04-118-127/+109
| | | | | | | | | | | | | | | | Drop Seq implementation of name. This implementation was always problematic because it entailed potentially very costly conversions to toSimpleName. We now have better control over when we convert a name to a simple name.
* | Cleanups of NameOpsMartin Odersky2017-04-112-80/+0
| | | | | | | | Remove unused functionality
* | Make outer select names semanticMartin Odersky2017-04-114-9/+12
| |
* | Make module var names semanticMartin Odersky2017-04-114-23/+4
| |
* | Avoid duplicate hashCode/equalsMartin Odersky2017-04-112-4/+2
| |
* | Fix dropModule logicMartin Odersky2017-04-111-2/+2
| |
* | Make field names semanticMartin Odersky2017-04-114-22/+12
| |
* | Make "direct names" semanticMartin Odersky2017-04-113-2/+3
| |
* | Revise qualified namesMartin Odersky2017-04-116-83/+60
| | | | | | | | | | 1. Fix problem in fullNameSeparated 2. Revise expandedName operations
* | New unmangling for ExpandedNameMartin Odersky2017-04-113-45/+40
| |
* | Decentralize unmangling, add new nameKindsMartin Odersky2017-04-116-50/+49
| | | | | | | | | | | | | | Start scheme where unmangling is done by NameKinds instead of in NameOps. Also add namekinds for protected accessors.
* | Rename NameExtractor -> NameKindMartin Odersky2017-04-1113-97/+96
| |
* | Make freshName semanticMartin Odersky2017-04-1112-109/+165
| |
* | Redefine definesNewNameMartin Odersky2017-04-113-8/+18
| | | | | | | | | | | | | | Make it a method of info instead of a convention over tags, because it's less fragile that way. Also, add UniqueName extractor.
* | Add ShadowedName and AvoidClashNameMartin Odersky2017-04-119-29/+22
| |