Skip to content

Conversation

@BarkingBad
Copy link
Contributor

No description provided.

Copy link
Contributor

@abgruszecki abgruszecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to improve some things, so I think we can merge it on that basis. However, we still display type lambdas instead of HKTs, see all the exnteds clauses here: https://scala3doc.virtuslab.com/pr-missing-wildcard-in-hkts/scala3/api/scala/collection/immutable.html. That should be considered a bug, and isn't fixed here.

Copy link
Contributor

@romanowski romanowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot simply strip anything after $ in type names

@BarkingBad
Copy link
Contributor Author

@abgruszecki I am not sure if it is correct behaviour, but look at this example, given code like this:

import scala.collection.immutable.ArraySeq trait SomeTraitWithHKTs[A[_], B[_], C[_], D[_], E[_]] abstract class Foo[Z] trait SomeTrait extends SomeTraitWithHKTs[Foo, scala.collection.immutable.ArraySeq, ArraySeq, List, [B] =>> List[B]]

we get following AppliedType's parameter list:

Full output

List(HKTypeLambda(List(Z), List(TypeBounds(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Nothing),TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Any))), AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class tests)),object hkts),Foo),List(TypeParamRef(Z)))), TypeRef(TermRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),object collection),object immutable),class ArraySeq), HKTypeLambda(List(A), List(TypeBounds(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Nothing),TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Any))), AppliedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class collection)),object immutable),ArraySeq),List(TypeParamRef(A)))), TypeRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),package),List), HKTypeLambda(List(B), List(TypeBounds(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Nothing),TypeRef(TermRe

which is actually List of [HKTypeLambda, TypeRef, HKTypeLambda, TypeRef, HKTypeLambda] and the output is:
obraz

  1. There is different behaviour to ArraySeq declared as an import or as fully qualified name making it just ArraySeq or type lambda of [A] =>> ArraySeq[A].
  2. If i would like to collapse the Foo type lamda, I could not disambiguate it with actual type lambdas, like [B] =>> List[B].

What do you think about these two things?

@abgruszecki
Copy link
Contributor

Ah, I see, in some cases we do display List as simply List. Do we have what you wrote as a test case? If not, we should.

At some point we should find out what exactly makes the types in stdlib display type lambdas instead of HKTs (variance annotations, perhaps?), but it's less of a problem than I thought, I'd say.

@BarkingBad BarkingBad force-pushed the scala3doc/missing-wildcard-in-hkts branch 2 times, most recently from 9c0f9fb to 3074292 Compare February 1, 2021 15:33
@BarkingBad
Copy link
Contributor Author

BarkingBad commented Feb 1, 2021

I am still not sure why this thing is happening, but I have shown the example where import of fullly qualified name makes difference for ArraySeq.
@romanowski the memberInfo was the unfinished work. I implemented parseTypeDef to use memberInfo property, however, there come out another weird problem, for given code:

trait A[X] { type SomeType[X] def x: SomeType[X] } trait B[D] extends A[D]

the expected behaviour to see SomeType from B class perspective would be with applied D symbolic name, not X. However, we get following, because memberInfo method from dotty.tools.dotc.core.Types returns such name though it is run in context of B class symbol.
obraz

@BarkingBad
Copy link
Contributor Author

Unfortunately I am enforced to rollback all memberInfo changes for TypeDefs as it returns HKTypeLambdas which lose variance

@BarkingBad BarkingBad requested a review from romanowski February 2, 2021 10:07
@BarkingBad BarkingBad force-pushed the scala3doc/missing-wildcard-in-hkts branch from 46f642b to d631da5 Compare February 2, 2021 14:32
@BarkingBad BarkingBad force-pushed the scala3doc/missing-wildcard-in-hkts branch from d631da5 to cdc1fc7 Compare February 8, 2021 12:00
@BarkingBad BarkingBad force-pushed the scala3doc/missing-wildcard-in-hkts branch from cdc1fc7 to 15000f3 Compare February 8, 2021 12:25
@BarkingBad BarkingBad merged commit 585c5e6 into scala:master Feb 9, 2021
@BarkingBad BarkingBad deleted the scala3doc/missing-wildcard-in-hkts branch February 9, 2021 15:02
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants