-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Change typeapply #994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change typeapply #994
Conversation
It seems to complciate things with no real purpose.
Done in order to keep the basics as simple as possible. Treating existentially bound parameters as still instantiatable type parameters does not seem to add anything fundamental, and makes the type system less regular.
Also: fix adaptArgs and LambdaTrait to make it work.
Also: fix EtaExpansion. Also: Add some debug code to Applications, awaiting further fixes.
typeSymbols always have empty type parameter list.
Previous implementation died because TermRef had no denotation.
Printing bounds omits the "<:" otherwise.
Arg bounds do not count is bindings.
Arg bounds do not count is bindings. Also: TypeLambda's $Apply binding should be covariant, because the parameter is (not sure it matters though).
Taking typeAlias is illegal in that case.
Makes i815 compile.
This prevents propagation changes leading to long recompiles when a printer is changed.
/** Lambda abstract `self` with given type parameters. Examples: | ||
* | ||
* type T[X] = U becomes type T = [X] -> U | ||
* type T[X] >: L <: U becomes type T >: L <: ([X] -> _ <: U) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that mean that we cannot refer to X
in L
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, then this should be explicitly disallowed somewhere, currently the following:
class Test {
type Foo[X] >: List[X]
}
Triggers an assertion: unresolved symbols: type X
On the other hand, couldn't we rewrite type T[X] >: L <: U
as type T = [X] -> (_ >: L <: U)
or something else to allow this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means bounds can be lambdas (and lambdas are complex arrangements of refinements and references). So what was a TypeBounds type now becomes something very complicated. I am afraid to got there. If we had explicit type lambdas as a separate type it would take it under consideration. But then we need also explicit AppliedType types.
All Lambda abstractions, not just eta expansions, should use actual parameter bounds, not the one retrieved from the parameter symbols.
by bringing homogenization of # $Apply projections back.
Seems to be a hk-type inference issue. Needs further investigation but is not high priority right now.
6f8d12a
to
169c8dc
Compare
Rebased to master |
* | ||
* (2) Try to eta expand the constructor of `other`. | ||
* | ||
* (3a) In mode `TypeVarsMissConetxt` replace the projection's hk constructor parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: TypevarsMissContext
The following: object Test {
def foo[M[X] <: List[X]](x: M[Int]) = ???
} gets pretty-printed after frontend as: package <empty> {
final lazy module val Test: Test$ = new Test$()
final module class Test$() extends Object() { this: Test.type =>
def foo[M <: [] -> <: scala.collection.immutable.List[X0]](x: M[Int]): Nothing = ???
}
} The list of type lambda arguments is |
As remarked by @smarter, argInfos does not work for type lambdas, so argBoundss is always Nil.
Also: various cleanups to comments.
All comments should be addressed now. |
Fixes problem raised in scala#966.
9268573
to
88f24ef
Compare
I'm looking into why |
class HKCov[M[+_]] {
def upcast(m: M[Int]): M[Any] = m
}
class Foo[T]
object Test {
val x: HKCov[Foo] = new HKCov[Foo]
val fi: Foo[Int] = new Foo[Int]
val fa: Foo[Any] = x.upcast(fi)
} The type parameter of I've tried simply removing Do you have a test case where |
The comment to adaptIfHK gives some clue. It certainly was needed at some point for compileStdLib. To make sure, it would be good to just compile with some of the mutable classes mentioned in the comment. I.e. starting with GenTraversable and ListBuffer and then add a few. |
Indeed we need to test whether the variances correspond before doing the adaptation. I.e. if the context requires nonvariant but the argument is covariant OK, in the other direction not. |
Previously adaptIfHK was performed on every type application. This made t3152 fail. We now do this only on demand, in isSubType. t3152 now passes again. But the change unmasked another error, which makes Iter2 fail to compile.
Comment explains why following aliases in general is incomplete and potentially unsound. This makes Iter2 compile, but causes cyclic reference errors for pos/sets.scala.
The tightened subtyping algorithm led to a cycle in baseTypeRef when compiling sets.scala. This commit fixes the problem.
Any is a supertype of every other type, so no need to analyze types in detail. This also fixes the cyclic reference error observed for sets.scala, but only for the special case where the base class is Any.
The change in subtyping led to a deep subtype recursion for sets.scala. It seems legit, so the -Yno-deep-subtypes check is disabled.
Changes to arrive at a more tractable treatment of higher-kinded types.