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

Don't count constructors in allMembers #13505

Merged
merged 1 commit into from Sep 13, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 10, 2021

This caused a crash for Metals with the following stacktrace

Caused by: dotty.tools.dotc.core.TypeError: Toplevel definition <init> is defined in
  /Users/odersky/workspace/dotty/compiler/target/scala-3.1.0-RC1/classes/dotty/tools/dotc/util/LinearMap$package.class
and also in
  /Users/odersky/workspace/dotty/compiler/target/scala-3.1.0-RC1/classes/dotty/tools/dotc/util/LinearSet$package.class
One of these files should be removed from the classpath.
	at dotty.tools.dotc.core.SymDenotations$PackageClassDenotation.dropStale$1(SymDenotations.scala:2439)
	at dotty.tools.dotc.core.SymDenotations$PackageClassDenotation.recur$1(SymDenotations.scala:2403)
	at dotty.tools.dotc.core.SymDenotations$PackageClassDenotation.computeMembersNamed(SymDenotations.scala:2459)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.membersNamed(SymDenotations.scala:2012)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:2063)
	at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:683)
	at dotty.tools.dotc.core.Types$Type.goThis$1(Types.scala:807)
	at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:700)
	at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:870)
	at dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:666)
	at dotty.tools.dotc.core.Types$Type.member(Types.scala:650)
	at dotty.tools.dotc.core.Types$Type.allMembers$$anonfun$1(Types.scala:1011)

The problem arises when calling allMembers on a package with multiple package objects. These
will all have a constructor, and the constructors fail the dropStale test. There is not really
a good way to pick one constructor over another, so it's better to drop constructors in allMembers.

This caused a crash for Metals with the following stacktrace

```
Caused by: dotty.tools.dotc.core.TypeError: Toplevel definition <init> is defined in
  /Users/odersky/workspace/dotty/compiler/target/scala-3.1.0-RC1/classes/dotty/tools/dotc/util/LinearMap$package.class
and also in
  /Users/odersky/workspace/dotty/compiler/target/scala-3.1.0-RC1/classes/dotty/tools/dotc/util/LinearSet$package.class
One of these files should be removed from the classpath.
	at dotty.tools.dotc.core.SymDenotations$PackageClassDenotation.dropStale$1(SymDenotations.scala:2439)
	at dotty.tools.dotc.core.SymDenotations$PackageClassDenotation.recur$1(SymDenotations.scala:2403)
	at dotty.tools.dotc.core.SymDenotations$PackageClassDenotation.computeMembersNamed(SymDenotations.scala:2459)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.membersNamed(SymDenotations.scala:2012)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:2063)
	at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:683)
	at dotty.tools.dotc.core.Types$Type.goThis$1(Types.scala:807)
	at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:700)
	at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:870)
	at dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:666)
	at dotty.tools.dotc.core.Types$Type.member(Types.scala:650)
	at dotty.tools.dotc.core.Types$Type.allMembers$$anonfun$1(Types.scala:1011)
```
The problem arises when calling allMembers on a package with multiple package objects. These
will all have a constructor, and the constructors fail the dropStale test. There is not really
a good way to pick one constructor over another, so it's better to drop constructors in allMembers.
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for fixing this one!

@odersky odersky merged commit 4742767 into scala:master Sep 13, 2021
@odersky odersky deleted the fix-allmembers branch September 13, 2021 16:43
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

Successfully merging this pull request may close these issues.

None yet

2 participants