Skip to content

Commit 5190981

Browse files
committed
Optimise for plain MethodTypeCompanion
1 parent 1e39afd commit 5190981

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
@@ -2837,9 +2837,10 @@ object Types {
28372837

28382838
def kind: MethodKind = Plain
28392839

2840-
private val methodTypes: mutable.Map[MethodKind, MethodTypeCompanion] = mutable.Map(self.kind -> self)
2840+
private val methodTypeCompanions: mutable.Map[MethodKind, MethodTypeCompanion] = mutable.Map.empty
28412841
def withKind(methodKind: MethodKind): MethodTypeCompanion =
2842-
methodTypes.getOrElseUpdate(methodKind, new MethodTypeCompanion { def kind = methodKind })
2842+
if (methodKind == Plain) this
2843+
else methodTypeCompanions.getOrElseUpdate(methodKind, new MethodTypeCompanion { def kind = methodKind })
28432844

28442845
def withKind(isJava: Boolean = false, isImplicit: Boolean = false): MethodTypeCompanion =
28452846
withKind(makeMethodKind(isJava, isImplicit))

0 commit comments

Comments
 (0)