aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeComparer.scala
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #1634 from dotty-staging/change-tasty-pos-ctdodersky2016-11-211-1/+1
|\ | | | | Towards correct positions in TASTY types
| * Merge syntheticTypeParamNames and syntheticLambdaParamNamesMartin Odersky2016-11-111-1/+1
| | | | | | | | | | It seems like overengineering to use different names for poly methods in definitions and synthetic lambdas.
* | Add warning on != with same type fix isNullable.Nicolas Stucki2016-11-171-1/+1
|/ | | | | Note that without the fix console tests will fail and without the warning there is no way to test the fix.
* Fix #1515: Don't narrow gadt bounds when frozenMartin Odersky2016-10-141-21/+22
| | | | Fixes #1515. Review by @smarter.
* Merge GenericType, TypeLambda and PolyTypeMartin Odersky2016-10-121-7/+8
|
* Refactor from distribute{And,Or} to {meet,join}InfoMartin Odersky2016-10-121-85/+2
| | | | | | | The refactored logic only applies to infos of denotations, not general types. The reactoring avoids special cases down the road then PolyTypes and MethodTypes can be used for terms as well as type(bounds).
* Make PolyType a subtype of TypeLambdaMartin Odersky2016-10-121-10/+0
|
* Harmonize PolyType and TypeLambdaMartin Odersky2016-10-121-1/+1
| | | | | | Let them inherit the same traits and push as much functionality as possibly into the common superclass GenericType.
* Make TypeLambdas not be ValueTypesMartin Odersky2016-10-121-1/+1
|
* Fix cutting problemMartin Odersky2016-10-111-2/+5
| | | | | | | | | | | | | Test case: orInf.scala. This showed a problem where an `either` operation had to arbitrarily pick one constraint over another, leading to a type error down the line. What happened was that a `constrainResult` generated the constraint Set[A] <: Set[String] | Set[Int] But this constraint cannot be simplified without a cut and a resulting loss of information. We avoid the problem by not constraining the result if the prototype is a disjunction.
* Handle feature interaction between subtyping or types and hk typesMartin Odersky2016-10-111-2/+12
|
* Clean up config.Printers importsOlivier Blanvillain2016-09-231-1/+1
| | | | And remove the not used Printer#echo
* Generalize self-referential member comparisons.Martin Odersky2016-08-261-3/+5
| | | | | | | The special case in hasMatchingMember dealing with self-refential members has to be generalized to deal lower and upper bounds. Test case is t762.scala
* Make expressions using GADTs type check in later phasesMartin Odersky2016-08-261-2/+17
| | | | | | GADT logic is lost after PatMat. To make code typecheck, the typer should already insert casts where a subtype check succeeded because it involved bounds established by a GADT comparison.
* Fixes in comparisons between singleton typesMartin Odersky2016-08-181-8/+4
| | | | | Needed to address problem shown by z1720.scala. Another fix to avoidance is needed to make it pass completely.
* Harden copmpareHkApply for ill-typed programsMartin Odersky2016-08-171-1/+1
| | | | Turn assertion into test. Without this, neg/tcpoly_overloaded.scala fails.
* New string infterpolatorsMartin Odersky2016-08-161-2/+1
| | | | | | Roll `sm` and `i` into one interpolator (also called `i`) Evolve `d` to `em` interpolator (for error messages) New interpolator `ex` with more explanations, replaces disambiguation.
* Fix #1447: Make X$ <:< X.type when X is an objectGuillaume Martres2016-08-091-1/+7
| | | | This allows objects to be easily aliased
* Take curried type lambdas into accountMartin Odersky2016-07-221-5/+14
| | | | | Adapt operations TypeApplications and TypeComparer to account for the possibilities of curried type lambdas.
* Merge pull request #1377 from dotty-staging/#1365odersky2016-07-151-8/+18
|\ | | | | Fix 1365: Fix bindings in patterns
| * Fix 1365: Fix bindings in patternsMartin Odersky2016-07-091-8/+18
| | | | | | | | | | | | We need to compare pattern types with expected types in order to derive knowledge about pattern-bound variables. This is done use the mechanism of gadt bounds.
* | Bounds of type lambdas compare contravariantlyMartin Odersky2016-07-151-12/+18
| | | | | | | | | | | | | | Enable checking of bounds when comparing type lambdas. This invalidates a pattern used in t2994 and potentially other code, where a bound [X] -> Any is used as a template that is a legal supertype of all other bounds. The old behavior is still available under language:Scala2.
* | Optimize hk comparisonsMartin Odersky2016-07-131-11/+11
| | | | | | | | Use (cached) superType where possible.
* | Avoid dealiasing on type applicationMartin Odersky2016-07-121-3/+4
| | | | | | | | | | | | | | | | | | When applying a type alias of a type lambda, keep the original application instead of reducing. But reduce anyway if - the reduced type is an application where the type constructor has the same kind as the original type constructor, or - some of the arguments are wildcards.
* | Address reviewers commentsMartin Odersky2016-07-111-8/+11
| |
* | Fix SI-2712Martin Odersky2016-07-111-13/+40
| | | | | | | | | | Allows partially instantiated types as type constrictors when inferring higher-kinded types.
* | Drop compareAliasedRefinedMartin Odersky2016-07-111-36/+3
| | | | | | | | | | | | | | | | If there is a new named type param scheme it will almost certainly not need something like compareAliasedRefined. Also: harden printer to compute less and thereby avoid a possible NPE.
* | Add a case where caching was missing.Martin Odersky2016-07-111-3/+4
| | | | | | | | Gave several times improvement for linker.
* | Unify aliases when taking a lub.Martin Odersky2016-07-111-2/+18
| |
* | Drop Config.checkKindsMartin Odersky2016-07-111-1/+1
| | | | | | | | | | Allows us to drop also the involved knownHK method. Lots of other cleanups.
* | Refactorings of GenericTypes and underlying/upperboundMartin Odersky2016-07-111-8/+5
| | | | | | | | | | | | | | 1. Make genericType a trait instead of a class. 2. Make TypeLambda a type proxy 3. Split underlying in TypeProxy into underlying and superType 4. Cleanups in many other places
* | Cleanup of Signature matchingMartin Odersky2016-07-111-2/+2
| | | | | | | | | | Eliminate sameParams, add comments. Also, minor cleanups elsewhere.
* | Remove refinement encoding of hk typesMartin Odersky2016-07-111-160/+15
| | | | | | | | | | | | | | | | | | | | Remove the code that implemented the encoding of hk types using refinements. Drop the notion that RefinedTypes can be type parameters. This is no longer true under the new representation. Also, refactoring MemberBinding -> TypeParamInfo
* | Fixes to hk comparisonsMartin Odersky2016-07-111-14/+8
| | | | | | | | | | | | | | | | | | | | | | - Follow aliases in isMatchingApply - Avoid comparing with TypeBounds in compareHkApply - Generalize kind adaption in liftIfHK Previously we only covered EtaExpansion/reduction. Need to generalize this to the case where a type is partially applied. Test case is pos/partialApplications.scala
* | Beta-reduce with wildcard arguments if this is safe.Martin Odersky2016-07-111-6/+0
| | | | | | | | | | | | | | | | Makes pos/partialApplications compile. - Fix appliedTo for aliasTypes Returned a general TypeBounds instance before.
* | When comparing types revert eta-expansion as neededMartin Odersky2016-07-111-11/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | The problem is that some existential types read from Java (and Scala as well? not sure) appear as naked typerefs. They consequently get expanded via eta expansion to type lambdas. This commit compensates for this by collapsing an eta expansion if this can make a subtype tests succeed or a union or intersection be legal. Also, take hk types into account for liftToClasses Needs to special-treat TypeLambda and HKApply since otherwise we risk creating malformed And-types.
* | Drop bounds checking for type lambdasMartin Odersky2016-07-111-5/+13
| |
* | Handle TypeLambdas in findMemberMartin Odersky2016-07-111-6/+2
| |
* | Refactoring of PolyType and TypeLambdaMartin Odersky2016-07-111-9/+10
| | | | | | | | | | | | | | Make them each inherit from common BaseType GenericType. That way we avoid inheriting accidentally stuff from PolyType in TypeLambda. Also, Fix adaptation of type lambdas. Don't confuse them with PolyTypes.
* | Fix appliedTo and typeParams, and higher kinded subtyping testsMartin Odersky2016-07-111-52/+146
| | | | | | | | Add existential type elimination for HKApply
* | Start new, direct HK schemeMartin Odersky2016-07-111-24/+104
| | | | | | | | | | - Re-introduce newHK option. Label some things that will be removed with OLD.
* | Remove old hk schemeMartin Odersky2016-07-111-112/+31
| | | | | | | | | | | | | | | | | | | | | | | | - Simplify RefinedType - Drop recursive definition of RefinedThis - this is now taken over by RecType. - Drop RefinedThis. - Simplify typeParams The logic avoiding forcing is no longer needed. - Remove unused code and out of date comments.
* | Various tweaksMartin Odersky2016-07-111-33/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Swap order of subtype tests The theory is that if two refined types have the same refined name, then they are likely to be of related classes. So it seems more fruitful to check the argument before the typeconstructor because that way we test the part that's more likely to fail first. Rough observations seem to indicate a 3% improvement in the junit test time. - Cleanups Drop some unnecessary cases; improve comments. - Smarter handling of LazyRefs in betaReduce Try to combine type constructor and arguments under a common LazyRef. - Optimize RecType/RecType comparisons - Fix compareHkLambda, make it check variances.
* | Change testsMartin Odersky2016-07-111-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - compileMixed failed because there was a cycle between immutable.Seq (compiled) and parallel.ParSeq (loaded from classfile). Inspection of the completion log (turn completions Printer on) and the stack trace showed that there's nothing we can do here. The old hk scheme did not go into the cycle because it did not force an unrelated type. I believe with enough tweaking we would also hva egotten a cycle in the old hk scheme. The test is "fixed" by adding parallel.ParSeq to the files to compile. - Disable named parameter tests Those tests do not work yet with the revised hk scheme. Before trying to fix this, we should first decide what parts of named parameters should be kept.
* | Avoid infinite recursion when comparing recursive types.Martin Odersky2016-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous scheme goes into an infinite recursion if the recursive type does not contain a reference to itself. Also, make typeParams more defensive The problematic case is something like { z => CC { type hk$0 = z.hk$0; type(param) hk$0 } Here $hk0 becomes a type parameter through CC and the type lambda. It's true that such types are eliminated later on. But we want to avoid mispredictions at all points.
* | Avoid accidental creation of hk typesMartin Odersky2016-07-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Swap subtype tests Previous order could create constraints where hk type parameters got a * bound. (this is now caught in an assert). - Make underlyingClassRef work for hk types under new scheme. - Ensure that toAvoid does not creat hk from * types - Let getClass return a * type We will be pickier than before. An unapplied type such as `java.lang.Class` will always be an hk type. Hence, the type of getClass has to be appleid to [_] to make it a * type.
* | Add a second betaReduceMartin Odersky2016-07-111-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | The new one only reduces straight applications of type lambdas with definite arguments. It is called very early on appliedTo, and derivedRefinedType. The old one, now renamed to normalizeHkApply also handles wildcard arguments and can garbage collect general unneeded hk-refinements. It is called later, at various places. TODO: See what functionality of normalizeHkApply should go into betaReduce instead. Maybe we can even drop normalizeHkApply? However: need to be careful to maintain aliases for hk type inference.
* | Fixes to BetaReduce and asMemberOf; add a second betaReduceMartin Odersky2016-07-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new one only reduces straight applications of type lambdas with definite arguments. It is called very early on appliedTo, and derivedRefinedType. The old one, now renamed to normalizeHkApply also handles wildcard arguments and can garbage collect general unneeded hk-refinements. It is called later, at various places. TODO: See what functionality of normalizeHkApply should go into betaReduce instead. Maybe we can even drop normalizeHkApply? However: need to be careful to maintain aliases for hk type inference. Handle LazyRefs in BetaReduce Needs to be careful to not skip LazyRefs when dealiasing. - Fix^2 of asMemberOf: This fix ensures that - under the old hk scheme test succeeds for compilestdlib and tasty-new-all - under the new scheme test succeeds for i94-nada (i.e. REP[T] = T). - Try to beta-reduce bounds before adding to a constraint. - More subtle handling of LazyRefs in BetaReduce - Another refinement to asMemberOf Need to assume lastSymbol in sync with lastDenotation. - Drop isSafe test from BetaReduce Instead, track the higherkinded argument names that a type variable could potentially instantiate to.
* | Multiple fixesMartin Odersky2016-07-111-20/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Swap order of tests in lookupRefined - Change joins of BindingKinds. A type parameter joint with a normal refinement represents a type parameter that has been filled in. So the Binding attribute should be removed. - Fix printing of type lambdas under new hk scheme - refine isRef for hk type The new definition avoids that a higher-kinded type "isRef" of an underlying class. I.e. `[X] -> Any` is not longer a ref to `Any`. - Fix withBindingKind for type aliases Old definition converted aliases to type bounds. - Multiple fixes to BetaReduce - Fix logic for hk subtype tests - Make isHK more precise
* | Turn on new hk schemeMartin Odersky2016-07-111-25/+119
| | | | | | | | | | | | | | For the moment under newHK flag. - avoid crasher in derivedTypeParams (NamedTypes don't always have symbols) - Revise logic in type comparer for new HK scheme