diff options
author | Martin Odersky <odersky@gmail.com> | 2006-04-04 12:18:15 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2006-04-04 12:18:15 +0000 |
commit | ac8b46abda17de619beb2b27dfe9d820c5e189cf (patch) | |
tree | b908b07eb95280352dea767dd0fd8ac9890d8472 /src/compiler/scala/tools/nsc/typechecker/Contexts.scala | |
parent | 486042e89abaa69b82f2d602d342f7b032ce7047 (diff) | |
download | scala-ac8b46abda17de619beb2b27dfe9d820c5e189cf.tar.gz scala-ac8b46abda17de619beb2b27dfe9d820c5e189cf.tar.bz2 scala-ac8b46abda17de619beb2b27dfe9d820c5e189cf.zip |
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Contexts.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 11d2aa2a3e..f24d2a21a4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -263,7 +263,7 @@ trait Contexts requires Analyzer { private def collectImplicits(syms: List[Symbol], pre: Type): List[ImplicitInfo] = for (val sym <- syms; sym.hasFlag(IMPLICIT) && isAccessible(sym, pre, false)) - yield ImplicitInfo(sym.name, pre.memberType(sym), sym); + yield new ImplicitInfo(sym.name, pre, sym); private def collectImplicitImports(imp: ImportInfo): List[ImplicitInfo] = { val pre = imp.qual.tpe; @@ -274,7 +274,7 @@ trait Contexts requires Analyzer { var impls = collect(sels1) filter (info => info.name != from); if (to != nme.WILDCARD) { val sym = imp.importedSymbol(to); - if (sym.hasFlag(IMPLICIT)) impls = ImplicitInfo(to, pre.memberType(sym), sym) :: impls; + if (sym.hasFlag(IMPLICIT)) impls = new ImplicitInfo(to, pre, sym) :: impls; } impls } @@ -338,9 +338,15 @@ trait Contexts requires Analyzer { override def toString() = tree.toString(); } - case class ImplicitInfo(val name: Name, val tpe: Type, val sym: Symbol); + class ImplicitInfo(val name: Name, pre: Type, val sym: Symbol) { + private var tpeCache: Type = null; + def tpe: Type = { + if (tpeCache == null) tpeCache = pre.memberType(sym) + tpeCache + } + } - val NoImplicitInfo = ImplicitInfo(null, null, null) + val NoImplicitInfo = new ImplicitInfo(null, null, null) case class ImportType(expr: Tree) extends Type; } |