aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #2209 from dotty-staging/fix-#2152odersky2017-04-131-8/+9
|\ | | | | Fix #2152: Instantiate dependent result type parameters
| * Fix #2152: Instantiate dependent result type parametersMartin Odersky2017-04-111-8/+9
| | | | | | | | | | | | | | #2152 shows that dependent result type parameters can end up in the types of terms, so we have to eliminate them. If we don't we get orphan parameters in pickling. Fix method name and comment
* | Revert <: Product requierment in pattern matchingOlivier Blanvillain2017-04-132-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 #2225 from dotty-staging/fix-#2192odersky2017-04-111-26/+22
|\ \ | | | | | | Fix #2212: Avoid imports in the wrong namespace
| * | Fix #2212: Avoid imports in the wrong namespaceMartin Odersky2017-04-111-26/+22
| | | | | | | | | | | | | | | | | | 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.
* | | Add fullyDefinedType for class parent typesMartin Odersky2017-04-111-1/+1
| |/ |/| | | | | | | | | 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.
* | Merge pull request #1938 from dotty-staging/named-based-patmatFelix Mulder2017-04-112-8/+12
|\ \ | | | | | | Change case class desugaring and decouple Products and name-based-pattern-matching
| * | Move isProductSubType to Applications & rename to canProductMatchOlivier Blanvillain2017-04-112-5/+7
| | |
| * | Decouple Product and pattern-matchingOlivier Blanvillain2017-04-062-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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*.
* | | Lazy entering of names with internal $'s in package scopesMartin Odersky2017-04-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Names are no longer SeqsMartin Odersky2017-04-112-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Cleanups of NameOpsMartin Odersky2017-04-112-16/+11
| | | | | | | | | | | | Remove unused functionality
* | | Make outer select names semanticMartin Odersky2017-04-111-6/+3
| | |
* | | 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.
* | | Rename NameExtractor -> NameKindMartin Odersky2017-04-114-4/+4
| | |
* | | Make freshName semanticMartin Odersky2017-04-113-7/+9
| | |
* | | Get rid of SuperAccessor flagMartin Odersky2017-04-111-1/+1
| | |
* | | Drop Config.semanticNames optionMartin Odersky2017-04-111-1/+2
| | | | | | | | | | | | | | | We now handle only semantic names. Also, name extractor tags and TASTY name tags are now aligned.
* | | Bug fixesMartin Odersky2017-04-111-1/+1
| | | | | | | | | | | | nameddefaults.scala now compiles without crashing
* | | Merge pull request #2215 from dotty-staging/#2142odersky2017-04-112-4/+21
|\ \ \ | | | | | | | | Fix #2142: Skolemize arguments of dependent methods if necessary
| * | | Align safe parameter substitution with other subst methodsMartin Odersky2017-04-102-6/+6
| | | | | | | | | | | | | | | | Change name and align order of parameters.
| * | | Skolemize arguments to dependent methods as necessary.Martin Odersky2017-04-102-4/+21
| | |/ | |/| | | | | | | This was missing before, led to errors not being detected.
* | | Merge pull request #2206 from dotty-staging/fix-#2198odersky2017-04-101-2/+4
|\ \ \ | |/ / |/| | Fix #2198: Don't widen module singletons
| * | Fix #2198: Don't widen module singletonsMartin Odersky2017-04-091-2/+4
| |/ | | | | | | | | | | | | | | 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.
* / Fix #2192: Fullow supertypes when determining whether an expect type is a ↵Martin Odersky2017-04-091-2/+12
|/ | | | function type
* PolishingsMartin Odersky2017-04-061-1/+1
|
* Narrow matches from TypeLambda to HKTypeLambda where appropriateMartin Odersky2017-04-061-3/+3
|
* Merge MethodType and PolyType functionality where possibleMartin Odersky2017-04-065-15/+7
| | | | | | 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.
* Split HKTypeLambda from PolyTypeMartin Odersky2017-04-064-17/+17
|
* Eliminate LambdaAbstractMartin Odersky2017-04-064-7/+6
| | | | Use fromParams instead.
* Further refactoringsMartin Odersky2017-04-067-19/+14
| | | | | - Use TypeLambda instead of PolyType. - Further harmonize factory operations
* Rename PolyTypeTree -> LambdaTypeTreeMartin Odersky2017-04-063-10/+10
|
* Eliminate MethodOrPolyMartin Odersky2017-04-062-2/+2
| | | | Replace with LambdaType
* replace derived{Method,Poly}Type with derivedLambdaTypeMartin Odersky2017-04-065-5/+5
|
* Rename PolyParam --> TypeParamRefMartin Odersky2017-04-067-18/+18
|
* Refactor ParamRef so that no type params are neededMartin Odersky2017-04-061-1/+1
|
* Harmonize paramTypes and paramBoundsMartin Odersky2017-04-0614-47/+47
| | | | | | 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-067-10/+10
| | | | | and generalize MethodParam to ParamRef, and TypeParamInfo to ParamInfo
* 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.
* Merge pull request #1958 from dotty-staging/add-enumodersky2017-04-062-2/+8
|\ | | | | Add "enum" construct
| * Avoid assertion failure on neg testMartin Odersky2017-04-041-1/+8
| | | | | | | | This commit can hopefully be reverted once #2121 is in.
| * Allow value expansion of modules in mergeCompanionDefsMartin Odersky2017-04-041-1/+0
| |
* | Merge pull request #2190 from dotty-staging/fix-robust-avoidanceGuillaume Martres2017-04-041-2/+8
|\ \ | | | | | | Make leak avoidance more robust
| * | Make leak avoidance more robustMartin Odersky2017-04-041-2/+8
| |/ | | | | | | | | | | 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: Do not allow types to refer to leaky aliasesGuillaume Martres2017-04-041-6/+17
| | | | | | | | | | | | | | | | | | | | | | `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.
* | Merge pull request #2168 from allanrenucci/warningsGuillaume Martres2017-04-041-1/+1
|\ \ | |/ |/| Fixes `@unchecked` warnings
| * Addresses review commentsAllan Renucci2017-04-041-1/+1
| |
| * Fixes @unchecked warningsAllan Renucci2017-04-031-1/+1
| |
* | Create dummy companions for classes without a real oneGuillaume Martres2017-03-291-5/+16
|/ | | | | | | | | | | | | | | | 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.
* Namer#createCompanionLinks: avoid using denotNamedGuillaume Martres2017-03-241-4/+4
| | | | | | | | | | | 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`.