diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-04-04 10:51:07 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-04-11 14:22:05 +0200 |
commit | 037eb2bf6d227bb67855d2b68e5bec496db57c96 (patch) | |
tree | f0c4c503f38bb697098619f5c3d10a6ed9c33ab0 /src | |
parent | 94716b9780c3bd3770bba43aee06e46b00375904 (diff) | |
download | dotty-037eb2bf6d227bb67855d2b68e5bec496db57c96.tar.gz dotty-037eb2bf6d227bb67855d2b68e5bec496db57c96.tar.bz2 dotty-037eb2bf6d227bb67855d2b68e5bec496db57c96.zip |
Allow closures to take type parameters.
This shouldn't require any changes to backend,
as all type parameters will be erased in erasure
Conflicts:
src/dotty/tools/dotc/core/Symbols.scala
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/ast/tpd.scala | 7 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Symbols.scala | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index 9a9ffe243..8b175721f 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -103,11 +103,14 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { * where the closure's type is the target type of the expression (FunctionN, unless * otherwise specified). */ - def Closure(meth: TermSymbol, rhsFn: List[List[Tree]] => Tree, targetType: Type = NoType)(implicit ctx: Context): Block = { + def Closure(meth: TermSymbol, rhsFn: List[List[Tree]] => Tree, targs: List[Tree] = Nil, targetType: Type = NoType)(implicit ctx: Context): Block = { val targetTpt = if (targetType.exists) TypeTree(targetType) else EmptyTree + val call = + if (targs.isEmpty) Ident(TermRef(NoPrefix, meth)) + else TypeApply(Ident(TermRef(NoPrefix, meth)), targs) Block( DefDef(meth, rhsFn) :: Nil, - Closure(Nil, Ident(TermRef(NoPrefix, meth)), targetTpt)) + Closure(Nil, call, targetTpt)) } def CaseDef(pat: Tree, guard: Tree, body: Tree)(implicit ctx: Context): CaseDef = diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index 8f66830e8..26553ddff 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -245,7 +245,7 @@ trait Symbols { this: Context => for (name <- names) { val tparam = newNakedSymbol[TypeName](NoCoord) tparamBuf += tparam - trefBuf += TypeRef(owner.thisType, name).withSym(tparam, Signature.NotAMethod) + trefBuf += TypeRef.withSymAndName(owner.thisType, tparam, name) } val tparams = tparamBuf.toList val bounds = boundsFn(trefBuf.toList) @@ -319,7 +319,7 @@ object Symbols { type ThisName <: Name private[this] var _id: Int = nextId - //assert(_id != 12325) + //assert(_id != 5859) /** The unique id of this symbol */ def id = _id |