Skip to content

Compiler accepts code that shouldn't typecheck, dies in the backend #3537

Closed
@smarter

Description

@smarter

I have no idea how this code manages to get past the frontend (this only happens in the REPL):

scala> class Foo(i: Int) 
// defined class Foo
scala> new Foo("42") 
java.lang.RuntimeException: Unexpected New(Foo/TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),rs$line$1$)),Foo)) reached GenBCode.
  Call was genLoad(New(TypeTree[TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),rs$line$1$)),Foo)]),Ljava/lang/Object;)
        at dotty.tools.backend.jvm.DottyBackendInterface.abort(DottyBackendInterface.scala:393)
        at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:313)
        at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.$anonfun$genLoadArguments$1(BCodeBodyBuilder.scala:1018)
        at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.$anonfun$genLoadArguments$1$adapted(BCodeBodyBuilder.scala:1018)
        at scala.collection.immutable.List.foreach(List.scala:389)
       ...

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