Skip to content

Another is not a class type error when creating an anonymous subclass of an abstract class via new through a type alias #19745

Open
@neko-kai

Description

@neko-kai

Compiler version

3.4.0

Minimized code

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

final abstract class ForcedRecompilationToken[T]
object ForcedRecompilationToken {
  implicit def default: ForcedRecompilationToken["abc"] = null
}

object x {
  abstract class GoodNoParens[T](implicit ev: ForcedRecompilationToken[T])
}
type BadNoParens[T] = x.GoodNoParens[T]

object App extends App {
  // error
  new BadNoParens {}

  // ok
  new BadNoParens() {}
  new x.GoodNoParens {}

  println("compiled")
}

Output

x.GoodNoParens is not a class type

Expectation

Same issue as in #18623, but this time it's when instantiating via new instead of declaring an object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogNo work planned on this by the core team for the time being.itype:enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions