Skip to content
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

Print the type parameter bounds of higher kinded types #13372

Merged
merged 2 commits into from
Aug 25, 2021

Conversation

adpi2
Copy link
Member

@adpi2 adpi2 commented Aug 24, 2021

Fix #13306

When the exported type is a higher-kinded type, we print the bounds of its type parameters.

Co-authored by @bishabosha
Co-authored by @mlachkar

@adpi2 adpi2 changed the title Print the type parameter bounds of higher kinded type lambdas Print the type parameter bounds of higher kinded types Aug 24, 2021
Co-authored-by: Jamie Thompson <jamie.thompson@bath.edu>
Co-authored-by: Meriam Lachkar <meriam.lachkar@gmail.com>
@adpi2
Copy link
Member Author

adpi2 commented Aug 25, 2021

This PR changes the error reporting of unchecked type bounds as in i11637:

object test2:
  class FunctorImpl[Generic1[T] <: Iterable[T]]{}
  class HKT3_1[Functor[Generic2[T<:String]<:Set[T]]]{}
  var h = new HKT3_1[FunctorImpl]();  // error // error
[E057] Type Mismatch Error: tests/neg-custom-args/i11637.scala:11:21 ------------------------------------------------
11 |  var h = new HKT3_1[FunctorImpl]();  // error // error
   |                     ^
-   |                 Type argument test2.FunctorImpl does not conform to upper bound [Generic2[T] <: Set[T]] =>> Any
+   |       Type argument test2.FunctorImpl does not conform to upper bound [Generic2[T <: String] <: Set[T]] =>> Any

I updated the check file because the new message looks more accurate.

@adpi2 adpi2 requested a review from odersky August 25, 2021 08:21
final module class Exports() extends Object() { this: example.Exports.type =>
val instance: example.MembersContainer = new example.MembersContainer()
export example.Exports.instance.*
final type MyType[T <: example.MyClass] = Comparable[T]
Copy link
Member

@bishabosha bishabosha Aug 25, 2021

Choose a reason for hiding this comment

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

i noticed the lower bound does not print either, implying it's Nothing, however it is still inconsistent with how a TypeBoundsTree is printed - if you look at the original MyType - but that would lead to very verbose error messages I think.

One solution could be some print mode parameter which knows if we are printing "full trees" or just the type, which could allow you to decide when to always print the lower bound

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@bishabosha bishabosha merged commit a085de5 into scala:master Aug 25, 2021
@Kordyjan Kordyjan added this to the 3.1.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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

-Xprint:all doesn't print type parameter bounds in the exported types
5 participants