Skip to content
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

Unhelpful compiler error message with incompatible structural types #4877

Closed
scabug opened this issue Aug 6, 2011 · 2 comments
Closed

Unhelpful compiler error message with incompatible structural types #4877

scabug opened this issue Aug 6, 2011 · 2 comments
Assignees

Comments

@scabug
Copy link

scabug commented Aug 6, 2011

scala> def foo: AnyRef{def bar: String} =  new AnyRef{def bar = 42}
<console>:7: error: type mismatch;
 found   : java.lang.Object{}
 required: AnyRef{def bar: String}
       def foo: AnyRef{def bar: String} =  new AnyRef{def bar = 42}
                                           ^

It looks a bit like as if the compiler error message would use the erasure of the right expression return type. I would have expected something like:

scala> def foo: AnyRef{def bar: String} =  new AnyRef{def bar = 42}
<console>:7: error: type mismatch;
 found   : AnyRef{def bar: Int}
 required: AnyRef{def bar: String}
       def foo: AnyRef{def bar: String} =  new AnyRef{def bar = 42}
                                                                ^

The caret positioning could also be a bit better if it pointed to the def bar.

@scabug
Copy link
Author

scabug commented Aug 6, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4877?orig=1
Reporter: @soc
See #4876

@scabug
Copy link
Author

scabug commented Aug 6, 2011

Commit Message Bot (anonymous) said:
(extempore in r25456) Improved structural type error messages, and other error message
related boosts. Closes #4877, review by odersky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants