summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-05-30 13:06:52 +0000
committerPaul Phillips <paulp@improving.org>2009-05-30 13:06:52 +0000
commit1dd1702022a67e5bd031c7f130bb4d78736b2e00 (patch)
tree11c4064761149fb4ae20e8997f835cad8f92ca94
parent12d57cd2b4371c9e15a062e3aade3f3deafdbb5d (diff)
downloadscala-1dd1702022a67e5bd031c7f130bb4d78736b2e00.tar.gz
scala-1dd1702022a67e5bd031c7f130bb4d78736b2e00.tar.bz2
scala-1dd1702022a67e5bd031c7f130bb4d78736b2e00.zip
Minor duplication removing refactoring.
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala49
1 files changed, 22 insertions, 27 deletions
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()