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

Anonymous inferred trait parameter is an Illegal field #6124

Closed
bishabosha opened this issue Mar 20, 2019 · 1 comment
Closed

Anonymous inferred trait parameter is an Illegal field #6124

bishabosha opened this issue Mar 20, 2019 · 1 comment
Labels

Comments

@bishabosha
Copy link
Member

The JVM crashes at runtime when loading example.BadTest.Bad because the given Foo[A] is encoded as a final field on an interface that has no value, whereas with implicit evidence, or an explicit name it is encoded as a method.

package example

type Box[A] = A

trait Foo[A]

implied [A] for Foo[A]

object OkTest {
  trait Ok[A: Foo] extends Foo[Box[A]] {}
  implied [A] given Foo[A] for Ok[A]

  def test: Unit = {
    println(the[Ok[Box[Unit]]])
  }
}

object OkTest2 {
  trait Ok[A] given (f: Foo[A]) extends Foo[Box[A]] {}
  implied [A] given Foo[A] for Ok[A]

  def test: Unit = {
    println(the[Ok[Box[Unit]]])
  }
}

object BadTest {
  trait Bad[A] given Foo[A] extends Foo[Box[A]] {}
  implied [A] given Foo[A] for Bad[A]

  def test: Unit = {
    println(the[Bad[Box[Unit]]])
  }
}
@bishabosha
Copy link
Member Author

This is fixed

WojciechMazur added a commit to WojciechMazur/dotty that referenced this issue Mar 28, 2023
WojciechMazur added a commit to WojciechMazur/dotty that referenced this issue Apr 6, 2023
WojciechMazur added a commit to WojciechMazur/dotty that referenced this issue Oct 9, 2023
WojciechMazur added a commit that referenced this issue Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants