| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
And remove the not used Printer#echo
|
|
|
|
|
| |
Adapt operations TypeApplications and TypeComparer to account
for the possibilities of curried type lambdas.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The special case:
case stripped: TypeRef =>
stripped.symbol.is(BaseTypeArg)
is wrong because you might still want to reduce applications involving
TypeRefs which are not base class parameters, like in:
class Foo[A]
type Alias[X] = Foo[X]
val x: Alias[Int] = ???
`Alias` is a TypeRef so before this commit `Alias[Int]` was never reduced
to `Foo[Int]`. It should have been:
case stripped: TypeRef if stripped.symbol.is(BaseTypeArg) =>
true
But even this is incorrect: it assumes that we can always safely reduce HK
applications involving base class parameters, this is not the case when
the parameter kind is different from the rhs kind as illustrated by
`i1181c.scala`. We fix this by simply dropping the special case.
|
|
|
|
|
| |
Previous logic could only handle classes as constructors.
Also, address other reviewers comments.
|
| |
|
|
|
|
|
|
|
|
|
| |
Beta-reduce only if `Config.simplifyApplications` is true.
Turning off beta-reduction revealed two problems which are
also fixed in this commit:
1. Bad treatement of higher-kinded argyments in cyclicity checking
2. Wrong variance for higher-kinded arguments in TypeAccumulator
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
Allows partially instantiated types as type constrictors when inferring higher-kinded
types.
|
|
|
|
|
|
|
|
|
|
|
| |
We cannot handle such types in general. So we now check that a hk application
C[args]
where some of the arguments are wildcards does not have as a supertype
a hk application
([X] -> B)[args]
|
|
|
|
|
| |
Allows us to drop also the involved knownHK method. Lots of other
cleanups.
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Only use one method instead of a succession of two.
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
| |
Keep the higher-kinded application instead. This should be
better for inference. We have to evaluate the performance impact.
Maybe dealias if the kind stays the same?
Also, reduce Nothing[...] to Nothing
Nothing cannot be a type constructor in a
HK application because it does not have type
parameters. Avoid the problemn by the reduction above.
|
|
|
|
|
|
|
|
| |
Makes pos/partialApplications compile.
- Fix appliedTo for aliasTypes
Returned a general TypeBounds instance before.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
- 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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Add existential type elimination for HKApply
|
|
|
|
|
| |
- Re-introduce newHK option. Label some things that will be
removed with OLD.
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 of operands of & and | match.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Their type parameters are not the type parameters in the completer,
but hk type parameters with the same variances.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Fixes a crasher in t2994.scala
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
Treat parent like refinedInfo. Introduce isBinding convenience method
in TypeBounds.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
Dealias TypeRefs that get applied to type arguments. Without that
precaution we get Stackoverflows in lookupRefined/betaReduce for
CollectionStrawMan5.scala.
|
|\
| |
| | |
Improvements to cyclic checking, avoidance, named parameters
|
| |
| |
| |
| | |
No need to form the glb.
|
| |
| |
| |
| |
| | |
Add methods for expressing what the named type parameters of a class or type are.
Also, add a method that widens a type so that is has a specified set of named type parameters.
|
|/
|
|
|
| |
Mode is used from a lot of low-level code, does not just reflect Typer info.
So it makes more sense top to place it in the core package.
|
|
|
|
| |
Was not fixed by accident then, so we do it here now.
|
|
|
|
|
| |
Changes needed to support simple named type parameters.
Not yet implemented: named arguments.
|
| |
|
|
|
|
|
|
|
|
|
| |
Type params should be computed before computing the whole info of
a type. Without the patch we get a cyclic reference in the compileMixed
test.
Note that compileIndexedSeq does not pass with this commit (it passed
before), this is fixed in the next commit.
|
|\
| |
| | |
More tests
|
| | |
|