aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/Typer.scala
Commit message (Collapse)AuthorAgeFilesLines
* Revert <: Product requierment in pattern matchingOlivier Blanvillain2017-04-131-1/+1
| | | | | | | | | | | | | | | 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.
* | Merge pull request #1938 from dotty-staging/named-based-patmatFelix Mulder2017-04-111-3/+2
|\ \ | | | | | | Change case class desugaring and decouple Products and name-based-pattern-matching
| * | Move isProductSubType to Applications & rename to canProductMatchOlivier Blanvillain2017-04-111-1/+1
| | |
| * | Decouple Product and pattern-matchingOlivier Blanvillain2017-04-061-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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*.
* | | Rename NameExtractor -> NameKindMartin 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.
* | 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
|
* Merge MethodType and PolyType functionality where possibleMartin Odersky2017-04-061-4/+2
| | | | | | 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-061-2/+2
|
* Rename PolyTypeTree -> LambdaTypeTreeMartin Odersky2017-04-061-6/+6
|
* Eliminate MethodOrPolyMartin Odersky2017-04-061-1/+1
| | | | Replace with LambdaType
* Rename PolyParam --> TypeParamRefMartin Odersky2017-04-061-1/+1
|
* Harmonize paramTypes and paramBoundsMartin Odersky2017-04-061-8/+8
| | | | | | 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
* Check there are no forward dependencies to method parametersMartin Odersky2017-03-141-0/+1
|
* Construct MethodTypes from parameter closureMartin Odersky2017-03-141-4/+4
| | | | | To allow for dependencies between method type parameters, construct MethodTypes from a closure that maps the currently constructed MethodType to its parameter types.
* Fix #2089: Error when compiling ParSetLike, ParSet, SetLike, in this orderGuillaume Martres2017-03-131-0/+7
| | | | | This fix is inspired by 6c91684, but I couldn't tell you why it works exactly, it's just something I tried.
* Merge pull request #2080 from dotty-staging/fix#-2066odersky2017-03-121-1/+1
|\ | | | | Fix #2066: Don't qualify private members in SelectionProto's...
| * Alternative fix of #2066.Martin Odersky2017-03-121-1/+1
| | | | | | | | | | Now we never match `? { name: T }` with types that have only a private `name` member. This is what scalac does, too.
* | Improve definition and doc comment for ensureNoLeaksMartin Odersky2017-03-121-22/+21
| | | | | | | | No more try-again business necessary.
* | Fix #1569: Improve avoidance algorithmMartin Odersky2017-03-121-4/+10
|/ | | | | | The essential change is that we do not throw away more precise info of the avoided type if the expected type is fully defined.
* Fix #2067: Compute defKind at Typer, not NamerMartin Odersky2017-03-081-0/+1
| | | | | | | 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 named type parameters in classesMartin Odersky2017-03-041-16/+14
| | | | | | | | | | | | | 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.
* 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.
* Merge pull request #1993 from dotty-staging/add-lazy-implicitsodersky2017-02-251-1/+1
|\ | | | | Treat implicit by-name arguments as lazy values
| * Treat implicit by-name arguments as lazy valuesMartin Odersky2017-02-171-1/+1
| | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #1974 from dotty-staging/fix/ctx-captureodersky2017-02-211-1/+1
|\ \ | | | | | | Avoid accidental captures of Context
| * | ImportInfo: removed ctx parameter from constructorGuillaume Martres2017-02-191-1/+1
| | | | | | | | | | | | | | | ImportInfo#toString required the ctx parameter,so it was replaced by ImportInfo#toText.
* | | Don't inline when errors are detectedMartin Odersky2017-02-211-1/+2
|/ / | | | | | | | | | | | | | | | | 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.
* | Fix binding of x @ (e: T) in ClassTag-based patmatGuillaume Martres2017-02-171-7/+5
| | | | | | | | | | | | 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.
* | Fix #1991: Use classtag where available in unapplyMartin Odersky2017-02-171-13/+20
|/
* Merge pull request #1962 from dotty-staging/centralize-function-logicodersky2017-02-161-4/+2
|\ | | | | Factor out logic for scala functions.
| * Add checks for synthetic functions and erased functions.Nicolas Stucki2017-02-131-4/+2
| | | | | | | | | | | | | | | | * 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.
* | Fix #1976: Hack to support scala.xml's $scope (#1977)odersky2017-02-141-0/+5
|/ | | | | | 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.
* Merge pull request #1931 from dotty-staging/fix-#1501Guillaume Martres2017-02-131-0/+2
|\ | | | | Fix #1501 - Check trait inheritance condition
| * Fix #1501 - Check trait inheritance conditionMartin Odersky2017-02-081-0/+2
| | | | | | | | | | We need to check a coherence condition between the superclass of a trait and the superclass of an inheriting class or trait.
* | Merge pull request #1941 from dotty-staging/fix/infix-posodersky2017-02-081-2/+2
|\ \ | |/ |/| Better positions for infix operations
| * Represent untyped operators as Ident instead of NameGuillaume Martres2017-02-051-2/+2
| | | | | | | | | | | | | | | | 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.
* | Allow implicit-by-name parametersMartin Odersky2017-02-081-1/+2
|/
* Merge pull request #1881 from dotty-staging/add-structural-selectodersky2017-02-011-4/+4
|\ | | | | Implement structural type member access
| * Disallow polymorphic refinements in stuctural types.Martin Odersky2017-01-281-1/+3
| | | | | | | | We can't handle them with the proposed scheme. I made a note in #1886.
| * CleanupsMartin Odersky2017-01-051-1/+0
| |
| * Implement structural type member accessMartin Odersky2017-01-051-4/+3
| | | | | | | | New scheme for implementing structural type member access.
* | Adopt scala's scheme for root import hidingMartin Odersky2017-01-151-1/+1
| | | | | | | | | | | | | | | | | | | | 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 #1878: Use Inline on final vals.Nicolas Stucki2017-01-101-0/+22
| |
* | Merge pull request #1887 from dotty-staging/fix-#1867Guillaume Martres2017-01-071-1/+1
|\ \ | |/ |/| Fix #1867: Set position of empty refined types
| * Fix #1867: Set position of empty refined typesMartin Odersky2017-01-041-1/+1
| |