From ce4bcb536279d97617f85da3f66b5296c6ee2b96 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Fri, 3 Aug 2012 18:28:03 +0200 Subject: SI-6175 reflect over classes with symbolic names Top-level classes with symbolic names (having binary names like $colon$colon) have previously been incorrectly treated as local classes by Scala reflection. As a result they were loaded as if they weren't pickled (i.e. as Java classes). Moreover this bug also had a more subtle, but more dangerous manifestation. If such a class has already been loaded indirectly by unpickling another class (which refers to it in its pickle) and then someone tried to load it explicitly via classToScala, then it would be loaded twice (once as a Scala artifact and once as a Java artifact). This is a short route to ambiguities and crashes. The fix first checks whether a class with a suspicious name (having dollars) can be loaded as a Scala artifact (by looking it up in a symbol table). If this fails, the class is then loaded in Java style (as it was done before). Ambiguous names that can be interpreted both ways (e.g. foo_$colon$colon) are first resolved as Scala and then as Java. This prioritization cannot lead to errors, because Scala and Java artifacts with the same name cannot coexist, therefore loading a Scala artifact won't shadow a homonymous Java artifact. --- test/files/run/t6175.scala | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/files/run/t6175.scala (limited to 'test/files/run') diff --git a/test/files/run/t6175.scala b/test/files/run/t6175.scala new file mode 100644 index 0000000000..69a0a712b6 --- /dev/null +++ b/test/files/run/t6175.scala @@ -0,0 +1,5 @@ +object Test extends App { + import reflect.runtime._ + val m = universe.typeOf[List[_]].members.head.asMethod + currentMirror.reflect (List (2, 3, 1)).reflectMethod(m) +} \ No newline at end of file -- cgit v1.2.3 From 509cc5287fe03f576ebaa44d4e875e3836fe8b7f Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 4 Aug 2012 09:42:25 +0200 Subject: staticTpe => staticType, actualTpe => actualType --- src/library/scala/reflect/base/Exprs.scala | 10 +++++----- .../neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala | 2 +- test/files/run/macro-impl-default-params/Impls_Macros_1.scala | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'test/files/run') diff --git a/src/library/scala/reflect/base/Exprs.scala b/src/library/scala/reflect/base/Exprs.scala index 8e429afb21..ea975bba52 100644 --- a/src/library/scala/reflect/base/Exprs.scala +++ b/src/library/scala/reflect/base/Exprs.scala @@ -14,8 +14,8 @@ trait Exprs { self: Universe => def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # Expr[T] def tree: Tree - def staticTpe: Type - def actualTpe: Type + def staticType: Type + def actualType: Type def splice: T val value: T @@ -24,7 +24,7 @@ trait Exprs { self: Universe => override def canEqual(x: Any) = x.isInstanceOf[Expr[_]] override def equals(x: Any) = x.isInstanceOf[Expr[_]] && this.mirror == x.asInstanceOf[Expr[_]].mirror && this.tree == x.asInstanceOf[Expr[_]].tree override def hashCode = mirror.hashCode * 31 + tree.hashCode - override def toString = "Expr["+staticTpe+"]("+tree+")" + override def toString = "Expr["+staticType+"]("+tree+")" } object Expr { @@ -43,8 +43,8 @@ trait Exprs { self: Universe => // [Eugene++] this is important // !!! remove when we have improved type inference for singletons // search for .type] to find other instances - lazy val staticTpe: Type = implicitly[AbsTypeTag[T]].tpe - def actualTpe: Type = treeType(tree) + lazy val staticType: Type = implicitly[AbsTypeTag[T]].tpe + def actualType: Type = treeType(tree) def splice: T = throw new UnsupportedOperationException(""" |the function you're calling has not been spliced by the compiler. diff --git a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala index b32a20ba06..b260a2fdfa 100644 --- a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala +++ b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala @@ -7,7 +7,7 @@ object Impls { import c.universe._ val body = Block( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticTpe)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.TypeTag[U]].tpe)))), Literal(Constant(()))) c.Expr[Unit](body) diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala index b57af2ede4..2ba28824e0 100644 --- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala @@ -8,7 +8,7 @@ object Impls { val U = implicitly[c.TypeTag[U]] val body = Block( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticTpe)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + U.tpe)))), Literal(Constant(()))) -- cgit v1.2.3 From 61cc8ff61c81a1276a921ad5288ee3bebea1c96e Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Mon, 6 Aug 2012 11:01:17 +0200 Subject: SI-6188 ICodeReader notes exception handlers, Inliner takes them into account --- src/compiler/scala/tools/nsc/backend/icode/Members.scala | 1 + src/compiler/scala/tools/nsc/backend/opt/Inliners.scala | 13 ++++++++++++- .../scala/tools/nsc/symtab/classfile/ICodeReader.scala | 3 +++ test/files/run/t6188.check | 1 + test/files/run/t6188.flags | 1 + test/files/run/t6188.scala | 12 ++++++++++++ 6 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t6188.check create mode 100644 test/files/run/t6188.flags create mode 100644 test/files/run/t6188.scala (limited to 'test/files/run') diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 00f4a9d262..44c4a3a6db 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -170,6 +170,7 @@ trait Members { var sourceFile: SourceFile = NoSourceFile var returnType: TypeKind = _ var recursive: Boolean = false + var bytecodeHasEHs = false // set by ICodeReader only, used by Inliner to prevent inlining (SI-6188) /** local variables and method parameters */ var locals: List[Local] = Nil diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index cce18d436f..dd7676a371 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -405,6 +405,12 @@ abstract class Inliners extends SubComponent { val inc = new IMethodInfo(callee) val pair = new CallerCalleeInfo(caller, inc, fresh, inlinedMethodCount) + if(inc.hasHandlers && (stackLength == -1)) { + // no inlining is done, yet don't warn about it, stackLength == -1 indicates we're trying to inlineWithoutTFA. + // Shortly, a TFA will be computed and an error message reported if indeed inlining not possible. + return false + } + (pair isStampedForInlining stackLength) match { case inlInfo if inlInfo.isSafe => @@ -605,7 +611,7 @@ abstract class Inliners extends SubComponent { def isSmall = (length <= SMALL_METHOD_SIZE) && blocks(0).length < 10 def isLarge = length > MAX_INLINE_SIZE def isRecursive = m.recursive - def hasHandlers = handlers.nonEmpty + def hasHandlers = handlers.nonEmpty || m.bytecodeHasEHs def isSynchronized = sym.hasFlag(Flags.SYNCHRONIZED) def hasNonFinalizerHandler = handlers exists { @@ -941,6 +947,7 @@ abstract class Inliners extends SubComponent { if(inc.isRecursive) { rs ::= "is recursive" } if(isInlineForbidden) { rs ::= "is annotated @noinline" } if(inc.isSynchronized) { rs ::= "is synchronized method" } + if(inc.m.bytecodeHasEHs) { rs ::= "bytecode contains exception handlers / finally clause" } // SI-6188 if(rs.isEmpty) null else rs.mkString("", ", and ", "") } @@ -974,6 +981,10 @@ abstract class Inliners extends SubComponent { return DontInlineHere("too low score (heuristics)") } + if(inc.hasHandlers && (stackLength != 0)) { + // TODO pending return DontInlineHere("callee contains exception handlers / finally clause, and is invoked with non-empty operand stack") // SI-6157 + } + if(isKnownToInlineSafely) { return InlineableAtThisCaller } if(stackLength > inc.minimumStack && inc.hasNonFinalizerHandler) { diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index bb9f9bde98..3a3be4dc78 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -594,6 +594,7 @@ abstract class ICodeReader extends ClassfileParser { while (pc < codeLength) parseInstruction val exceptionEntries = in.nextChar.toInt + code.containsEHs = (exceptionEntries != 0) var i = 0 while (i < exceptionEntries) { // skip start end PC @@ -647,6 +648,7 @@ abstract class ICodeReader extends ClassfileParser { var containsDUPX = false var containsNEW = false + var containsEHs = false def emit(i: Instruction) { instrs += ((pc, i)) @@ -664,6 +666,7 @@ abstract class ICodeReader extends ClassfileParser { val code = new Code(method) method.setCode(code) + method.bytecodeHasEHs = containsEHs var bb = code.startBlock def makeBasicBlocks: mutable.Map[Int, BasicBlock] = diff --git a/test/files/run/t6188.check b/test/files/run/t6188.check new file mode 100644 index 0000000000..1af3932ecd --- /dev/null +++ b/test/files/run/t6188.check @@ -0,0 +1 @@ +Failure(java.lang.Exception: this is an exception) diff --git a/test/files/run/t6188.flags b/test/files/run/t6188.flags new file mode 100644 index 0000000000..0ebca3e7af --- /dev/null +++ b/test/files/run/t6188.flags @@ -0,0 +1 @@ + -optimize diff --git a/test/files/run/t6188.scala b/test/files/run/t6188.scala new file mode 100644 index 0000000000..48180ddf9d --- /dev/null +++ b/test/files/run/t6188.scala @@ -0,0 +1,12 @@ +// SI-6188 Optimizer incorrectly removes method invocations containing throw expressions + +import scala.util.Success + +object Test { + def main(args: Array[String]) { + val e = new Exception("this is an exception") + val res = Success(1).flatMap[Int](x => throw e) + println(res) + } +} + -- cgit v1.2.3 From 17037367049312eb3d26766a5759295ac9f8aed6 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Mon, 6 Aug 2012 18:31:35 +0200 Subject: SI-6157 don't inline callee with exception-handler(s) if potentially unsafe --- .../backend/icode/analysis/TypeFlowAnalysis.scala | 8 ++++++- .../scala/tools/nsc/backend/opt/Inliners.scala | 4 ++-- test/files/pos/t6157.flags | 1 + test/files/pos/t6157.scala | 25 ++++++++++++++++++++++ test/files/run/private-inline.scala | 2 +- 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 test/files/pos/t6157.flags create mode 100644 test/files/pos/t6157.scala (limited to 'test/files/run') diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala index 962c47f443..e791936470 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala @@ -736,7 +736,13 @@ abstract class TypeFlowAnalysis { val succs = point.successors filter relevantBBs succs foreach { p => assert((p.predecessors filter isOnPerimeter).isEmpty) - val updated = lattice.lub(List(output, in(p)), p.exceptionHandlerStart) + val existing = in(p) + // TODO move the following assertion to typeFlowLattice.lub2 for wider applicability (ie MethodTFA in addition to MTFAGrowable). + assert(existing == lattice.bottom || + p.exceptionHandlerStart || + (output.stack.length == existing.stack.length), + "Trying to merge non-bottom type-stacks with different stack heights. For a possible cause see SI-6157.") + val updated = lattice.lub(List(output, existing), p.exceptionHandlerStart) if(updated != in(p)) { in(p) = updated enqueue(p) diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index dd7676a371..22f0a9ca7c 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -981,8 +981,8 @@ abstract class Inliners extends SubComponent { return DontInlineHere("too low score (heuristics)") } - if(inc.hasHandlers && (stackLength != 0)) { - // TODO pending return DontInlineHere("callee contains exception handlers / finally clause, and is invoked with non-empty operand stack") // SI-6157 + if(inc.hasHandlers && (stackLength > inc.minimumStack)) { + return DontInlineHere("callee contains exception handlers / finally clause, and is invoked with non-empty operand stack") // SI-6157 } if(isKnownToInlineSafely) { return InlineableAtThisCaller } diff --git a/test/files/pos/t6157.flags b/test/files/pos/t6157.flags new file mode 100644 index 0000000000..0ebca3e7af --- /dev/null +++ b/test/files/pos/t6157.flags @@ -0,0 +1 @@ + -optimize diff --git a/test/files/pos/t6157.scala b/test/files/pos/t6157.scala new file mode 100644 index 0000000000..7463989b14 --- /dev/null +++ b/test/files/pos/t6157.scala @@ -0,0 +1,25 @@ +// SI-6157 - Compiler crash on inlined function and -optimize option + +object Test { + def main(args: Array[String]) { + Console.println( + ErrorHandler.defaultIfIOException("String")("String") + ) + } +} + +import java.io.IOException + +object ErrorHandler { + + @inline + def defaultIfIOException[T](default: => T)(closure: => T): T = { + try { + closure + } catch { + case e: IOException => + default + } + } +} + diff --git a/test/files/run/private-inline.scala b/test/files/run/private-inline.scala index a45300b026..a62007779c 100644 --- a/test/files/run/private-inline.scala +++ b/test/files/run/private-inline.scala @@ -30,7 +30,7 @@ final class A { } object Test { - def methodClasses = List("f1a", "f1b", "f2a", "f2b") map ("A$$anonfun$" + _ + "$1") + def methodClasses = List("f1a", "f2a") map ("A$$anonfun$" + _ + "$1") def main(args: Array[String]): Unit = { val a = new A -- cgit v1.2.3 From c2bb028deb7a03acb5dcf2fa905a466fef8be1a6 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Mon, 6 Aug 2012 21:37:43 +0200 Subject: test case for SI-6102 --- test/files/run/t6102.check | 1 + test/files/run/t6102.flags | 1 + test/files/run/t6102.scala | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 test/files/run/t6102.check create mode 100644 test/files/run/t6102.flags create mode 100644 test/files/run/t6102.scala (limited to 'test/files/run') diff --git a/test/files/run/t6102.check b/test/files/run/t6102.check new file mode 100644 index 0000000000..b6fc4c620b --- /dev/null +++ b/test/files/run/t6102.check @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/test/files/run/t6102.flags b/test/files/run/t6102.flags new file mode 100644 index 0000000000..e35535c8ea --- /dev/null +++ b/test/files/run/t6102.flags @@ -0,0 +1 @@ + -Ydead-code diff --git a/test/files/run/t6102.scala b/test/files/run/t6102.scala new file mode 100644 index 0000000000..53584055bb --- /dev/null +++ b/test/files/run/t6102.scala @@ -0,0 +1,13 @@ +// SI-6102 Wrong bytecode in lazyval + no-op finally clause + +object Test { + + def main(args: Array[String]) { + try { + val x = 3 + } finally { + print("hello") + } + } +} + -- cgit v1.2.3 From b65b7b13924a86d38e04873f9c68d69590dec661 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 6 Aug 2012 11:01:50 -0700 Subject: Fix for SI-6063, broken static forwarders. Have to rule out access boundaries as well as private/protected. --- src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala | 2 ++ test/files/run/t6063.check | 1 + test/files/run/t6063/S_1.scala | 11 +++++++++++ test/files/run/t6063/S_2.scala | 8 ++++++++ 4 files changed, 22 insertions(+) create mode 100644 test/files/run/t6063.check create mode 100644 test/files/run/t6063/S_1.scala create mode 100644 test/files/run/t6063/S_2.scala (limited to 'test/files/run') diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index a804cc92d3..ecd7f3964f 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -1173,6 +1173,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters { debuglog("No forwarder for '%s' from %s to '%s'".format(m, jclassName, moduleClass)) else if (conflictingNames(m.name)) log("No forwarder for " + m + " due to conflict with " + linkedClass.info.member(m.name)) + else if (m.hasAccessBoundary) + log(s"No forwarder for non-public member $m") else { log("Adding static forwarder for '%s' from %s to '%s'".format(m, jclassName, moduleClass)) if (m.isAccessor && m.accessed.hasStaticAnnotation) { diff --git a/test/files/run/t6063.check b/test/files/run/t6063.check new file mode 100644 index 0000000000..39347383f3 --- /dev/null +++ b/test/files/run/t6063.check @@ -0,0 +1 @@ +public static int foo.Ob.f5() diff --git a/test/files/run/t6063/S_1.scala b/test/files/run/t6063/S_1.scala new file mode 100644 index 0000000000..69b1e91271 --- /dev/null +++ b/test/files/run/t6063/S_1.scala @@ -0,0 +1,11 @@ +package foo + +abstract class Foo { + private[foo] def f1 = 1 + private def f2 = 2 + protected[foo] def f3 = 3 + protected def f4 = 4 + def f5 = 5 +} + +object Ob extends Foo diff --git a/test/files/run/t6063/S_2.scala b/test/files/run/t6063/S_2.scala new file mode 100644 index 0000000000..a990cc7931 --- /dev/null +++ b/test/files/run/t6063/S_2.scala @@ -0,0 +1,8 @@ +import java.lang.reflect.Modifier._ + +object Test { + def main(args: Array[String]): Unit = { + val forwarders = Class.forName("foo.Ob").getMethods.toList filter (m => isStatic(m.getModifiers)) + forwarders.sortBy(_.toString) foreach println + } +} -- cgit v1.2.3 From 432d7b86cb7c46d0415b8c06bf8045e309c63f03 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 4 Aug 2012 11:08:10 +0200 Subject: SI-6178 reflective invocation of magic symbols In Scala there are some methods that only exist in symbol tables, but don't have corresponding method entries in Java class files. To the best of my knowledge, these methods can be subdivided into five groups: 1) stuff weaved onto Any, AnyVal and AnyRef (aka Object), 2) magic methods that Scala exposes to fix Java arrays, 3) magic methods declared on Scala primitive value classes, 4) compile-time methods (such as classOf and all kinds of macros), 5) miscellaneous stuff (currently only String_+). To support these magic symbols, I've modified the `checkMemberOf` validator to special case Any/AnyVal/AnyRef methods and adjusted MethodMirror and ConstructorMirror classes to use special invokers for those instead of relying on Java reflection. Support for value classes will arrive in the subsequent commit, because it requires some unrelated changes to the mirror API (currently mirrors only support AnyRefs as their targets). --- .../scala/reflect/runtime/JavaMirrors.scala | 110 +++++++++++++++--- .../files/run/reflection-magicsymbols-invoke.check | 124 +++++++++++++++++++++ .../files/run/reflection-magicsymbols-invoke.scala | 94 ++++++++++++++++ test/files/run/t6178.check | 1 + test/files/run/t6178.scala | 7 ++ 5 files changed, 320 insertions(+), 16 deletions(-) create mode 100644 test/files/run/reflection-magicsymbols-invoke.check create mode 100644 test/files/run/reflection-magicsymbols-invoke.scala create mode 100644 test/files/run/t6178.check create mode 100644 test/files/run/t6178.scala (limited to 'test/files/run') diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 5eb7770de6..83fbee97cc 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -20,6 +20,7 @@ import internal.Flags._ //import scala.tools.nsc.util.ScalaClassLoader._ import ReflectionUtils.{singletonInstance} import language.existentials +import scala.runtime.ScalaRunTime trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: SymbolTable => @@ -152,8 +153,15 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym def moduleSymbol(rtcls: RuntimeClass): ModuleSymbol = classToScala(rtcls).companionModule.asModule - private def checkMemberOf(wannabe: Symbol, owner: Symbol) = - if (!owner.info.member(wannabe.name).alternatives.contains(wannabe)) ErrorNotMember(wannabe, owner) + private def checkMemberOf(wannabe: Symbol, owner: ClassSymbol) { + if (wannabe.owner == AnyClass || wannabe.owner == AnyRefClass || wannabe.owner == ObjectClass) { + // do nothing + } else if (wannabe.owner == AnyValClass) { + if (!owner.isPrimitiveValueClass && !owner.isDerivedValueClass) ErrorNotMember(wannabe, owner) + } else { + if (!owner.info.member(wannabe.name).alternatives.contains(wannabe)) ErrorNotMember(wannabe, owner) + } + } private class JavaInstanceMirror(obj: AnyRef) extends InstanceMirror { @@ -175,7 +183,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym } def reflectMethod(method: MethodSymbol): MethodMirror = { checkMemberOf(method, symbol) - new JavaMethodMirror(obj, method) + mkJavaMethodMirror(obj, method) } def reflectClass(cls: ClassSymbol): ClassMirror = { if (cls.isStatic) ErrorStaticClass(cls) @@ -230,26 +238,93 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym sig } - private class JavaMethodMirror(val receiver: AnyRef, val symbol: MethodSymbol) + // the "symbol == Any_getClass || symbol == Object_getClass" test doesn't cut it + // because both AnyVal and its primitive descendants define their own getClass methods + private def isGetClass(meth: MethodSymbol) = meth.name.toString == "getClass" && meth.params.flatten.isEmpty + private def isMagicPrimitiveMethod(meth: MethodSymbol) = meth.owner.isPrimitiveValueClass + private def isStringConcat(meth: MethodSymbol) = meth == String_+ || (isMagicPrimitiveMethod(meth) && meth.returnType =:= StringClass.toType) + lazy val magicMethodOwners = Set[Symbol](AnyClass, AnyValClass, AnyRefClass, ObjectClass, ArrayClass) ++ ScalaPrimitiveValueClasses + lazy val nonMagicObjectMethods = Set[Symbol](Object_clone, Object_equals, Object_finalize, Object_hashCode, Object_toString, + Object_notify, Object_notifyAll) ++ ObjectClass.info.member(nme.wait_).asTerm.alternatives.map(_.asMethod) + private def isMagicMethod(meth: MethodSymbol): Boolean = { + if (isGetClass(meth) || isStringConcat(meth) || isMagicPrimitiveMethod(meth) || meth == Predef_classOf || meth.isTermMacro) return true + magicMethodOwners(meth.owner) && !nonMagicObjectMethods(meth) + } + + // unlike other mirrors, method mirrors are created by a factory + // that's because we want to have decent performance + // therefore we move special cases into separate subclasses + // rather than have them on a hot path them in a unified implementation of the `apply` method + private def mkJavaMethodMirror(receiver: AnyRef, symbol: MethodSymbol): JavaMethodMirror = { + if (isMagicMethod(symbol)) new JavaMagicMethodMirror(receiver, symbol) + else new JavaVanillaMethodMirror(receiver, symbol) + } + + private abstract class JavaMethodMirror(val receiver: AnyRef, val symbol: MethodSymbol) extends MethodMirror { lazy val jmeth = { val jmeth = methodToJava(symbol) if (!jmeth.isAccessible) jmeth.setAccessible(true) jmeth } - def apply(args: Any*): Any = - if (symbol.owner == ArrayClass) - symbol.name match { - case nme.length => jArray.getLength(receiver) - case nme.apply => jArray.get(receiver, args(0).asInstanceOf[Int]) - case nme.update => jArray.set(receiver, args(0).asInstanceOf[Int], args(1)) - case _ => assert(false, s"unexpected array method: $symbol") - } - else - jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) + override def toString = s"method mirror for ${showMethodSig(symbol)} (bound to $receiver)" } + private class JavaVanillaMethodMirror(receiver: AnyRef, symbol: MethodSymbol) + extends JavaMethodMirror(receiver, symbol) { + def apply(args: Any*): Any = jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) + } + + private class JavaMagicMethodMirror(receiver: AnyRef, symbol: MethodSymbol) + extends JavaMethodMirror(receiver, symbol) { + def apply(args: Any*): Any = { + // checking type conformance is too much of a hassle, so we don't do it here + // actually it's not even necessary, because we manually dispatch arguments to magic methods below + val params = symbol.paramss.flatten + val perfectMatch = args.length == params.length + // todo. this doesn't account for multiple vararg parameter lists + // however those aren't supported by the mirror API: https://issues.scala-lang.org/browse/SI-6182 + // hence I leave this code as is, to be fixed when the corresponding bug is fixed + val varargMatch = args.length >= params.length - 1 && isVarArgsList(params) + if (!perfectMatch && !varargMatch) { + val n_arguments = if (isVarArgsList(params)) s"${params.length - 1} or more" else s"${params.length}" + var s_arguments = if (params.length == 1 && !isVarArgsList(params)) "argument" else "arguments" + throw new ScalaReflectionException(s"${showMethodSig(symbol)} takes $n_arguments $s_arguments") + } + + def objArg0 = args(0).asInstanceOf[AnyRef] + def objArgs = args.asInstanceOf[Seq[AnyRef]] + def fail(msg: String) = throw new ScalaReflectionException(msg + ", it cannot be invoked with mirrors") + + symbol match { + case Any_== | Object_== => ScalaRunTime.inlinedEquals(receiver, objArg0) + case Any_!= | Object_!= => !ScalaRunTime.inlinedEquals(receiver, objArg0) + case Any_## | Object_## => ScalaRunTime.hash(receiver) + case Any_equals => receiver.equals(objArg0) + case Any_hashCode => receiver.hashCode + case Any_toString => receiver.toString + case Object_eq => receiver eq objArg0 + case Object_ne => receiver ne objArg0 + case Object_synchronized => receiver.synchronized(objArg0) + case sym if isGetClass(sym) => receiver.getClass + case Any_asInstanceOf => fail("Any.asInstanceOf requires a type argument") + case Any_isInstanceOf => fail("Any.isInstanceOf requires a type argument") + case Object_asInstanceOf => fail("AnyRef.$asInstanceOf is an internal method") + case Object_isInstanceOf => fail("AnyRef.$isInstanceOf is an internal method") + case Array_length => ScalaRunTime.array_length(receiver) + case Array_apply => ScalaRunTime.array_apply(receiver, args(0).asInstanceOf[Int]) + case Array_update => ScalaRunTime.array_update(receiver, args(0).asInstanceOf[Int], args(1)) + case Array_clone => ScalaRunTime.array_clone(receiver) + case sym if isStringConcat(sym) => receiver.toString + objArg0 + case sym if isMagicPrimitiveMethod(sym) => fail("implementation restriction: ${symbol.fullName} is a magic primitive method") + case sym if sym == Predef_classOf => fail("Predef.classOf is a compile-time function") + case sym if sym.isTermMacro => fail(s"${symbol.fullName} is a macro, i.e. a compile-time function") + case _ => assert(false, this) + } + } + } + private class JavaConstructorMirror(val outer: AnyRef, val symbol: MethodSymbol) extends MethodMirror { override val receiver = outer @@ -259,6 +334,9 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym jconstr } def apply(args: Any*): Any = { + if (symbol.owner == ArrayClass) + throw new ScalaReflectionException("Cannot instantiate arrays with mirrors. Consider using `scala.reflect.ClassTag().newArray()` instead") + val effectiveArgs = if (outer == null) args.asInstanceOf[Seq[AnyRef]] else outer +: args.asInstanceOf[Seq[AnyRef]] @@ -1067,7 +1145,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym mirrors(rootToLoader getOrElseUpdate(root, findLoader)).get.get } - private lazy val magicSymbols: Map[(String, Name), Symbol] = { + private lazy val magicClasses: Map[(String, Name), Symbol] = { def mapEntry(sym: Symbol): ((String, Name), Symbol) = (sym.owner.fullName, sym.name) -> sym Map() ++ (definitions.magicSymbols filter (_.isType) map mapEntry) } @@ -1088,7 +1166,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym if (name.isTermName && !owner.isEmptyPackageClass) return mirror.makeScalaPackage( if (owner.isRootSymbol) name.toString else owner.fullName+"."+name) - magicSymbols get (owner.fullName, name) match { + magicClasses get (owner.fullName, name) match { case Some(tsym) => owner.info.decls enter tsym return tsym diff --git a/test/files/run/reflection-magicsymbols-invoke.check b/test/files/run/reflection-magicsymbols-invoke.check new file mode 100644 index 0000000000..a180ed806e --- /dev/null +++ b/test/files/run/reflection-magicsymbols-invoke.check @@ -0,0 +1,124 @@ +============ +Any +it's important to print the list of Any's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +method !=: (x$1: Any)Boolean +method ##: ()Int +method ==: (x$1: Any)Boolean +method asInstanceOf: [T0]=> T0 +method equals: (x$1: Any)Boolean +method getClass: ()java.lang.Class[_] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method toString: ()java.lang.String +testing Any.!=: false +testing Any.##: 50 +testing Any.==: true +testing Any.asInstanceOf: class scala.ScalaReflectionException: Any.asInstanceOf requires a type argument, it cannot be invoked with mirrors +testing Any.asInstanceOf: class scala.ScalaReflectionException: scala.Any.asInstanceOf[T0]: T0 takes 0 arguments +testing Any.equals: true +testing Any.getClass: class java.lang.String +testing Any.hashCode: 50 +testing Any.isInstanceOf: class scala.ScalaReflectionException: Any.isInstanceOf requires a type argument, it cannot be invoked with mirrors +testing Any.isInstanceOf: class scala.ScalaReflectionException: scala.Any.isInstanceOf[T0]: Boolean takes 0 arguments +testing Any.toString: 2 +============ +AnyVal +it's important to print the list of AnyVal's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor AnyVal: ()AnyVal +method getClass: ()Class[_ <: AnyVal] +testing AnyVal.: class java.lang.InstantiationException: null +testing AnyVal.getClass: class scala.ScalaReflectionException: expected a member of class Integer, you provided method scala.AnyVal.getClass +============ +AnyRef +it's important to print the list of AnyRef's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor Object: ()java.lang.Object +method !=: (x$1: Any)Boolean +method !=: (x$1: AnyRef)Boolean +method ##: ()Int +method $asInstanceOf: [T0]()T0 +method $isInstanceOf: [T0]()Boolean +method ==: (x$1: Any)Boolean +method ==: (x$1: AnyRef)Boolean +method asInstanceOf: [T0]=> T0 +method clone: ()java.lang.Object +method eq: (x$1: AnyRef)Boolean +method equals: (x$1: Any)Boolean +method finalize: ()Unit +method getClass: ()java.lang.Class[_] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method ne: (x$1: AnyRef)Boolean +method notify: ()Unit +method notifyAll: ()Unit +method synchronized: [T0](x$1: T0)T0 +method toString: ()java.lang.String +method wait: ()Unit +method wait: (x$1: Long)Unit +method wait: (x$1: Long, x$2: Int)Unit +testing Object.!=: false +testing Object.##: 50 +testing Object.$asInstanceOf: class scala.ScalaReflectionException: AnyRef.$asInstanceOf is an internal method, it cannot be invoked with mirrors +testing Object.$asInstanceOf: class scala.ScalaReflectionException: java.lang.Object.$asInstanceOf[T0](): T0 takes 0 arguments +testing Object.$isInstanceOf: class scala.ScalaReflectionException: AnyRef.$isInstanceOf is an internal method, it cannot be invoked with mirrors +testing Object.$isInstanceOf: class scala.ScalaReflectionException: java.lang.Object.$isInstanceOf[T0](): Boolean takes 0 arguments +testing Object.==: true +testing Object.clone: class java.lang.CloneNotSupportedException: java.lang.String +testing Object.eq: true +testing Object.equals: true +testing Object.finalize: null +testing Object.getClass: class java.lang.String +testing Object.hashCode: 50 +testing Object.ne: false +testing Object.notify: class java.lang.IllegalMonitorStateException: null +testing Object.notifyAll: class java.lang.IllegalMonitorStateException: null +testing Object.synchronized: 2 +testing Object.toString: 2 +TODO: also test AnyRef.wait overloads +============ +Array +it's important to print the list of Array's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor Array: (_length: Int)Array[T] +constructor Object: ()java.lang.Object +method !=: (x$1: Any)Boolean +method !=: (x$1: AnyRef)Boolean +method ##: ()Int +method $asInstanceOf: [T0]()T0 +method $isInstanceOf: [T0]()Boolean +method ==: (x$1: Any)Boolean +method ==: (x$1: AnyRef)Boolean +method apply: (i: )T +method asInstanceOf: [T0]=> T0 +method clone: ()Array[T] +method eq: (x$1: AnyRef)Boolean +method equals: (x$1: Any)Boolean +method finalize: ()Unit +method getClass: ()java.lang.Class[_] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method length: => Int +method ne: (x$1: AnyRef)Boolean +method notify: ()Unit +method notifyAll: ()Unit +method synchronized: [T0](x$1: T0)T0 +method toString: ()java.lang.String +method update: (i: , x: )Unit +method wait: ()Unit +method wait: (x$1: Long)Unit +method wait: (x$1: Long, x$2: Int)Unit +value _length: Int +testing Array.length: 2 +testing Array.apply: 1 +testing Array.update: () +testing Array.clone: List(1, 2) +============ +Other +testing String.+: 23 +============ +CTM +testing Predef.classOf: class scala.ScalaReflectionException: Predef.classOf is a compile-time function, it cannot be invoked with mirrors +testing Predef.classOf: class scala.ScalaReflectionException: scala.Predef.classOf[T]: Class[T] takes 0 arguments +testing Universe.reify: class scala.ScalaReflectionException: scala.reflect.base.Universe.reify is a macro, i.e. a compile-time function, it cannot be invoked with mirrors diff --git a/test/files/run/reflection-magicsymbols-invoke.scala b/test/files/run/reflection-magicsymbols-invoke.scala new file mode 100644 index 0000000000..61ecc6458d --- /dev/null +++ b/test/files/run/reflection-magicsymbols-invoke.scala @@ -0,0 +1,94 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.universe.definitions._ +import scala.reflect.runtime.{currentMirror => cm} + +object Test extends App { + def key(sym: Symbol) = sym + ": " + sym.typeSignature + def test(tpe: Type, receiver: Any, method: String, args: Any*) { + def wrap[T](op: => T) = + try { + var result = op.asInstanceOf[AnyRef] + if (scala.runtime.ScalaRunTime.isArray(result)) + result = scala.runtime.ScalaRunTime.toObjectArray(result).toList + println(result) + } catch { + case ex: Throwable => + val realex = scala.reflect.runtime.ReflectionUtils.unwrapThrowable(ex) + println(realex.getClass + ": " + realex.getMessage) + } + print(s"testing ${tpe.typeSymbol.name}.$method: ") + wrap({ + if (method == nme.CONSTRUCTOR.toString) { + val ctor = tpe.declaration(nme.CONSTRUCTOR).asMethod + cm.reflectClass(ctor.owner.asClass).reflectConstructor(ctor)(args: _*) + } else { + val meth = tpe.declaration(newTermName(method).encodedName.toTermName).asMethod + cm.reflect(receiver).reflectMethod(meth)(args: _*) + } + }) + } + + println("============\nAny") + println("it's important to print the list of Any's members") + println("if some of them change (possibly, adding and/or removing magic symbols), we must update this test") + typeOf[Any].members.toList.sortBy(key).foreach(sym => println(key(sym))) + test(typeOf[Any], "2", "!=", "2") + test(typeOf[Any], "2", "##") + test(typeOf[Any], "2", "==", "2") + test(typeOf[Any], "2", "asInstanceOf") + test(typeOf[Any], "2", "asInstanceOf", typeOf[String]) + test(typeOf[Any], "2", "equals", "2") + test(typeOf[Any], "2", "getClass") + test(typeOf[Any], "2", "hashCode") + test(typeOf[Any], "2", "isInstanceOf") + test(typeOf[Any], "2", "isInstanceOf", typeOf[String]) + test(typeOf[Any], "2", "toString") + + println("============\nAnyVal") + println("it's important to print the list of AnyVal's members") + println("if some of them change (possibly, adding and/or removing magic symbols), we must update this test") + typeOf[AnyVal].declarations.toList.sortBy(key).foreach(sym => println(key(sym))) + test(typeOf[AnyVal], null, "") + test(typeOf[AnyVal], 2, "getClass") + + println("============\nAnyRef") + println("it's important to print the list of AnyRef's members") + println("if some of them change (possibly, adding and/or removing magic symbols), we must update this test") + typeOf[AnyRef].members.toList.sortBy(key).foreach(sym => println(key(sym))) + test(typeOf[AnyRef], "2", "!=", "2") + test(typeOf[AnyRef], "2", "##") + test(typeOf[AnyRef], "2", "$asInstanceOf") + test(typeOf[AnyRef], "2", "$asInstanceOf", typeOf[String]) + test(typeOf[AnyRef], "2", "$isInstanceOf") + test(typeOf[AnyRef], "2", "$isInstanceOf", typeOf[String]) + test(typeOf[AnyRef], "2", "==", "2") + test(typeOf[AnyRef], "2", "clone") + test(typeOf[AnyRef], "2", "eq", "2") + test(typeOf[AnyRef], "2", "equals", "2") + test(typeOf[AnyRef], "2", "finalize") + test(typeOf[AnyRef], "2", "getClass") + test(typeOf[AnyRef], "2", "hashCode") + test(typeOf[AnyRef], "2", "ne", "2") + test(typeOf[AnyRef], "2", "notify") + test(typeOf[AnyRef], "2", "notifyAll") + test(typeOf[AnyRef], "2", "synchronized", "2") + test(typeOf[AnyRef], "2", "toString") + println("TODO: also test AnyRef.wait overloads") + + println("============\nArray") + println("it's important to print the list of Array's members") + println("if some of them change (possibly, adding and/or removing magic symbols), we must update this test") + ArrayClass.typeSignature.members.toList.sortBy(key).foreach(sym => println(key(sym))) + test(ArrayClass.typeSignature, Array(1, 2), "length") + test(ArrayClass.typeSignature, Array(1, 2), "apply", 0) + test(ArrayClass.typeSignature, Array(1, 2), "update", 0, 0) + test(ArrayClass.typeSignature, Array(1, 2), "clone") + + println("============\nOther") + test(typeOf[String], "2", "+", 3) + + println("============\nCTM") + test(PredefModule.moduleClass.typeSignature, Predef, "classOf") + test(PredefModule.moduleClass.typeSignature, Predef, "classOf", typeOf[String]) + test(typeOf[scala.reflect.base.Universe], scala.reflect.runtime.universe, "reify", "2") +} \ No newline at end of file diff --git a/test/files/run/t6178.check b/test/files/run/t6178.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/files/run/t6178.check @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/test/files/run/t6178.scala b/test/files/run/t6178.scala new file mode 100644 index 0000000000..0b4cf0bbf5 --- /dev/null +++ b/test/files/run/t6178.scala @@ -0,0 +1,7 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +object Test extends App { + val plus = typeOf[java.lang.String].member(newTermName("$plus")).asMethod + println(cm.reflect("").reflectMethod(plus).apply("2")) +} \ No newline at end of file -- cgit v1.2.3 From 3aa221e28c3ae0381b876448e3174f0c527e9abc Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sun, 5 Aug 2012 20:02:39 +0200 Subject: SI-6179 mirrors now work with value classes mirrors now carry a class tag of the receiver, so that they can detect value classes being reflected upon and adjust accordingly (e.g. allow Int_+ for ints, but disallow it for Integers). Surprisingly enough derived value classes (SIP-15 guys that inherit from AnyVal) have been working all along, so no modification were required to fix them. --- src/reflect/scala/reflect/api/Mirrors.scala | 6 +- src/reflect/scala/reflect/internal/StdNames.scala | 6 + .../scala/reflect/runtime/JavaMirrors.scala | 74 +- .../run/reflection-valueclasses-derived.check | 3 + .../run/reflection-valueclasses-derived.scala | 12 + test/files/run/reflection-valueclasses-magic.check | 1456 ++++++++++++++++++++ test/files/run/reflection-valueclasses-magic.scala | 110 ++ .../run/reflection-valueclasses-standard.check | 27 + .../run/reflection-valueclasses-standard.scala | 21 + 9 files changed, 1681 insertions(+), 34 deletions(-) create mode 100644 test/files/run/reflection-valueclasses-derived.check create mode 100644 test/files/run/reflection-valueclasses-derived.scala create mode 100644 test/files/run/reflection-valueclasses-magic.check create mode 100644 test/files/run/reflection-valueclasses-magic.scala create mode 100644 test/files/run/reflection-valueclasses-standard.check create mode 100644 test/files/run/reflection-valueclasses-standard.scala (limited to 'test/files/run') diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala index a4d86cf1fd..41acd73492 100644 --- a/src/reflect/scala/reflect/api/Mirrors.scala +++ b/src/reflect/scala/reflect/api/Mirrors.scala @@ -91,7 +91,7 @@ trait Mirrors { self: Universe => trait FieldMirror { /** The object containing the field */ - def receiver: AnyRef + def receiver: Any /** The field symbol representing the field. * @@ -125,7 +125,7 @@ trait Mirrors { self: Universe => trait MethodMirror { /** The receiver object of the method */ - def receiver: AnyRef + def receiver: Any /** The method symbol representing the method */ def symbol: MethodSymbol @@ -226,7 +226,7 @@ trait Mirrors { self: Universe => * Such a mirror can be used to further reflect against the members of the object * to get/set fields, invoke methods and inspect inner classes and objects. */ - def reflect(obj: Any): InstanceMirror + def reflect[T: ClassTag](obj: T): InstanceMirror /** Reflects against a static class symbol and returns a mirror * that can be used to create instances of the class, inspect its companion object or perform further reflections. diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index 67456cf86b..689a4dd37a 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -937,6 +937,12 @@ trait StdNames { case _ => NO_NAME } + def primitiveMethodName(name: Name): TermName = + primitiveInfixMethodName(name) match { + case NO_NAME => primitivePostfixMethodName(name) + case name => name + } + /** Translate a String into a list of simple TypeNames and TermNames. * In all segments before the last, type/term is determined by whether * the following separator char is '.' or '#'. In the last segment, diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 83fbee97cc..3a18c60720 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -20,7 +20,7 @@ import internal.Flags._ //import scala.tools.nsc.util.ScalaClassLoader._ import ReflectionUtils.{singletonInstance} import language.existentials -import scala.runtime.ScalaRunTime +import scala.runtime.{ScalaRunTime, BoxesRunTime} trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: SymbolTable => @@ -133,7 +133,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym """.trim.stripMargin) private def ErrorSetImmutableField(wannabe: Symbol) = throw new ScalaReflectionException(s"cannot set an immutable field ${wannabe.name}") - def reflect(obj: Any): InstanceMirror = new JavaInstanceMirror(obj.asInstanceOf[AnyRef]) + def reflect[T: ClassTag](obj: T): InstanceMirror = new JavaInstanceMirror(obj) def reflectClass(cls: ClassSymbol): ClassMirror = { if (!cls.isStatic) ErrorInnerClass(cls) @@ -155,7 +155,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym private def checkMemberOf(wannabe: Symbol, owner: ClassSymbol) { if (wannabe.owner == AnyClass || wannabe.owner == AnyRefClass || wannabe.owner == ObjectClass) { - // do nothing + // do nothing } else if (wannabe.owner == AnyValClass) { if (!owner.isPrimitiveValueClass && !owner.isDerivedValueClass) ErrorNotMember(wannabe, owner) } else { @@ -163,10 +163,15 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym } } - private class JavaInstanceMirror(obj: AnyRef) + private def preciseClass[T: ClassTag](instance: T) = { + val staticClazz = classTag[T].runtimeClass + val dynamicClazz = instance.getClass + if (staticClazz.isPrimitive) staticClazz else dynamicClazz + } + + private class JavaInstanceMirror[T: ClassTag](val instance: T) extends InstanceMirror { - def instance = obj - def symbol = wholemirror.classSymbol(obj.getClass) + def symbol = wholemirror.classSymbol(preciseClass(instance)) def reflectField(field: TermSymbol): FieldMirror = { checkMemberOf(field, symbol) if ((field.isMethod && !field.isAccessor) || field.isModule) ErrorNotField(field) @@ -179,26 +184,26 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym catch { case _: NoSuchFieldException => ErrorNonExistentField(field1) } - new JavaFieldMirror(obj, field1) + new JavaFieldMirror(instance, field1) } def reflectMethod(method: MethodSymbol): MethodMirror = { checkMemberOf(method, symbol) - mkJavaMethodMirror(obj, method) + mkJavaMethodMirror(instance, method) } def reflectClass(cls: ClassSymbol): ClassMirror = { if (cls.isStatic) ErrorStaticClass(cls) checkMemberOf(cls, symbol) - new JavaClassMirror(instance, cls) + new JavaClassMirror(instance.asInstanceOf[AnyRef], cls) } def reflectModule(mod: ModuleSymbol): ModuleMirror = { if (mod.isStatic) ErrorStaticModule(mod) checkMemberOf(mod, symbol) - new JavaModuleMirror(instance, mod) + new JavaModuleMirror(instance.asInstanceOf[AnyRef], mod) } - override def toString = s"instance mirror for $obj" + override def toString = s"instance mirror for $instance" } - private class JavaFieldMirror(val receiver: AnyRef, val symbol: TermSymbol) + private class JavaFieldMirror(val receiver: Any, val symbol: TermSymbol) extends FieldMirror { lazy val jfield = { val jfield = fieldToJava(symbol) @@ -255,12 +260,12 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym // that's because we want to have decent performance // therefore we move special cases into separate subclasses // rather than have them on a hot path them in a unified implementation of the `apply` method - private def mkJavaMethodMirror(receiver: AnyRef, symbol: MethodSymbol): JavaMethodMirror = { + private def mkJavaMethodMirror[T: ClassTag](receiver: T, symbol: MethodSymbol): JavaMethodMirror = { if (isMagicMethod(symbol)) new JavaMagicMethodMirror(receiver, symbol) else new JavaVanillaMethodMirror(receiver, symbol) } - private abstract class JavaMethodMirror(val receiver: AnyRef, val symbol: MethodSymbol) + private abstract class JavaMethodMirror(val symbol: MethodSymbol) extends MethodMirror { lazy val jmeth = { val jmeth = methodToJava(symbol) @@ -271,13 +276,13 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym override def toString = s"method mirror for ${showMethodSig(symbol)} (bound to $receiver)" } - private class JavaVanillaMethodMirror(receiver: AnyRef, symbol: MethodSymbol) - extends JavaMethodMirror(receiver, symbol) { + private class JavaVanillaMethodMirror(val receiver: Any, symbol: MethodSymbol) + extends JavaMethodMirror(symbol) { def apply(args: Any*): Any = jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) } - private class JavaMagicMethodMirror(receiver: AnyRef, symbol: MethodSymbol) - extends JavaMethodMirror(receiver, symbol) { + private class JavaMagicMethodMirror[T: ClassTag](val receiver: T, symbol: MethodSymbol) + extends JavaMethodMirror(symbol) { def apply(args: Any*): Any = { // checking type conformance is too much of a hassle, so we don't do it here // actually it's not even necessary, because we manually dispatch arguments to magic methods below @@ -293,37 +298,44 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym throw new ScalaReflectionException(s"${showMethodSig(symbol)} takes $n_arguments $s_arguments") } + def objReceiver = receiver.asInstanceOf[AnyRef] def objArg0 = args(0).asInstanceOf[AnyRef] def objArgs = args.asInstanceOf[Seq[AnyRef]] def fail(msg: String) = throw new ScalaReflectionException(msg + ", it cannot be invoked with mirrors") + def invokeMagicPrimitiveMethod = { + val jmeths = classOf[BoxesRunTime].getDeclaredMethods.filter(_.getName == nme.primitiveMethodName(symbol.name).toString) + assert(jmeths.length == 1, jmeths.toList) + jmeths.head.invoke(null, (objReceiver +: objArgs): _*) + } + symbol match { - case Any_== | Object_== => ScalaRunTime.inlinedEquals(receiver, objArg0) - case Any_!= | Object_!= => !ScalaRunTime.inlinedEquals(receiver, objArg0) - case Any_## | Object_## => ScalaRunTime.hash(receiver) + case Any_== | Object_== => ScalaRunTime.inlinedEquals(objReceiver, objArg0) + case Any_!= | Object_!= => !ScalaRunTime.inlinedEquals(objReceiver, objArg0) + case Any_## | Object_## => ScalaRunTime.hash(objReceiver) case Any_equals => receiver.equals(objArg0) case Any_hashCode => receiver.hashCode case Any_toString => receiver.toString - case Object_eq => receiver eq objArg0 - case Object_ne => receiver ne objArg0 - case Object_synchronized => receiver.synchronized(objArg0) - case sym if isGetClass(sym) => receiver.getClass + case Object_eq => objReceiver eq objArg0 + case Object_ne => objReceiver ne objArg0 + case Object_synchronized => objReceiver.synchronized(objArg0) + case sym if isGetClass(sym) => preciseClass(receiver) case Any_asInstanceOf => fail("Any.asInstanceOf requires a type argument") case Any_isInstanceOf => fail("Any.isInstanceOf requires a type argument") case Object_asInstanceOf => fail("AnyRef.$asInstanceOf is an internal method") case Object_isInstanceOf => fail("AnyRef.$isInstanceOf is an internal method") - case Array_length => ScalaRunTime.array_length(receiver) - case Array_apply => ScalaRunTime.array_apply(receiver, args(0).asInstanceOf[Int]) - case Array_update => ScalaRunTime.array_update(receiver, args(0).asInstanceOf[Int], args(1)) - case Array_clone => ScalaRunTime.array_clone(receiver) + case Array_length => ScalaRunTime.array_length(objReceiver) + case Array_apply => ScalaRunTime.array_apply(objReceiver, args(0).asInstanceOf[Int]) + case Array_update => ScalaRunTime.array_update(objReceiver, args(0).asInstanceOf[Int], args(1)) + case Array_clone => ScalaRunTime.array_clone(objReceiver) case sym if isStringConcat(sym) => receiver.toString + objArg0 - case sym if isMagicPrimitiveMethod(sym) => fail("implementation restriction: ${symbol.fullName} is a magic primitive method") + case sym if isMagicPrimitiveMethod(sym) => invokeMagicPrimitiveMethod case sym if sym == Predef_classOf => fail("Predef.classOf is a compile-time function") case sym if sym.isTermMacro => fail(s"${symbol.fullName} is a macro, i.e. a compile-time function") case _ => assert(false, this) } } - } + } private class JavaConstructorMirror(val outer: AnyRef, val symbol: MethodSymbol) extends MethodMirror { diff --git a/test/files/run/reflection-valueclasses-derived.check b/test/files/run/reflection-valueclasses-derived.check new file mode 100644 index 0000000000..bfcfcade5e --- /dev/null +++ b/test/files/run/reflection-valueclasses-derived.check @@ -0,0 +1,3 @@ +4 +class C +C@2 diff --git a/test/files/run/reflection-valueclasses-derived.scala b/test/files/run/reflection-valueclasses-derived.scala new file mode 100644 index 0000000000..6b08f987ba --- /dev/null +++ b/test/files/run/reflection-valueclasses-derived.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +class C(val x: Int) extends AnyVal { + def foo(y: Int) = x + y +} + +object Test extends App { + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("foo")).asMethod)(2)) + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("getClass")).asMethod)()) + println(cm.reflect(new C(2)).reflectMethod(typeOf[C].member(newTermName("toString")).asMethod)()) +} \ No newline at end of file diff --git a/test/files/run/reflection-valueclasses-magic.check b/test/files/run/reflection-valueclasses-magic.check new file mode 100644 index 0000000000..8ecad3eb91 --- /dev/null +++ b/test/files/run/reflection-valueclasses-magic.check @@ -0,0 +1,1456 @@ +============ +Byte +it's important to print the list of Byte's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor Byte: ()Byte +method !=: (x$1: Any)Boolean +method !=: (x: Byte)Boolean +method !=: (x: Char)Boolean +method !=: (x: Double)Boolean +method !=: (x: Float)Boolean +method !=: (x: Int)Boolean +method !=: (x: Long)Boolean +method !=: (x: Short)Boolean +method ##: ()Int +method %: (x: Byte)Int +method %: (x: Char)Int +method %: (x: Double)Double +method %: (x: Float)Float +method %: (x: Int)Int +method %: (x: Long)Long +method %: (x: Short)Int +method &: (x: Byte)Int +method &: (x: Char)Int +method &: (x: Int)Int +method &: (x: Long)Long +method &: (x: Short)Int +method *: (x: Byte)Int +method *: (x: Char)Int +method *: (x: Double)Double +method *: (x: Float)Float +method *: (x: Int)Int +method *: (x: Long)Long +method *: (x: Short)Int +method +: (x: Byte)Int +method +: (x: Char)Int +method +: (x: Double)Double +method +: (x: Float)Float +method +: (x: Int)Int +method +: (x: Long)Long +method +: (x: Short)Int +method +: (x: String)String +method -: (x: Byte)Int +method -: (x: Char)Int +method -: (x: Double)Double +method -: (x: Float)Float +method -: (x: Int)Int +method -: (x: Long)Long +method -: (x: Short)Int +method /: (x: Byte)Int +method /: (x: Char)Int +method /: (x: Double)Double +method /: (x: Float)Float +method /: (x: Int)Int +method /: (x: Long)Long +method /: (x: Short)Int +method <: (x: Byte)Boolean +method <: (x: Char)Boolean +method <: (x: Double)Boolean +method <: (x: Float)Boolean +method <: (x: Int)Boolean +method <: (x: Long)Boolean +method <: (x: Short)Boolean +method <<: (x: Int)Int +method <<: (x: Long)Int +method <=: (x: Byte)Boolean +method <=: (x: Char)Boolean +method <=: (x: Double)Boolean +method <=: (x: Float)Boolean +method <=: (x: Int)Boolean +method <=: (x: Long)Boolean +method <=: (x: Short)Boolean +method ==: (x$1: Any)Boolean +method ==: (x: Byte)Boolean +method ==: (x: Char)Boolean +method ==: (x: Double)Boolean +method ==: (x: Float)Boolean +method ==: (x: Int)Boolean +method ==: (x: Long)Boolean +method ==: (x: Short)Boolean +method >: (x: Byte)Boolean +method >: (x: Char)Boolean +method >: (x: Double)Boolean +method >: (x: Float)Boolean +method >: (x: Int)Boolean +method >: (x: Long)Boolean +method >: (x: Short)Boolean +method >=: (x: Byte)Boolean +method >=: (x: Char)Boolean +method >=: (x: Double)Boolean +method >=: (x: Float)Boolean +method >=: (x: Int)Boolean +method >=: (x: Long)Boolean +method >=: (x: Short)Boolean +method >>: (x: Int)Int +method >>: (x: Long)Int +method >>>: (x: Int)Int +method >>>: (x: Long)Int +method ^: (x: Byte)Int +method ^: (x: Char)Int +method ^: (x: Int)Int +method ^: (x: Long)Long +method ^: (x: Short)Int +method asInstanceOf: [T0]=> T0 +method equals: (x$1: Any)Boolean +method getClass: ()Class[Byte] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method toByte: => Byte +method toChar: => Char +method toDouble: => Double +method toFloat: => Float +method toInt: => Int +method toLong: => Long +method toShort: => Short +method toString: ()java.lang.String +method unary_+: => Int +method unary_-: => Int +method unary_~: => Int +method |: (x: Byte)Int +method |: (x: Char)Int +method |: (x: Int)Int +method |: (x: Long)Long +method |: (x: Short)Int +testing Byte.toByte() with receiver = 2 and args = List(): [class java.lang.Byte] =======> 2 +testing Byte.toShort() with receiver = 2 and args = List(): [class java.lang.Short] =======> 2 +testing Byte.toChar() with receiver = 2 and args = List(): [class java.lang.Character] =======>  +testing Byte.toInt() with receiver = 2 and args = List(): [class java.lang.Integer] =======> 2 +testing Byte.toLong() with receiver = 2 and args = List(): [class java.lang.Long] =======> 2 +testing Byte.toFloat() with receiver = 2 and args = List(): [class java.lang.Float] =======> 2.0 +testing Byte.toDouble() with receiver = 2 and args = List(): [class java.lang.Double] =======> 2.0 +testing Byte.==(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Byte.==(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Byte.==(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Byte.==(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Byte.==(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Byte.==(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Byte.==(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Byte.!=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Byte.!=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Byte.!=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Byte.!=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Byte.!=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Byte.!=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Byte.!=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Byte.<(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Byte.<(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Byte.<(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Byte.<(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Byte.<(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Byte.<(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Byte.<(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Byte.<=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Byte.<=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Byte.<=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Byte.<=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Byte.<=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Byte.<=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Byte.<=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Byte.>(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Byte.>(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Byte.>(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Byte.>(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Byte.>(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Byte.>(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Byte.>(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Byte.>=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Byte.>=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Byte.>=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Byte.>=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Byte.>=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Byte.>=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Byte.>=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Byte.+(String) with receiver = 2 and args = List(2 class java.lang.String): [class java.lang.String] =======> 22 +testing Byte.+(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 4 +testing Byte.+(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 4 +testing Byte.+(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 4 +testing Byte.+(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 4 +testing Byte.+(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 4 +testing Byte.+(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Byte.+(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Byte.-(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 0 +testing Byte.-(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 0 +testing Byte.-(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 0 +testing Byte.-(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 0 +testing Byte.-(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 0 +testing Byte.-(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Byte.-(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +testing Byte.*(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 4 +testing Byte.*(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 4 +testing Byte.*(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 4 +testing Byte.*(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 4 +testing Byte.*(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 4 +testing Byte.*(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Byte.*(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Byte./(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 1 +testing Byte./(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 1 +testing Byte./(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 1 +testing Byte./(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 1 +testing Byte./(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 1 +testing Byte./(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 1.0 +testing Byte./(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 1.0 +testing Byte.%(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 0 +testing Byte.%(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 0 +testing Byte.%(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 0 +testing Byte.%(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 0 +testing Byte.%(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 0 +testing Byte.%(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Byte.%(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +============ +Short +it's important to print the list of Byte's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor Short: ()Short +method !=: (x$1: Any)Boolean +method !=: (x: Byte)Boolean +method !=: (x: Char)Boolean +method !=: (x: Double)Boolean +method !=: (x: Float)Boolean +method !=: (x: Int)Boolean +method !=: (x: Long)Boolean +method !=: (x: Short)Boolean +method ##: ()Int +method %: (x: Byte)Int +method %: (x: Char)Int +method %: (x: Double)Double +method %: (x: Float)Float +method %: (x: Int)Int +method %: (x: Long)Long +method %: (x: Short)Int +method &: (x: Byte)Int +method &: (x: Char)Int +method &: (x: Int)Int +method &: (x: Long)Long +method &: (x: Short)Int +method *: (x: Byte)Int +method *: (x: Char)Int +method *: (x: Double)Double +method *: (x: Float)Float +method *: (x: Int)Int +method *: (x: Long)Long +method *: (x: Short)Int +method +: (x: Byte)Int +method +: (x: Char)Int +method +: (x: Double)Double +method +: (x: Float)Float +method +: (x: Int)Int +method +: (x: Long)Long +method +: (x: Short)Int +method +: (x: String)String +method -: (x: Byte)Int +method -: (x: Char)Int +method -: (x: Double)Double +method -: (x: Float)Float +method -: (x: Int)Int +method -: (x: Long)Long +method -: (x: Short)Int +method /: (x: Byte)Int +method /: (x: Char)Int +method /: (x: Double)Double +method /: (x: Float)Float +method /: (x: Int)Int +method /: (x: Long)Long +method /: (x: Short)Int +method <: (x: Byte)Boolean +method <: (x: Char)Boolean +method <: (x: Double)Boolean +method <: (x: Float)Boolean +method <: (x: Int)Boolean +method <: (x: Long)Boolean +method <: (x: Short)Boolean +method <<: (x: Int)Int +method <<: (x: Long)Int +method <=: (x: Byte)Boolean +method <=: (x: Char)Boolean +method <=: (x: Double)Boolean +method <=: (x: Float)Boolean +method <=: (x: Int)Boolean +method <=: (x: Long)Boolean +method <=: (x: Short)Boolean +method ==: (x$1: Any)Boolean +method ==: (x: Byte)Boolean +method ==: (x: Char)Boolean +method ==: (x: Double)Boolean +method ==: (x: Float)Boolean +method ==: (x: Int)Boolean +method ==: (x: Long)Boolean +method ==: (x: Short)Boolean +method >: (x: Byte)Boolean +method >: (x: Char)Boolean +method >: (x: Double)Boolean +method >: (x: Float)Boolean +method >: (x: Int)Boolean +method >: (x: Long)Boolean +method >: (x: Short)Boolean +method >=: (x: Byte)Boolean +method >=: (x: Char)Boolean +method >=: (x: Double)Boolean +method >=: (x: Float)Boolean +method >=: (x: Int)Boolean +method >=: (x: Long)Boolean +method >=: (x: Short)Boolean +method >>: (x: Int)Int +method >>: (x: Long)Int +method >>>: (x: Int)Int +method >>>: (x: Long)Int +method ^: (x: Byte)Int +method ^: (x: Char)Int +method ^: (x: Int)Int +method ^: (x: Long)Long +method ^: (x: Short)Int +method asInstanceOf: [T0]=> T0 +method equals: (x$1: Any)Boolean +method getClass: ()Class[Short] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method toByte: => Byte +method toChar: => Char +method toDouble: => Double +method toFloat: => Float +method toInt: => Int +method toLong: => Long +method toShort: => Short +method toString: ()java.lang.String +method unary_+: => Int +method unary_-: => Int +method unary_~: => Int +method |: (x: Byte)Int +method |: (x: Char)Int +method |: (x: Int)Int +method |: (x: Long)Long +method |: (x: Short)Int +testing Short.toByte() with receiver = 2 and args = List(): [class java.lang.Byte] =======> 2 +testing Short.toShort() with receiver = 2 and args = List(): [class java.lang.Short] =======> 2 +testing Short.toChar() with receiver = 2 and args = List(): [class java.lang.Character] =======>  +testing Short.toInt() with receiver = 2 and args = List(): [class java.lang.Integer] =======> 2 +testing Short.toLong() with receiver = 2 and args = List(): [class java.lang.Long] =======> 2 +testing Short.toFloat() with receiver = 2 and args = List(): [class java.lang.Float] =======> 2.0 +testing Short.toDouble() with receiver = 2 and args = List(): [class java.lang.Double] =======> 2.0 +testing Short.==(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Short.==(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Short.==(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Short.==(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Short.==(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Short.==(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Short.==(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Short.!=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Short.!=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Short.!=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Short.!=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Short.!=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Short.!=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Short.!=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Short.<(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Short.<(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Short.<(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Short.<(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Short.<(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Short.<(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Short.<(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Short.<=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Short.<=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Short.<=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Short.<=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Short.<=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Short.<=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Short.<=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Short.>(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Short.>(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Short.>(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Short.>(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Short.>(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Short.>(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Short.>(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Short.>=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Short.>=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Short.>=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Short.>=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Short.>=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Short.>=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Short.>=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Short.+(String) with receiver = 2 and args = List(2 class java.lang.String): [class java.lang.String] =======> 22 +testing Short.+(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 4 +testing Short.+(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 4 +testing Short.+(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 4 +testing Short.+(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 4 +testing Short.+(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 4 +testing Short.+(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Short.+(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Short.-(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 0 +testing Short.-(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 0 +testing Short.-(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 0 +testing Short.-(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 0 +testing Short.-(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 0 +testing Short.-(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Short.-(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +testing Short.*(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 4 +testing Short.*(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 4 +testing Short.*(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 4 +testing Short.*(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 4 +testing Short.*(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 4 +testing Short.*(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Short.*(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Short./(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 1 +testing Short./(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 1 +testing Short./(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 1 +testing Short./(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 1 +testing Short./(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 1 +testing Short./(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 1.0 +testing Short./(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 1.0 +testing Short.%(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 0 +testing Short.%(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 0 +testing Short.%(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 0 +testing Short.%(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 0 +testing Short.%(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 0 +testing Short.%(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Short.%(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +============ +Char +it's important to print the list of Byte's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor Char: ()Char +method !=: (x$1: Any)Boolean +method !=: (x: Byte)Boolean +method !=: (x: Char)Boolean +method !=: (x: Double)Boolean +method !=: (x: Float)Boolean +method !=: (x: Int)Boolean +method !=: (x: Long)Boolean +method !=: (x: Short)Boolean +method ##: ()Int +method %: (x: Byte)Int +method %: (x: Char)Int +method %: (x: Double)Double +method %: (x: Float)Float +method %: (x: Int)Int +method %: (x: Long)Long +method %: (x: Short)Int +method &: (x: Byte)Int +method &: (x: Char)Int +method &: (x: Int)Int +method &: (x: Long)Long +method &: (x: Short)Int +method *: (x: Byte)Int +method *: (x: Char)Int +method *: (x: Double)Double +method *: (x: Float)Float +method *: (x: Int)Int +method *: (x: Long)Long +method *: (x: Short)Int +method +: (x: Byte)Int +method +: (x: Char)Int +method +: (x: Double)Double +method +: (x: Float)Float +method +: (x: Int)Int +method +: (x: Long)Long +method +: (x: Short)Int +method +: (x: String)String +method -: (x: Byte)Int +method -: (x: Char)Int +method -: (x: Double)Double +method -: (x: Float)Float +method -: (x: Int)Int +method -: (x: Long)Long +method -: (x: Short)Int +method /: (x: Byte)Int +method /: (x: Char)Int +method /: (x: Double)Double +method /: (x: Float)Float +method /: (x: Int)Int +method /: (x: Long)Long +method /: (x: Short)Int +method <: (x: Byte)Boolean +method <: (x: Char)Boolean +method <: (x: Double)Boolean +method <: (x: Float)Boolean +method <: (x: Int)Boolean +method <: (x: Long)Boolean +method <: (x: Short)Boolean +method <<: (x: Int)Int +method <<: (x: Long)Int +method <=: (x: Byte)Boolean +method <=: (x: Char)Boolean +method <=: (x: Double)Boolean +method <=: (x: Float)Boolean +method <=: (x: Int)Boolean +method <=: (x: Long)Boolean +method <=: (x: Short)Boolean +method ==: (x$1: Any)Boolean +method ==: (x: Byte)Boolean +method ==: (x: Char)Boolean +method ==: (x: Double)Boolean +method ==: (x: Float)Boolean +method ==: (x: Int)Boolean +method ==: (x: Long)Boolean +method ==: (x: Short)Boolean +method >: (x: Byte)Boolean +method >: (x: Char)Boolean +method >: (x: Double)Boolean +method >: (x: Float)Boolean +method >: (x: Int)Boolean +method >: (x: Long)Boolean +method >: (x: Short)Boolean +method >=: (x: Byte)Boolean +method >=: (x: Char)Boolean +method >=: (x: Double)Boolean +method >=: (x: Float)Boolean +method >=: (x: Int)Boolean +method >=: (x: Long)Boolean +method >=: (x: Short)Boolean +method >>: (x: Int)Int +method >>: (x: Long)Int +method >>>: (x: Int)Int +method >>>: (x: Long)Int +method ^: (x: Byte)Int +method ^: (x: Char)Int +method ^: (x: Int)Int +method ^: (x: Long)Long +method ^: (x: Short)Int +method asInstanceOf: [T0]=> T0 +method equals: (x$1: Any)Boolean +method getClass: ()Class[Char] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method toByte: => Byte +method toChar: => Char +method toDouble: => Double +method toFloat: => Float +method toInt: => Int +method toLong: => Long +method toShort: => Short +method toString: ()java.lang.String +method unary_+: => Int +method unary_-: => Int +method unary_~: => Int +method |: (x: Byte)Int +method |: (x: Char)Int +method |: (x: Int)Int +method |: (x: Long)Long +method |: (x: Short)Int +testing Char.toByte() with receiver =  and args = List(): [class java.lang.Byte] =======> 2 +testing Char.toShort() with receiver =  and args = List(): [class java.lang.Short] =======> 2 +testing Char.toChar() with receiver =  and args = List(): [class java.lang.Character] =======>  +testing Char.toInt() with receiver =  and args = List(): [class java.lang.Integer] =======> 2 +testing Char.toLong() with receiver =  and args = List(): [class java.lang.Long] =======> 2 +testing Char.toFloat() with receiver =  and args = List(): [class java.lang.Float] =======> 2.0 +testing Char.toDouble() with receiver =  and args = List(): [class java.lang.Double] =======> 2.0 +testing Char.==(Byte) with receiver =  and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Char.==(Short) with receiver =  and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Char.==(Char) with receiver =  and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Char.==(Int) with receiver =  and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Char.==(Long) with receiver =  and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Char.==(Float) with receiver =  and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Char.==(Double) with receiver =  and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Char.!=(Byte) with receiver =  and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Char.!=(Short) with receiver =  and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Char.!=(Char) with receiver =  and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Char.!=(Int) with receiver =  and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Char.!=(Long) with receiver =  and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Char.!=(Float) with receiver =  and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Char.!=(Double) with receiver =  and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Char.<(Byte) with receiver =  and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Char.<(Short) with receiver =  and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Char.<(Char) with receiver =  and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Char.<(Int) with receiver =  and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Char.<(Long) with receiver =  and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Char.<(Float) with receiver =  and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Char.<(Double) with receiver =  and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Char.<=(Byte) with receiver =  and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Char.<=(Short) with receiver =  and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Char.<=(Char) with receiver =  and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Char.<=(Int) with receiver =  and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Char.<=(Long) with receiver =  and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Char.<=(Float) with receiver =  and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Char.<=(Double) with receiver =  and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Char.>(Byte) with receiver =  and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Char.>(Short) with receiver =  and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Char.>(Char) with receiver =  and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Char.>(Int) with receiver =  and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Char.>(Long) with receiver =  and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Char.>(Float) with receiver =  and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Char.>(Double) with receiver =  and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Char.>=(Byte) with receiver =  and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Char.>=(Short) with receiver =  and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Char.>=(Char) with receiver =  and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Char.>=(Int) with receiver =  and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Char.>=(Long) with receiver =  and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Char.>=(Float) with receiver =  and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Char.>=(Double) with receiver =  and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Char.+(String) with receiver =  and args = List(2 class java.lang.String): [class java.lang.String] =======> 2 +testing Char.+(Byte) with receiver =  and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 4 +testing Char.+(Short) with receiver =  and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 4 +testing Char.+(Char) with receiver =  and args = List( class java.lang.Character): [class java.lang.Integer] =======> 4 +testing Char.+(Int) with receiver =  and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 4 +testing Char.+(Long) with receiver =  and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 4 +testing Char.+(Float) with receiver =  and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Char.+(Double) with receiver =  and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Char.-(Byte) with receiver =  and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 0 +testing Char.-(Short) with receiver =  and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 0 +testing Char.-(Char) with receiver =  and args = List( class java.lang.Character): [class java.lang.Integer] =======> 0 +testing Char.-(Int) with receiver =  and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 0 +testing Char.-(Long) with receiver =  and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 0 +testing Char.-(Float) with receiver =  and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Char.-(Double) with receiver =  and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +testing Char.*(Byte) with receiver =  and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 4 +testing Char.*(Short) with receiver =  and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 4 +testing Char.*(Char) with receiver =  and args = List( class java.lang.Character): [class java.lang.Integer] =======> 4 +testing Char.*(Int) with receiver =  and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 4 +testing Char.*(Long) with receiver =  and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 4 +testing Char.*(Float) with receiver =  and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Char.*(Double) with receiver =  and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Char./(Byte) with receiver =  and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 1 +testing Char./(Short) with receiver =  and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 1 +testing Char./(Char) with receiver =  and args = List( class java.lang.Character): [class java.lang.Integer] =======> 1 +testing Char./(Int) with receiver =  and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 1 +testing Char./(Long) with receiver =  and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 1 +testing Char./(Float) with receiver =  and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 1.0 +testing Char./(Double) with receiver =  and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 1.0 +testing Char.%(Byte) with receiver =  and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 0 +testing Char.%(Short) with receiver =  and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 0 +testing Char.%(Char) with receiver =  and args = List( class java.lang.Character): [class java.lang.Integer] =======> 0 +testing Char.%(Int) with receiver =  and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 0 +testing Char.%(Long) with receiver =  and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 0 +testing Char.%(Float) with receiver =  and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Char.%(Double) with receiver =  and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +============ +Int +it's important to print the list of Byte's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor Int: ()Int +method !=: (x$1: Any)Boolean +method !=: (x: Byte)Boolean +method !=: (x: Char)Boolean +method !=: (x: Double)Boolean +method !=: (x: Float)Boolean +method !=: (x: Int)Boolean +method !=: (x: Long)Boolean +method !=: (x: Short)Boolean +method ##: ()Int +method %: (x: Byte)Int +method %: (x: Char)Int +method %: (x: Double)Double +method %: (x: Float)Float +method %: (x: Int)Int +method %: (x: Long)Long +method %: (x: Short)Int +method &: (x: Byte)Int +method &: (x: Char)Int +method &: (x: Int)Int +method &: (x: Long)Long +method &: (x: Short)Int +method *: (x: Byte)Int +method *: (x: Char)Int +method *: (x: Double)Double +method *: (x: Float)Float +method *: (x: Int)Int +method *: (x: Long)Long +method *: (x: Short)Int +method +: (x: Byte)Int +method +: (x: Char)Int +method +: (x: Double)Double +method +: (x: Float)Float +method +: (x: Int)Int +method +: (x: Long)Long +method +: (x: Short)Int +method +: (x: String)String +method -: (x: Byte)Int +method -: (x: Char)Int +method -: (x: Double)Double +method -: (x: Float)Float +method -: (x: Int)Int +method -: (x: Long)Long +method -: (x: Short)Int +method /: (x: Byte)Int +method /: (x: Char)Int +method /: (x: Double)Double +method /: (x: Float)Float +method /: (x: Int)Int +method /: (x: Long)Long +method /: (x: Short)Int +method <: (x: Byte)Boolean +method <: (x: Char)Boolean +method <: (x: Double)Boolean +method <: (x: Float)Boolean +method <: (x: Int)Boolean +method <: (x: Long)Boolean +method <: (x: Short)Boolean +method <<: (x: Int)Int +method <<: (x: Long)Int +method <=: (x: Byte)Boolean +method <=: (x: Char)Boolean +method <=: (x: Double)Boolean +method <=: (x: Float)Boolean +method <=: (x: Int)Boolean +method <=: (x: Long)Boolean +method <=: (x: Short)Boolean +method ==: (x$1: Any)Boolean +method ==: (x: Byte)Boolean +method ==: (x: Char)Boolean +method ==: (x: Double)Boolean +method ==: (x: Float)Boolean +method ==: (x: Int)Boolean +method ==: (x: Long)Boolean +method ==: (x: Short)Boolean +method >: (x: Byte)Boolean +method >: (x: Char)Boolean +method >: (x: Double)Boolean +method >: (x: Float)Boolean +method >: (x: Int)Boolean +method >: (x: Long)Boolean +method >: (x: Short)Boolean +method >=: (x: Byte)Boolean +method >=: (x: Char)Boolean +method >=: (x: Double)Boolean +method >=: (x: Float)Boolean +method >=: (x: Int)Boolean +method >=: (x: Long)Boolean +method >=: (x: Short)Boolean +method >>: (x: Int)Int +method >>: (x: Long)Int +method >>>: (x: Int)Int +method >>>: (x: Long)Int +method ^: (x: Byte)Int +method ^: (x: Char)Int +method ^: (x: Int)Int +method ^: (x: Long)Long +method ^: (x: Short)Int +method asInstanceOf: [T0]=> T0 +method equals: (x$1: Any)Boolean +method getClass: ()Class[Int] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method toByte: => Byte +method toChar: => Char +method toDouble: => Double +method toFloat: => Float +method toInt: => Int +method toLong: => Long +method toShort: => Short +method toString: ()java.lang.String +method unary_+: => Int +method unary_-: => Int +method unary_~: => Int +method |: (x: Byte)Int +method |: (x: Char)Int +method |: (x: Int)Int +method |: (x: Long)Long +method |: (x: Short)Int +testing Int.toByte() with receiver = 2 and args = List(): [class java.lang.Byte] =======> 2 +testing Int.toShort() with receiver = 2 and args = List(): [class java.lang.Short] =======> 2 +testing Int.toChar() with receiver = 2 and args = List(): [class java.lang.Character] =======>  +testing Int.toInt() with receiver = 2 and args = List(): [class java.lang.Integer] =======> 2 +testing Int.toLong() with receiver = 2 and args = List(): [class java.lang.Long] =======> 2 +testing Int.toFloat() with receiver = 2 and args = List(): [class java.lang.Float] =======> 2.0 +testing Int.toDouble() with receiver = 2 and args = List(): [class java.lang.Double] =======> 2.0 +testing Int.==(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Int.==(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Int.==(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Int.==(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Int.==(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Int.==(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Int.==(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Int.!=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Int.!=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Int.!=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Int.!=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Int.!=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Int.!=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Int.!=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Int.<(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Int.<(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Int.<(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Int.<(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Int.<(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Int.<(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Int.<(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Int.<=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Int.<=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Int.<=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Int.<=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Int.<=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Int.<=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Int.<=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Int.>(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Int.>(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Int.>(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Int.>(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Int.>(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Int.>(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Int.>(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Int.>=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Int.>=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Int.>=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Int.>=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Int.>=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Int.>=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Int.>=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Int.+(String) with receiver = 2 and args = List(2 class java.lang.String): [class java.lang.String] =======> 22 +testing Int.+(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 4 +testing Int.+(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 4 +testing Int.+(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 4 +testing Int.+(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 4 +testing Int.+(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 4 +testing Int.+(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Int.+(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Int.-(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 0 +testing Int.-(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 0 +testing Int.-(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 0 +testing Int.-(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 0 +testing Int.-(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 0 +testing Int.-(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Int.-(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +testing Int.*(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 4 +testing Int.*(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 4 +testing Int.*(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 4 +testing Int.*(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 4 +testing Int.*(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 4 +testing Int.*(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Int.*(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Int./(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 1 +testing Int./(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 1 +testing Int./(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 1 +testing Int./(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 1 +testing Int./(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 1 +testing Int./(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 1.0 +testing Int./(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 1.0 +testing Int.%(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Integer] =======> 0 +testing Int.%(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Integer] =======> 0 +testing Int.%(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Integer] =======> 0 +testing Int.%(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Integer] =======> 0 +testing Int.%(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 0 +testing Int.%(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Int.%(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +============ +Long +it's important to print the list of Byte's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor Long: ()Long +method !=: (x$1: Any)Boolean +method !=: (x: Byte)Boolean +method !=: (x: Char)Boolean +method !=: (x: Double)Boolean +method !=: (x: Float)Boolean +method !=: (x: Int)Boolean +method !=: (x: Long)Boolean +method !=: (x: Short)Boolean +method ##: ()Int +method %: (x: Byte)Long +method %: (x: Char)Long +method %: (x: Double)Double +method %: (x: Float)Float +method %: (x: Int)Long +method %: (x: Long)Long +method %: (x: Short)Long +method &: (x: Byte)Long +method &: (x: Char)Long +method &: (x: Int)Long +method &: (x: Long)Long +method &: (x: Short)Long +method *: (x: Byte)Long +method *: (x: Char)Long +method *: (x: Double)Double +method *: (x: Float)Float +method *: (x: Int)Long +method *: (x: Long)Long +method *: (x: Short)Long +method +: (x: Byte)Long +method +: (x: Char)Long +method +: (x: Double)Double +method +: (x: Float)Float +method +: (x: Int)Long +method +: (x: Long)Long +method +: (x: Short)Long +method +: (x: String)String +method -: (x: Byte)Long +method -: (x: Char)Long +method -: (x: Double)Double +method -: (x: Float)Float +method -: (x: Int)Long +method -: (x: Long)Long +method -: (x: Short)Long +method /: (x: Byte)Long +method /: (x: Char)Long +method /: (x: Double)Double +method /: (x: Float)Float +method /: (x: Int)Long +method /: (x: Long)Long +method /: (x: Short)Long +method <: (x: Byte)Boolean +method <: (x: Char)Boolean +method <: (x: Double)Boolean +method <: (x: Float)Boolean +method <: (x: Int)Boolean +method <: (x: Long)Boolean +method <: (x: Short)Boolean +method <<: (x: Int)Long +method <<: (x: Long)Long +method <=: (x: Byte)Boolean +method <=: (x: Char)Boolean +method <=: (x: Double)Boolean +method <=: (x: Float)Boolean +method <=: (x: Int)Boolean +method <=: (x: Long)Boolean +method <=: (x: Short)Boolean +method ==: (x$1: Any)Boolean +method ==: (x: Byte)Boolean +method ==: (x: Char)Boolean +method ==: (x: Double)Boolean +method ==: (x: Float)Boolean +method ==: (x: Int)Boolean +method ==: (x: Long)Boolean +method ==: (x: Short)Boolean +method >: (x: Byte)Boolean +method >: (x: Char)Boolean +method >: (x: Double)Boolean +method >: (x: Float)Boolean +method >: (x: Int)Boolean +method >: (x: Long)Boolean +method >: (x: Short)Boolean +method >=: (x: Byte)Boolean +method >=: (x: Char)Boolean +method >=: (x: Double)Boolean +method >=: (x: Float)Boolean +method >=: (x: Int)Boolean +method >=: (x: Long)Boolean +method >=: (x: Short)Boolean +method >>: (x: Int)Long +method >>: (x: Long)Long +method >>>: (x: Int)Long +method >>>: (x: Long)Long +method ^: (x: Byte)Long +method ^: (x: Char)Long +method ^: (x: Int)Long +method ^: (x: Long)Long +method ^: (x: Short)Long +method asInstanceOf: [T0]=> T0 +method equals: (x$1: Any)Boolean +method getClass: ()Class[Long] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method toByte: => Byte +method toChar: => Char +method toDouble: => Double +method toFloat: => Float +method toInt: => Int +method toLong: => Long +method toShort: => Short +method toString: ()java.lang.String +method unary_+: => Long +method unary_-: => Long +method unary_~: => Long +method |: (x: Byte)Long +method |: (x: Char)Long +method |: (x: Int)Long +method |: (x: Long)Long +method |: (x: Short)Long +testing Long.toByte() with receiver = 2 and args = List(): [class java.lang.Byte] =======> 2 +testing Long.toShort() with receiver = 2 and args = List(): [class java.lang.Short] =======> 2 +testing Long.toChar() with receiver = 2 and args = List(): [class java.lang.Character] =======>  +testing Long.toInt() with receiver = 2 and args = List(): [class java.lang.Integer] =======> 2 +testing Long.toLong() with receiver = 2 and args = List(): [class java.lang.Long] =======> 2 +testing Long.toFloat() with receiver = 2 and args = List(): [class java.lang.Float] =======> 2.0 +testing Long.toDouble() with receiver = 2 and args = List(): [class java.lang.Double] =======> 2.0 +testing Long.==(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Long.==(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Long.==(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Long.==(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Long.==(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Long.==(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Long.==(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Long.!=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Long.!=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Long.!=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Long.!=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Long.!=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Long.!=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Long.!=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Long.<(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Long.<(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Long.<(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Long.<(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Long.<(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Long.<(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Long.<(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Long.<=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Long.<=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Long.<=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Long.<=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Long.<=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Long.<=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Long.<=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Long.>(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Long.>(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Long.>(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Long.>(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Long.>(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Long.>(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Long.>(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Long.>=(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Long.>=(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Long.>=(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Long.>=(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Long.>=(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Long.>=(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Long.>=(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Long.+(String) with receiver = 2 and args = List(2 class java.lang.String): [class java.lang.String] =======> 22 +testing Long.+(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Long] =======> 4 +testing Long.+(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Long] =======> 4 +testing Long.+(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Long] =======> 4 +testing Long.+(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Long] =======> 4 +testing Long.+(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 4 +testing Long.+(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Long.+(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Long.-(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Long] =======> 0 +testing Long.-(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Long] =======> 0 +testing Long.-(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Long] =======> 0 +testing Long.-(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Long] =======> 0 +testing Long.-(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 0 +testing Long.-(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Long.-(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +testing Long.*(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Long] =======> 4 +testing Long.*(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Long] =======> 4 +testing Long.*(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Long] =======> 4 +testing Long.*(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Long] =======> 4 +testing Long.*(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 4 +testing Long.*(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Long.*(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Long./(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Long] =======> 1 +testing Long./(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Long] =======> 1 +testing Long./(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Long] =======> 1 +testing Long./(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Long] =======> 1 +testing Long./(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 1 +testing Long./(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 1.0 +testing Long./(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 1.0 +testing Long.%(Byte) with receiver = 2 and args = List(2 class java.lang.Byte): [class java.lang.Long] =======> 0 +testing Long.%(Short) with receiver = 2 and args = List(2 class java.lang.Short): [class java.lang.Long] =======> 0 +testing Long.%(Char) with receiver = 2 and args = List( class java.lang.Character): [class java.lang.Long] =======> 0 +testing Long.%(Int) with receiver = 2 and args = List(2 class java.lang.Integer): [class java.lang.Long] =======> 0 +testing Long.%(Long) with receiver = 2 and args = List(2 class java.lang.Long): [class java.lang.Long] =======> 0 +testing Long.%(Float) with receiver = 2 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Long.%(Double) with receiver = 2 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +============ +Float +it's important to print the list of Byte's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor Float: ()Float +method !=: (x$1: Any)Boolean +method !=: (x: Byte)Boolean +method !=: (x: Char)Boolean +method !=: (x: Double)Boolean +method !=: (x: Float)Boolean +method !=: (x: Int)Boolean +method !=: (x: Long)Boolean +method !=: (x: Short)Boolean +method ##: ()Int +method %: (x: Byte)Float +method %: (x: Char)Float +method %: (x: Double)Double +method %: (x: Float)Float +method %: (x: Int)Float +method %: (x: Long)Float +method %: (x: Short)Float +method *: (x: Byte)Float +method *: (x: Char)Float +method *: (x: Double)Double +method *: (x: Float)Float +method *: (x: Int)Float +method *: (x: Long)Float +method *: (x: Short)Float +method +: (x: Byte)Float +method +: (x: Char)Float +method +: (x: Double)Double +method +: (x: Float)Float +method +: (x: Int)Float +method +: (x: Long)Float +method +: (x: Short)Float +method +: (x: String)String +method -: (x: Byte)Float +method -: (x: Char)Float +method -: (x: Double)Double +method -: (x: Float)Float +method -: (x: Int)Float +method -: (x: Long)Float +method -: (x: Short)Float +method /: (x: Byte)Float +method /: (x: Char)Float +method /: (x: Double)Double +method /: (x: Float)Float +method /: (x: Int)Float +method /: (x: Long)Float +method /: (x: Short)Float +method <: (x: Byte)Boolean +method <: (x: Char)Boolean +method <: (x: Double)Boolean +method <: (x: Float)Boolean +method <: (x: Int)Boolean +method <: (x: Long)Boolean +method <: (x: Short)Boolean +method <=: (x: Byte)Boolean +method <=: (x: Char)Boolean +method <=: (x: Double)Boolean +method <=: (x: Float)Boolean +method <=: (x: Int)Boolean +method <=: (x: Long)Boolean +method <=: (x: Short)Boolean +method ==: (x$1: Any)Boolean +method ==: (x: Byte)Boolean +method ==: (x: Char)Boolean +method ==: (x: Double)Boolean +method ==: (x: Float)Boolean +method ==: (x: Int)Boolean +method ==: (x: Long)Boolean +method ==: (x: Short)Boolean +method >: (x: Byte)Boolean +method >: (x: Char)Boolean +method >: (x: Double)Boolean +method >: (x: Float)Boolean +method >: (x: Int)Boolean +method >: (x: Long)Boolean +method >: (x: Short)Boolean +method >=: (x: Byte)Boolean +method >=: (x: Char)Boolean +method >=: (x: Double)Boolean +method >=: (x: Float)Boolean +method >=: (x: Int)Boolean +method >=: (x: Long)Boolean +method >=: (x: Short)Boolean +method asInstanceOf: [T0]=> T0 +method equals: (x$1: Any)Boolean +method getClass: ()Class[Float] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method toByte: => Byte +method toChar: => Char +method toDouble: => Double +method toFloat: => Float +method toInt: => Int +method toLong: => Long +method toShort: => Short +method toString: ()java.lang.String +method unary_+: => Float +method unary_-: => Float +testing Float.toByte() with receiver = 2.0 and args = List(): [class java.lang.Byte] =======> 2 +testing Float.toShort() with receiver = 2.0 and args = List(): [class java.lang.Short] =======> 2 +testing Float.toChar() with receiver = 2.0 and args = List(): [class java.lang.Character] =======>  +testing Float.toInt() with receiver = 2.0 and args = List(): [class java.lang.Integer] =======> 2 +testing Float.toLong() with receiver = 2.0 and args = List(): [class java.lang.Long] =======> 2 +testing Float.toFloat() with receiver = 2.0 and args = List(): [class java.lang.Float] =======> 2.0 +testing Float.toDouble() with receiver = 2.0 and args = List(): [class java.lang.Double] =======> 2.0 +testing Float.==(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Float.==(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Float.==(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Float.==(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Float.==(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Float.==(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Float.==(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Float.!=(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Float.!=(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Float.!=(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Float.!=(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Float.!=(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Float.!=(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Float.!=(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Float.<(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Float.<(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Float.<(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Float.<(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Float.<(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Float.<(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Float.<(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Float.<=(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Float.<=(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Float.<=(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Float.<=(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Float.<=(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Float.<=(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Float.<=(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Float.>(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Float.>(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Float.>(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Float.>(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Float.>(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Float.>(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Float.>(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Float.>=(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Float.>=(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Float.>=(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Float.>=(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Float.>=(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Float.>=(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Float.>=(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Float.+(String) with receiver = 2.0 and args = List(2 class java.lang.String): [class java.lang.String] =======> 2.02 +testing Float.+(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Float] =======> 4.0 +testing Float.+(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Float] =======> 4.0 +testing Float.+(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Float] =======> 4.0 +testing Float.+(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Float] =======> 4.0 +testing Float.+(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Float] =======> 4.0 +testing Float.+(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Float.+(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Float.-(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Float] =======> 0.0 +testing Float.-(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Float] =======> 0.0 +testing Float.-(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Float] =======> 0.0 +testing Float.-(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Float] =======> 0.0 +testing Float.-(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Float] =======> 0.0 +testing Float.-(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Float.-(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +testing Float.*(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Float] =======> 4.0 +testing Float.*(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Float] =======> 4.0 +testing Float.*(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Float] =======> 4.0 +testing Float.*(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Float] =======> 4.0 +testing Float.*(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Float] =======> 4.0 +testing Float.*(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 4.0 +testing Float.*(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Float./(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Float] =======> 1.0 +testing Float./(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Float] =======> 1.0 +testing Float./(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Float] =======> 1.0 +testing Float./(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Float] =======> 1.0 +testing Float./(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Float] =======> 1.0 +testing Float./(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 1.0 +testing Float./(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 1.0 +testing Float.%(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Float] =======> 0.0 +testing Float.%(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Float] =======> 0.0 +testing Float.%(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Float] =======> 0.0 +testing Float.%(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Float] =======> 0.0 +testing Float.%(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Float] =======> 0.0 +testing Float.%(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Float] =======> 0.0 +testing Float.%(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +============ +Double +it's important to print the list of Byte's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor Double: ()Double +method !=: (x$1: Any)Boolean +method !=: (x: Byte)Boolean +method !=: (x: Char)Boolean +method !=: (x: Double)Boolean +method !=: (x: Float)Boolean +method !=: (x: Int)Boolean +method !=: (x: Long)Boolean +method !=: (x: Short)Boolean +method ##: ()Int +method %: (x: Byte)Double +method %: (x: Char)Double +method %: (x: Double)Double +method %: (x: Float)Double +method %: (x: Int)Double +method %: (x: Long)Double +method %: (x: Short)Double +method *: (x: Byte)Double +method *: (x: Char)Double +method *: (x: Double)Double +method *: (x: Float)Double +method *: (x: Int)Double +method *: (x: Long)Double +method *: (x: Short)Double +method +: (x: Byte)Double +method +: (x: Char)Double +method +: (x: Double)Double +method +: (x: Float)Double +method +: (x: Int)Double +method +: (x: Long)Double +method +: (x: Short)Double +method +: (x: String)String +method -: (x: Byte)Double +method -: (x: Char)Double +method -: (x: Double)Double +method -: (x: Float)Double +method -: (x: Int)Double +method -: (x: Long)Double +method -: (x: Short)Double +method /: (x: Byte)Double +method /: (x: Char)Double +method /: (x: Double)Double +method /: (x: Float)Double +method /: (x: Int)Double +method /: (x: Long)Double +method /: (x: Short)Double +method <: (x: Byte)Boolean +method <: (x: Char)Boolean +method <: (x: Double)Boolean +method <: (x: Float)Boolean +method <: (x: Int)Boolean +method <: (x: Long)Boolean +method <: (x: Short)Boolean +method <=: (x: Byte)Boolean +method <=: (x: Char)Boolean +method <=: (x: Double)Boolean +method <=: (x: Float)Boolean +method <=: (x: Int)Boolean +method <=: (x: Long)Boolean +method <=: (x: Short)Boolean +method ==: (x$1: Any)Boolean +method ==: (x: Byte)Boolean +method ==: (x: Char)Boolean +method ==: (x: Double)Boolean +method ==: (x: Float)Boolean +method ==: (x: Int)Boolean +method ==: (x: Long)Boolean +method ==: (x: Short)Boolean +method >: (x: Byte)Boolean +method >: (x: Char)Boolean +method >: (x: Double)Boolean +method >: (x: Float)Boolean +method >: (x: Int)Boolean +method >: (x: Long)Boolean +method >: (x: Short)Boolean +method >=: (x: Byte)Boolean +method >=: (x: Char)Boolean +method >=: (x: Double)Boolean +method >=: (x: Float)Boolean +method >=: (x: Int)Boolean +method >=: (x: Long)Boolean +method >=: (x: Short)Boolean +method asInstanceOf: [T0]=> T0 +method equals: (x$1: Any)Boolean +method getClass: ()Class[Double] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method toByte: => Byte +method toChar: => Char +method toDouble: => Double +method toFloat: => Float +method toInt: => Int +method toLong: => Long +method toShort: => Short +method toString: ()java.lang.String +method unary_+: => Double +method unary_-: => Double +testing Double.toByte() with receiver = 2.0 and args = List(): [class java.lang.Byte] =======> 2 +testing Double.toShort() with receiver = 2.0 and args = List(): [class java.lang.Short] =======> 2 +testing Double.toChar() with receiver = 2.0 and args = List(): [class java.lang.Character] =======>  +testing Double.toInt() with receiver = 2.0 and args = List(): [class java.lang.Integer] =======> 2 +testing Double.toLong() with receiver = 2.0 and args = List(): [class java.lang.Long] =======> 2 +testing Double.toFloat() with receiver = 2.0 and args = List(): [class java.lang.Float] =======> 2.0 +testing Double.toDouble() with receiver = 2.0 and args = List(): [class java.lang.Double] =======> 2.0 +testing Double.==(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Double.==(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Double.==(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Double.==(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Double.==(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Double.==(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Double.==(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Double.!=(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Double.!=(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Double.!=(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Double.!=(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Double.!=(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Double.!=(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Double.!=(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Double.<(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Double.<(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Double.<(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Double.<(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Double.<(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Double.<(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Double.<(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Double.<=(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Double.<=(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Double.<=(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Double.<=(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Double.<=(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Double.<=(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Double.<=(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Double.>(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> false +testing Double.>(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> false +testing Double.>(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> false +testing Double.>(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> false +testing Double.>(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> false +testing Double.>(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> false +testing Double.>(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> false +testing Double.>=(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Boolean] =======> true +testing Double.>=(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Boolean] =======> true +testing Double.>=(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Boolean] =======> true +testing Double.>=(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Boolean] =======> true +testing Double.>=(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Boolean] =======> true +testing Double.>=(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Boolean] =======> true +testing Double.>=(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Boolean] =======> true +testing Double.+(String) with receiver = 2.0 and args = List(2 class java.lang.String): [class java.lang.String] =======> 2.02 +testing Double.+(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Double] =======> 4.0 +testing Double.+(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Double] =======> 4.0 +testing Double.+(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Double] =======> 4.0 +testing Double.+(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Double] =======> 4.0 +testing Double.+(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Double] =======> 4.0 +testing Double.+(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Double] =======> 4.0 +testing Double.+(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Double.-(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Double] =======> 0.0 +testing Double.-(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Double] =======> 0.0 +testing Double.-(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Double] =======> 0.0 +testing Double.-(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Double] =======> 0.0 +testing Double.-(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Double] =======> 0.0 +testing Double.-(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Double] =======> 0.0 +testing Double.-(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +testing Double.*(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Double] =======> 4.0 +testing Double.*(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Double] =======> 4.0 +testing Double.*(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Double] =======> 4.0 +testing Double.*(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Double] =======> 4.0 +testing Double.*(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Double] =======> 4.0 +testing Double.*(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Double] =======> 4.0 +testing Double.*(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 4.0 +testing Double./(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Double] =======> 1.0 +testing Double./(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Double] =======> 1.0 +testing Double./(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Double] =======> 1.0 +testing Double./(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Double] =======> 1.0 +testing Double./(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Double] =======> 1.0 +testing Double./(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Double] =======> 1.0 +testing Double./(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 1.0 +testing Double.%(Byte) with receiver = 2.0 and args = List(2 class java.lang.Byte): [class java.lang.Double] =======> 0.0 +testing Double.%(Short) with receiver = 2.0 and args = List(2 class java.lang.Short): [class java.lang.Double] =======> 0.0 +testing Double.%(Char) with receiver = 2.0 and args = List( class java.lang.Character): [class java.lang.Double] =======> 0.0 +testing Double.%(Int) with receiver = 2.0 and args = List(2 class java.lang.Integer): [class java.lang.Double] =======> 0.0 +testing Double.%(Long) with receiver = 2.0 and args = List(2 class java.lang.Long): [class java.lang.Double] =======> 0.0 +testing Double.%(Float) with receiver = 2.0 and args = List(2.0 class java.lang.Float): [class java.lang.Double] =======> 0.0 +testing Double.%(Double) with receiver = 2.0 and args = List(2.0 class java.lang.Double): [class java.lang.Double] =======> 0.0 +============ +Boolean +it's important to print the list of Byte's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor Boolean: ()Boolean +method !=: (x$1: Any)Boolean +method !=: (x: Boolean)Boolean +method ##: ()Int +method &&: (x: Boolean)Boolean +method &: (x: Boolean)Boolean +method ==: (x$1: Any)Boolean +method ==: (x: Boolean)Boolean +method ^: (x: Boolean)Boolean +method asInstanceOf: [T0]=> T0 +method equals: (x$1: Any)Boolean +method getClass: ()Class[Boolean] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method toString: ()java.lang.String +method unary_!: => Boolean +method |: (x: Boolean)Boolean +method ||: (x: Boolean)Boolean +testing Boolean.unary_!() with receiver = true and args = List(): [class java.lang.Boolean] =======> false +testing Boolean.==(Boolean) with receiver = true and args = List(true class java.lang.Boolean): [class java.lang.Boolean] =======> true +testing Boolean.!=(Boolean) with receiver = true and args = List(true class java.lang.Boolean): [class java.lang.Boolean] =======> false +testing Boolean.||(Boolean) with receiver = true and args = List(true class java.lang.Boolean): [class java.lang.Boolean] =======> true +testing Boolean.&&(Boolean) with receiver = true and args = List(true class java.lang.Boolean): [class java.lang.Boolean] =======> true +testing Boolean.|(Boolean) with receiver = true and args = List(true class java.lang.Boolean): [class java.lang.Boolean] =======> true +testing Boolean.&(Boolean) with receiver = true and args = List(true class java.lang.Boolean): [class java.lang.Boolean] =======> true +testing Boolean.^(Boolean) with receiver = true and args = List(true class java.lang.Boolean): [class java.lang.Boolean] =======> false +============ +Unit +it's important to print the list of Byte's members +if some of them change (possibly, adding and/or removing magic symbols), we must update this test +constructor Unit: ()Unit +method !=: (x$1: Any)Boolean +method ##: ()Int +method ==: (x$1: Any)Boolean +method asInstanceOf: [T0]=> T0 +method equals: (x$1: Any)Boolean +method getClass: ()Class[Unit] +method hashCode: ()Int +method isInstanceOf: [T0]=> Boolean +method toString: ()java.lang.String diff --git a/test/files/run/reflection-valueclasses-magic.scala b/test/files/run/reflection-valueclasses-magic.scala new file mode 100644 index 0000000000..f9feb2d504 --- /dev/null +++ b/test/files/run/reflection-valueclasses-magic.scala @@ -0,0 +1,110 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.universe.definitions._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.reflect.ClassTag + +object Test extends App { + def key(sym: Symbol) = { + sym match { + // initialize parameter symbols + case meth: MethodSymbol => meth.params.flatten.map(_.typeSignature) + } + sym + ": " + sym.typeSignature + } + + def convert(value: Any, tpe: Type) = { + import scala.runtime.BoxesRunTime._ + if (tpe =:= typeOf[Byte]) toByte(value) + else if (tpe =:= typeOf[Short]) toShort(value) + else if (tpe =:= typeOf[Char]) toCharacter(value) + else if (tpe =:= typeOf[Int]) toInteger(value) + else if (tpe =:= typeOf[Long]) toLong(value) + else if (tpe =:= typeOf[Float]) toFloat(value) + else if (tpe =:= typeOf[Double]) toDouble(value) + else if (tpe =:= typeOf[String]) value.toString + else if (tpe =:= typeOf[Boolean]) value.asInstanceOf[Boolean] + else throw new Exception(s"not supported: value = $value, tpe = $tpe") + } + + def test[T: ClassTag](tpe: Type, receiver: T, method: String, args: Any*) { + def wrap[T](op: => T) = + try { + var result = op.asInstanceOf[AnyRef] + if (scala.runtime.ScalaRunTime.isArray(result)) + result = scala.runtime.ScalaRunTime.toObjectArray(result).toList + println(s"[${result.getClass}] =======> $result") + } catch { + case ex: Throwable => + val realex = scala.reflect.runtime.ReflectionUtils.unwrapThrowable(ex) + println(realex.getClass + ": " + realex.getMessage) + } + val meth = tpe.declaration(newTermName(method).encodedName.toTermName) + val testees = if (meth.isMethod) List(meth.asMethod) else meth.asTerm.alternatives.map(_.asMethod) + testees foreach (testee => { + val convertedArgs = args.zipWithIndex.map { case (arg, i) => convert(arg, testee.params.flatten.apply(i).typeSignature) } + print(s"testing ${tpe.typeSymbol.name}.$method(${testee.params.flatten.map(_.typeSignature).mkString(','.toString)}) with receiver = $receiver and args = ${convertedArgs.map(arg => arg + ' '.toString + arg.getClass).toList}: ") + wrap(cm.reflect(receiver).reflectMethod(testee)(convertedArgs: _*)) + }) + } + def header(tpe: Type) { + println(s"============\n$tpe") + println("it's important to print the list of Byte's members") + println("if some of them change (possibly, adding and/or removing magic symbols), we must update this test") + tpe.members.toList.sortBy(key).foreach(sym => println(key(sym))) + } + + def testNumeric[T: ClassTag](tpe: Type, value: T) { + header(tpe) + List("toByte", "toShort", "toChar", "toInt", "toLong", "toFloat", "toDouble") foreach (meth => test(tpe, value, meth)) + test(tpe, value, "==", 2) + test(tpe, value, "!=", 2) + test(tpe, value, "<", 2) + test(tpe, value, "<=", 2) + test(tpe, value, ">", 2) + test(tpe, value, ">=", 2) + test(tpe, value, "+", 2) + test(tpe, value, "-", 2) + test(tpe, value, "*", 2) + test(tpe, value, "/", 2) + test(tpe, value, "%", 2) + } + + def testIntegral[T: ClassTag](tpe: Type, value: T) { + testNumeric(tpe, value) + test(tpe, value, "unary_~") + test(tpe, value, "unary_+") + test(tpe, value, "unary_-") + test(tpe, value, "<<", 2) + test(tpe, value, ">>", 2) + test(tpe, value, ">>>", 2) + test(tpe, value, "|", 2) + test(tpe, value, "&", 2) + test(tpe, value, "^", 2) + } + + def testBoolean() { + header(typeOf[Boolean]) + test(typeOf[Boolean], true, "unary_!") + test(typeOf[Boolean], true, "==", true) + test(typeOf[Boolean], true, "!=", true) + test(typeOf[Boolean], true, "||", true) + test(typeOf[Boolean], true, "&&", true) + test(typeOf[Boolean], true, "|", true) + test(typeOf[Boolean], true, "&", true) + test(typeOf[Boolean], true, "^", true) + } + + def testUnit() { + header(typeOf[Unit]) + } + + testNumeric(typeOf[Byte], 2.toByte) + testNumeric(typeOf[Short], 2.toShort) + testNumeric(typeOf[Char], 2.toChar) + testNumeric(typeOf[Int], 2.toInt) + testNumeric(typeOf[Long], 2.toLong) + testNumeric(typeOf[Float], 2.toFloat) + testNumeric(typeOf[Double], 2.toDouble) + testBoolean() + testUnit() +} \ No newline at end of file diff --git a/test/files/run/reflection-valueclasses-standard.check b/test/files/run/reflection-valueclasses-standard.check new file mode 100644 index 0000000000..060ab55406 --- /dev/null +++ b/test/files/run/reflection-valueclasses-standard.check @@ -0,0 +1,27 @@ +========byte======== +byte +2 +========short======== +short +2 +========int======== +int +2 +========long======== +long +2 +========float======== +float +2.0 +========double======== +double +2.0 +========char======== +char +2 +========boolean======== +boolean +true +========void======== +void +() diff --git a/test/files/run/reflection-valueclasses-standard.scala b/test/files/run/reflection-valueclasses-standard.scala new file mode 100644 index 0000000000..18a3d1fa04 --- /dev/null +++ b/test/files/run/reflection-valueclasses-standard.scala @@ -0,0 +1,21 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.reflect.{ClassTag, classTag} + +object Test extends App { + def test[T: ClassTag: TypeTag](x: T) = { + println(s"========${classTag[T].runtimeClass}========") + println(cm.reflect(x).reflectMethod(typeOf[T].member(newTermName("getClass")).asMethod)()) + println(cm.reflect(x).reflectMethod(typeOf[T].member(newTermName("toString")).asMethod)()) + } + + test(2.toByte) + test(2.toShort) + test(2.toInt) + test(2.toLong) + test(2.toFloat) + test(2.toDouble) + test('2') + test(true) + test(()) +} \ No newline at end of file -- cgit v1.2.3 From 3c4f4865f6420f98a7ed502257bc65387951e26c Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 6 Aug 2012 17:40:28 +0200 Subject: SI-6181 method mirrors now support by-name args Arguments provided in by-name positions are now automatically wrapped in Function0 instances by method mirrors. --- src/reflect/scala/reflect/runtime/JavaMirrors.scala | 10 ++++++++++ test/files/run/t6181.check | 1 + test/files/run/t6181.scala | 8 ++++++++ 3 files changed, 19 insertions(+) create mode 100644 test/files/run/t6181.check create mode 100644 test/files/run/t6181.scala (limited to 'test/files/run') diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 3a18c60720..1698e99dae 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -21,6 +21,7 @@ import internal.Flags._ import ReflectionUtils.{singletonInstance} import language.existentials import scala.runtime.{ScalaRunTime, BoxesRunTime} +import scala.reflect.internal.util.Collections._ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: SymbolTable => @@ -262,6 +263,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym // rather than have them on a hot path them in a unified implementation of the `apply` method private def mkJavaMethodMirror[T: ClassTag](receiver: T, symbol: MethodSymbol): JavaMethodMirror = { if (isMagicMethod(symbol)) new JavaMagicMethodMirror(receiver, symbol) + else if (symbol.params.flatten exists (p => isByNameParamType(p.info))) new JavaByNameMethodMirror(receiver, symbol) else new JavaVanillaMethodMirror(receiver, symbol) } @@ -281,6 +283,14 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym def apply(args: Any*): Any = jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) } + private class JavaByNameMethodMirror(val receiver: Any, symbol: MethodSymbol) + extends JavaMethodMirror(symbol) { + def apply(args: Any*): Any = { + val transformed = map2(args.toList, symbol.params.flatten)((arg, param) => if (isByNameParamType(param.info)) () => arg else arg) + jmeth.invoke(receiver, transformed.asInstanceOf[Seq[AnyRef]]: _*) + } + } + private class JavaMagicMethodMirror[T: ClassTag](val receiver: T, symbol: MethodSymbol) extends JavaMethodMirror(symbol) { def apply(args: Any*): Any = { diff --git a/test/files/run/t6181.check b/test/files/run/t6181.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/files/run/t6181.check @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/test/files/run/t6181.scala b/test/files/run/t6181.scala new file mode 100644 index 0000000000..fb23eaff63 --- /dev/null +++ b/test/files/run/t6181.scala @@ -0,0 +1,8 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +object Test extends App { + class C { def test(x: => Int) = println(x) } + val mm = cm.reflect(new C).reflectMethod(typeOf[C].member(newTermName("test")).asMethod) + mm(2) +} \ No newline at end of file -- cgit v1.2.3 From 3cbe07f3e3ddb7201d1d174399d14d4a69df52fd Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 6 Aug 2012 17:55:12 +0200 Subject: sanity check for reflectConstructor In 911bbc4 I've completely overlooked the fact that reflectConstructor exists and that is also needs sanity checks. Now reflectConstructor checks that the incoming symbol is actually a ctor, and that it is actually a ctor of the class reflected by the current mirror. --- src/reflect/scala/reflect/runtime/JavaMirrors.scala | 9 +++++++-- test/files/run/reflection-sanitychecks.check | 4 ++++ test/files/run/reflection-sanitychecks.scala | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'test/files/run') diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 1698e99dae..f9407d5b1b 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -126,13 +126,14 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym private def ErrorStaticClass(wannabe: Symbol) = throw new ScalaReflectionException(s"$wannabe is a static class, use reflectClass on a RuntimeMirror to obtain its ClassMirror") private def ErrorStaticModule(wannabe: Symbol) = throw new ScalaReflectionException(s"$wannabe is a static module, use reflectModule on a RuntimeMirror to obtain its ModuleMirror") private def ErrorNotMember(wannabe: Symbol, owner: Symbol) = throw new ScalaReflectionException(s"expected a member of $owner, you provided ${wannabe.kind} ${wannabe.fullName}") - private def ErrorNotField(wannabe: Symbol) = throw new ScalaReflectionException(s"expected a field or an accessor method symbol, you provided $wannabe}") + private def ErrorNotField(wannabe: Symbol) = throw new ScalaReflectionException(s"expected a field or an accessor method symbol, you provided $wannabe") private def ErrorNonExistentField(wannabe: Symbol) = throw new ScalaReflectionException(s""" |Scala field ${wannabe.name} isn't represented as a Java field, neither it has a Java accessor method |note that private parameters of class constructors don't get mapped onto fields and/or accessors, |unless they are used outside of their declaring constructors. """.trim.stripMargin) private def ErrorSetImmutableField(wannabe: Symbol) = throw new ScalaReflectionException(s"cannot set an immutable field ${wannabe.name}") + private def ErrorNotConstructor(wannabe: Symbol, owner: Symbol) = throw new ScalaReflectionException(s"expected a constructor of $owner, you provided $wannabe") def reflect[T: ClassTag](obj: T): InstanceMirror = new JavaInstanceMirror(obj) @@ -379,7 +380,11 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym extends JavaTemplateMirror with ClassMirror { def erasure = symbol def isStatic = false - def reflectConstructor(constructor: MethodSymbol) = new JavaConstructorMirror(outer, constructor) + def reflectConstructor(constructor: MethodSymbol) = { + if (!constructor.isClassConstructor) ErrorNotConstructor(constructor, symbol) + if (!symbol.info.decls.toList.contains(constructor)) ErrorNotConstructor(constructor, symbol) + new JavaConstructorMirror(outer, constructor) + } def companion: Option[ModuleMirror] = symbol.companionModule match { case module: ModuleSymbol => Some(new JavaModuleMirror(outer, module)) case _ => None diff --git a/test/files/run/reflection-sanitychecks.check b/test/files/run/reflection-sanitychecks.check index d977e0ed66..4881285bc0 100644 --- a/test/files/run/reflection-sanitychecks.check +++ b/test/files/run/reflection-sanitychecks.check @@ -1,8 +1,12 @@ field: 1 method: 2 +constructor #1: scala.ScalaReflectionException: expected a constructor of class C, you provided method bar +constructor #2: an instance of class C class: CC object: java.lang.Error: inner and nested modules are not supported yet field: scala.ScalaReflectionException: expected a member of class C, you provided value D.foo method: scala.ScalaReflectionException: expected a member of class C, you provided method D.bar +constructor #1: scala.ScalaReflectionException: expected a constructor of class C, you provided method bar +constructor #2: scala.ScalaReflectionException: expected a constructor of class C, you provided constructor D class: scala.ScalaReflectionException: expected a member of class C, you provided class D.C object: scala.ScalaReflectionException: expected a member of class C, you provided object D.O diff --git a/test/files/run/reflection-sanitychecks.scala b/test/files/run/reflection-sanitychecks.scala index e95d130460..b0982fc2fc 100644 --- a/test/files/run/reflection-sanitychecks.scala +++ b/test/files/run/reflection-sanitychecks.scala @@ -3,6 +3,7 @@ class C { def bar = 2 class C { override def toString = "CC" } object O { override def toString = "CO" } + override def toString = "an instance of class C" } class D { @@ -10,6 +11,7 @@ class D { def bar = 4 class C { override def toString = "DC" } object O { override def toString = "DO" } + override def toString = "an instance of class D" } object Test extends App { @@ -21,6 +23,8 @@ object Test extends App { def failsafe(action: => Any): Any = try action catch { case ex: Throwable => ex.toString } println("field: " + failsafe(im.reflectField(tpe.member(newTermName("foo")).asTerm).get)) println("method: " + failsafe(im.reflectMethod(tpe.member(newTermName("bar")).asMethod)())) + println("constructor #1: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("bar")).asMethod)())) + println("constructor #2: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("")).asMethod)())) println("class: " + failsafe(im.reflectClass(tpe.member(newTypeName("C")).asClass).reflectConstructor(typeOf[C].member(newTypeName("C")).asClass.typeSignature.member(newTermName("")).asMethod)())) println("object: " + failsafe(im.reflectModule(tpe.member(newTermName("O")).asModule).instance)) } -- cgit v1.2.3 From 7bcb9da47362ba862a695f7c82c0095a8205e3e2 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 6 Aug 2012 19:37:07 +0200 Subject: mirrors now support overriden fields and methods Previously `checkMemberOf` was blocking base fields and methods that are overriden in receiver.getClass. Now this is fixed. The fix also uncovered an issue with field mirrors. Currently their `get` and `set` methods don't respect overriding and always return field values from a base class. After discussing this on a reflection meeting, we decided that this behavior is desirable and that for overriding people should use reflectMethod and then apply on getters/setters. See the discussion at: https://github.com/scala/scala/pull/1054. --- src/reflect/scala/reflect/api/Mirrors.scala | 16 +++++++++ .../scala/reflect/runtime/JavaMirrors.scala | 6 +++- test/files/run/reflection-sanitychecks.check | 42 +++++++++++++++------- test/files/run/reflection-sanitychecks.scala | 35 ++++++++++++------ 4 files changed, 76 insertions(+), 23 deletions(-) (limited to 'test/files/run') diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala index 41acd73492..8f69ab526b 100644 --- a/src/reflect/scala/reflect/api/Mirrors.scala +++ b/src/reflect/scala/reflect/api/Mirrors.scala @@ -33,6 +33,14 @@ trait Mirrors { self: Universe => /** Reflects against a field symbol and returns a mirror * that can be used to get and, if appropriate, set the value of the field. * + * FieldMirrors are the only way to get at private[this] vals and vars and + * might be useful to inspect the data of underlying Java fields. + * For all other uses, it's better to go through the fields accessor. + * + * In particular, there should be no need to ever access a field mirror + * when reflecting on just the public members of a class or trait. + * Note also that only accessor MethodMirrors, but not FieldMirrors will accurately reflect overriding behavior. + * * To get a field symbol by the name of the field you would like to reflect, * use `.symbol.typeSignature.member(newTermName()).asTerm.accessed`. * For further information about member lookup refer to `Symbol.typeSignature`. @@ -107,6 +115,10 @@ trait Mirrors { self: Universe => * Scala reflection uses reflection capabilities of the underlying platform, * so `FieldMirror.get` might throw platform-specific exceptions associated * with getting a field or invoking a getter method of the field. + * + * If `symbol` represents a field of a base class with respect to the class of the receiver, + * and this base field is overriden in the class of the receiver, then this method will retrieve + * the value of the base field. To achieve overriding behavior, use reflectMethod on an accessor. */ def get: Any @@ -117,6 +129,10 @@ trait Mirrors { self: Universe => * Scala reflection uses reflection capabilities of the underlying platform, * so `FieldMirror.get` might throw platform-specific exceptions associated * with setting a field or invoking a setter method of the field. + * + * If `symbol` represents a field of a base class with respect to the class of the receiver, + * and this base field is overriden in the class of the receiver, then this method will set + * the value of the base field. To achieve overriding behavior, use reflectMethod on an accessor. */ def set(value: Any): Unit } diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index f9407d5b1b..d671225c37 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -161,7 +161,11 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym } else if (wannabe.owner == AnyValClass) { if (!owner.isPrimitiveValueClass && !owner.isDerivedValueClass) ErrorNotMember(wannabe, owner) } else { - if (!owner.info.member(wannabe.name).alternatives.contains(wannabe)) ErrorNotMember(wannabe, owner) + def isMemberOf(wannabe: Symbol, owner: ClassSymbol): Boolean = { + val isNonShadowedMember = owner.info.member(wannabe.name).alternatives.contains(wannabe) + isNonShadowedMember || owner.info.baseClasses.tail.exists(base => isMemberOf(wannabe, base.asClass)) + } + if (!isMemberOf(wannabe, owner)) ErrorNotMember(wannabe, owner) } } diff --git a/test/files/run/reflection-sanitychecks.check b/test/files/run/reflection-sanitychecks.check index 4881285bc0..a1df486b51 100644 --- a/test/files/run/reflection-sanitychecks.check +++ b/test/files/run/reflection-sanitychecks.check @@ -1,12 +1,30 @@ -field: 1 -method: 2 -constructor #1: scala.ScalaReflectionException: expected a constructor of class C, you provided method bar -constructor #2: an instance of class C -class: CC -object: java.lang.Error: inner and nested modules are not supported yet -field: scala.ScalaReflectionException: expected a member of class C, you provided value D.foo -method: scala.ScalaReflectionException: expected a member of class C, you provided method D.bar -constructor #1: scala.ScalaReflectionException: expected a constructor of class C, you provided method bar -constructor #2: scala.ScalaReflectionException: expected a constructor of class C, you provided constructor D -class: scala.ScalaReflectionException: expected a member of class C, you provided class D.C -object: scala.ScalaReflectionException: expected a member of class C, you provided object D.O +=========members of C in a mirror of D========= +field #1: 11 +method #1: 22 +field #2: 13 +method #2: 14 +constructor #1: scala.ScalaReflectionException: expected a constructor of class D, you provided method bar +constructor #2: scala.ScalaReflectionException: expected a constructor of class D, you provided constructor C +class: CC +object: java.lang.Error: inner and nested modules are not supported yet + +=========members of D in a mirror of D========= +field #1: 21 +method #1: 22 +field #2: 13 +method #2: 14 +constructor #1: scala.ScalaReflectionException: expected a constructor of class D, you provided method bar +constructor #2: an instance of class D +class: CC +object: java.lang.Error: inner and nested modules are not supported yet + +=========members of E in a mirror of D========= +field #1: scala.ScalaReflectionException: expected a member of class D, you provided value E.foo +method #1: scala.ScalaReflectionException: expected a member of class D, you provided method E.bar +field #2: scala.ScalaReflectionException: expected a member of class D, you provided value E.quux +method #2: scala.ScalaReflectionException: expected a member of class D, you provided method E.baz +constructor #1: scala.ScalaReflectionException: expected a constructor of class D, you provided method bar +constructor #2: scala.ScalaReflectionException: expected a constructor of class D, you provided constructor E +class: scala.ScalaReflectionException: expected a member of class D, you provided class E.C +object: scala.ScalaReflectionException: expected a member of class D, you provided object E.O + diff --git a/test/files/run/reflection-sanitychecks.scala b/test/files/run/reflection-sanitychecks.scala index b0982fc2fc..f817f23731 100644 --- a/test/files/run/reflection-sanitychecks.scala +++ b/test/files/run/reflection-sanitychecks.scala @@ -1,34 +1,49 @@ class C { - val foo = 1 - def bar = 2 + val foo = 11 + def bar = 12 + val quux = 13 + def baz = 14 class C { override def toString = "CC" } object O { override def toString = "CO" } override def toString = "an instance of class C" } -class D { - val foo = 3 - def bar = 4 - class C { override def toString = "DC" } - object O { override def toString = "DO" } +class D extends C { + override val foo = 21 + override def bar = 22 override def toString = "an instance of class D" } +class E { + val foo = 31 + def bar = 32 + val quux = 33 + def baz = 34 + class C { override def toString = "EC" } + object O { override def toString = "EO" } + override def toString = "an instance of class E" +} + object Test extends App { import scala.reflect.runtime.universe._ import scala.reflect.runtime.{currentMirror => cm} - val im = cm.reflect(new C) + val im = cm.reflect(new D) def test(tpe: Type): Unit = { def failsafe(action: => Any): Any = try action catch { case ex: Throwable => ex.toString } - println("field: " + failsafe(im.reflectField(tpe.member(newTermName("foo")).asTerm).get)) - println("method: " + failsafe(im.reflectMethod(tpe.member(newTermName("bar")).asMethod)())) + println(s"=========members of ${tpe.typeSymbol.name} in a mirror of D=========") + println("field #1: " + failsafe(im.reflectField(tpe.member(newTermName("foo")).asTerm).get)) + println("method #1: " + failsafe(im.reflectMethod(tpe.member(newTermName("bar")).asMethod)())) + println("field #2: " + failsafe(im.reflectField(tpe.member(newTermName("quux")).asTerm).get)) + println("method #2: " + failsafe(im.reflectMethod(tpe.member(newTermName("baz")).asMethod)())) println("constructor #1: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("bar")).asMethod)())) println("constructor #2: " + failsafe(cm.reflectClass(im.symbol).reflectConstructor(tpe.member(newTermName("")).asMethod)())) println("class: " + failsafe(im.reflectClass(tpe.member(newTypeName("C")).asClass).reflectConstructor(typeOf[C].member(newTypeName("C")).asClass.typeSignature.member(newTermName("")).asMethod)())) println("object: " + failsafe(im.reflectModule(tpe.member(newTermName("O")).asModule).instance)) + println() } test(typeOf[C]) test(typeOf[D]) + test(typeOf[E]) } \ No newline at end of file -- cgit v1.2.3 From cac52ac3e3bd34dfc6540968c30d3e861799f9e4 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 6 Aug 2012 21:53:42 +0200 Subject: SI-6199 unit-returning methods now return unit Since Scala reflection relies on Java reflection to perform member invocations, it inherits some of the quirks of the underlying platform. One of such quirks is returning null when invoking a void-returning method. This is now fixed by introducing a check after calling invoke. --- src/compiler/scala/tools/reflect/ToolBoxFactory.scala | 3 ++- src/reflect/scala/reflect/runtime/JavaMirrors.scala | 12 +++++++++--- test/files/run/reflection-magicsymbols-invoke.check | 2 +- test/files/run/t6199-mirror.check | 1 + test/files/run/t6199-mirror.scala | 7 +++++++ test/files/run/t6199-toolbox.check | 1 + test/files/run/t6199-toolbox.scala | 8 ++++++++ 7 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 test/files/run/t6199-mirror.check create mode 100644 test/files/run/t6199-mirror.scala create mode 100644 test/files/run/t6199-toolbox.check create mode 100644 test/files/run/t6199-toolbox.scala (limited to 'test/files/run') diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index 9987931cf3..eeec973299 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -256,7 +256,8 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => // } val (singleton, jmeth) = compileExpr(expr) val result = jmeth.invoke(singleton, thunks map (_.asInstanceOf[AnyRef]): _*) - result + if (jmeth.getReturnType == java.lang.Void.TYPE) () + else result } def parseExpr(code: String): Tree = { diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index d671225c37..e48c933584 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -280,19 +280,25 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym jmeth } + def jinvoke(jmeth: jMethod, receiver: Any, args: Seq[Any]): Any = { + val result = jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) + if (jmeth.getReturnType == java.lang.Void.TYPE) () + else result + } + override def toString = s"method mirror for ${showMethodSig(symbol)} (bound to $receiver)" } private class JavaVanillaMethodMirror(val receiver: Any, symbol: MethodSymbol) extends JavaMethodMirror(symbol) { - def apply(args: Any*): Any = jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) + def apply(args: Any*): Any = jinvoke(jmeth, receiver, args) } private class JavaByNameMethodMirror(val receiver: Any, symbol: MethodSymbol) extends JavaMethodMirror(symbol) { def apply(args: Any*): Any = { val transformed = map2(args.toList, symbol.params.flatten)((arg, param) => if (isByNameParamType(param.info)) () => arg else arg) - jmeth.invoke(receiver, transformed.asInstanceOf[Seq[AnyRef]]: _*) + jinvoke(jmeth, receiver, transformed) } } @@ -321,7 +327,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym def invokeMagicPrimitiveMethod = { val jmeths = classOf[BoxesRunTime].getDeclaredMethods.filter(_.getName == nme.primitiveMethodName(symbol.name).toString) assert(jmeths.length == 1, jmeths.toList) - jmeths.head.invoke(null, (objReceiver +: objArgs): _*) + jinvoke(jmeths.head, null, objReceiver +: objArgs) } symbol match { diff --git a/test/files/run/reflection-magicsymbols-invoke.check b/test/files/run/reflection-magicsymbols-invoke.check index a180ed806e..674716adfe 100644 --- a/test/files/run/reflection-magicsymbols-invoke.check +++ b/test/files/run/reflection-magicsymbols-invoke.check @@ -68,7 +68,7 @@ testing Object.==: true testing Object.clone: class java.lang.CloneNotSupportedException: java.lang.String testing Object.eq: true testing Object.equals: true -testing Object.finalize: null +testing Object.finalize: () testing Object.getClass: class java.lang.String testing Object.hashCode: 50 testing Object.ne: false diff --git a/test/files/run/t6199-mirror.check b/test/files/run/t6199-mirror.check new file mode 100644 index 0000000000..ec969b5b93 --- /dev/null +++ b/test/files/run/t6199-mirror.check @@ -0,0 +1 @@ +() diff --git a/test/files/run/t6199-mirror.scala b/test/files/run/t6199-mirror.scala new file mode 100644 index 0000000000..772a384542 --- /dev/null +++ b/test/files/run/t6199-mirror.scala @@ -0,0 +1,7 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +object Test extends App { + class C { def foo = () } + println(cm.reflect(new C).reflectMethod(typeOf[C].member(newTermName("foo")).asMethod)()) +} \ No newline at end of file diff --git a/test/files/run/t6199-toolbox.check b/test/files/run/t6199-toolbox.check new file mode 100644 index 0000000000..ec969b5b93 --- /dev/null +++ b/test/files/run/t6199-toolbox.check @@ -0,0 +1 @@ +() diff --git a/test/files/run/t6199-toolbox.scala b/test/files/run/t6199-toolbox.scala new file mode 100644 index 0000000000..14670f8e21 --- /dev/null +++ b/test/files/run/t6199-toolbox.scala @@ -0,0 +1,8 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val tb = cm.mkToolBox() + println(tb.runExpr(Literal(Constant(())))) +} \ No newline at end of file -- cgit v1.2.3 From fd3601a833baac6258d28687d1a73979f4369826 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 6 Aug 2012 14:05:24 -0700 Subject: Restored :warnings to working order. As seen here. scala> class A { @deprecated("foo") def a = 1 } warning: there were 1 deprecation warnings; re-run with -deprecation for details defined class A scala> :warnings :7: warning: @deprecated now takes two arguments; see the scaladoc. class A { @deprecated("foo") def a = 1 } ^ scala> val x = 5 toString warning: there were 1 feature warnings; re-run with -feature for details x: String = 5 scala> :warnings :7: warning: postfix operator toString should be enabled by making the implicit value language.postfixOps visible. This can be achieved by adding the import clause 'import language.postfixOps' or by setting the compiler option -language:postfixOps. See the Scala docs for value scala.language.postfixOps for a discussion why the feature should be explicitly enabled. val x = 5 toString ^ --- .../scala/tools/nsc/interpreter/ILoop.scala | 5 +- .../scala/tools/nsc/interpreter/IMain.scala | 80 +-- test/files/jvm/interpreter.check | 741 ++++++++++----------- test/files/run/constrained-types.check | 3 - test/files/run/t4172.check | 1 - test/files/run/t4542.check | 3 - 6 files changed, 407 insertions(+), 426 deletions(-) (limited to 'test/files/run') diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala index b567293a3f..0e1658ff17 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala @@ -438,7 +438,10 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) } private def warningsCommand(): Result = { - intp.lastWarnings foreach { case (pos, msg) => intp.reporter.warning(pos, msg) } + if (intp.lastWarnings.isEmpty) + "Can't find any cached warnings." + else + intp.lastWarnings foreach { case (pos, msg) => intp.reporter.warning(pos, msg) } } private def javapCommand(line: String): Result = { diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 7bdbff8627..e6a142934d 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -108,27 +108,19 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends else new PathResolver(settings).result.asURLs // the compiler's classpath ) def settings = currentSettings - def savingSettings[T](fn: Settings => Unit)(body: => T): T = { - val saved = currentSettings - currentSettings = saved.copy() - fn(currentSettings) - try body - finally currentSettings = saved - } def mostRecentLine = prevRequestList match { case Nil => "" case req :: _ => req.originalLine } - def rerunWith(names: String*) = { - savingSettings((ss: Settings) => { - import ss._ - names flatMap lookupSetting foreach { - case s: BooleanSetting => s.value = true - case _ => () - } - })(interpret(mostRecentLine)) + // Run the code body with the given boolean settings flipped to true. + def withoutWarnings[T](body: => T): T = beQuietDuring { + val saved = settings.nowarn.value + if (!saved) + settings.nowarn.value = true + + try body + finally if (!saved) settings.nowarn.value = false } - def rerunForWarnings = rerunWith("-deprecation", "-unchecked", "-Xlint") /** construct an interpreter that reports to Console */ def this(settings: Settings) = this(settings, new NewLinePrintWriter(new ConsoleWriter, true)) @@ -699,6 +691,10 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends class ReadEvalPrint(lineId: Int) { def this() = this(freshLineId()) + private var lastRun: Run = _ + private var evalCaught: Option[Throwable] = None + private var conditionalWarnings: List[ConditionalWarning] = Nil + val packageName = sessionNames.line + lineId val readName = sessionNames.read val evalName = sessionNames.eval @@ -754,7 +750,6 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends catch { case ex: Throwable => evalError(path, unwrap(ex)) } } - var evalCaught: Option[Throwable] = None lazy val evalClass = load(evalPath) lazy val evalValue = callEither(resultName) match { case Left(ex) => evalCaught = Some(ex) ; None @@ -776,27 +771,25 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends /** We get a bunch of repeated warnings for reasons I haven't * entirely figured out yet. For now, squash. */ - private def removeDupWarnings(xs: List[(Position, String)]): List[(Position, String)] = { - if (xs.isEmpty) - return Nil - - val ((pos, msg)) :: rest = xs - val filtered = rest filter { case (pos0, msg0) => - (msg != msg0) || (pos.lineContent.trim != pos0.lineContent.trim) || { - // same messages and same line content after whitespace removal - // but we want to let through multiple warnings on the same line - // from the same run. The untrimmed line will be the same since - // there's no whitespace indenting blowing it. - (pos.lineContent == pos0.lineContent) - } + private def updateRecentWarnings(run: Run) { + def loop(xs: List[(Position, String)]): List[(Position, String)] = xs match { + case Nil => Nil + case ((pos, msg)) :: rest => + val filtered = rest filter { case (pos0, msg0) => + (msg != msg0) || (pos.lineContent.trim != pos0.lineContent.trim) || { + // same messages and same line content after whitespace removal + // but we want to let through multiple warnings on the same line + // from the same run. The untrimmed line will be the same since + // there's no whitespace indenting blowing it. + (pos.lineContent == pos0.lineContent) + } + } + ((pos, msg)) :: loop(filtered) } - ((pos, msg)) :: removeDupWarnings(filtered) + val warnings = loop(run.allConditionalWarnings flatMap (_.warnings)) + if (warnings.nonEmpty) + mostRecentWarnings = warnings } - def lastWarnings: List[(Position, String)] = ( - if (lastRun == null) Nil - else removeDupWarnings(lastRun.allConditionalWarnings flatMap (_.warnings)) - ) - private var lastRun: Run = _ private def evalMethod(name: String) = evalClass.getMethods filter (_.getName == name) match { case Array(method) => method case xs => sys.error("Internal error: eval object " + evalClass + ", " + xs.mkString("\n", "\n", "")) @@ -804,6 +797,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends private def compileAndSaveRun(label: String, code: String) = { showCodeIfDebugging(code) val (success, run) = compileSourcesKeepingRun(new BatchSourceFile(label, packaged(code))) + updateRecentWarnings(run) lastRun = run success } @@ -953,11 +947,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends } // compile the result-extraction object - beQuietDuring { - savingSettings(_.nowarn.value = true) { - lineRep compile ResultObjectSourceCode(handlers) - } - } + withoutWarnings(lineRep compile ResultObjectSourceCode(handlers)) } } @@ -1008,12 +998,8 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends case _ => naming.mostRecentVar }) - def lastWarnings: List[(global.Position, String)] = ( - prevRequests.reverseIterator - map (_.lineRep.lastWarnings) - find (_.nonEmpty) - getOrElse Nil - ) + private var mostRecentWarnings: List[(global.Position, String)] = Nil + def lastWarnings = mostRecentWarnings def treesForRequestId(id: Int): List[Tree] = requestForReqId(id).toList flatMap (_.trees) diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index dc835bf8b6..6145b6c4d2 100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -1,374 +1,373 @@ -Type in expressions to have them evaluated. -Type :help for more information. - -scala> - -scala> // basics - -scala> 3+4 -res0: Int = 7 - -scala> def gcd(x: Int, y: Int): Int = { - if (x == 0) y - else if (y == 0) x - else gcd(y%x, x) -} -gcd: (x: Int, y: Int)Int - -scala> val five = gcd(15,35) -five: Int = 5 - -scala> var x = 1 -x: Int = 1 - -scala> x = 2 -x: Int = 2 - -scala> val three = x+1 -three: Int = 3 - -scala> type anotherint = Int -defined type alias anotherint - -scala> val four: anotherint = 4 -four: anotherint = 4 - -scala> val bogus: anotherint = "hello" -:8: error: type mismatch; - found : String("hello") - required: anotherint - (which expands to) Int - val bogus: anotherint = "hello" - ^ - -scala> trait PointlessTrait -defined trait PointlessTrait - -scala> val (x,y) = (2,3) -x: Int = 2 -y: Int = 3 - -scala> println("hello") -hello - -scala> - -scala> // ticket #1513 - -scala> val t1513 = Array(null) -t1513: Array[Null] = Array(null) - -scala> // ambiguous toString problem from #547 - -scala> val atom = new scala.xml.Atom() -atom: scala.xml.Atom[Unit] = () - -scala> // overriding toString problem from #1404 - -scala> class S(override val toString : String) -defined class S - -scala> val fish = new S("fish") -fish: S = fish - -scala> // Test that arrays pretty print nicely. - -scala> val arr = Array("What's", "up", "doc?") -arr: Array[String] = Array(What's, up, doc?) - -scala> // Test that arrays pretty print nicely, even when we give them type Any - -scala> val arrInt : Any = Array(1,2,3) -arrInt: Any = Array(1, 2, 3) - -scala> // Test that nested arrays are pretty-printed correctly - -scala> val arrArrInt : Any = Array(Array(1, 2), Array(3, 4)) -arrArrInt: Any = Array(Array(1, 2), Array(3, 4)) - -scala> - -scala> // implicit conversions - -scala> case class Foo(n: Int) -defined class Foo - -scala> case class Bar(n: Int) -defined class Bar - -scala> implicit def foo2bar(foo: Foo) = Bar(foo.n) -warning: there were 1 feature warnings; re-run with -feature for details -foo2bar: (foo: Foo)Bar - -scala> val bar: Bar = Foo(3) -bar: Bar = Bar(3) - -scala> - -scala> // importing from a previous result - -scala> import bar._ -import bar._ - -scala> val m = n -m: Int = 3 - -scala> - -scala> // stressing the imports mechanism - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> val one = 1 -one: Int = 1 - -scala> - -scala> - -scala> val x1 = 1 -x1: Int = 1 - -scala> val x2 = 1 -x2: Int = 1 - -scala> val x3 = 1 -x3: Int = 1 - -scala> val x4 = 1 -x4: Int = 1 - -scala> val x5 = 1 -x5: Int = 1 - -scala> val x6 = 1 -x6: Int = 1 - -scala> val x7 = 1 -x7: Int = 1 - -scala> val x8 = 1 -x8: Int = 1 - -scala> val x9 = 1 -x9: Int = 1 - -scala> val x10 = 1 -x10: Int = 1 - -scala> val x11 = 1 -x11: Int = 1 - -scala> val x12 = 1 -x12: Int = 1 - -scala> val x13 = 1 -x13: Int = 1 - -scala> val x14 = 1 -x14: Int = 1 - -scala> val x15 = 1 -x15: Int = 1 - -scala> val x16 = 1 -x16: Int = 1 - -scala> val x17 = 1 -x17: Int = 1 - -scala> val x18 = 1 -x18: Int = 1 - -scala> val x19 = 1 -x19: Int = 1 - -scala> val x20 = 1 -x20: Int = 1 - -scala> - -scala> val two = one + x5 -two: Int = 2 - -scala> - -scala> // handling generic wildcard arrays (#2386) - -scala> // It's put here because type feedback is an important part of it. - -scala> val xs: Array[_] = Array(1, 2) -xs: Array[_] = Array(1, 2) - -scala> xs.size -res2: Int = 2 - -scala> xs.head -res3: Any = 1 - -scala> xs filter (_ == 2) -res4: Array[_] = Array(2) - -scala> xs map (_ => "abc") -res5: Array[String] = Array(abc, abc) - -scala> xs map (x => x) -res6: Array[_] = Array(1, 2) - -scala> xs map (x => (x, x)) -warning: there were 1 feature warnings; re-run with -feature for details -warning: there were 1 feature warnings; re-run with -feature for details -res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2)) - -scala> - -scala> // interior syntax errors should *not* go into multi-line input mode. - -scala> // both of the following should abort immediately: - -scala> def x => y => z -:1: error: '=' expected but '=>' found. - def x => y => z - ^ - -scala> [1,2,3] -:1: error: illegal start of definition - [1,2,3] - ^ - -scala> - -scala> - -scala> // multi-line XML - -scala> - -res8: scala.xml.Elem = - - - -scala> - -scala> - -scala> /* - /* - multi-line comment - */ -*/ - - -You typed two blank lines. Starting a new command. - -scala> // multi-line string - -scala> """ -hello -there -""" -res12: String = -" -hello -there -" - -scala> - -scala> (1 + // give up early by typing two blank lines - - -You typed two blank lines. Starting a new command. - -scala> // defining and using quoted names should work (ticket #323) - -scala> def `match` = 1 -match: Int - -scala> val x = `match` -x: Int = 1 - -scala> - -scala> // multiple classes defined on one line - -scala> sealed class Exp; class Fact extends Exp; class Term extends Exp -defined class Exp -defined class Fact -defined class Term - -scala> def f(e: Exp) = e match { // non-exhaustive warning here - case _:Fact => 3 -} -:18: warning: match is not exhaustive! -missing combination Exp -missing combination Term - - def f(e: Exp) = e match { // non-exhaustive warning here - ^ -f: (e: Exp)Int - -scala> - -scala> +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> // basics + +scala> 3+4 +res0: Int = 7 + +scala> def gcd(x: Int, y: Int): Int = { + if (x == 0) y + else if (y == 0) x + else gcd(y%x, x) +} +gcd: (x: Int, y: Int)Int + +scala> val five = gcd(15,35) +five: Int = 5 + +scala> var x = 1 +x: Int = 1 + +scala> x = 2 +x: Int = 2 + +scala> val three = x+1 +three: Int = 3 + +scala> type anotherint = Int +defined type alias anotherint + +scala> val four: anotherint = 4 +four: anotherint = 4 + +scala> val bogus: anotherint = "hello" +:8: error: type mismatch; + found : String("hello") + required: anotherint + (which expands to) Int + val bogus: anotherint = "hello" + ^ + +scala> trait PointlessTrait +defined trait PointlessTrait + +scala> val (x,y) = (2,3) +x: Int = 2 +y: Int = 3 + +scala> println("hello") +hello + +scala> + +scala> // ticket #1513 + +scala> val t1513 = Array(null) +t1513: Array[Null] = Array(null) + +scala> // ambiguous toString problem from #547 + +scala> val atom = new scala.xml.Atom() +atom: scala.xml.Atom[Unit] = () + +scala> // overriding toString problem from #1404 + +scala> class S(override val toString : String) +defined class S + +scala> val fish = new S("fish") +fish: S = fish + +scala> // Test that arrays pretty print nicely. + +scala> val arr = Array("What's", "up", "doc?") +arr: Array[String] = Array(What's, up, doc?) + +scala> // Test that arrays pretty print nicely, even when we give them type Any + +scala> val arrInt : Any = Array(1,2,3) +arrInt: Any = Array(1, 2, 3) + +scala> // Test that nested arrays are pretty-printed correctly + +scala> val arrArrInt : Any = Array(Array(1, 2), Array(3, 4)) +arrArrInt: Any = Array(Array(1, 2), Array(3, 4)) + +scala> + +scala> // implicit conversions + +scala> case class Foo(n: Int) +defined class Foo + +scala> case class Bar(n: Int) +defined class Bar + +scala> implicit def foo2bar(foo: Foo) = Bar(foo.n) +warning: there were 1 feature warnings; re-run with -feature for details +foo2bar: (foo: Foo)Bar + +scala> val bar: Bar = Foo(3) +bar: Bar = Bar(3) + +scala> + +scala> // importing from a previous result + +scala> import bar._ +import bar._ + +scala> val m = n +m: Int = 3 + +scala> + +scala> // stressing the imports mechanism + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> + +scala> + +scala> val x1 = 1 +x1: Int = 1 + +scala> val x2 = 1 +x2: Int = 1 + +scala> val x3 = 1 +x3: Int = 1 + +scala> val x4 = 1 +x4: Int = 1 + +scala> val x5 = 1 +x5: Int = 1 + +scala> val x6 = 1 +x6: Int = 1 + +scala> val x7 = 1 +x7: Int = 1 + +scala> val x8 = 1 +x8: Int = 1 + +scala> val x9 = 1 +x9: Int = 1 + +scala> val x10 = 1 +x10: Int = 1 + +scala> val x11 = 1 +x11: Int = 1 + +scala> val x12 = 1 +x12: Int = 1 + +scala> val x13 = 1 +x13: Int = 1 + +scala> val x14 = 1 +x14: Int = 1 + +scala> val x15 = 1 +x15: Int = 1 + +scala> val x16 = 1 +x16: Int = 1 + +scala> val x17 = 1 +x17: Int = 1 + +scala> val x18 = 1 +x18: Int = 1 + +scala> val x19 = 1 +x19: Int = 1 + +scala> val x20 = 1 +x20: Int = 1 + +scala> + +scala> val two = one + x5 +two: Int = 2 + +scala> + +scala> // handling generic wildcard arrays (#2386) + +scala> // It's put here because type feedback is an important part of it. + +scala> val xs: Array[_] = Array(1, 2) +xs: Array[_] = Array(1, 2) + +scala> xs.size +res2: Int = 2 + +scala> xs.head +res3: Any = 1 + +scala> xs filter (_ == 2) +res4: Array[_] = Array(2) + +scala> xs map (_ => "abc") +res5: Array[String] = Array(abc, abc) + +scala> xs map (x => x) +res6: Array[_] = Array(1, 2) + +scala> xs map (x => (x, x)) +warning: there were 1 feature warnings; re-run with -feature for details +res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2)) + +scala> + +scala> // interior syntax errors should *not* go into multi-line input mode. + +scala> // both of the following should abort immediately: + +scala> def x => y => z +:1: error: '=' expected but '=>' found. + def x => y => z + ^ + +scala> [1,2,3] +:1: error: illegal start of definition + [1,2,3] + ^ + +scala> + +scala> + +scala> // multi-line XML + +scala> + +res8: scala.xml.Elem = + + + +scala> + +scala> + +scala> /* + /* + multi-line comment + */ +*/ + + +You typed two blank lines. Starting a new command. + +scala> // multi-line string + +scala> """ +hello +there +""" +res12: String = +" +hello +there +" + +scala> + +scala> (1 + // give up early by typing two blank lines + + +You typed two blank lines. Starting a new command. + +scala> // defining and using quoted names should work (ticket #323) + +scala> def `match` = 1 +match: Int + +scala> val x = `match` +x: Int = 1 + +scala> + +scala> // multiple classes defined on one line + +scala> sealed class Exp; class Fact extends Exp; class Term extends Exp +defined class Exp +defined class Fact +defined class Term + +scala> def f(e: Exp) = e match { // non-exhaustive warning here + case _:Fact => 3 +} +:18: warning: match is not exhaustive! +missing combination Exp +missing combination Term + + def f(e: Exp) = e match { // non-exhaustive warning here + ^ +f: (e: Exp)Int + +scala> + +scala> plusOne: (x: Int)Int res0: Int = 6 res0: String = after reset diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index 37784a20ca..da97a378e6 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -76,12 +76,10 @@ four: String = four scala> val four2 = m(four) // should have an existential bound warning: there were 1 feature warnings; re-run with -feature for details -warning: there were 1 feature warnings; re-run with -feature for details four2: String @Annot(x) forSome { val x: String } = four scala> val four3 = four2 // should have the same type as four2 warning: there were 1 feature warnings; re-run with -feature for details -warning: there were 1 feature warnings; re-run with -feature for details four3: String @Annot(x) forSome { val x: String } = four scala> val stuff = m("stuff") // should not crash @@ -105,7 +103,6 @@ scala> def m = { y } // x should not escape the local scope with a narrow type warning: there were 1 feature warnings; re-run with -feature for details -warning: there were 1 feature warnings; re-run with -feature for details m: String @Annot(x) forSome { val x: String } scala> diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check index 4598e02d1f..f16c9e5151 100644 --- a/test/files/run/t4172.check +++ b/test/files/run/t4172.check @@ -5,7 +5,6 @@ scala> scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) } warning: there were 1 feature warnings; re-run with -feature for details -warning: there were 1 feature warnings; re-run with -feature for details c: (C, C{def f: Int}) forSome { type C <: Object } = (C,C) scala> diff --git a/test/files/run/t4542.check b/test/files/run/t4542.check index a0600ba859..cd7a2905e2 100644 --- a/test/files/run/t4542.check +++ b/test/files/run/t4542.check @@ -15,9 +15,6 @@ scala> val f = new Foo :8: warning: class Foo is deprecated: foooo val f = new Foo ^ -:5: warning: class Foo is deprecated: foooo - lazy val $result = `f` - ^ f: Foo = Bippy scala> -- cgit v1.2.3 From cc3badae17e160a446c3a160ab83a11348f75546 Mon Sep 17 00:00:00 2001 From: Vlad Ureche Date: Tue, 7 Aug 2012 13:19:57 +0200 Subject: Removes AnyRef specialization from library As discussed in #999, #1025 and https://groups.google.com/forum/?hl=en&fromgroups#!topic/scala-internals/5P5TS9ZWe_w instrumented.jar is generated from the current source, there's no need for a bootstrap commit. Review by @paulp. --- src/build/genprod.scala | 16 +++++++++------- .../scala/tools/nsc/transform/SpecializeTypes.scala | 4 ++-- src/library/scala/Function0.scala | 4 ++-- src/library/scala/Function1.scala | 2 +- src/library/scala/Tuple2.scala | 2 +- src/library/scala/runtime/AbstractFunction0.scala | 2 +- src/library/scala/runtime/AbstractFunction1.scala | 2 +- src/library/scala/specialized.scala | 2 +- test/files/run/t3575.scala | 8 ++++---- test/files/speclib/instrumented.jar.desired.sha1 | 2 +- 10 files changed, 23 insertions(+), 21 deletions(-) (limited to 'test/files/run') diff --git a/src/build/genprod.scala b/src/build/genprod.scala index 8c91128de0..83a65e6876 100644 --- a/src/build/genprod.scala +++ b/src/build/genprod.scala @@ -6,6 +6,8 @@ ** |/ ** \* */ +import language.postfixOps + /** This program generates the ProductN, TupleN, FunctionN, * and AbstractFunctionN, where 0 <= N <= MAX_ARITY. * @@ -75,7 +77,7 @@ package %s if (args.length != 1) { println("please give path of output directory") - exit(-1) + sys.exit(-1) } val out = args(0) def writeFile(node: scala.xml.Node) { @@ -96,7 +98,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz */ object FunctionZero extends Function(0) { override def genprodString = "\n// genprod generated these sources at: " + new java.util.Date() - override def covariantSpecs = "@specialized " + override def covariantSpecs = "@specialized(Specializable.Primitives) " override def descriptiveComment = " " + functionNTemplate.format("javaVersion", "anonfun0", """ * val javaVersion = () => sys.props("java.version") @@ -111,8 +113,8 @@ object FunctionZero extends Function(0) { object FunctionOne extends Function(1) { override def classAnnotation = "@annotation.implicitNotFound(msg = \"No implicit view available from ${T1} => ${R}.\")\n" - override def contravariantSpecs = "@specialized(scala.Int, scala.Long, scala.Float, scala.Double, scala.AnyRef) " - override def covariantSpecs = "@specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double, scala.AnyRef) " + override def contravariantSpecs = "@specialized(scala.Int, scala.Long, scala.Float, scala.Double/*, scala.AnyRef*/) " + override def covariantSpecs = "@specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double/*, scala.AnyRef*/) " override def descriptiveComment = " " + functionNTemplate.format("succ", "anonfun1", """ @@ -169,7 +171,7 @@ object Function { class Function(val i: Int) extends Group("Function") with Arity { def descriptiveComment = "" - def functionNTemplate = + def functionNTemplate = """ * In the following example, the definition of %s is a * shorthand for the anonymous class definition %s: @@ -226,7 +228,7 @@ class Function(val i: Int) extends Group("Function") with Arity { } def tupleMethod = { - def comment = + def comment = """ /** Creates a tupled version of this function: instead of %d arguments, * it accepts a single [[scala.Tuple%d]] argument. * @@ -275,7 +277,7 @@ object TupleOne extends Tuple(1) object TupleTwo extends Tuple(2) { override def imports = Tuple.zipImports - override def covariantSpecs = "@specialized(Int, Long, Double, Char, Boolean, AnyRef) " + override def covariantSpecs = "@specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) " override def moreMethods = """ /** Swaps the elements of this `Tuple`. * @return a new Tuple where the first element is the second element of this Tuple and the diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 63f93aa000..9f158eac35 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -69,7 +69,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { import definitions.{ BooleanClass, UnitClass, ArrayClass, ScalaValueClasses, isPrimitiveValueClass, isPrimitiveValueType, - SpecializedClass, UnspecializedClass, AnyRefClass, ObjectClass, AnyRefModule, + SpecializedClass, UnspecializedClass, AnyRefClass, ObjectClass, GroupOfSpecializable, uncheckedVarianceClass, ScalaInlineClass } import rootMirror.RootClass @@ -326,7 +326,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { } } - lazy val specializableTypes = (ScalaValueClasses :+ AnyRefClass) map (_.tpe) sorted + lazy val specializableTypes = ScalaValueClasses map (_.tpe) sorted /** If the symbol is the companion of a value class, the value class. * Otherwise, AnyRef. diff --git a/src/library/scala/Function0.scala b/src/library/scala/Function0.scala index 3690a0e65b..5f87b38057 100644 --- a/src/library/scala/Function0.scala +++ b/src/library/scala/Function0.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ // GENERATED CODE: DO NOT EDIT. -// genprod generated these sources at: Mon Apr 30 07:46:11 PDT 2012 +// genprod generated these sources at: Tue Aug 07 11:54:44 CEST 2012 package scala @@ -33,7 +33,7 @@ package scala * latter can specify inputs which it will not handle. */ -trait Function0[@specialized +R] extends AnyRef { self => +trait Function0[@specialized(Specializable.Primitives) +R] extends AnyRef { self => /** Apply the body of this function to the arguments. * @return the result of function application. */ diff --git a/src/library/scala/Function1.scala b/src/library/scala/Function1.scala index f9b37fc6bd..22393c65dd 100644 --- a/src/library/scala/Function1.scala +++ b/src/library/scala/Function1.scala @@ -32,7 +32,7 @@ package scala */ @annotation.implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.") -trait Function1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double, scala.AnyRef) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double, scala.AnyRef) +R] extends AnyRef { self => +trait Function1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double/*, scala.AnyRef*/) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double/*, scala.AnyRef*/) +R] extends AnyRef { self => /** Apply the body of this function to the argument. * @return the result of function application. */ diff --git a/src/library/scala/Tuple2.scala b/src/library/scala/Tuple2.scala index 5e77127080..35d5a441c8 100644 --- a/src/library/scala/Tuple2.scala +++ b/src/library/scala/Tuple2.scala @@ -16,7 +16,7 @@ package scala * @param _1 Element 1 of this Tuple2 * @param _2 Element 2 of this Tuple2 */ -case class Tuple2[@specialized(Int, Long, Double, Char, Boolean, AnyRef) +T1, @specialized(Int, Long, Double, Char, Boolean, AnyRef) +T2](_1: T1, _2: T2) +case class Tuple2[@specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T1, @specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T2](_1: T1, _2: T2) extends Product2[T1, T2] { override def toString() = "(" + _1 + "," + _2 + ")" diff --git a/src/library/scala/runtime/AbstractFunction0.scala b/src/library/scala/runtime/AbstractFunction0.scala index c4ce0ebcdc..1b351c62ae 100644 --- a/src/library/scala/runtime/AbstractFunction0.scala +++ b/src/library/scala/runtime/AbstractFunction0.scala @@ -9,6 +9,6 @@ package scala.runtime -abstract class AbstractFunction0[@specialized +R] extends Function0[R] { +abstract class AbstractFunction0[@specialized(Specializable.Primitives) +R] extends Function0[R] { } diff --git a/src/library/scala/runtime/AbstractFunction1.scala b/src/library/scala/runtime/AbstractFunction1.scala index b2f336fe52..a68a82e6a2 100644 --- a/src/library/scala/runtime/AbstractFunction1.scala +++ b/src/library/scala/runtime/AbstractFunction1.scala @@ -9,6 +9,6 @@ package scala.runtime -abstract class AbstractFunction1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double, scala.AnyRef) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double, scala.AnyRef) +R] extends Function1[T1, R] { +abstract class AbstractFunction1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double/*, scala.AnyRef*/) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double/*, scala.AnyRef*/) +R] extends Function1[T1, R] { } diff --git a/src/library/scala/specialized.scala b/src/library/scala/specialized.scala index b876869afb..761c7cb25e 100644 --- a/src/library/scala/specialized.scala +++ b/src/library/scala/specialized.scala @@ -28,5 +28,5 @@ import Specializable._ class specialized(group: SpecializedGroup) extends annotation.StaticAnnotation { def this(types: Specializable*) = this(new Group(types.toList)) - def this() = this(Everything) + def this() = this(Primitives) } diff --git a/test/files/run/t3575.scala b/test/files/run/t3575.scala index 9ccd90a8c4..7ede65b00c 100644 --- a/test/files/run/t3575.scala +++ b/test/files/run/t3575.scala @@ -1,8 +1,8 @@ // This is here to tell me if the behavior changes, not because // the output is endorsed. case class Two[ - @specialized A, - @specialized B + @specialized(Specializable.Everything) A, + @specialized(Specializable.Everything) B ](v: A, w: B) case class TwoLong[ @@ -16,8 +16,8 @@ case class TwoCool[ ](v: A, w: B) case class TwoShort[ - @specialized() A, - @specialized() B + @specialized(Specializable.Everything) A, + @specialized(Specializable.Everything) B ](v: A, w: B) case class TwoMinimal[ diff --git a/test/files/speclib/instrumented.jar.desired.sha1 b/test/files/speclib/instrumented.jar.desired.sha1 index 0b8ee593da..9dd577164e 100644 --- a/test/files/speclib/instrumented.jar.desired.sha1 +++ b/test/files/speclib/instrumented.jar.desired.sha1 @@ -1 +1 @@ -474d8c20ab31438d5d4a2ba6bc07ebdcdb530b50 *instrumented.jar +1b11ac773055c1e942c6b5eb4aabdf02292a7194 ?instrumented.jar -- cgit v1.2.3 From 788478d3ab7dbb6386932eb8cb58dfcc5ee950b1 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 7 Aug 2012 16:17:59 +0200 Subject: SI-6186 TypeTags no longer supported in macros The original idea was to support both both TypeTags and ConcreteTypeTags as context bounds on macro implementations. Back then TypeTags were the implied default flavor of type tags. Basically because "TypeTag" is shorter than "ConcreteTypeTag" everyone jumped onto them and used them everywhere. That led to problems, because at that time TypeTags could reify unresolved type parameters ("unresolved" = not having TypeTag annotations for them). This led to a series of creepy errors, when one forgets to add a context bound in the middle of a chain of methods that all pass a type tag around, and then suddenly all the tags turn into pumpkins (because that unlucky method just reifies TypeRef(NoPrefix, , Nil and passes it down the chain). Hence we decided to rename ConcreteTypeTag => TypeTag & TypeTag => AbsTypeTag, which makes a lot of sense from a reflection point of view. Unfortunately this broke macros (in a sense), because now everyone writes TypeTag context bounds on macro implementations, which breaks in trivial situations like: "def foo[T](x: T) = identity_macro(x)" (the type of x is not concrete, so macro expansion will emit an error when trying to materialize the corresponding TypeTag). Now we restore the broken balance by banning TypeTag from macro impls. This forces anyone to use AbsTypeTags, and if someone wants to check the input for presence of abstract types, it's possible to do that manually. --- src/compiler/scala/tools/nsc/typechecker/Macros.scala | 12 ++++-------- src/compiler/scala/tools/reflect/FastTrack.scala | 2 +- src/library/scala/reflect/base/Universe.scala | 4 ++-- src/reflect/scala/reflect/macros/Infrastructure.scala | 2 +- src/reflect/scala/reflect/runtime/package.scala | 2 +- test/files/neg/macro-invalidsig-context-bounds.check | 4 ++-- test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala | 2 +- test/files/neg/macro-invalidsig-implicit-params.check | 6 +++--- .../macro-invalidsig-implicit-params/Impls_Macros_1.scala | 4 ++-- .../neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala | 2 +- .../neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala | 6 +++--- test/files/neg/macro-invalidsig-tparams-notparams-c.check | 2 +- .../neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala | 6 +++--- test/files/pos/t6047.scala | 4 ++-- .../run/macro-def-path-dependent-d/Impls_Macros_1.scala | 2 +- test/files/run/macro-expand-nullary-generic/Impls_1.scala | 12 ++++++------ test/files/run/macro-expand-tparams-explicit/Impls_1.scala | 4 ++-- test/files/run/macro-expand-tparams-implicit/Impls_1.scala | 4 ++-- test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala | 4 ++-- test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala | 6 +++--- test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala | 4 ++-- .../run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala | 4 ++-- .../files/run/macro-impl-default-params/Impls_Macros_1.scala | 4 ++-- .../Impls_Macros_1.scala | 2 +- test/files/run/macro-reify-freevars/Macros_1.scala | 2 +- test/files/run/macro-reify-nested-a/Impls_Macros_1.scala | 6 +++--- test/files/run/macro-reify-nested-b/Impls_Macros_1.scala | 6 +++--- test/files/run/macro-reify-tagful-a/Macros_1.scala | 2 +- test/files/run/macro-reify-tagless-a.check | 6 +++--- .../run/macro-undetparams-macroitself/Impls_Macros_1.scala | 2 +- .../Impls_1.scala | 2 +- .../pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala | 4 ++-- .../pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala | 4 ++-- test/pending/run/macro-reify-array/Macros_1.scala | 2 +- test/pending/run/macro-reify-tagful-b/Macros_1.scala | 2 +- 35 files changed, 69 insertions(+), 73 deletions(-) (limited to 'test/files/run') diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 1381450970..7c5d458fee 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -23,7 +23,7 @@ import java.lang.reflect.{Array => jArray, Method => jMethod} * * Then fooBar needs to point to a static method of the following form: * - * def fooBar[T: c.TypeTag] + * def fooBar[T: c.AbsTypeTag] * (c: scala.reflect.macros.Context) * (xs: c.Expr[List[T]]) * : c.Expr[T] = { @@ -156,7 +156,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { case TypeRef(SingleType(NoPrefix, contextParam), sym, List(tparam)) => var wannabe = sym while (wannabe.isAliasType) wannabe = wannabe.info.typeSymbol - if (wannabe != definitions.AbsTypeTagClass && wannabe != definitions.TypeTagClass) + if (wannabe != definitions.AbsTypeTagClass) List(param) else transform(param, tparam.typeSymbol) map (_ :: Nil) getOrElse Nil @@ -202,7 +202,6 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { def abbreviateCoreAliases: String = { // hack! var result = s result = result.replace("c.universe.AbsTypeTag", "c.AbsTypeTag") - result = result.replace("c.universe.TypeTag", "c.TypeTag") result = result.replace("c.universe.Expr", "c.Expr") result } @@ -440,7 +439,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { // we don't have to do this, but it appears to be more clear than allowing them val implicitParams = actparamss.flatten filter (_.isImplicit) if (implicitParams.length > 0) { - reportError(implicitParams.head.pos, "macro implementations cannot have implicit parameters other than TypeTag evidences") + reportError(implicitParams.head.pos, "macro implementations cannot have implicit parameters other than AbsTypeTag evidences") macroTraceVerbose("macro def failed to satisfy trivial preconditions: ")(macroDef) } @@ -854,9 +853,6 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { param.tpe.typeSymbol match { case definitions.AbsTypeTagClass => // do nothing - case definitions.TypeTagClass => - if (!tpe.isConcrete) context.abort(context.enclosingPosition, "cannot create TypeTag from a type %s having unresolved type parameters".format(tpe)) - // otherwise do nothing case _ => throw new Error("unsupported tpe: " + tpe) } @@ -1019,7 +1015,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { ) val forgotten = ( if (sym.isTerm) "splice when splicing this variable into a reifee" - else "c.TypeTag annotation for this type parameter" + else "c.AbsTypeTag annotation for this type parameter" ) typer.context.error(expandee.pos, template.replaceAllLiterally("@kind@", sym.name.nameKind).format( diff --git a/src/compiler/scala/tools/reflect/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala index e093c64c72..f84877cccb 100644 --- a/src/compiler/scala/tools/reflect/FastTrack.scala +++ b/src/compiler/scala/tools/reflect/FastTrack.scala @@ -28,7 +28,7 @@ trait FastTrack { def run(args: List[Any]): Any = { val c = args(0).asInstanceOf[MacroContext] val result = expander((c, c.expandee)) - c.Expr[Nothing](result)(c.TypeTag.Nothing) + c.Expr[Nothing](result)(c.AbsTypeTag.Nothing) } } diff --git a/src/library/scala/reflect/base/Universe.scala b/src/library/scala/reflect/base/Universe.scala index 6f37214fa8..f098876c18 100644 --- a/src/library/scala/reflect/base/Universe.scala +++ b/src/library/scala/reflect/base/Universe.scala @@ -46,8 +46,8 @@ abstract class Universe extends Symbols * def macroImpl[T](c: Context) = { * ... * // T here is just a type parameter, so the tree produced by reify won't be of much use in a macro expansion - * // however, if T were annotated with c.TypeTag (which would declare an implicit parameter for macroImpl) - * // then reification would subtitute T with the TypeTree that was used in a TypeApply of this particular macro invocation + * // however, if T were annotated with c.AbsTypeTag (which would declare an implicit parameter for macroImpl) + * // then reification would substitute T with the TypeTree that was used in a TypeApply of this particular macro invocation * val factory = c.reify{ new Queryable[T] } * ... * } diff --git a/src/reflect/scala/reflect/macros/Infrastructure.scala b/src/reflect/scala/reflect/macros/Infrastructure.scala index 1f1bd160a1..5ae2c08265 100644 --- a/src/reflect/scala/reflect/macros/Infrastructure.scala +++ b/src/reflect/scala/reflect/macros/Infrastructure.scala @@ -35,7 +35,7 @@ trait Infrastructure { * * def staticEval[T](x: T) = macro staticEval[T] * - * def staticEval[T: c.TypeTag](c: Context)(x: c.Expr[T]) = { + * def staticEval[T](c: Context)(x: c.Expr[T]) = { * import scala.reflect.runtime.{universe => ru} * val mirror = ru.runtimeMirror(c.libraryClassLoader) * import scala.tools.reflect.ToolBox diff --git a/src/reflect/scala/reflect/runtime/package.scala b/src/reflect/scala/reflect/runtime/package.scala index 2cb72d3824..d00094c0c1 100644 --- a/src/reflect/scala/reflect/runtime/package.scala +++ b/src/reflect/scala/reflect/runtime/package.scala @@ -19,7 +19,7 @@ package runtime { if (runtimeClass.isEmpty) c.abort(c.enclosingPosition, "call site does not have an enclosing class") val runtimeUniverse = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("universe")) val currentMirror = Apply(Select(runtimeUniverse, newTermName("runtimeMirror")), List(Select(runtimeClass, newTermName("getClassLoader")))) - c.Expr[Nothing](currentMirror)(c.TypeTag.Nothing) + c.Expr[Nothing](currentMirror)(c.AbsTypeTag.Nothing) } } } diff --git a/test/files/neg/macro-invalidsig-context-bounds.check b/test/files/neg/macro-invalidsig-context-bounds.check index b2ce4b1caa..894eabc442 100644 --- a/test/files/neg/macro-invalidsig-context-bounds.check +++ b/test/files/neg/macro-invalidsig-context-bounds.check @@ -1,4 +1,4 @@ -Impls_1.scala:5: error: macro implementations cannot have implicit parameters other than TypeTag evidences - def foo[U: c.TypeTag: Numeric](c: Ctx) = { +Impls_1.scala:5: error: macro implementations cannot have implicit parameters other than AbsTypeTag evidences + def foo[U: c.AbsTypeTag: Numeric](c: Ctx) = { ^ one error found diff --git a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala index 633981ce19..5aa9a7eaf9 100644 --- a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.TypeTag: Numeric](c: Ctx) = { + def foo[U: c.AbsTypeTag: Numeric](c: Ctx) = { import c.universe._ Literal(Constant(42)) } diff --git a/test/files/neg/macro-invalidsig-implicit-params.check b/test/files/neg/macro-invalidsig-implicit-params.check index 6416ed0a09..029b8a4634 100644 --- a/test/files/neg/macro-invalidsig-implicit-params.check +++ b/test/files/neg/macro-invalidsig-implicit-params.check @@ -1,4 +1,4 @@ -Impls_Macros_1.scala:5: error: macro implementations cannot have implicit parameters other than TypeTag evidences - def foo_targs[T, U: c.TypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { - ^ +Impls_Macros_1.scala:5: error: macro implementations cannot have implicit parameters other than AbsTypeTag evidences + def foo_targs[T, U: c.AbsTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { + ^ one error found diff --git a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala index b260a2fdfa..f724538993 100644 --- a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala +++ b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala @@ -2,13 +2,13 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo_targs[T, U: c.TypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { + def foo_targs[T, U: c.AbsTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { import c.{prefix => prefix} import c.universe._ val body = Block( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.TypeTag[U]].tpe)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.AbsTypeTag[U]].tpe)))), Literal(Constant(()))) c.Expr[Unit](body) } diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala index 98a3a6db7c..afbe0f0915 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala @@ -2,5 +2,5 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.TypeTag](c: Ctx) = ??? + def foo[U: c.AbsTypeTag](c: Ctx) = ??? } \ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala index dbc7000485..b48f9d5f98 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.TypeTag, U: c.TypeTag, V](c: Ctx)(implicit V: c.TypeTag[V]): c.Expr[Unit] = { - println(implicitly[c.TypeTag[T]]) - println(implicitly[c.TypeTag[U]]) + def foo[T: c.AbsTypeTag, U: c.AbsTypeTag, V](c: Ctx)(implicit V: c.AbsTypeTag[V]): c.Expr[Unit] = { + println(implicitly[c.AbsTypeTag[T]]) + println(implicitly[c.AbsTypeTag[U]]) println(V) c.literalUnit } diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c.check b/test/files/neg/macro-invalidsig-tparams-notparams-c.check index e3e17c7506..b1078fb233 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.TypeTag[T], implicit evidence$2: c.TypeTag[U], implicit V: c.TypeTag[V])c.Expr[Unit] +Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[T], implicit evidence$2: c.AbsTypeTag[U], implicit V: c.AbsTypeTag[V])c.Expr[Unit] def foo[V] = macro Impls.foo[V] ^ one error found diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala index 3edadb115d..3506bdc789 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala @@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.TypeTag, U: c.TypeTag, V](c: Ctx)(implicit V: c.TypeTag[V]): c.Expr[Unit] = { + def foo[T: c.AbsTypeTag, U: c.AbsTypeTag, V](c: Ctx)(implicit V: c.AbsTypeTag[V]): c.Expr[Unit] = { import c.universe._ - println(implicitly[c.TypeTag[T]]) - println(implicitly[c.TypeTag[U]]) + println(implicitly[c.AbsTypeTag[T]]) + println(implicitly[c.AbsTypeTag[U]]) println(V) c.literalUnit } diff --git a/test/files/pos/t6047.scala b/test/files/pos/t6047.scala index edabb95ee3..80d5e9668b 100644 --- a/test/files/pos/t6047.scala +++ b/test/files/pos/t6047.scala @@ -4,7 +4,7 @@ import java.io.InputStream object Macros { def unpack[A](input: InputStream): A = macro unpack_impl[A] - def unpack_impl[A: c.TypeTag](c: Context)(input: c.Expr[InputStream]): c.Expr[A] = { + def unpack_impl[A: c.AbsTypeTag](c: Context)(input: c.Expr[InputStream]): c.Expr[A] = { import c.universe._ def unpackcode(tpe: c.Type): c.Expr[_] = { @@ -14,7 +14,7 @@ object Macros { ??? } - unpackcode(c.typeOf[A]) + unpackcode(implicitly[c.AbsTypeTag[A]].tpe) ??? } } \ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala index 8ba687327a..2daf6fc3fb 100644 --- a/test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala +++ b/test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala @@ -5,5 +5,5 @@ import scala.reflect.api.Universe object Test { def materializeTypeTag[T](u: Universe)(e: T) = macro materializeTypeTag_impl[T] - def materializeTypeTag_impl[T: c.TypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? + def materializeTypeTag_impl[T: c.AbsTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? } \ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-generic/Impls_1.scala b/test/files/run/macro-expand-nullary-generic/Impls_1.scala index 9a0e97c8e0..fbbc23a824 100644 --- a/test/files/run/macro-expand-nullary-generic/Impls_1.scala +++ b/test/files/run/macro-expand-nullary-generic/Impls_1.scala @@ -2,14 +2,14 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def impl[T: c.TypeTag](c: Ctx) = { + def impl[T: c.AbsTypeTag](c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works " + implicitly[c.TypeTag[T]])))) + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works " + implicitly[c.AbsTypeTag[T]])))) c.Expr[Unit](body) } - def fooNullary[T: c.TypeTag](c: Ctx) = impl[T](c) - def fooEmpty[T: c.TypeTag](c: Ctx)() = impl[T](c) - def barNullary[T: c.TypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c) - def barEmpty[T: c.TypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c) + def fooNullary[T: c.AbsTypeTag](c: Ctx) = impl[T](c) + def fooEmpty[T: c.AbsTypeTag](c: Ctx)() = impl[T](c) + def barNullary[T: c.AbsTypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c) + def barEmpty[T: c.AbsTypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c) } \ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala index 9baea020f9..0a879687e8 100644 --- a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.TypeTag](c: Ctx) = { + def foo[U: c.AbsTypeTag](c: Ctx) = { import c.universe._ - val U = implicitly[c.TypeTag[U]] + val U = implicitly[c.AbsTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala index c707e5e3c0..f6cb63b9c9 100644 --- a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.TypeTag](c: Ctx)(x: c.Expr[U]) = { + def foo[U: c.AbsTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ - val U = implicitly[c.TypeTag[U]] + val U = implicitly[c.AbsTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala index c707e5e3c0..f6cb63b9c9 100644 --- a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.TypeTag](c: Ctx)(x: c.Expr[U]) = { + def foo[U: c.AbsTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ - val U = implicitly[c.TypeTag[U]] + val U = implicitly[c.AbsTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala index 4d58467638..7e0fa26569 100644 --- a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala @@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.TypeTag, U: c.TypeTag](c: Ctx)(x: c.Expr[U]) = { + def foo[T: c.AbsTypeTag, U: c.AbsTypeTag](c: Ctx)(x: c.Expr[U]) = { import c.universe._ - val T = implicitly[c.TypeTag[T]] - val U = implicitly[c.TypeTag[U]] + val T = implicitly[c.AbsTypeTag[T]] + val U = implicitly[c.AbsTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) c.Expr[Unit](body) } diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala index 961d5b658d..ca515be627 100644 --- a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(())))) } diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala index ab92c54d2c..5a554590d8 100644 --- a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala +++ b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(())))) } diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala index 2ba28824e0..06c58d96ab 100644 --- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala @@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo_targs[T, U: c.TypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = { + def foo_targs[T, U: c.AbsTypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = { import c.{prefix => prefix} import c.universe._ - val U = implicitly[c.TypeTag[U]] + val U = implicitly[c.AbsTypeTag[U]] val body = Block( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala index 5ce9e42b57..a54b7f4b08 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala @@ -1,7 +1,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.TypeTag](c: Ctx)(x: c.Expr[T]) = { + def foo[T: c.AbsTypeTag](c: Ctx)(x: c.Expr[T]) = { import c.universe._ val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(x.tree.toString)))) c.Expr[Unit](body) diff --git a/test/files/run/macro-reify-freevars/Macros_1.scala b/test/files/run/macro-reify-freevars/Macros_1.scala index c72a7ab54f..57fdc32437 100644 --- a/test/files/run/macro-reify-freevars/Macros_1.scala +++ b/test/files/run/macro-reify-freevars/Macros_1.scala @@ -1,7 +1,7 @@ package scala.collection.slick object QueryableMacros{ - def map[T:c.TypeTag, S:c.TypeTag] + def map[T:c.AbsTypeTag, S:c.AbsTypeTag] (c: scala.reflect.macros.Context) (projection: c.Expr[T => S]) : c.Expr[scala.collection.slick.Queryable[S]] = { diff --git a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala index 4dda80a117..04714970dd 100644 --- a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala @@ -21,9 +21,9 @@ case class Utils[C <: Context]( c:C ) { } } object QueryableMacros{ - def _helper[C <: Context,S:c.TypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { + def _helper[C <: Context,S:c.AbsTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { import c.universe._ - val element_type = c.typeOf[S] + val element_type = implicitly[c.AbsTypeTag[S]].tpe val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( c.runtimeUniverse, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( @@ -32,7 +32,7 @@ object QueryableMacros{ ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} } - def map[T:c.TypeTag, S:c.TypeTag] + def map[T:c.AbsTypeTag, S:c.AbsTypeTag] (c: scala.reflect.macros.Context) (projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection ) } diff --git a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala index 4dda80a117..04714970dd 100644 --- a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala @@ -21,9 +21,9 @@ case class Utils[C <: Context]( c:C ) { } } object QueryableMacros{ - def _helper[C <: Context,S:c.TypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { + def _helper[C <: Context,S:c.AbsTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { import c.universe._ - val element_type = c.typeOf[S] + val element_type = implicitly[c.AbsTypeTag[S]].tpe val foo = c.Expr[ru.Expr[Queryable[S]]]( c.reifyTree( c.runtimeUniverse, EmptyTree, c.typeCheck( Utils[c.type](c).removeDoubleReify( @@ -32,7 +32,7 @@ object QueryableMacros{ ))) c.universe.reify{ Queryable.factory[S]( foo.splice )} } - def map[T:c.TypeTag, S:c.TypeTag] + def map[T:c.AbsTypeTag, S:c.AbsTypeTag] (c: scala.reflect.macros.Context) (projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection ) } diff --git a/test/files/run/macro-reify-tagful-a/Macros_1.scala b/test/files/run/macro-reify-tagful-a/Macros_1.scala index acca4921dc..0eac74236f 100644 --- a/test/files/run/macro-reify-tagful-a/Macros_1.scala +++ b/test/files/run/macro-reify-tagful-a/Macros_1.scala @@ -5,7 +5,7 @@ object Macros { def foo[T](s: T) = macro Impls.foo[T] object Impls { - def foo[T: c.TypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.AbsTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { List(s.splice) } } diff --git a/test/files/run/macro-reify-tagless-a.check b/test/files/run/macro-reify-tagless-a.check index 4ee11190d6..d69f641280 100644 --- a/test/files/run/macro-reify-tagless-a.check +++ b/test/files/run/macro-reify-tagless-a.check @@ -1,3 +1,3 @@ -reflective compilation has failed: - -Macro expansion contains free type variable T defined by foo in Impls_Macros_1.scala:7:13. Have you forgotten to use c.TypeTag annotation for this type parameter? If you have troubles tracking free type variables, consider using -Xlog-free-types +reflective compilation has failed: + +Macro expansion contains free type variable T defined by foo in Impls_Macros_1.scala:7:13. Have you forgotten to use c.AbsTypeTag annotation for this type parameter? If you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala index 4bcc610b1d..081894cf52 100644 --- a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala +++ b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.Context object Macros { - def impl[T: c.TypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = c.universe.reify { println(c.literal(implicitly[c.TypeTag[T]].toString).splice) } + def impl[T: c.AbsTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = c.universe.reify { println(c.literal(implicitly[c.AbsTypeTag[T]].toString).splice) } def foo[T](foo: T) = macro impl[T] } \ No newline at end of file diff --git a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala index 0dac664d38..26d4a45fee 100644 --- a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala +++ b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala @@ -1,7 +1,7 @@ import scala.reflect.macros.Context object Impls { - def foo[T: c.TypeTag](c: Context): c.Expr[List[T]] = c.universe.reify { + def foo[T: c.AbsTypeTag](c: Context): c.Expr[List[T]] = c.universe.reify { println("openImplicits are: " + c.literal(c.openImplicits.toString).splice) println("enclosingImplicits are: " + c.literal(c.enclosingImplicits.toString).splice) println("typetag is: " + c.literal(c.tag[T].toString).splice) diff --git a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala index eff11d4a20..d6ebb907e5 100644 --- a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala +++ b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala @@ -1,11 +1,11 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { import c.universe._ Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(()))) } diff --git a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala index eff11d4a20..d6ebb907e5 100644 --- a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala +++ b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala @@ -1,11 +1,11 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { import c.universe._ Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(()))) } diff --git a/test/pending/run/macro-reify-array/Macros_1.scala b/test/pending/run/macro-reify-array/Macros_1.scala index 8fa945b9c6..99006c548a 100644 --- a/test/pending/run/macro-reify-array/Macros_1.scala +++ b/test/pending/run/macro-reify-array/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def foo[T](s: String) = macro Impls.foo[T] object Impls { - def foo[T: c.TypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.AbsTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { Array(s.splice) } } diff --git a/test/pending/run/macro-reify-tagful-b/Macros_1.scala b/test/pending/run/macro-reify-tagful-b/Macros_1.scala index af078d93b4..a14187e8a7 100644 --- a/test/pending/run/macro-reify-tagful-b/Macros_1.scala +++ b/test/pending/run/macro-reify-tagful-b/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def foo[T](s: T) = macro Impls.foo[List[T]] object Impls { - def foo[T: c.TypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.AbsTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { List(s.splice) } } -- cgit v1.2.3