Skip to content

Fix Missing error message on FailureToEliminateExistential #3296

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

Merged

Conversation

CucumisSativus
Copy link
Contributor

One step forward with #1589

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

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

Could you rebase and add a test case?

@@ -1778,4 +1778,15 @@ object messages {
hl"""A class marked with the ${"final"} keyword cannot be extended"""
}

case class FailureToEliminateExistential(tp: Types.Type, tp1: Types.Type, tp2: Types.Type, boundSyms: List[Symbols.Symbol])(implicit ctx: Context)
extends Message(FailureToEliminateExistentialID) {
val kind = "Syntax"
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't a syntax related message. Maybe: Compatibility

@@ -1778,4 +1778,15 @@ object messages {
hl"""A class marked with the ${"final"} keyword cannot be extended"""
}

case class FailureToEliminateExistential(tp: Types.Type, tp1: Types.Type, tp2: Types.Type, boundSyms: List[Symbols.Symbol])(implicit ctx: Context)
Copy link
Contributor

Choose a reason for hiding this comment

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

Simply use Type instead of Types.Type and Symbol instead of Symbols.Symbol

case class FailureToEliminateExistential(tp: Types.Type, tp1: Types.Type, tp2: Types.Type, boundSyms: List[Symbols.Symbol])(implicit ctx: Context)
extends Message(FailureToEliminateExistentialID) {
val kind = "Syntax"
val msg = hl"failure to eliminate existential"
Copy link
Contributor

Choose a reason for hiding this comment

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

hl"Failure to eliminate existential type. Proceed at own risk."

hl"""original type : $tp forSome {${ctx.dclsText(boundSyms, "; ").show}
|reduces to : $tp1
|type used instead: $tp2
|proceed at own risk.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is better as part of the msg

val kind = "Syntax"
val msg = hl"failure to eliminate existential"
val explanation =
hl"""original type : $tp forSome {${ctx.dclsText(boundSyms, "; ").show}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would extract original type in order to fully syntax highlight it:

val explanation = {
  val originalTpe = s"$tp forSome {${ctx.dclsText(boundSyms, "; ").show}"
  hl"""original type    : $originalTpe
  ...
}

@CucumisSativus
Copy link
Contributor Author

Thanks for code review @allanrenucci, i'll rebase and fix the issuses later this week

@CucumisSativus CucumisSativus force-pushed the failed_to_eliminate_existential branch from 64e1866 to d7d4f21 Compare October 26, 2017 20:05
@CucumisSativus
Copy link
Contributor Author

Hey @allanrenucci can you lend me a hand with writing the test as such? I was moving through the documentation but I could find the documented case when such warning should appear. Any help with this would be very welcome

@allanrenucci
Copy link
Contributor

@smarter I looked at our test suite and I can't find any test that exercises this warning. Could you give us an example?

@smarter
Copy link
Member

smarter commented Oct 27, 2017

You'll need to compile some code with scalac (or find some existing code) that uses an existential type that cannot be expressed with wildcards, e.g. Array[Array[T]] forSome { type T }

@allanrenucci allanrenucci merged commit 31c94c3 into scala:master Oct 30, 2017
@CucumisSativus CucumisSativus deleted the failed_to_eliminate_existential branch October 31, 2017 18:45
@CucumisSativus
Copy link
Contributor Author

thanks @allanrenucci !

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.

4 participants