| 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.
|
|\
| |
| | |
Fix #2212: Avoid imports in the wrong namespace
|
| |
| |
| |
| |
| |
| | |
Don't issue an error if when considering a named import that
refers to a valoe or type which does not exist. Instead, disregard
the import an continue.
|
|\ \
| | |
| | | |
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*.
|
| | | |
|
| |/
|/|
| |
| |
| | |
We now handle only semantic names. Also, name extractor tags
and TASTY name tags are now aligned.
|
|/
|
|
| |
function type
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
| |
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
|
| |
|
|
|
|
|
| |
To allow for dependencies between method type parameters, construct MethodTypes
from a closure that maps the currently constructed MethodType to its parameter types.
|
|
|
|
|
| |
This fix is inspired by 6c91684, but I couldn't tell you why it works
exactly, it's just something I tried.
|
|\
| |
| | |
Fix #2066: Don't qualify private members in SelectionProto's...
|
| |
| |
| |
| |
| | |
Now we never match `? { name: T }` with types that
have only a private `name` member. This is what scalac does, too.
|
| |
| |
| |
| | |
No more try-again business necessary.
|
|/
|
|
|
|
| |
The essential change is that we do not throw away more
precise info of the avoided type if the expected type
is fully defined.
|
|
|
|
|
|
|
| |
It's hard to predict for defKind all the desugarings that can be
applied to a definition. Better to do it once the desugarings have been
applied. NoInit and PureInterface are both tested only after Typer,
so it's OK to delay their initialization until regular Typer.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Drop the [type T] syntax, and what's associated to make it work.
Motivation: It's an alternative way of doing things for which there seems
to be little need. The implementation was provisional and bitrotted during
the various iterations to introduce higher-kinded types. So in the end the
complxity-cost for language and compiler was not worth the added benefit
that [type T] parameters provide.
Noe that we still accept _named arguments_ [A = T] in expressions; these are useful
for specifying some parameters and letting others be inferred.
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
Treat implicit by-name arguments as lazy values
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
With the previous rules, the two test cases produce a
diverging implicit expansion. We avoid this by creating
for every implicit by-name argument of type T a lazy implicit
value of the same type. The implicit value is visible for all
nested implicit searches of by-name arguments. That way,
we tie the knot and obtain a recursive lazy value instead of
a diverging expansion.
|
|\ \
| | |
| | | |
Avoid accidental captures of Context
|
| | |
| | |
| | |
| | |
| | | |
ImportInfo#toString required the ctx parameter,so it was replaced by
ImportInfo#toText.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| | |
Inlining is only well-defined if the body to inline does not
have any errors. We therefore check for errors before we
perform any transformation of trees related to inlining.
The error check is global, i.e. we stop on any error
not just on errors in the code to be inlined. This is a safe
approximation, of course.
|
| |
| |
| |
| |
| |
| | |
We cannot assume that the untyped rhs of the bind is a `Typed` tree,
with extractors it might be an `Apply` node, and in general it might
also be a `Parens` node.
|
|/ |
|
|\
| |
| | |
Factor out logic for scala functions.
|
| |
| |
| |
| |
| |
| |
| |
| | |
* 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.
|
|/
|
|
|
|
| |
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.
|
|\
| |
| | |
Fix #1501 - Check trait inheritance condition
|
| |
| |
| |
| |
| | |
We need to check a coherence condition between the superclass
of a trait and the superclass of an inheriting class or trait.
|
|\ \
| |/
|/| |
Better positions for infix operations
|
| |
| |
| |
| |
| |
| |
| |
| | |
This has two advantages:
- We can distinguish BackquotedIdent from Ident, allowing the user to
use a defined "type `&`", see testcase.
- We get better positions for the operators. This is useful in IDEs, for
example to get the type at point.
|
|/ |
|
|\
| |
| | |
Implement structural type member access
|
| |
| |
| |
| | |
We can't handle them with the proposed scheme. I made a note in #1886.
|
| | |
|
| |
| |
| |
| | |
New scheme for implementing structural type member access.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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 #1867: Set position of empty refined types
|
| | |
|