Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
prolativ opened this issue Dec 30, 2022 · 4 comments · Fixed by #16635
Closed

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

prolativ opened this issue Dec 30, 2022 · 4 comments · Fixed by #16635
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc good first issue Perfect for someone who wants to get started contributing itype:bug
Milestone

Comments

@prolativ
Copy link
Contributor

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.

@prolativ prolativ added itype:bug area:reporting Error reporting including formatting, implicit suggestions, etc good first issue Perfect for someone who wants to get started contributing labels Dec 30, 2022
@yzia2000
Copy link
Contributor

yzia2000 commented Jan 8, 2023

Hi I would like to tackle this issue. It seems that scala 2 type symbol passed into checkInstantiable is Unit while scala 3 has the right symbol.

Since this is my first dotty issue, @prolativ may I know why this issue was marked as good-first-issue? Have we dealt with such cases in the past?

@nizhikov
Copy link
Contributor

nizhikov commented Jan 8, 2023

Hello. I prepared PR to fix this - #16635

@nizhikov
Copy link
Contributor

nizhikov commented Jan 8, 2023

@prolativ Can you, please, help me. What is the next steps to get this fix (#16635) merged?

@dwijnand dwijnand linked a pull request Jan 8, 2023 that will close this issue
@yzia2000
Copy link
Contributor

yzia2000 commented Jan 8, 2023

Hey @nizhikov, why is it that the symbol in Apply type (tree.tpe) has the right name for Scala 3 but not for Scala 2? While the symbol in New (nu.tpe) does have the right symbol in it for both? Should the difference be there in the first place?

@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc good first issue Perfect for someone who wants to get started contributing itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants