From 1dd1702022a67e5bd031c7f130bb4d78736b2e00 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 30 May 2009 13:06:52 +0000 Subject: Minor duplication removing refactoring. --- .../tools/nsc/symtab/classfile/UnPickler.scala | 49 ++++++++++------------ 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala index 3db8b4ea6f..1fc87fa3a7 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala @@ -258,6 +258,26 @@ abstract class UnPickler { sym } + /** To avoid cutting and pasting between METHODtpe and IMPLICITMETHODtpe */ + private def readMethodParams(isImplicit: Boolean, end: Int): List[Symbol] = { + if (readIndex == end) + return Nil + + val index = readNat() + if (isSymbolRef(index)) + at(index, readSymbol) :: until(end, readSymbolRef) + else { + val formals = + if (isImplicit) until(end, readTypeRef) + else at(index, readType) :: until(end, readTypeRef) + + // @LUC TODO the owner should be the method symbol, and newSyntheticValueParams + // should only be called once, not separately for each parameter list + val dummyMethod = new TermSymbol(NoSymbol, NoPosition, "unPickler$dummy") + dummyMethod.newSyntheticValueParams(formals) + } + } + /** Read a type */ private def readType(): Type = { val tag = readByte() @@ -295,37 +315,12 @@ abstract class UnPickler { ClassInfoType(until(end, readTypeRef), symScope(clazz), clazz) case METHODtpe => val restpe = readTypeRef() - // compatibility with old format. TODO replace by "until(end, readSymbolRef)" - val params = if (readIndex == end) List[Symbol]() - else { - val index = readNat() - if (isSymbolRef(index)) - at(index, readSymbol) :: until(end, readSymbolRef) - else { - val formals = at(index, readType) :: until(end, readTypeRef) - // @LUC TODO the owner should be the method symbol, and newSyntheticValueParams - // should only be called once, not separately for each parameter list - val dummyMethod = new TermSymbol(NoSymbol, NoPosition, "unPickler$dummy") - dummyMethod.newSyntheticValueParams(formals) - } - } + val params = readMethodParams(false, end) MethodType(params, restpe) case IMPLICITMETHODtpe => val restpe = readTypeRef() - val params = if (readIndex == end) List[Symbol]() - else { - val index = readNat() - if (isSymbolRef(index)) - at(index, readSymbol) :: until(end, readSymbolRef) - else { - val formals = until(end, readTypeRef) - // @LUC TODO the owner should be the method symbol, and newSyntheticValueParams - // should only be called once, not separately for each parameter list - val dummyMethod = new TermSymbol(NoSymbol, NoPosition, "unPickler$dummy") - dummyMethod.newSyntheticValueParams(formals) - } - } + val params = readMethodParams(true, end) ImplicitMethodType(params, restpe) case POLYtpe => val restpe = readTypeRef() -- cgit v1.2.3