| 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.
|
| |
| |
| |
| |
| |
| | |
If we do not do that, any type variables in the parent type get interpolated
later, when the whole primary constructor is typed. But by then we miss the
context of what their variance was.
|
|\ \
| | |
| | | |
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*.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | | |
Remove unused functionality
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Start scheme where unmangling is done by NameKinds instead of
in NameOps.
Also add namekinds for protected accessors.
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
We now handle only semantic names. Also, name extractor tags
and TASTY name tags are now aligned.
|
| | |
| | |
| | |
| | | |
nameddefaults.scala now compiles without crashing
|
|\ \ \
| | | |
| | | | |
Fix #2142: Skolemize arguments of dependent methods if necessary
|
| | | |
| | | |
| | | |
| | | | |
Change name and align order of parameters.
|
| | |/
| |/|
| | |
| | | |
This was missing before, led to errors not being detected.
|
|\ \ \
| |/ /
|/| | |
Fix #2198: Don't widen module singletons
|
| |/
| |
| |
| |
| |
| |
| |
| | |
Since module classes are a compiler-generated construct that's not directly
visible to programmers, it seems better not to automatically widen a module
singleton to its underlying class.
Fixes #2198.
|
|/
|
|
| |
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.
|
| |
|
|
|
|
| |
Use fromParams instead.
|
|
|
|
|
| |
- 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 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.
|
|\
| |
| | |
Add "enum" construct
|
| |
| |
| |
| | |
This commit can hopefully be reverted once #2121 is in.
|
| | |
|
|\ \
| | |
| | | |
Make leak avoidance more robust
|
| |/
| |
| |
| |
| |
| | |
If class files are missing, finding an underlying class
reference might give a NoType. This caused an asInstanceOf
to fail. We now handle that case gracefully.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`checkNoPrivateLeaks` can force a lot of things, this lead to
hard-to-reproduce issues in unpickling because we called
`checkNoPrivateLeaks` on the type parameters of a class before anything
in the class was indexed. We fix this by making sure that
`checkNoPrivateLeaks` never transforms type symbols, only term symbols,
therefore we can unpickle type parameters without forcing too many
things. tests/neg/leak-type.scala illustrates the new restriction that
this necessitates.
|
|\ \
| |/
|/| |
Fixes `@unchecked` warnings
|
| | |
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In #2139 I added code to create dummy companions for companion-less
objects, but not for companion-less classes because I thought it wasn't
needed. But it turns out that even if the classpath only has `Foo.class`
and not `Foo$.class`, a module for `Foo` is entered by
`initializeFromClassPath` when it calls `enterClassAndModule`, so we
have to add dummy companions to classes. I don't have a test to
illustrate this issue, but note that it fixes the incremental
compilation bug demonstrated by
https://github.com/dotty-staging/dotty/commits/incremental-compilation-bug.
Note: I verified that adding a dummy companion to "class Foo" did not
cause the backend to emit a Foo$.class, so this should have no visible
impact.
|
|
|
|
|
|
|
|
|
|
|
| |
The previous commit introduced two new usages of `denotNamed` which broke
tests/run/t1987b because `denotNamed` indirectly calls `packageObj`
which caches the package object, except that at this point the package
object is not yet entered, so the cache was incorrect. We fix this by
using `effectiveScope.lookup` instead since we only need to look into
the current scope, this is also true for the two existing usage of
`denotNamed` in `createCompanionLinks` so they were also replaced by
`effectiveScope.lookup`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, we sometimes ended up forcing a companion class symbol from
a previous run or from the classpath which lead to weird issues like in
`false-companion`. Even if we end up not forcing such a symbol, its
presence can still lead to issue: before this commit incremental
compilation of `dotty-compiler-bootstrapped` was broken because we
recorded a false dependency on the non-bootstrapped `dotty-compiler`
jar.
The added test is currently marked pending because it does not work with
JUnit (which doesn't handle separate compilation), only partest. I
didn't managed to get it to work right, and this won't be necessary once
our testing framework is overhauled by
https://github.com/lampepfl/dotty/pull/2125 anyway, so I'll just have to
remember to enable this test afterwards.
|
|\
| |
| | |
Fix position of errors in Inliner TreeTypeMap
|