diff options
author | James Iry <jamesiry@gmail.com> | 2013-02-07 21:40:25 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-02-07 21:40:25 -0800 |
commit | 40056d1cf028a967ae24f392a8d825ac7827b913 (patch) | |
tree | e7dc9d126678e5a37221a60fc547dc6fd84df6c0 /src/reflect | |
parent | 4c08eb604f6a23077fd1c65d0bb073ea94389961 (diff) | |
parent | dfbaaa179fddd3d37abf66a08080f646b8557b6f (diff) | |
download | scala-40056d1cf028a967ae24f392a8d825ac7827b913.tar.gz scala-40056d1cf028a967ae24f392a8d825ac7827b913.tar.bz2 scala-40056d1cf028a967ae24f392a8d825ac7827b913.zip |
Merge pull request #2090 from adriaanm/rebase-pr-2011
SI-6187 Make partial functions re-typable
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/StdNames.scala | 1 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/TreeInfo.scala | 7 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Trees.scala | 18 |
3 files changed, 25 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index 5e7f5777b2..ddc5d94e70 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -297,6 +297,7 @@ trait StdNames { // Compiler internal names val ANYname: NameType = "<anyname>" val CONSTRUCTOR: NameType = "<init>" + val DEFAULT_CASE: NameType = "defaultCase$" val EQEQ_LOCAL_VAR: NameType = "eqEqTemp$" val FAKE_LOCAL_THIS: NameType = "this$" val INITIALIZER: NameType = CONSTRUCTOR // Is this buying us something? diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index 2cc848d458..bccad69638 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -434,6 +434,13 @@ abstract class TreeInfo { case _ => false } + /** Is this pattern node a synthetic catch-all case, added during PartialFuction synthesis before we know + * whether the user provided cases are exhaustive. */ + def isSyntheticDefaultCase(cdef: CaseDef) = cdef match { + case CaseDef(Bind(nme.DEFAULT_CASE, _), EmptyTree, _) => true + case _ => false + } + /** Does this CaseDef catch Throwable? */ def catchesThrowable(cdef: CaseDef) = catchesAllOf(cdef, ThrowableClass.tpe) diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 5522c47cfa..754adcb80d 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -523,7 +523,11 @@ trait Trees extends api.Trees { self: SymbolTable => override private[scala] def copyAttrs(tree: Tree) = { super.copyAttrs(tree) tree match { - case other: TypeTree => wasEmpty = other.wasEmpty // SI-6648 Critical for correct operation of `resetAttrs`. + case other: TypeTree => + // SI-6648 Critical for correct operation of `resetAttrs`. + wasEmpty = other.wasEmpty + if (other.orig != null) + orig = other.orig.duplicate case _ => } this @@ -984,6 +988,18 @@ trait Trees extends api.Trees { self: SymbolTable => def DefDef(sym: Symbol, mods: Modifiers, rhs: Tree): DefDef = DefDef(sym, mods, mapParamss(sym)(ValDef), rhs) + /** A DefDef with original trees attached to the TypeTree of each parameter */ + def DefDef(sym: Symbol, mods: Modifiers, originalParamTpts: Symbol => Tree, rhs: Tree): DefDef = { + val paramms = mapParamss(sym){ sym => + val vd = ValDef(sym, EmptyTree) + (vd.tpt : @unchecked) match { + case tt: TypeTree => tt setOriginal (originalParamTpts(sym) setPos sym.pos.focus) + } + vd + } + DefDef(sym, mods, paramms, rhs) + } + def DefDef(sym: Symbol, rhs: Tree): DefDef = DefDef(sym, Modifiers(sym.flags), rhs) |