aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/Definitions.scala
Commit message (Collapse)AuthorAgeFilesLines
* 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
| |
* | Scope refactoringMartin Odersky2017-04-111-20/+1
| | | | | | | | | | | | 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`.
* | Fix and activate package scopesMartin Odersky2017-04-111-1/+1
| | | | | | | | Prevviously they were actually unused.
* | Further simplification for NameMartin Odersky2017-04-111-1/+1
| |
* | Names are no longer SeqsMartin Odersky2017-04-111-10/+9
| | | | | | | | | | | | | | | | 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.
* | Get rid of ExpandedName flagMartin Odersky2017-04-111-1/+1
|/
* Merge MethodType and PolyType functionality where possibleMartin Odersky2017-04-061-1/+1
| | | | | | Two benefits: (1) less code. (2) finding subtle bugs about parameter dependent method types. By merging with PolyTypes we are forced to take parameter dependencies into account.
* Rename PolyParam --> TypeParamRefMartin Odersky2017-04-061-3/+3
|
* Harmonize paramTypes and paramBoundsMartin Odersky2017-04-061-2/+2
| | | | | | MethodTypes have paramTypes whereas PolyTypes have paramBounds. We now harmonize by alling both paramInfos, and parameterizing types that will become common to both.
* Encode variances in parameter namesMartin Odersky2017-04-061-1/+1
| | | | | | | | | | This leads to a slight overall simplification, harmonizes pickle format with internal representation, and makes MethodTypes and PolyTypes more similar to each other. I believe the change is useful as it is, but in particular it is a useful step for an eventual unification of MethodTypes and PolyTypes.
* Implement enum desugaringMartin Odersky2017-04-041-0/+4
|
* Merge pull request #2045 from dotty-staging/fix-hlist-hmapodersky2017-03-091-0/+1
|\ | | | | Fix type inference for HLists and HMaps
| * Fix handling of dependent method typesMartin Odersky2017-03-011-0/+1
| | | | | | | | | | Need to use fresh PolyParams instead of WildcardTypes if constraint is committable.
* | Drop special case around Function1Martin Odersky2017-03-081-0/+2
| | | | | | | | | | | | Now only Scala2 mode treats Function1's as implicit conversions. Instead we introduce a new subclass ImplicitConverter of Function1, instances of which are turned into implicit conversions.
* | Disallow subtypes of Function1 acting as implicit conversionsMartin Odersky2017-03-081-0/+2
| | | | | | | | | | | | | | | | | | | | The new test `falseView.scala` shows the problem. We might create an implicit value of some type that happens to be a subtype of Function1. We might now expect that this gives us an implicit conversion, this is most often unintended and surprising. See the comment in Implicits#discardForView for a discussion why we picked the particular scheme implemented here.
* | Remove unused scala.reflect importsGuillaume Martres2017-03-071-1/+0
|/
* Remove wrapArrayMethodName from defn.Nicolas Stucki2017-02-271-7/+0
| | | | Note that it is never used and the same method exists in transform.TreeGen
* Merge pull request #1984 from dotty-staging/fix-#1747-v2odersky2017-02-211-1/+2
|\ | | | | Fix #1747: Improve error message for Scala/Java type mismatch
| * Avoid automatism for passing variances to PolyTypesMartin Odersky2017-02-141-1/+2
| | | | | | | | | | We used to "fill-in" with zeroes if variances were missing. I now think that;'s too error-prone. Better define all variances explicitly.
* | Merge pull request #1962 from dotty-staging/centralize-function-logicodersky2017-02-161-28/+62
|\ \ | | | | | | Factor out logic for scala functions.
| * | Add checks for synthetic functions and erased functions.Nicolas Stucki2017-02-131-28/+62
| |/ | | | | | | | | | | | | | | * Add `isSyntheticFunction` checks for synthetic functions such as FuntionN for N > 22 and ImplicitFunctionN for N >= 0. * Add `erasedFunctionClass` to get the erased verion of synthetic functions. * Change the semantics of `isFunctionClass` to return true if it is any kind of FunctionN or ImplicitFunctionN.
* / Fix #1976: Hack to support scala.xml's $scope (#1977)odersky2017-02-141-0/+2
|/ | | | | | This is a gross hack to support the need for a $scope binding when XML literals are created. It should go away once we phase out XML literals. A library-based solution should use implicits instead.
* Merge pull request #1931 from dotty-staging/fix-#1501Guillaume Martres2017-02-131-1/+1
|\ | | | | Fix #1501 - Check trait inheritance condition
| * Fix package name of Java's Serializable classMartin Odersky2017-02-101-1/+1
| | | | | | | | It's java.io, not java.lang.
* | Fix #1916: fix erasure of implicit xxl closuresNicolas Stucki2017-02-031-2/+2
|/ | | | This commit extends the fix done in #1920 to implicit closures.
* Merge pull request #1919 from dotty-staging/fix-#1915Nicolas Stucki2017-02-011-1/+13
|\ | | | | Fix #1915 Synthetic function traits need NoInits flag
| * Add explanation to NoInitClassesMartin Odersky2017-02-011-0/+10
| |
| * Make it known that FunctionXXL does not have an initializer.Martin Odersky2017-02-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When compiled from Scala2 that knowledge was lost. Normally that would be not a problem (e.g. the same thing happens for Function0-22). But FunctionXXL is special in that it is inherited only after erasure. Since `augmentScala2Trait` runs before erasure, it is having no effect on FunctionXXL itself when running on classes that inherit function types of large arities. Therefore, FunctionXXL is missing an implementation class at phase Mixin, which means that the supercall logic which rewires super.<init> to implementation class init cannot work. This leaves us with a super.<init> to FunctionXXL in `i1915.scala`. The fix is to always know that `FunctionXXL` has no init method, so no super.<init> will be generated for it.
| * Fix #1915 Synthetic function traits need NoInits flagMartin Odersky2017-01-311-1/+1
| | | | | | | | Fixes #1915.
* | Merge pull request #1881 from dotty-staging/add-structural-selectodersky2017-02-011-0/+4
|\ \ | |/ |/| Implement structural type member access
| * Address reviewer commentsMartin Odersky2017-01-101-1/+1
| |
| * Change scheme to use SelectableMartin Odersky2017-01-071-2/+1
| | | | | | | | | | Use base types instead of implicits. This is more robust in the presence of type abstraction.
| * Implement structural type member accessMartin Odersky2017-01-051-0/+5
| | | | | | | | New scheme for implementing structural type member access.
* | Workaroud #1856: recursively calling a lazy val works differently in DottyGuillaume Martres2017-01-281-1/+11
| |
* | Adopt scala's scheme for root import hidingMartin Odersky2017-01-151-0/+1
|/ | | | | | | | | | scalac hides a root import from Predef if there is an eplicit Predef import. We now do the same (previously we did this only if the overriding import undefined something, using a `x => _` syntax). To avoid cycles and races one had to be very careful not to force import symbols too early, so we now compare the name before the symbol proper. All this is likely temporary - the comment of ImportInfo#unimported points to a different, more systematic solution.
* Fix formattingMartin Odersky2016-12-171-2/+1
|
* Fix rebase breakageMartin Odersky2016-12-171-1/+5
|
* Create implicit closures to math expected implicit functionsMartin Odersky2016-12-171-0/+3
| | | | | When the expected type is an implicit function, create an implicit closure to match it.
* Refactor function operations in DefinitionsMartin Odersky2016-12-171-13/+19
| | | | | | | | | Also: show implicit function types correctly. Also: refine applications of implicit funcitons - don't do it for closure trees - don't do it after typer.
* Always insert apply for expressions of implicit function typeMartin Odersky2016-12-171-5/+24
|
* Add ImplicitFunctionN classesMartin Odersky2016-12-171-9/+21
| | | | These are always synthetic; generated on demand.
* Fix #1799: Make compilation of FunctionN traits possible.Martin Odersky2016-12-161-1/+1
|
* Implement new rules for name-based pattern matchingMartin Odersky2016-12-151-1/+9
| | | | This implements the rules laid down in #1805.
* Change by-name pattern matching.Martin Odersky2016-12-141-1/+3
| | | | New implementation following the scheme outlined in #1790.
* Merge pull request #1758 from dotty-staging/change-functionsodersky2016-12-031-77/+137
|\ | | | | Drop function 22 limit
| * Adress reviewers commentsMartin Odersky2016-12-011-1/+1
| |
| * Add missing fileMartin Odersky2016-11-301-1/+2
| |