aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/Applications.scala
Commit message (Collapse)AuthorAgeFilesLines
* Revert <: Product requierment in pattern matchingOlivier Blanvillain2017-04-131-5/+2
| | | | | | | | | | | | | | | 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.
* Merge pull request #1938 from dotty-staging/named-based-patmatFelix Mulder2017-04-111-5/+10
|\ | | | | Change case class desugaring and decouple Products and name-based-pattern-matching
| * Move isProductSubType to Applications & rename to canProductMatchOlivier Blanvillain2017-04-111-4/+6
| |
| * Decouple Product and pattern-matchingOlivier Blanvillain2017-04-061-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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*.
* | Names are no longer SeqsMartin Odersky2017-04-111-2/+3
| | | | | | | | | | | | | | | | 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.
* | Decentralize unmangling, add new nameKindsMartin Odersky2017-04-111-1/+2
| | | | | | | | | | | | | | Start scheme where unmangling is done by NameKinds instead of in NameOps. Also add namekinds for protected accessors.
* | Align safe parameter substitution with other subst methodsMartin Odersky2017-04-101-1/+1
| | | | | | | | Change name and align order of parameters.
* | Skolemize arguments to dependent methods as necessary.Martin Odersky2017-04-101-3/+2
|/ | | | This was missing before, led to errors not being detected.
* Merge MethodType and PolyType functionality where possibleMartin Odersky2017-04-061-2/+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.
* Further refactoringsMartin Odersky2017-04-061-7/+2
| | | | | - Use TypeLambda instead of PolyType. - Further harmonize factory operations
* Eliminate MethodOrPolyMartin Odersky2017-04-061-1/+1
| | | | Replace with LambdaType
* replace derived{Method,Poly}Type with derivedLambdaTypeMartin Odersky2017-04-061-1/+1
|
* Rename PolyParam --> TypeParamRefMartin Odersky2017-04-061-1/+1
|
* Harmonize paramTypes and paramBoundsMartin Odersky2017-04-061-10/+10
| | | | | | MethodTypes have paramTypes whereas PolyTypes have paramBounds. We now harmonize by alling both paramInfos, and parameterizing types that will become common to both.
* Break out functionality from MethodTypeMartin Odersky2017-04-061-2/+2
| | | | | and generalize MethodParam to ParamRef, and TypeParamInfo to ParamInfo
* Avoid assertion failure on neg testMartin Odersky2017-04-041-1/+8
| | | | This commit can hopefully be reverted once #2121 is in.
* Take parameter dependencies into accountMartin Odersky2017-03-141-5/+21
| | | | Take parameter dependencies into account when typechecking arguments.
* Construct MethodTypes from parameter closureMartin Odersky2017-03-141-1/+2
| | | | | To allow for dependencies between method type parameters, construct MethodTypes from a closure that maps the currently constructed MethodType to its parameter types.
* Merge pull request #2045 from dotty-staging/fix-hlist-hmapodersky2017-03-091-14/+11
|\ | | | | Fix type inference for HLists and HMaps
| * Fix handling of dependent method typesMartin Odersky2017-03-011-2/+3
| | | | | | | | | | Need to use fresh PolyParams instead of WildcardTypes if constraint is committable.
| * Systematic treatment of result types of dependent methodsMartin Odersky2017-02-281-14/+10
| | | | | | | | | | | | We approximate dependencies to parameters by Wildcards. This was already done in one place, is now done in other places as well, instead of doing nothing for dependent methods.
* | Merge pull request #2031 from dotty-staging/fix-#2030odersky2017-03-031-1/+1
|\ \ | |/ |/| Fix #2030: Don't chain implicit conversions
| * Don't chain implicit conversionsMartin Odersky2017-02-271-1/+1
| | | | | | | | | | | | | | When inferring a view, we are not allowed to use another implicit conversion to adapt its result. Fixing this revealed another problem where we have to re-enable implicit conversions when pre-typing arguments in overloading resolution.
* | Fix #2033: Improve handling of unresolved overloaded argumentsMartin Odersky2017-02-271-1/+10
|/
* Merge pull request #2015 from dotty-staging/add-pf-overloadingodersky2017-02-231-27/+27
|\ | | | | Add overloading support for case-closures
| * Drop stray printlnMartin Odersky2017-02-211-1/+1
| |
| * Extend argument pretyping to case-closuresMartin Odersky2017-02-211-32/+25
| |
| * Add overloading support for case-closuresMartin Odersky2017-02-211-1/+8
| | | | | | | | | | | | case-closures (which are represented as Match nodes) have a known arity just like other function literals. So shape analysis for overloading resolution should apply to them as well.
* | typedUnApply#trySelectUnapply: small cleanupGuillaume Martres2017-02-181-6/+6
| | | | | | | | | | | | | | | | | | Previously, `specificProto` was a def even though it is always called, this is because in cece884812143c6c8090ce08c6321bd4a1d52ea6, the usages of `specificProto` and `genericProto` were swapped. We fix this by only defining the protos where they are used. Incidentally, this mean that the calls to UnapplyFunProto will use the correct Context inside `tryEither`, although in this case this shouldn't matter.
* | typedApply: Avoid using incorrect context in tryEitherGuillaume Martres2017-02-181-1/+1
|/ | | | | | | | Previously, the following code accidentally used the implicit Context parameter of `typedApply`: tryEither { implicit ctx => typedOpAssign
* Fix #1991: Use classtag where available in unapplyMartin Odersky2017-02-171-1/+1
|
* More lenient handling of mixed parameterless and nullary methodsMartin Odersky2016-12-201-12/+14
| | | | | When faced with a denotation that combines parameterless and nullary method definitions (toString is a common example), ignore any redundant () applications.
* Merge pull request #1775 from dotty-staging/add-implicit-funtypesodersky2016-12-181-6/+18
|\ | | | | Add implicit function types
| * Take nesting into account when ranking implicitsMartin Odersky2016-12-171-4/+16
| | | | | | | | | | | | This will need a spec change. It's necessary in order not to confuse synthetic implicits with each other or with explicit ones in the environment.
| * Refactor function operations in DefinitionsMartin Odersky2016-12-171-2/+2
| | | | | | | | | | | | | | | | | | 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.
* | Make errors are not swept under the carpetMartin Odersky2016-12-171-3/+3
|/ | | | | | | | | Typer#ensureReported's comment outlines an example where errors could go unreported, resulting in error trees after typer without any reported error messages. This commit makes sure that at least one error is reported if a tree node has an error type. Fixes #1802.
* Merge pull request #1801 from dotty-staging/fix-#1790Dmitry Petrashko2016-12-161-18/+52
|\ | | | | Fix #1790: Change by-name pattern matching.
| * Implement new rules for name-based pattern matchingMartin Odersky2016-12-151-17/+27
| | | | | | | | This implements the rules laid down in #1805.
| * Change by-name pattern matching.Martin Odersky2016-12-141-19/+43
| | | | | | | | New implementation following the scheme outlined in #1790.
* | Drop explicit types for local implicit valsMartin Odersky2016-12-121-1/+1
|/ | | | | Drop explicit types for local implicit vals of type Context and Position. Exercises the functionality and shortens the code.
* Add explanationMartin Odersky2016-12-021-0/+22
|
* Fix #1757: Be more careful about positions of type variable bindersMartin Odersky2016-12-011-3/+10
| | | | | | | | | | | | | | We interpolate a type variable if the current tree contains the type variables binding tree. Previously, this was the application owning the variable. However, sometimes this tree is transformed so that the containment test fails, and type variables are instantiated too late (in the case of #1757 this was never). We fix this by - setting the binding tree to the type tree that first contains the type variable - making sure that tree is never copied literally anywhere else. It's a tricky dance, but I believe we got it right now.
* Move compiler and compiler tests to compiler dirFelix Mulder2016-11-221-0/+1351