| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
Change case class desugaring and decouple Products and name-based-pattern-matching
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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*.
|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| | |
Start scheme where unmangling is done by NameKinds instead of
in NameOps.
Also add namekinds for protected accessors.
|
| |
| |
| |
| | |
Change name and align order of parameters.
|
|/
|
|
| |
This was missing before, led to errors not being detected.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
- Use TypeLambda instead of PolyType.
- Further harmonize factory operations
|
|
|
|
| |
Replace with LambdaType
|
| |
|
| |
|
|
|
|
|
|
| |
MethodTypes have paramTypes whereas PolyTypes have paramBounds.
We now harmonize by alling both paramInfos, and parameterizing
types that will become common to both.
|
|
|
|
|
| |
and generalize MethodParam to ParamRef, and
TypeParamInfo to ParamInfo
|
|
|
|
| |
This commit can hopefully be reverted once #2121 is in.
|
|
|
|
| |
Take parameter dependencies into account when typechecking arguments.
|
|
|
|
|
| |
To allow for dependencies between method type parameters, construct MethodTypes
from a closure that maps the currently constructed MethodType to its parameter types.
|
|\
| |
| | |
Fix type inference for HLists and HMaps
|
| |
| |
| |
| |
| | |
Need to use fresh PolyParams instead of WildcardTypes
if constraint is committable.
|
| |
| |
| |
| |
| |
| | |
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.
|
|\ \
| |/
|/| |
Fix #2030: Don't chain implicit conversions
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/ |
|
|\
| |
| | |
Add overloading support for case-closures
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
|
|
|
| |
Previously, the following code accidentally used the implicit Context
parameter of `typedApply`:
tryEither {
implicit ctx => typedOpAssign
|
| |
|
|
|
|
|
| |
When faced with a denotation that combines parameterless and nullary method
definitions (toString is a common example), ignore any redundant () applications.
|
|\
| |
| | |
Add implicit function types
|
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
Fix #1790: Change by-name pattern matching.
|
| |
| |
| |
| | |
This implements the rules laid down in #1805.
|
| |
| |
| |
| | |
New implementation following the scheme outlined in #1790.
|
|/
|
|
|
| |
Drop explicit types for local implicit vals of type Context
and Position. Exercises the functionality and shortens the code.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|