Skip to content

Incorrect errors shown in the editor when object defined with same name as case class #2926

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
scabug opened this issue Jan 19, 2010 · 11 comments
Assignees

Comments

@scabug
Copy link

scabug commented Jan 19, 2010

The presentation compiler seems to have issues when an object is defined with the same name as a case class.

Steps to reproduce:

(1) Create a file Foo.scala:

package test

object Foo {
  
}
case class Foo(t: String) {

}

(2) Open editor

(3) Notice that the editor shows two incorrect errors (construction definition not allowed here and constructor Foo is defined twice).

The file is actually compiled fine and nothing is shown in the Problems view. scalac also handles the file fine:

/opt/scala-2.8.0.Beta1-RC8/bin/scalac test/Foo.scala
@scabug
Copy link
Author

scabug commented Jan 19, 2010

Imported From: https://issues.scala-lang.org/browse/SI-2926?orig=1
Reporter: @ijuma

@scabug
Copy link
Author

scabug commented Jan 19, 2010

@milessabin said:
Interestingly reordering the object and class definitions makes the error go away.

@scabug
Copy link
Author

scabug commented Jan 19, 2010

@milessabin said:
As does changing the class to a vanilla class.

@scabug
Copy link
Author

scabug commented Jan 19, 2010

@ijuma said:
Interesting that reordering fixes the issue. I'll use that workaround. :)

I believe the issue is related to the fact that a companion object is created for case classes, so it doesn't surprise me that the problem goes away with a vanilla class.

@scabug
Copy link
Author

scabug commented Jan 20, 2010

@odersky said:
(In r20625) Attempt to fix #2926 (companion object of case class problem in Eclipse)

@scabug
Copy link
Author

scabug commented Jan 20, 2010

@milessabin said:
Unfortunately the problem is still present after r20625.

@scabug
Copy link
Author

scabug commented Jan 22, 2010

@odersky said:
(In r20634) Second attempt to fix #2926. Reverted first attempt. review by milessabin.

@scabug
Copy link
Author

scabug commented Jan 22, 2010

@milessabin said:
This looks very, very good (and fixes a lot of the residual case of #2767 as well).

Unfortunately tweaking the example slightly gets the originally reported error back,

package test

object Foo2 {
  object Foo {
  
  }
  case class Foo(t: String) {

  }
}

@scabug
Copy link
Author

scabug commented Jan 22, 2010

@odersky said:
I'll look at the remaining problem tomorrow.

@scabug
Copy link
Author

scabug commented Jan 24, 2010

@odersky said:
Should be fixed by now.

@scabug
Copy link
Author

scabug commented Jan 26, 2010

@ijuma said:
I can confirm that both cases now work.

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

No branches or pull requests

2 participants