aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | | Handle findMember for unreduced hk types.Martin Odersky2016-07-111-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Follow upper bound, as before. - But if type constructor is a lambda, needs special treatment.
| * | | | | Beta-reduce with wildcard arguments if this is safe.Martin Odersky2016-07-112-9/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Makes pos/partialApplications compile. - Fix appliedTo for aliasTypes Returned a general TypeBounds instance before.
| * | | | | When comparing types revert eta-expansion as neededMartin Odersky2016-07-113-14/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | | Skip typeBounds when computing upperBoundMartin Odersky2016-07-111-1/+1
| | | | | |
| * | | | | Drop bounds checking for type lambdasMartin Odersky2016-07-111-5/+13
| | | | | |
| * | | | | Allow for HK types in widenForMatchSelectorMartin Odersky2016-07-111-2/+4
| | | | | |
| * | | | | Refactor handling of unpickled type paramsMartin Odersky2016-07-117-64/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under the new hk scheme we discovered that type parameters are sometimes unpickled in the wrong order. The fault was always present but the previous hk schemes were somehow lenient enough in their subtyping rules to not discover the problem. E.g., when reading Coder.scala, dotc believed that parameter `A` of `TraversableOnce#BufferedCanBuildFrom` is higher-kinded and parameter `CC` is first-order where the opposite is true. This commit hardens the way we read type parameters in order to make this swap impossible by design. - Revert auto-healing in derivedAppliedType The healing hid a real error about order of type parameters in Scala2 unpickling which was fixed in the previous commits. The healing caused Map.scala to fail because it is possible that type parameters are mis-prediced to be Nil in an F-bounded context. - Smallish fixes to type applications
| * | | | | Avoid cyclic errors when reading nsc.GlobalMartin Odersky2016-07-111-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the change in the next commit this addition is needed to make i859.scala compile. Previously the same effect was achieved accidentally by `updateTypeParams`. The comment admits that we do not really know why the functionality is needed.
| * | | | | Handle TypeLambdas in findMemberMartin Odersky2016-07-112-10/+7
| | | | | |
| * | | | | Ensure wildApprox maintains kindsMartin Odersky2016-07-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When approximating the constructor of an ak apply to a wildcard type, approximate the whole application by WildcardType. Otherwise we might have a wildcardtype with hk bounds as result.
| * | | | | Change underlying of HKApplyMartin Odersky2016-07-111-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's now the same as upperBound, i.e. the underlying of the type constructor re-applied to the arguments.
| * | | | | Tweaks to appliedToMartin Odersky2016-07-111-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Allow appliedTo over TypeBounds - Difference in handling of empty type parameter lists - Always consider EtaExpansions in appliedTo EtaExpanions were not simplified before in Coder.scala and collections.scala. Need to come back and simplify appliedTo logic.
| * | | | | Refactoring of PolyType and TypeLambdaMartin Odersky2016-07-1116-102/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | | Various hk related fixes in typesMartin Odersky2016-07-113-45/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Handle hk applications in normalizeToRefs - Handle type lambdas in classSymbol(s) - Fix variances computation in type lambdas - Provide type parameters for uncompleted type lambdas - Revert TermOrHK type characterization
| * | | | | Fix printing of type lambda trees and typesMartin Odersky2016-07-112-3/+5
| | | | | |
| * | | | | Fix appliedTo and typeParams, and higher kinded subtyping testsMartin Odersky2016-07-113-65/+196
| | | | | | | | | | | | | | | | | | | | | | | | Add existential type elimination for HKApply
| * | | | | Make Constraint#bounds work for aliasesMartin Odersky2016-07-111-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bounds did not do the right thing if a constrain parameter was aliased.
| * | | | | Start new, direct HK schemeMartin Odersky2016-07-1118-186/+478
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Re-introduce newHK option. Label some things that will be removed with OLD.
| * | | | | Remove old hk schemeMartin Odersky2016-07-1123-688/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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-114-69/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
| * | | | | Deal with nested findMember calls over the same RecTypeMartin Odersky2016-07-111-5/+43
| | | | | |
| * | | | | Change testsMartin Odersky2016-07-1111-3/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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 creating dependent function types for closuresMartin Odersky2016-07-111-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this step, anonymous functions can have dependent types which causes the parameter references to "leak out" to types in the environment in illegal ways. This caused a tasty failure for Typer before (not sure why the failure was not observed under the old hk scheme).
| * | | | | Make TypeAccumulators follow LazyRefsMartin Odersky2016-07-112-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TypeMaps do the same, so it is logical, and helps prevent subtle errors as when we mispredicted whether a RecType contains references that point to it. Also, add normalizeHkApply to homogenize Fixes some discrepancies in Tasty typing. Also, homogenize skolem types Skolem types are eliminated by pickling, so they should not appear in the "before-pickling" output.
| * | | | | Fix condition for lambda abstracting in NamerMartin Odersky2016-07-113-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous condition could make a (derived) type a * type for a little while even though it had type parameters. This loophole caused collection/generic/MapFactory.scala and with it compile-stdlib to fail. Refinement for knownHK for PolyParams pos test t2082.scala shows that knownHK can be constructed before the binder PolyType of a PolyParam is initialized.
| * | | | | Avoid infinite recursion when comparing recursive types.Martin Odersky2016-07-113-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | | Optionally, check kinds match for & and |Martin Odersky2016-07-113-1/+38
| | | | | | | | | | | | | | | | | | | | | | | | Optionally, check kinds of operands of & and | match.
| * | | | | Restrict betaReduce to hk applicationsMartin Odersky2016-07-112-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, handle LazyRefs conservatively in isReferredTo Without the change we risk losing RecTypes because it looks like nobody refers to them. This was observed for pos/i974.scala.
| * | | | | Eta-expand unapplied types that have type parametersMartin Odersky2016-07-1111-39/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We would like to change from a scheme where eta-expansion was prototype driven to one where unapplied parameterized types are always eta expanded. The reason is that we might miss some eta expansions due to cyclic references. run/colltest4 is an exmaple. Here, we missed an eta expansion in the type of Iterator. The class definition is: trait Iterable[+A] extends IterableOnce[A] with FromIterable[Iterable] { We'd expect that the second parent would expand to FromIterable[[X0] -> Iterable[X0]] But we miss the expansion because at the time we complete Iterable we have not completed FromIterable yet. In fact this happens in both the old and the new hk scheme. But in the old scheme we did not notice the error whereas in the new scheme we get an error in PostTyper that the type Iterable does not conform to its bound `[X0] -> Iterable[X0]`. With this commit, we change the scheme, so that eta-expansion depends on the type parameters of a type itself, instead of the expected type. We should investigate whether we can do a similar change for Scala2 classloading. Check kinds of type parameters Also, do not allow a hk type if the bound is a * type.
| * | | | | Avoid accidental creation of hk typesMartin Odersky2016-07-115-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
| * | | | | Fix typeParams for abstract types under completionMartin Odersky2016-07-111-10/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Their type parameters are not the type parameters in the completer, but hk type parameters with the same variances.
| * | | | | Adapt widenForMatchSelector to new HK schemeMartin Odersky2016-07-111-3/+9
| | | | | |
| * | | | | Add a second betaReduceMartin Odersky2016-07-116-15/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | | Normalize RecTypes on creation to avoid cycles.Martin Odersky2016-07-112-27/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this change, ski compiles (but with more errors than before). Without it, it goes into various infinite recursions.
| * | | | | Fixes to BetaReduce and asMemberOf; add a second betaReduceMartin Odersky2016-07-115-67/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | | Don't map info of SkolemTypes in type mapsMartin Odersky2016-07-111-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mapping the info may create new skolems which undermines the idea of a skolem as a fixed reference. In a sense, SkolemTypes are like Termrefs, mapping them does not map their info either. Creating new skolems on the fly in type maps caused some hard find to infinite loops under the new hk scheme.
| * | | | | Make etaExpandIfHk work for non-symbol type paramsMartin Odersky2016-07-112-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | Fixes a crasher in t2994.scala
| * | | | | Refinement of cycle avoidanceMartin Odersky2016-07-112-3/+27
| | | | | | | | | | | | | | | | | | | | | | | | The previous fix caused 4 tests to fail under the old hk scheme.
| * | | | | Beta-reduce when simplifyingMartin Odersky2016-07-111-1/+2
| | | | | |
| * | | | | Multiple fixesMartin Odersky2016-07-114-47/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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-1115-169/+404
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | | | Remove special case in parserMartin Odersky2016-07-111-10/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was a special case that triggered a parse error in this course def lift[T <: Type](tp: T): (RecType => T) = arg match { case rt0: RecType => tp.subst(rt0, _).asInstanceOf[T] case _ => (x => tp) } The problem was that the rhs of the first case became a Function node, which caused a premature return from the case clause sequence. I could not determine anymore what the purpose of the removed case in the parser was; all tests compile without it.
| * | | | | Add printing of type lambda treesMartin Odersky2016-07-113-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also fix printing of variances in typedefs and params; they were suppressed before.
| * | | | | Disable checkInst in RecTypeMartin Odersky2016-07-111-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It can give false negatives. Also, simplify RecType.closeOver
| * | | | | Abstract type parameters out from type symbolsMartin Odersky2016-07-1110-43/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the new hk scheme, a type parameter can be represented by a refinement without a corresponding symbol. Therefore, we need to disentangle the info inherent in a type parameter from the contents of a type symbol. We achieve this by creating a common super trait "MemerInfo" of Symbol and RefinedType.
| * | | | | Introduce recursive typesMartin Odersky2016-07-1118-39/+296
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Map self-references in refinements to recursive types. This commit does this for refinement types appearing in source. We still have to do it for unpickled refinements. Test apply-equiv got moved to pending because it simulates the old higher-kinded type encoding in source, which relies on the old representation in terms of self-referential refinement types. The plan is not to adapt this encoding to the new representation, but to replace it with a different encoding that makes critical use of the added power of recursive types. Use recursive types also when unpickling from Scala 2.x. Add mapInfo method to Denotations.
| * | | | | New type lambda scheme for hk typesMartin Odersky2016-07-118-4/+86
| | | | | |
| * | | | | Better printing of skolemsMartin Odersky2016-07-112-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | They not print similar to scalac: "?x" where `x` is a unique number. Todo: An offline explanation what they are, similar to javac. I.e. ... ?3 ... where ?3: T
| * | | | | Allow general recursion in refined types.Martin Odersky2016-07-1113-41/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Treat parent like refinedInfo. Introduce isBinding convenience method in TypeBounds.
| * | | | | Allow refinements of new typesMartin Odersky2016-07-115-18/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously a refinement could only apply to a type bound in the parent. This restriction needs to be dropped for the new encoding of hk type parameters.