aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Commit message (Collapse)AuthorAgeFilesLines
* Tweak logic for hk type comparisonsMartin Odersky2017-04-091-4/+3
|
* Narrow matches from TypeLambda to HKTypeLambda where appropriateMartin Odersky2017-04-061-1/+1
|
* Merge MethodType and PolyType functionality where possibleMartin Odersky2017-04-061-30/+30
| | | | | | 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
|
* Generalize comparisons from PolyTypes to TypeLambdasMartin Odersky2017-04-061-7/+7
|
* Further refactoringsMartin Odersky2017-04-061-16/+16
| | | | | - Use TypeLambda instead of PolyType. - Further harmonize factory operations
* Rename PolyParam --> TypeParamRefMartin Odersky2017-04-061-16/+16
|
* Harmonize paramTypes and paramBoundsMartin Odersky2017-04-061-6/+6
| | | | | | 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-8/+8
| | | | | and generalize MethodParam to ParamRef, and TypeParamInfo to ParamInfo
* Encode variances in parameter namesMartin Odersky2017-04-061-4/+4
| | | | | | | | | | 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.
* Better type inference in harmonizeUnionGuillaume Martres2017-03-181-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, the added testcase failed because the type of `inv` was inferred to be `Inv[Any]` instead of `Inv[Int]`. The situation looks like this: def inv(cond: Boolean) = if (cond) new Inv(1) // : Inv[A] where A >: Int else Inv.empty // : Inv[A'] where A' unconstrained // : Inv[A] | Inv[A'] To get the type of `inv`, we call `harmonizeUnion` which will take the lub of `Inv[A]` and `Inv[A']`, eventually this mean that we do: A' <:< A But since `harmonizeUnion` uses `fluidly`, this does not result in `A'` getting constrained to be a subtype of `A`, instead we constrain `A` to the upper bound of `A'`: Any <:< A We use `fluidly` to avoid creating OrTypes in `lub`, but it turns out that there is a less aggressive solution: `lub` calls `mergeIfSuper` which then calls `isSubTypeWhenFrozen`, if we just make these subtype calls non-frozen, we can achieve what we want. This is what the new `lub` parameter `canConstrain` allows.
* 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.
* Merge pull request #2045 from dotty-staging/fix-hlist-hmapodersky2017-03-091-14/+19
|\ | | | | Fix type inference for HLists and HMaps
| * Adress reviewers commentsMartin Odersky2017-03-031-1/+1
| |
| * More testsMartin Odersky2017-03-021-1/+1
| | | | | | | | and a typo fixed
| * Make alignArgsInAnd safe and turn it on by defaultMartin Odersky2017-03-011-2/+2
| | | | | | | | | | | | | | Turned out hmaps.scala requires the arg alignment to compile. So we have our first counterexample that we cannot drop this hack. Now it is made safe in the sense that no constraints get lost anymore.
| * Don't align aliases in refined types by defaultMartin Odersky2017-02-281-14/+19
| | | | | | | | | | | | | | | | | | | | | | We previously tried to force S1 and S2 be the same type when encountering a lub like `T1 { A = S1 } & T2 { A = S2 }`. The comments in this commit explain why this is unsound, so this rewrite is now made subject to a new config option, which is off by default. I verified that the new behavior does not affect the performance of the junit tests.
* | Drop named type parameters in classesMartin Odersky2017-03-041-13/+1
|/ | | | | | | | | | | | | 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.
* Fix #2000: Make implicit and non-implicit functions incomparable with <:<Martin Odersky2017-02-211-1/+1
| | | | | | | | | Implicit and non-implicit functions are incomparable with <:<, but are treated as equivalent with `matches`. This means implicit and non-implicit functions of the same types override each other, but RefChecks will give an error because their types are not subtypes. Also contains a test for #2002.
* Add more explanation.Martin Odersky2017-01-111-0/+3
|
* Fix #1891: Don't add redundant constraintMartin Odersky2017-01-101-2/+10
| | | | | | | | Before adding a constraint, make sure there is no way the two types are already in a subtype relation. Adding redundant constraints is problematic because we might introduce cycles. See i1891.scala for a test.
* Fix subtyping of hk types with wildcard argumentsMartin Odersky2016-12-201-2/+8
| | | | | Argument comparison of hk types did not take into account that the compared types could have themselves wildcard arguments.
* Merge pull request #1775 from dotty-staging/add-implicit-funtypesodersky2016-12-181-4/+4
|\ | | | | Add implicit function types
| * Changes for matching and subtyping implicit methodsMartin Odersky2016-12-171-4/+4
| | | | | | | | | | | | Implicitness is ignored for matching (otherwise apply in ImplicitFunction could not shadow apply in Function). And explicit trumps implicit in subtyping comparisons.
* | Make errors are not swept under the carpetMartin Odersky2016-12-171-2/+2
|/ | | | | | | | | 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.
* Drop explicit types for local implicit valsMartin Odersky2016-12-121-2/+2
| | | | | Drop explicit types for local implicit vals of type Context and Position. Exercises the functionality and shortens the code.
* handle ConstantType in TypeComparerReto Hablützel2016-12-041-0/+5
|
* Fix $1753 Better comparison of path typesMartin Odersky2016-11-301-2/+4
| | | | | | In this case, a path went through a type parameter which was aliased to a singleton type. Need to dealias to get to the special case handling two paths.
* Move compiler and compiler tests to compiler dirFelix Mulder2016-11-221-0/+1502