Skip to content

Misleading NPE from inner class with null outer pointer #8440

@scabug

Description

@scabug

This snippet fails with a NPE as expected:

class A {
  class B // 1
}

val a: A = null
val b = new a.B // 2

The position that the stack trace points to, however, is (1), not (2) as one would expect when dereferencing a def or a val. This is not helped by not giving an error message that would make this situation clearer (e.g. "Cannot instantiate inner class where outer is null").

See slick/slick#722 for a motivating example.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions