Skip to content

Top-level defs cause "cannot merge" errors in ide #6605

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
drdozer opened this issue Jun 5, 2019 · 4 comments
Closed

Top-level defs cause "cannot merge" errors in ide #6605

drdozer opened this issue Jun 5, 2019 · 4 comments

Comments

@drdozer
Copy link

drdozer commented Jun 5, 2019

image

I get a lot of these "cannot merge" errors when editing dotty code in visual studio code, run with sbt launchIDE. I can't nail down exactly what triggers it, other than it is a lot worse when the package contains the new allowed top-level declarations. Top-level defs and implied instances. In this case, helloWorld is a top-level def.

@smarter
Copy link
Member

smarter commented Jun 5, 2019

Do you have a github repo where the problem is reproducible?

@drdozer
Copy link
Author

drdozer commented Jun 5, 2019

Trying to build one that's minimal which shows the fault reliably ... it seems to be a bit of a heizenbug

@drdozer
Copy link
Author

drdozer commented Jun 5, 2019

cannotmerge.zip

Here's a self-contained project. It fairly reliably does this for me in the file cannotMergeg.

sbt
launchIDE

Navigate in vs code to src/main/scala/cannotMerge/Routs.scala. Hover over line 11, the bracket before choice.

smarter added a commit to dotty-staging/dotty that referenced this issue Jun 5, 2019
Toplevel defs are enclosed in an object named `<source>$package` by
`Desugar#packageDef`, this didn't work correctly in the IDE because the
name of the VirtualFile was the whole URI of the file. In particular
this lead to double-vision problems ("cannot merge ...") when the
toplevel definition was also present on the classpath.
smarter added a commit to dotty-staging/dotty that referenced this issue Jun 5, 2019
Toplevel defs are enclosed in an object named `<source>$package` by
`Desugar#packageDef`, this didn't work correctly in the IDE because the
name of the VirtualFile was the whole URI of the file. In particular
this lead to double-vision problems ("cannot merge ...") when the
toplevel definition was also present on the classpath.

Also one of the overload of Driver#compile to Driver#compileFromString
for clarity and give better names to VirtualFile it creates since they
could also leak into the names of generated objects.
odersky added a commit that referenced this issue Jun 5, 2019
Fix #6208, #6605: Properly support toplevel defs in the IDE
@smarter
Copy link
Member

smarter commented Jun 5, 2019

Fixed by #6611, thanks for the minimization!

@smarter smarter closed this as completed Jun 5, 2019
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