Skip to content

traits and self-type cause java.lang.AbstractMethodError #11833

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

Closed
dieu opened this issue Dec 23, 2019 · 3 comments
Closed

traits and self-type cause java.lang.AbstractMethodError #11833

dieu opened this issue Dec 23, 2019 · 3 comments

Comments

@dieu
Copy link

dieu commented Dec 23, 2019

Hello,

I have a simple code which throws an error on 2.12.x+ but work perfectly fine on dotty.

abstract class Base[T] {
  type Type = T
  
  def methodOp(arg: Type): Unit = {
    this match {
      case m: Base[T] with Mark =>
        m.method(arg.asInstanceOf[m.Type]) throw java.lang.AbstractMethodError Apps$.method(Ljava/lang/Object;)V
      case _ =>
      
    }
  }
}

trait Mark { this: Base[_] => 
  def method(arg: Type): Unit
}

object Apps extends Base[Int] with Mark {
  override def method(arg: Apps.Type): Unit = {
    println(arg)
  }
}

https://scastie.scala-lang.org/ndlr1yZiSyiuORdjAvULmw

works with dotty:

https://scastie.scala-lang.org/nG7jh4zpRKWB9P20WuoXZw

Is it possible to work around this error?

@som-snytt
Copy link

I don't see any workaround on #8681

@eed3si9n
Copy link
Member

eed3si9n commented Jan 8, 2020

Looks like we can close this. Also in general questions should be on Scala Users or Stackoverflow - https://www.scala-lang.org/community/

@eed3si9n eed3si9n closed this as completed Jan 8, 2020
@dieu
Copy link
Author

dieu commented Jan 18, 2020

@som-snytt @eed3si9n

JFYI: We found a workaround to force the scala compiler to generated the bridge method.

def method[T <: Type](arg: T): Unit  

https://scastie.scala-lang.org/dih0xBjORWa65k901ekT6w

@som-snytt som-snytt closed this as not planned Won't fix, can't repro, duplicate, stale Nov 23, 2024
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

No branches or pull requests

3 participants