Skip to content

Incorrect bridge gen for method that has value class with underlying Object type as result type #1169

Closed
@VladimirNik

Description

@VladimirNik

Incorrect bridge generation for method that has value class with the underlying Object type as result type.
The compilation of this code with -Ycheck:all:

class A(val x: Object) extends AnyVal
abstract class VCACompanion[T] {
  def yyyy(x: Object): T
}
class XXX extends VCACompanion[A] {
  override def yyyy(x: Object): A = new A("fff")
}

results in:

 method yyyy is already defined as method yyyy: (x: Object)ErasedValueType(A, Object)
 (the definitions have matching type signatures)

The problem is that there is a bridge generation during Erasure for def yyyy(x: Object): A = ....
This bridge has the same signature as original def yyyy(x: Object): A = ...:

override def yyyy(x: Object): Object = "fff"
def yyyy(x: Object): Object = new A(this.yyyy(x))

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions