Compiler part of fast orElse. Review by moors. t1545 got disabled. As the comment there says:
"According to the spec this code should not be legal. Disabling for now." Need to come back and either make it work or (more likely) make nsc reject the test) git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@26046 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
636f6e0793
commit
33d22581b2
|
@ -250,6 +250,7 @@ trait StdNames extends /*reflect.generic.StdNames with*/ NameManglers { self: Sy
|
|||
val lift_ : NameType = "lift"
|
||||
val main: NameType = "main"
|
||||
val map: NameType = "map"
|
||||
val missingCase: NameType = "missingCase"
|
||||
val ne: NameType = "ne"
|
||||
val newArray: NameType = "newArray"
|
||||
val next: NameType = "next"
|
||||
|
|
|
@ -46,6 +46,18 @@ abstract class TreeGen extends reflect.internal.TreeGen {
|
|||
case Match(selector, cases) => atPos(tree.pos)(Match(mkUnchecked(selector), cases))
|
||||
case _ => tree
|
||||
}
|
||||
|
||||
def withDefaultCase(matchExpr: Tree, defaultAction: Tree/*scrutinee*/ => Tree): Tree = matchExpr match {
|
||||
case Match(scrutinee, cases) =>
|
||||
if (cases exists treeInfo.isDefaultCase) matchExpr
|
||||
else {
|
||||
val defaultCase = CaseDef(Ident(nme.WILDCARD), EmptyTree, defaultAction(scrutinee))
|
||||
Match(scrutinee, cases :+ defaultCase)
|
||||
}
|
||||
case _ =>
|
||||
matchExpr
|
||||
// [Martin] Adriaan: please fill in virtpatmat transformation here
|
||||
}
|
||||
|
||||
def mkCached(cvar: Symbol, expr: Tree): Tree = {
|
||||
val cvarRef = mkUnattributedRef(cvar)
|
||||
|
|
|
@ -264,8 +264,13 @@ abstract class UnCurry extends InfoTransform
|
|||
|
||||
fun.vparams foreach (_.symbol.owner = applyMethod)
|
||||
new ChangeOwnerTraverser(fun.symbol, applyMethod) traverse fun.body
|
||||
def applyMethodDef() = {
|
||||
val body = if (isPartial) gen.mkUncheckedMatch(fun.body) else fun.body
|
||||
|
||||
def missingCaseCall(scrutinee: Tree): Tree = Apply(Select(This(anonClass), nme.missingCase), List(scrutinee))
|
||||
|
||||
def applyMethodDef() = scala.tools.nsc.util.trace("pf "){
|
||||
val body =
|
||||
if (isPartial) gen.mkUncheckedMatch(gen.withDefaultCase(fun.body, missingCaseCall))
|
||||
else fun.body
|
||||
DefDef(Modifiers(FINAL), nme.apply, Nil, List(fun.vparams), TypeTree(restpe), body) setSymbol applyMethod
|
||||
}
|
||||
def isDefinedAtMethodDef() = {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// According to the spec this code should not be legal.
|
||||
// Disabling for now.
|
||||
object Main extends App {
|
||||
|
||||
case class Foo (field : Option[String])
|
Loading…
Reference in New Issue