diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2010-04-12 17:19:59 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2010-04-12 17:19:59 +0000 |
commit | 0beec154209cae7d8aaf34831f8a2bc79af926cc (patch) | |
tree | 9a2b2dacd240837812d21b470379d937c12e9d9e /src/compiler | |
parent | 303d9f812b221abdb1355b43e9b8a1d9be76f56a (diff) | |
download | scala-0beec154209cae7d8aaf34831f8a2bc79af926cc.tar.gz scala-0beec154209cae7d8aaf34831f8a2bc79af926cc.tar.bz2 scala-0beec154209cae7d8aaf34831f8a2bc79af926cc.zip |
Companion objects of case classes extend Abstra...
Companion objects of case classes extend AbstractFunctionN instead of
FunctionN. This saves quite some space, since FunctionN methods are not
re-mixed in for each object.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/TreeGen.scala | 11 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Unapplies.scala | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index f8678ce24e..cc3581c3f8 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -31,10 +31,13 @@ abstract class TreeGen private def isRootOrEmptyPackageClass(s: Symbol) = s.isRoot || s.isEmptyPackageClass - def scalaFunctionConstr(argtpes: List[Tree], restpe: Tree): Tree = - AppliedTypeTree( - scalaDot(newTypeName("Function"+argtpes.length)), - argtpes ::: List(restpe)) + def scalaFunctionConstr(argtpes: List[Tree], restpe: Tree, abstractFun: Boolean = false): Tree = { + val cls = if (abstractFun) + mkAttributedRef(AbstractFunctionClass(argtpes.length)) + else + mkAttributedRef(FunctionClass(argtpes.length)) + AppliedTypeTree(cls, argtpes ::: List(restpe)) + } /** Builds a reference to value whose type is given stable prefix. * The type must be suitable for this. For example, it diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala index 5ba52f5f06..6f432cc3c4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala @@ -135,7 +135,7 @@ trait Unapplies extends ast.TreeDSL */ def caseModuleDef(cdef: ClassDef): ModuleDef = { def inheritFromFun = !(cdef.mods hasFlag ABSTRACT) && cdef.tparams.isEmpty && constrParamss(cdef).length == 1 - def createFun = gen.scalaFunctionConstr(constrParamss(cdef).head map (_.tpt), toIdent(cdef)) + def createFun = gen.scalaFunctionConstr(constrParamss(cdef).head map (_.tpt), toIdent(cdef), abstractFun = true) def parents = if (inheritFromFun) List(createFun) else Nil companionModuleDef(cdef, parents ::: List(gen.scalaScalaObjectConstr)) |