Skip to content

package object member "type X" not found if "object X" exists in the same package #2200

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
olafurpg opened this issue Apr 7, 2017 · 6 comments

Comments

@olafurpg
Copy link
Contributor

olafurpg commented Apr 7, 2017

I found one example with type aliases and higher kinded types where scalac reports no type errors while dotc reports E006 Unbound Identifier Error cf26eeb#commitcomment-21672034

I bumped into this error while trying to compile https://github.com/johnynek/paiges with Dotty. The commands I ran were

$ scalac -version
Scala compiler version 2.12.1 -- Copyright 2002-2016, LAMP/EPFL and Lightbend, Inc.
$ scalac tests/pos/packageobjecttypealias/*.scala
$ ./bin/dotc tests/pos/packageobjecttypealias/*.scala 
@olafurpg olafurpg changed the title Type alias for higher kinded types Type alias and higher kinded type Apr 7, 2017
@smarter
Copy link
Member

smarter commented Apr 7, 2017

  1. E006 Unbound Identifier Error cf26eeb#commitcomment-21672034

The problem seems to be that the stuff in the package object is not found, I've seen that happen before. The reason is that we cache the package object denotation, but sometimes we cache it before the package object has been entered into scope, so the cache is wrong and never invalidated. I don't know if there's a systematic solution to this, maybe simply dropping the cache assuming it doesn't have a big impact on performance? /cc @odersky

  1. E007 Type mismatch eae920a#commitcomment-21672052

That's a good one! No clue what's going on but it shouldn't be too hard to debug.

@olafurpg Since these are two separate issues, would you mine splitting this issue into two?

@olafurpg olafurpg changed the title Type alias and higher kinded type Type alias and higher kinded type cause E006 Unbound Identifier Error Apr 7, 2017
@olafurpg
Copy link
Contributor Author

olafurpg commented Apr 7, 2017

Since these are two separate issues, would you mine splitting this issue into two?

@smarter Done, see #2201. I removed the reference to the second error of the description in this issue.

@smarter smarter changed the title Type alias and higher kinded type cause E006 Unbound Identifier Error package object cache is sometimes wrong (returns NoDenotation although a package object exists, because the cache was created before the package object was entered) Apr 7, 2017
@odersky
Copy link
Contributor

odersky commented Apr 8, 2017

It's not just a caching problem. The problem is that the first type found is the class type that comes with the DocString object, but that one does not really exist. But by then we don't look in the package object anymore. It's tricky because at the point where we do look into the package object we are not allowed to ask whether the companion class really exists, as that would force too much.

@smarter
Copy link
Member

smarter commented Apr 8, 2017

@odersky Ah, I see! So it's not the issue I thought it was.

@smarter smarter changed the title package object cache is sometimes wrong (returns NoDenotation although a package object exists, because the cache was created before the package object was entered) package object member "type X" not found if "object X" exists in the same package Apr 8, 2017
@odersky
Copy link
Contributor

odersky commented Apr 9, 2017

Fixed by #2205

@odersky odersky closed this as completed Apr 9, 2017
@olafurpg
Copy link
Contributor Author

I confirm that I'm unable to reproduce the error after #2205.

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

4 participants