Skip to content

Wrong error message when instantiating a trait from scala 2.13 stdlib #16601

Closed
@prolativ

Description

@prolativ

Compiler version

3.2.1 and before

Minimized code

new concurrent.ExecutionContext

Output

-- [E042] Type Error: ----------------------------------------------------------
1 |new concurrent.ExecutionContext
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |    Unit is abstract; it cannot be instantiated
  |
  | longer explanation available when compiling with `-explain`

With -explain enabled:

-- [E042] Type Error: ----------------------------------------------------------
1 |new concurrent.ExecutionContext
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |    Unit is abstract; it cannot be instantiated
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | Abstract classes and traits need to be extended by a concrete class or object
  | to make their functionality accessible.
  |
  | You may want to create an anonymous class extending Unit with
  |   class Unit { }
  |
  | or add a companion object with
  |   object Unit extends Unit
  |
  | You need to implement any abstract members in both cases.
   -----------------------------------------------------------------------------

Expectation

The actual name of the instantiated trait (e.g. ExecutionContext in the example above) should be displayed instead of Unit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:reportingError reporting including formatting, implicit suggestions, etcgood first issuePerfect for someone who wants to get started contributingitype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions