Skip to content

Inherited type symbol problem #3591

Closed
Closed
@LPTK

Description

@LPTK

See the scastie.
The code is reproduced below:

class Base {
  class A
  class B extends A
  type of[+A0 <: A,T] = A0
}
object Base extends Base
import Base._
object Main {
  def foo = new B
  def foo2: B of Any = foo
  
  def main(args: Array[String]) = ()
}

Fails with:

-- [E056] Type Mismatch Error: /tmp/scastie722928142903515025/src/main/scala/main.scala:10:12 
10 |  def foo2: B of Any = foo
   |            ^
   |       Type argument Base.B does not conform to upper bound Base.this.A 

It works in Scalac, and it works in Dotty if the definitions are moved to the object!

PS: note that it has nothing to do with object Base having the same name as class Base.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions