Skip to content

Commit 3c63040

Browse files
committed
Optimise for plain MethodTypeCompanion
1 parent 4b96c3e commit 3c63040

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,9 +2826,10 @@ object Types {
28262826

28272827
def kind: MethodKind = Plain
28282828

2829-
private val methodTypes: mutable.Map[MethodKind, MethodTypeCompanion] = mutable.Map(self.kind -> self)
2829+
private val methodTypeCompanions: mutable.Map[MethodKind, MethodTypeCompanion] = mutable.Map.empty
28302830
def withKind(methodKind: MethodKind): MethodTypeCompanion =
2831-
methodTypes.getOrElseUpdate(methodKind, new MethodTypeCompanion { def kind = methodKind })
2831+
if (methodKind == Plain) this
2832+
else methodTypeCompanions.getOrElseUpdate(methodKind, new MethodTypeCompanion { def kind = methodKind })
28322833

28332834
def withKind(isJava: Boolean = false, isImplicit: Boolean = false): MethodTypeCompanion =
28342835
withKind(makeMethodKind(isJava, isImplicit))

0 commit comments

Comments
 (0)