Skip to content

Commit fa9634c

Browse files
committed
Don't count 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.
1 parent a82a1a6 commit fa9634c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -6093,7 +6093,7 @@ object Types {
60936093
}
60946094

60956095
object takeAllFilter extends NameFilter {
6096-
def apply(pre: Type, name: Name)(using Context): Boolean = true
6096+
def apply(pre: Type, name: Name)(using Context): Boolean = name != nme.CONSTRUCTOR
60976097
def isStable = true
60986098
}
60996099

0 commit comments

Comments
 (0)