diff options
author | Paul Phillips <paulp@improving.org> | 2009-06-26 13:35:55 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-06-26 13:35:55 +0000 |
commit | 2f085cf0d2c4bfd22810568898394aac327a5b98 (patch) | |
tree | b7b9a32ba3d40ff566c7ac12f9c05fe7e10077c1 /src | |
parent | 26adfa06101a0744c235cdab0cc67a133e9978ab (diff) | |
download | scala-2f085cf0d2c4bfd22810568898394aac327a5b98.tar.gz scala-2f085cf0d2c4bfd22810568898394aac327a5b98.tar.bz2 scala-2f085cf0d2c4bfd22810568898394aac327a5b98.zip |
Removed unused Any_asInstanceOfErased and Any_i...
Removed unused Any_asInstanceOfErased and Any_isInstanceOfErased
variations on is/as.
Diffstat (limited to 'src')
7 files changed, 21 insertions, 49 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index 0a5df116ac..221d08e824 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -174,39 +174,24 @@ abstract class TreeGen { } /** Builds an instance test with given value and type. */ - def mkIsInstanceOf(value: Tree, tpe: Type, erased: Boolean): Tree = { // buraq: we ignore erase, no rtt - val sym = definitions.Any_isInstanceOf - /* - val sym = - if (erased) definitions.Any_isInstanceOfErased - else definitions.Any_isInstanceOf - */ + def mkIsInstanceOf(value: Tree, tpe: Type): Tree = // buraq: we ignore erase, no rtt Apply( TypeApply( - mkAttributedSelect(value, sym), - List(TypeTree(tpe.normalize))), - List()) - } - - def mkIsInstanceOf(value: Tree, tpe: Type): Tree = { - mkIsInstanceOf(value, tpe, false/*global.phase.erasedTypes*/) // buraq: ignore which phase it is - } + mkAttributedSelect(value, Any_isInstanceOf), + List(TypeTree(tpe.normalize)) + ), + Nil + ) /** Builds a cast with given value and type. */ - def mkAsInstanceOf(value: Tree, tpe: Type, erased: Boolean): Tree = { - val sym = - if (erased) definitions.Any_asInstanceOfErased - else definitions.Any_asInstanceOf - + def mkAsInstanceOf(value: Tree, tpe: Type): Tree = Apply( TypeApply( - mkAttributedSelect(value, sym), - List(TypeTree(tpe.normalize))), - List()) - } - - def mkAsInstanceOf(value: Tree, tpe: Type): Tree = - mkAsInstanceOf(value, tpe, global.phase.erasedTypes) + mkAttributedSelect(value, Any_asInstanceOf), + List(TypeTree(tpe.normalize)) + ), + Nil + ) def mkClassOf(tp: Type): Tree = Literal(Constant(tp)) setType Predef_classOfType(tp) diff --git a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala index f89b576d8b..fdaa1ad42c 100644 --- a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala +++ b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala @@ -214,8 +214,6 @@ abstract class ScalaPrimitives { addPrimitive(Any_!=, NE) addPrimitive(Any_isInstanceOf, IS) addPrimitive(Any_asInstanceOf, AS) - addPrimitive(Any_isInstanceOfErased, ISERASED) - addPrimitive(Any_asInstanceOfErased, ASERASED) // java.lang.Object addPrimitive(Object_eq, ID) diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 258057f4e7..d821bc4956 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -1015,7 +1015,7 @@ trait ParallelMatching { outerAccessor(tpe2test.typeSymbol) match { case NoSymbol => if (settings.debug.value) cunit.warning(scrut.pos, "no outer acc for "+tpe2test.typeSymbol) ; cond - case outerAcc => And(cond, Eq(Code.fn(gen.mkAsInstanceOf(scrut, tpe2test, true), outerAcc), theRef)) + case outerAcc => And(cond, Eq(Code.fn(gen.mkAsInstanceOf(scrut, tpe2test), outerAcc), theRef)) } } diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index d9041472a3..aba7f34cef 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -301,8 +301,6 @@ trait Definitions { var Any_toString : Symbol = _ var Any_isInstanceOf: Symbol = _ var Any_asInstanceOf: Symbol = _ - var Any_isInstanceOfErased: Symbol = _ - var Any_asInstanceOfErased: Symbol = _ // members of class java.lang.{Object, String} var Object_eq : Symbol = _ @@ -795,11 +793,6 @@ trait Definitions { AnyClass, nme.isInstanceOf_, tparam => booltype) setFlag FINAL Any_asInstanceOf = newPolyMethod( AnyClass, nme.asInstanceOf_, tparam => tparam.typeConstructor) setFlag FINAL - Any_isInstanceOfErased = newPolyMethod( - AnyClass, nme.isInstanceOfErased, tparam => booltype) setFlag FINAL - //todo: do we need this? - Any_asInstanceOfErased = newPolyMethod( - AnyClass, nme.asInstanceOfErased, tparam => tparam.typeConstructor) setFlag FINAL // members of class java.lang.{Object, String} Object_== = newMethod(ObjectClass, nme.EQ, anyrefparam, booltype) setFlag FINAL diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index 0f60d2796f..31650bb531 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -263,7 +263,6 @@ trait StdNames { val assert_ = newTermName("assert") val assume_ = newTermName("assume") val asInstanceOf_ = newTermName("asInstanceOf") - val asInstanceOfErased = newTermName("asInstanceOf$erased") val box = newTermName("box") val boxArray = newTermName("boxArray") val forceBoxedArray = newTermName("forceBoxedArray") @@ -297,7 +296,6 @@ trait StdNames { val identity = newTermName("identity") val invoke_ = newTermName("invoke") val isInstanceOf_ = newTermName("isInstanceOf") - val isInstanceOfErased = newTermName("isInstanceOf$erased") val isDefinedAt = newTermName("isDefinedAt") val isEmpty = newTermName("isEmpty") val java = newTermName("java") diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 84b5e14298..188bab5810 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -615,8 +615,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { atPos(tree.pos) { Typed(Apply(translated, args), tpt) } - case Apply(TypeApply(sel @ Select(qual, name), List(targ)), List()) - if ((tree.symbol == Any_asInstanceOf || tree.symbol == Any_asInstanceOfErased)) => + case Apply(TypeApply(sel @ Select(qual, name), List(targ)), List()) if tree.symbol == Any_asInstanceOf => val qual1 = typedQualifier(qual) val qualClass = qual1.tpe.typeSymbol val targClass = targ.tpe.typeSymbol @@ -636,9 +635,9 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { case Select(qual, name) if (name != nme.CONSTRUCTOR) => if (tree.symbol == NoSymbol) tree - else if (tree.symbol == Any_asInstanceOf || tree.symbol == Any_asInstanceOfErased) + else if (tree.symbol == Any_asInstanceOf) adaptMember(atPos(tree.pos)(Select(qual, Object_asInstanceOf))) - else if (tree.symbol == Any_isInstanceOf || tree.symbol == Any_isInstanceOfErased) + else if (tree.symbol == Any_isInstanceOf) adaptMember(atPos(tree.pos)(Select(qual, Object_isInstanceOf))) else if (tree.symbol.owner == AnyClass) adaptMember(atPos(tree.pos)(Select(qual, getMember(ObjectClass, name)))) @@ -982,7 +981,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { unit.warning(tree.pos, "System.arraycopy should be applied only to arrays with fixed element types;\n" + "use Array.copy instead") - if (fn.symbol == Any_asInstanceOf || fn.symbol == Any_asInstanceOfErased) + if (fn.symbol == Any_asInstanceOf) fn match { case TypeApply(Select(qual, _), List(targ)) => if (qual.tpe <:< targ.tpe) { @@ -997,9 +996,8 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { } else tree } - // todo: get rid of instanceOfErased // todo: also handle the case where the singleton type is buried in a compound - else if (fn.symbol == Any_isInstanceOf || fn.symbol == Any_isInstanceOfErased) + else if (fn.symbol == Any_isInstanceOf) fn match { case TypeApply(sel @ Select(qual, name), List(targ)) => def mkIsInstanceOf(q: () => Tree)(tp: Type): Tree = diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 193ff216e0..6292968c7a 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -1094,7 +1094,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { val tree1 = super.transform(tree) if (needsCast(tree1)) { log("inserting cast for " + tree1 + " tpe: " + tree1.tpe) - val tree2 = gen.mkAsInstanceOf(tree1, tree1.tpe.typeSymbol.info.bounds.hi, false) + val tree2 = gen.mkAsInstanceOf(tree1, tree1.tpe.typeSymbol.info.bounds.hi) log(" casted to: " + tree2) tree2 } else @@ -1201,7 +1201,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { log("no need to cast from " + tpe + " to " + pt) tree } else - gen.mkAsInstanceOf(tree, pt, false) + gen.mkAsInstanceOf(tree, pt) private def makeArguments(fun: Symbol, vparams: List[Symbol]): List[Tree] = { @@ -1212,7 +1212,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { for ((tp, arg) <- fun.info.paramTypes zip vparams) yield { if (needsCast(arg.tpe, tp)) { //log("tp: " + tp + " " + tp.typeSymbol.owner) - gen.mkAsInstanceOf(Ident(arg), tp, false) + gen.mkAsInstanceOf(Ident(arg), tp) } else Ident(arg) } } |