@@ -424,18 +424,26 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
424424 }.bits
425425
426426 def isQualifierSafeToElide (qual : Tree ): Boolean = tpd.isIdempotentExpr(qual)
427+
428+ private val desugared = new java.util.IdentityHashMap [Type , tpd.Select ]
429+
427430 def desugarIdent (i : Ident ): Option [tpd.Select ] = {
428- i.tpe match {
429- case TermRef (prefix : TermRef , name) =>
430- Some (tpd.ref(prefix).select(i.symbol))
431- case TermRef (prefix : ThisType , name) =>
432- Some (tpd.This (prefix.cls).select(i.symbol))
433- case TermRef (NoPrefix , name) =>
434- if (i.symbol is Flags .Method ) Some (This (i.symbol.topLevelClass).select(i.symbol)) // workaround #342 todo: remove after fixed
435- else None
436- case _ => None
431+ var found = desugared.get(i.tpe)
432+ if (found == null ) {
433+ i.tpe match {
434+ case TermRef (prefix : TermRef , name) =>
435+ found = tpd.ref(prefix).select(i.symbol)
436+ case TermRef (prefix : ThisType , name) =>
437+ found = tpd.This (prefix.cls).select(i.symbol)
438+ case TermRef (NoPrefix , name) =>
439+ if (i.symbol is Flags .Method ) found = This (i.symbol.topLevelClass).select(i.symbol) // workaround #342 todo: remove after fixed
440+ case _ =>
441+ }
442+ if (found != null ) desugared.put(i.tpe, found)
437443 }
444+ if (found == null ) None else Some (found)
438445 }
446+
439447 def getLabelDefOwners (tree : Tree ): Map [Tree , List [LabelDef ]] = {
440448 // for each rhs of a defdef returns LabelDefs inside this DefDef
441449 val res = new collection.mutable.HashMap [Tree , List [LabelDef ]]()
@@ -892,8 +900,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
892900 def parents : List [Type ] = tp.parents
893901 }
894902
895-
896-
897903 object Assign extends AssignDeconstructor {
898904 def _1 : Tree = field.lhs
899905 def _2 : Tree = field.rhs
0 commit comments