diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index a0db1a893062..0e611d6f6ed1 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -4,8 +4,8 @@ package core import scala.annotation.{threadUnsafe => tu} import Types._, Contexts._, Symbols._, SymDenotations._, StdNames._, Names._, Phases._ -import Flags._, Scopes._, Decorators._, NameOps._, Periods._, NullOpsDecorator._ -import unpickleScala2.Scala2Unpickler.ensureConstructor +import Flags._, Scopes._, Decorators._, NameOps._, Periods._, NullOpsDecorator._, Annotations.Annotation +import unpickleScala2.Scala2Unpickler, Scala2Unpickler.ensureConstructor import scala.collection.mutable import collection.mutable import Denotations.SingleDenotation @@ -764,7 +764,50 @@ class Definitions { @tu lazy val SelectableClass: ClassSymbol = requiredClass("scala.Selectable") @tu lazy val WithoutPreciseParameterTypesClass: Symbol = requiredClass("scala.Selectable.WithoutPreciseParameterTypes") - @tu lazy val ReflectPackageClass: Symbol = requiredPackage("scala.reflect.package").moduleClass + @tu lazy val TypeTagType: Type = { + val optTypeTagsClass = getClassIfDefined("scala.reflect.api.TypeTags") // in scala-reflect module + if optTypeTagsClass ne NoSymbol then + TypeRef(optTypeTagsClass.typeRef, optTypeTagsClass.requiredClass("TypeTag")) + else + NoType + } + @tu lazy val ReflectRuntimePackageObject_universe: Symbol = { + val runtimePkg = getModuleIfDefined("scala.reflect.runtime.package") + if runtimePkg.exists then + runtimePkg.requiredValue("universe") + else + NoSymbol + } + @tu lazy val ClassManifestAlias: Symbol = ReflectPackageClass.requiredType("ClassManifest") + @tu lazy val ManifestClass: ClassSymbol = requiredClass("scala.reflect.Manifest") + @tu lazy val ManifestFactoryModule: Symbol = requiredModule("scala.reflect.ManifestFactory") + @tu lazy val ClassManifestFactoryModule: Symbol = requiredModule("scala.reflect.ClassManifestFactory") + @tu lazy val OptManifestClass: ClassSymbol = requiredClass("scala.reflect.OptManifest") + @tu lazy val NoManifestModule: Symbol = requiredModule("scala.reflect.NoManifest") + + @tu lazy val ReflectPackageClass: Symbol = { + + def adjustClassManifest(module: Symbol)(using Context): Unit = + // `scala.reflect.ClassManifest` is a type alias to `scala.reflect.ClassTag`, + // however we need to prevent it from being dealiased for the purpose of summoning of + // a `ClassManifest`, which has a different result in Scala 2. + // With this solution values of `ClassManifest` and `ClassTag` are still interchangeable. + val classManifest = module.moduleClass.requiredType("ClassManifest") + classManifest.infoOrCompleter match + case TypeAlias(HKTypeLambda(params, ref)) => + val unchecked = Annotation(UncheckedAnnot) // could be any annotation really + classManifest.info = HKTypeLambda.fromParams(params, TypeBounds(ref, AnnotatedType(ref, unchecked))) + end adjustClassManifest + + val module = requiredPackage("scala.reflect.package") + module.infoOrCompleter match + case completer: ModuleCompleter => + module.info = new ModuleCompleter(completer.moduleClass): + override def complete(root: SymDenotation)(using Context): Unit = + completer.complete(root) + adjustClassManifest(module) + module.moduleClass + } @tu lazy val ClassTagClass: ClassSymbol = requiredClass("scala.reflect.ClassTag") @tu lazy val ClassTagModule: Symbol = ClassTagClass.companionModule @tu lazy val ClassTagModule_apply: Symbol = ClassTagModule.requiredMethod(nme.apply) @@ -1200,6 +1243,8 @@ class Definitions { @tu lazy val untestableClasses: Set[Symbol] = Set(NothingClass, NullClass, SingletonClass) + @tu lazy val isPhantomClass = Set[Symbol](AnyClass, AnyValClass, NullClass, NothingClass) + @tu lazy val AbstractFunctionType: Array[TypeRef] = mkArityArray("scala.runtime.AbstractFunction", MaxImplementedFunctionArity, 0) val AbstractFunctionClassPerRun: PerRun[Array[Symbol]] = new PerRun(AbstractFunctionType.map(_.symbol.asClass)) def AbstractFunctionClass(n: Int)(using Context): Symbol = AbstractFunctionClassPerRun()(using ctx)(n) @@ -1774,7 +1819,7 @@ class Definitions { this.initCtx = ctx if (!isInitialized) { // force initialization of every symbol that is synthesized or hijacked by the compiler - val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses() :+ JavaEnumClass + val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses() :+ JavaEnumClass :+ ReflectPackageClass isInitialized = true } diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index 5c718d4af0da..8cbec764461c 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -367,7 +367,6 @@ object StdNames { val EnumValue: N = "EnumValue" val ExistentialTypeTree: N = "ExistentialTypeTree" val Flag : N = "Flag" - val floatHash: N = "floatHash" val Ident: N = "Ident" val Import: N = "Import" val Literal: N = "Literal" @@ -414,6 +413,7 @@ object StdNames { val argv : N = "argv" val arrayClass: N = "arrayClass" val arrayElementClass: N = "arrayElementClass" + val arrayType: N = "arrayType" val arrayValue: N = "arrayValue" val array_apply : N = "array_apply" val array_clone : N = "array_clone" @@ -440,6 +440,7 @@ object StdNames { val checkInitialized: N = "checkInitialized" val ClassManifestFactory: N = "ClassManifestFactory" val classOf: N = "classOf" + val classType: N = "classType" val clone_ : N = "clone" val common: N = "common" val compiletime : N = "compiletime" @@ -481,6 +482,7 @@ object StdNames { val find_ : N = "find" val flagsFromBits : N = "flagsFromBits" val flatMap: N = "flatMap" + val floatHash: N = "floatHash" val foreach: N = "foreach" val format: N = "format" val fromDigits: N = "fromDigits" @@ -489,6 +491,7 @@ object StdNames { val genericClass: N = "genericClass" val get: N = "get" val getClass_ : N = "getClass" + val getClassLoader: N = "getClassLoader" val getOrElse: N = "getOrElse" val hasNext: N = "hasNext" val hashCode_ : N = "hashCode" @@ -497,6 +500,7 @@ object StdNames { val head: N = "head" val higherKinds: N = "higherKinds" val identity: N = "identity" + val intersectionType: N = "intersectionType" val implicitConversions: N = "implicitConversions" val implicitly: N = "implicitly" val in: N = "in" @@ -588,6 +592,7 @@ object StdNames { val setSymbol: N = "setSymbol" val setType: N = "setType" val setTypeSignature: N = "setTypeSignature" + val singleType: N = "singleType" val standardInterpolator: N = "standardInterpolator" val staticClass : N = "staticClass" val staticModule : N = "staticModule" @@ -626,6 +631,7 @@ object StdNames { val values: N = "values" val view_ : N = "view" val wait_ : N = "wait" + val wildcardType: N = "wildcardType" val withFilter: N = "withFilter" val withFilterIfRefutable: N = "withFilterIfRefutable$" val WorksheetWrapper: N = "WorksheetWrapper" diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 1a70fb1e9d2d..b7a201e626ea 100644 --- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -731,6 +731,11 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas case tp: AndOrType => // scalajs.js.|.UnionOps has a type parameter upper-bounded by `_ | _` tp.derivedAndOrType(mapArg(tp.tp1).bounds.hi, mapArg(tp.tp2).bounds.hi) + case tp @ AnnotatedType(inner, annot) => + // added to support hijacking of `scala.reflect.ClassManifest`, + // we set its info to `[T] >: ClassTag[T] <: ClassTag[T] @unchecked` + val inner1 = elim(inner) + tp.derivedAnnotatedType(inner1, annot) case _ => tp } diff --git a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala index e848a19e147e..9f539678df98 100644 --- a/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala @@ -4,18 +4,21 @@ package typer import core._ import util.Spans.Span +import unpickleScala2.Scala2Erasure import Contexts._ import Types._, Flags._, Symbols._, Types._, Names._, StdNames._, Constants._ import TypeErasure.{erasure, hasStableErasure} import Decorators._ import ProtoTypes._ import Inferencing.{fullyDefinedType, isFullyDefined} +import Implicits.SearchSuccess import ast.untpd import transform.SymUtils._ import transform.TypeUtils._ import transform.SyntheticMembers._ import util.Property import annotation.{tailrec, constructorOnly} +import collection.mutable /** Synthesize terms for special classes */ class Synthesizer(typer: Typer)(using @constructorOnly c: Context): @@ -23,7 +26,8 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context): /** Handlers to synthesize implicits for special types */ type SpecialHandler = (Type, Span) => Context ?=> Tree - private type SpecialHandlers = List[(ClassSymbol, SpecialHandler)] + type SpecialHandlerGen = Type => Context ?=> SpecialHandler + private type SpecialHandlers = List[(ClassSymbol, SpecialHandlerGen)] val synthesizedClassTag: SpecialHandler = (formal, span) => formal.argInfos match @@ -375,14 +379,206 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context): synthesizedSumMirror(formal, span) case _ => EmptyTree - val specialHandlers = List( - defn.ClassTagClass -> synthesizedClassTag, - defn.TypeTestClass -> synthesizedTypeTest, - defn.CanEqualClass -> synthesizedCanEqual, - defn.ValueOfClass -> synthesizedValueOf, - defn.Mirror_ProductClass -> synthesizedProductMirror, - defn.Mirror_SumClass -> synthesizedSumMirror, - defn.MirrorClass -> synthesizedMirror) + private type Scala2RefinedType = RecType | RefinedType | AndType + + /** @see dotty.tools.dotc.core.unpickleScala2.Scala2Erasure.flattenedParents */ + private object Scala2RefinedType: + + def unapply(tp: Scala2RefinedType)(using Context): Option[List[Type]] = + + def checkSupported(tp: Type): Boolean = tp match + case AnnotatedType(_, _) => false + case tp @ TypeRef(prefix, _) => !(!tp.symbol.exists && prefix.dealias.isInstanceOf[Scala2RefinedType]) + case ground => true + + @tailrec + def inner(explore: List[Type], acc: mutable.ListBuffer[Type]): Option[List[Type]] = explore match + case tp :: rest => tp match + case tp: RecType => inner(tp.parent :: rest, acc) + case RefinedType(parent, _, _) => inner(parent :: rest, acc) + case AndType(l, r) => inner(l :: r :: rest, acc) + case tp if checkSupported(tp) => inner(rest, acc += tp) + case _ => None // we can not create a manifest for unsupported parents + + case nil => Some(acc.toList) + end inner + + inner(tp :: Nil, new mutable.ListBuffer()) + + end unapply + + end Scala2RefinedType + + /** Replication of the `Implicits.ImplicitSearch.manifestOfType` algorithm found in nsc compiler. + * @see (https://github.com/scala/scala/blob/0c011547b1ccf961ca427c3d3459955e618e93d5/src/compiler/scala/tools/nsc/typechecker/Implicits.scala#L1519) + */ + private def manifestOfFactory(flavor: Symbol): SpecialHandler = (formal, span) => + + def materializeImplicit(formal: Type, span: Span)(using Context): Tree = + val arg = typer.inferImplicitArg(formal, span) + if arg.tpe.isError then + EmptyTree + else + arg + + def inner(tp: Type, flavour: Symbol): Tree = + + val full = flavor == defn.ManifestClass + val opt = flavor == defn.OptManifestClass + + /* Creates a tree that calls the factory method called constructor in object scala.reflect.Manifest */ + def manifestFactoryCall(constructor: TermName, tparg: Type, args: Tree*): Tree = + if args contains EmptyTree then + EmptyTree + else + val factory = if full then defn.ManifestFactoryModule else defn.ClassManifestFactoryModule + applyOverloaded(ref(factory), constructor, args.toList, tparg :: Nil, Types.WildcardType) + .withSpan(span) + + /* Creates a tree representing one of the singleton manifests.*/ + def findSingletonManifest(name: TermName) = + ref(defn.ManifestFactoryModule) + .select(name) + .ensureApplied + .withSpan(span) + + /** Re-wraps a type in a manifest before calling `materializeImplicit` on the result + */ + def findManifest(tp: Type, manifestClass: Symbol = if full then defn.ManifestClass else defn.ClassManifestAlias) = + materializeImplicit(manifestClass.typeRef.appliedTo(tp), span) + + def findSubManifest(tp: Type) = + findManifest(tp, if (full) defn.ManifestClass else defn.OptManifestClass) + + def inferTypeTag(tp: Type) = + if defn.TypeTagType.exists then + typer.inferImplicit(defn.TypeTagType.appliedTo(tp), EmptyTree, span) match + case SearchSuccess(tagInScope, _, _, _) => Some(tagInScope) + case _ => None + else + None + + def interopTypeTag(tp: Type, tagInScope: Tree) = + materializeImplicit(defn.ClassTagClass.typeRef.appliedTo(tp), span) match + case EmptyTree => + report.error(i"""To create a Manifest here, it is necessary to interoperate with the + |TypeTag `$tagInScope` in scope. However TypeTag to Manifest conversion requires a + |ClassTag for the corresponding type to be present. + |To proceed add a ClassTag for the type `$tp` (e.g. by introducing a context bound) + |and recompile.""".stripMargin, ctx.source.atSpan(span)) + EmptyTree + case clsTag => + // if TypeTag is available, assume scala.reflect.runtime.universe is also + val ru = ref(defn.ReflectRuntimePackageObject_universe) + val optEnclosing = ctx.owner.enclosingClass + if optEnclosing.exists then + val enclosing = ref(defn.Predef_classOf).appliedToType(optEnclosing.typeRef) + val classLoader = enclosing.select(nme.getClassLoader).ensureApplied + val currentMirror = ru.select(nme.runtimeMirror).appliedTo(classLoader) + ru.select(nme.internal) + .select(nme.typeTagToManifest) + .appliedToType(tp) + .appliedTo(currentMirror, tagInScope) + .appliedTo(clsTag) + .withSpan(span) + else + EmptyTree + + def manifestOfType(tp0: Type, isLowerBound: Boolean): Tree = + + val tp1 = tp0.dealiasKeepAnnots + + extension [T](xs: List[T]) def isSingleton = xs.lengthCompare(1) == 0 + + def classManifest(clsRef: Type, args: List[Type]): Tree = + val classarg = ref(defn.Predef_classOf).appliedToType(tp1) + val suffix0 = classarg :: (args map findSubManifest) + val pre = clsRef.normalizedPrefix + val ignorePrefix = (pre eq NoPrefix) || pre.typeSymbol.isStaticOwner + val suffix = if ignorePrefix then suffix0 else findSubManifest(pre) :: suffix0 + manifestFactoryCall(nme.classType, tp, suffix*) + + tp1 match + case ThisType(_) | TermRef(_,_) => manifestFactoryCall(nme.singleType, tp, singleton(tp1)) + case ConstantType(c) => inner(c.tpe, defn.ManifestClass) + + case tp1 @ TypeRef(pre, desig) => + val tpSym = tp1.typeSymbol + if tpSym.isPrimitiveValueClass || defn.isPhantomClass(tpSym) then + if !isLowerBound && defn.isBottomClassAfterErasure(tpSym) then + EmptyTree // `Nothing`/`Null` manifests are ClassTags, lets not make a loophole for them + else + findSingletonManifest(tpSym.name.toTermName) + else if tpSym == defn.ObjectClass || tpSym == defn.AnyRefAlias then + findSingletonManifest(nme.Object) + else if tpSym.isClass then + classManifest(tp1, Nil) + else + EmptyTree + + case tp1 @ AppliedType(tycon, args) => + val tpSym = tycon.typeSymbol + if tpSym == defn.RepeatedParamClass then + EmptyTree + else if tpSym == defn.ArrayClass && args.isSingleton then + manifestFactoryCall(nme.arrayType, args.head, findManifest(args.head)) + else if tpSym.isClass then + classManifest(tycon, args) + else + EmptyTree + + case TypeBounds(lo, hi) if full => + manifestFactoryCall(nme.wildcardType, tp, + manifestOfType(lo, isLowerBound = true), manifestOfType(hi, isLowerBound)) + + case Scala2RefinedType(parents) => + if parents.isSingleton then findManifest(parents.head) + else if full then manifestFactoryCall(nme.intersectionType, tp, (parents map findSubManifest)*) + else manifestOfType(Scala2Erasure.intersectionDominator(parents), isLowerBound) + + case _ => + EmptyTree + end manifestOfType + + if full then + inferTypeTag(tp) match + case Some(tagInScope) => interopTypeTag(tp, tagInScope) + case _ => manifestOfType(tp, isLowerBound = false) + else + manifestOfType(tp, isLowerBound = false) match + case EmptyTree if opt => ref(defn.NoManifestModule) + case result => result + + end inner + + formal.argInfos match + case arg :: Nil => + inner(fullyDefinedType(arg, "Manifest argument", span), flavor) + case _ => + EmptyTree + end manifestOfFactory + + val synthesizedManifest: SpecialHandler = manifestOfFactory(defn.ManifestClass) + val synthesizedOptManifest: SpecialHandler = manifestOfFactory(defn.OptManifestClass) + val synthesizedClassManifest: SpecialHandler = manifestOfFactory(defn.ClassManifestAlias) + + def genSynthesizedClassTag(formal: Type)(using Context): SpecialHandler = + if formal.dealias.typeSymbol == defn.ClassManifestAlias then + synthesizedClassManifest + else + synthesizedClassTag + + val specialHandlers: SpecialHandlers = List( + defn.ClassTagClass -> genSynthesizedClassTag, + defn.TypeTestClass -> Function.const(synthesizedTypeTest), + defn.CanEqualClass -> Function.const(synthesizedCanEqual), + defn.ValueOfClass -> Function.const(synthesizedValueOf), + defn.Mirror_ProductClass -> Function.const(synthesizedProductMirror), + defn.Mirror_SumClass -> Function.const(synthesizedSumMirror), + defn.MirrorClass -> Function.const(synthesizedMirror), + defn.ManifestClass -> Function.const(synthesizedManifest), + defn.OptManifestClass -> Function.const(synthesizedOptManifest), + ) def tryAll(formal: Type, span: Span)(using Context): Tree = def recur(handlers: SpecialHandlers): Tree = handlers match @@ -394,10 +590,10 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context): tp.baseType(cls) val base = baseWithRefinements(formal) val result = - if (base <:< formal.widenExpr) - // With the subtype test we enforce that the searched type `formal` is of the right form - handler(base, span) - else EmptyTree + if base <:< formal.widenExpr then + handler(formal)(base, span) + else + EmptyTree result.orElse(recur(rest)) case Nil => EmptyTree diff --git a/tests/disabled/reflect/neg/interop_abstypetags_arenot_classmanifests.check b/tests/disabled/reflect/neg/interop_abstypetags_arenot_classmanifests.check deleted file mode 100644 index d15e33346cbc..000000000000 --- a/tests/disabled/reflect/neg/interop_abstypetags_arenot_classmanifests.check +++ /dev/null @@ -1,4 +0,0 @@ -interop_abstypetags_arenot_classmanifests.scala:5: error: No ClassManifest available for T. - println(classManifest[T]) - ^ -one error found diff --git a/tests/disabled/reflect/neg/interop_abstypetags_arenot_classmanifests.scala b/tests/disabled/reflect/neg/interop_abstypetags_arenot_classmanifests.scala deleted file mode 100644 index 6b05eddf7653..000000000000 --- a/tests/disabled/reflect/neg/interop_abstypetags_arenot_classmanifests.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.runtime.universe._ - -object Test extends App { - def weakTypeTagIsnotClassManifest[T: WeakTypeTag] = { - println(classManifest[T]) - } - - weakTypeTagIsnotClassManifest[Int] - weakTypeTagIsnotClassManifest[String] - weakTypeTagIsnotClassManifest[Array[Int]] -} diff --git a/tests/disabled/reflect/neg/interop_abstypetags_arenot_classtags.check b/tests/disabled/reflect/neg/interop_abstypetags_arenot_classtags.check deleted file mode 100644 index 3aa7a50b5034..000000000000 --- a/tests/disabled/reflect/neg/interop_abstypetags_arenot_classtags.check +++ /dev/null @@ -1,4 +0,0 @@ -interop_abstypetags_arenot_classtags.scala:6: error: No ClassTag available for T - println(classTag[T]) - ^ -one error found diff --git a/tests/disabled/reflect/neg/interop_abstypetags_arenot_classtags.scala b/tests/disabled/reflect/neg/interop_abstypetags_arenot_classtags.scala deleted file mode 100644 index 7e049bf65582..000000000000 --- a/tests/disabled/reflect/neg/interop_abstypetags_arenot_classtags.scala +++ /dev/null @@ -1,12 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.{ClassTag, classTag} - -object Test extends App { - def weakTypeTagIsnotClassTag[T: WeakTypeTag] = { - println(classTag[T]) - } - - weakTypeTagIsnotClassTag[Int] - weakTypeTagIsnotClassTag[String] - weakTypeTagIsnotClassTag[Array[Int]] -} diff --git a/tests/disabled/reflect/neg/interop_abstypetags_arenot_manifests.check b/tests/disabled/reflect/neg/interop_abstypetags_arenot_manifests.check deleted file mode 100644 index 5916b68742b8..000000000000 --- a/tests/disabled/reflect/neg/interop_abstypetags_arenot_manifests.check +++ /dev/null @@ -1,4 +0,0 @@ -interop_abstypetags_arenot_manifests.scala:5: error: No Manifest available for T. - println(manifest[T]) - ^ -one error found diff --git a/tests/disabled/reflect/neg/interop_abstypetags_arenot_manifests.scala b/tests/disabled/reflect/neg/interop_abstypetags_arenot_manifests.scala deleted file mode 100644 index 1f934e0bba2f..000000000000 --- a/tests/disabled/reflect/neg/interop_abstypetags_arenot_manifests.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.runtime.universe._ - -object Test extends App { - def weakTypeTagIsnotManifest[T: WeakTypeTag] = { - println(manifest[T]) - } - - weakTypeTagIsnotManifest[Int] - weakTypeTagIsnotManifest[String] - weakTypeTagIsnotManifest[Array[Int]] -} diff --git a/tests/disabled/reflect/neg/interop_classtags_arenot_manifests.check b/tests/disabled/reflect/neg/interop_classtags_arenot_manifests.check deleted file mode 100644 index fa805b5918b8..000000000000 --- a/tests/disabled/reflect/neg/interop_classtags_arenot_manifests.check +++ /dev/null @@ -1,4 +0,0 @@ -interop_classtags_arenot_manifests.scala:5: error: No Manifest available for T. - println(manifest[T]) - ^ -one error found diff --git a/tests/disabled/reflect/neg/interop_typetags_arenot_classmanifests.check b/tests/disabled/reflect/neg/interop_typetags_arenot_classmanifests.check deleted file mode 100644 index 88fb1647e57b..000000000000 --- a/tests/disabled/reflect/neg/interop_typetags_arenot_classmanifests.check +++ /dev/null @@ -1,4 +0,0 @@ -interop_typetags_arenot_classmanifests.scala:5: error: No ClassManifest available for T. - println(classManifest[T]) - ^ -one error found diff --git a/tests/disabled/reflect/neg/interop_typetags_arenot_classmanifests.scala b/tests/disabled/reflect/neg/interop_typetags_arenot_classmanifests.scala deleted file mode 100644 index 04857aaa6d98..000000000000 --- a/tests/disabled/reflect/neg/interop_typetags_arenot_classmanifests.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.runtime.universe._ - -object Test extends App { - def typeTagIsnotClassManifest[T: TypeTag] = { - println(classManifest[T]) - } - - typeTagIsnotClassManifest[Int] - typeTagIsnotClassManifest[String] - typeTagIsnotClassManifest[Array[Int]] -} diff --git a/tests/disabled/reflect/neg/interop_typetags_arenot_classtags.check b/tests/disabled/reflect/neg/interop_typetags_arenot_classtags.check deleted file mode 100644 index 1d1fb15f9ebb..000000000000 --- a/tests/disabled/reflect/neg/interop_typetags_arenot_classtags.check +++ /dev/null @@ -1,4 +0,0 @@ -interop_typetags_arenot_classtags.scala:6: error: No ClassTag available for T - println(classTag[T]) - ^ -one error found diff --git a/tests/disabled/reflect/neg/interop_typetags_arenot_classtags.scala b/tests/disabled/reflect/neg/interop_typetags_arenot_classtags.scala deleted file mode 100644 index f5bd75fb3362..000000000000 --- a/tests/disabled/reflect/neg/interop_typetags_arenot_classtags.scala +++ /dev/null @@ -1,12 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.{ClassTag, classTag} - -object Test extends App { - def typeTagIsnotClassTag[T: TypeTag] = { - println(classTag[T]) - } - - typeTagIsnotClassTag[Int] - typeTagIsnotClassTag[String] - typeTagIsnotClassTag[Array[Int]] -} diff --git a/tests/disabled/reflect/neg/interop_typetags_without_classtags_arenot_manifests.check b/tests/disabled/reflect/neg/interop_typetags_without_classtags_arenot_manifests.check deleted file mode 100644 index ba744a883777..000000000000 --- a/tests/disabled/reflect/neg/interop_typetags_without_classtags_arenot_manifests.check +++ /dev/null @@ -1,6 +0,0 @@ -interop_typetags_without_classtags_arenot_manifests.scala:6: error: to create a manifest here, it is necessary to interoperate with the type tag `evidence$1` in scope. -however typetag -> manifest conversion requires a class tag for the corresponding type to be present. -to proceed add a class tag to the type `T` (e.g. by introducing a context bound) and recompile. - println(manifest[T]) - ^ -one error found diff --git a/tests/disabled/reflect/neg/interop_typetags_without_classtags_arenot_manifests.scala b/tests/disabled/reflect/neg/interop_typetags_without_classtags_arenot_manifests.scala deleted file mode 100644 index ec69c1460a78..000000000000 --- a/tests/disabled/reflect/neg/interop_typetags_without_classtags_arenot_manifests.scala +++ /dev/null @@ -1,12 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.ClassTag - -object Test extends App { - def typeTagWithoutClassTagIsnotManifest[T: TypeTag] = { - println(manifest[T]) - } - - typeTagWithoutClassTagIsnotManifest[Int] - typeTagWithoutClassTagIsnotManifest[String] - typeTagWithoutClassTagIsnotManifest[Array[Int]] -} diff --git a/tests/disabled/reflect/run/interop_typetags_are_manifests.check b/tests/disabled/reflect/run/interop_typetags_are_manifests.check deleted file mode 100644 index e02de1fdc20f..000000000000 --- a/tests/disabled/reflect/run/interop_typetags_are_manifests.check +++ /dev/null @@ -1,3 +0,0 @@ -int -java.lang.String -Array[Int] diff --git a/tests/disabled/reflect/run/interop_typetags_are_manifests.flags b/tests/disabled/reflect/run/interop_typetags_are_manifests.flags deleted file mode 100644 index ea7fc37e1af3..000000000000 --- a/tests/disabled/reflect/run/interop_typetags_are_manifests.flags +++ /dev/null @@ -1 +0,0 @@ --Yrangepos:false diff --git a/tests/neg/interop_abstypetags_arenot_classmanifests.check b/tests/neg/interop_abstypetags_arenot_classmanifests.check new file mode 100644 index 000000000000..f13e0526322a --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_classmanifests.check @@ -0,0 +1,6 @@ + + +-- Error: tests/neg/interop_abstypetags_arenot_classmanifests/Test_3.scala:6:40 ---------------------------------------- +6 | println(implicitly[ClassManifest[T]]) // error + | ^ + | No ClassManifest available for T. diff --git a/tests/neg/interop_abstypetags_arenot_classmanifests/Test_3.scala b/tests/neg/interop_abstypetags_arenot_classmanifests/Test_3.scala new file mode 100644 index 000000000000..fc42cb42ad78 --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_classmanifests/Test_3.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.ClassManifest + +object Test extends App { + def weakTypeTagIsnotClassManifest[T: WeakTypeTag] = { + println(implicitly[ClassManifest[T]]) // error + } + + // weakTypeTagIsnotClassManifest[Int] + // weakTypeTagIsnotClassManifest[String] + // weakTypeTagIsnotClassManifest[Array[Int]] +} diff --git a/tests/neg/interop_abstypetags_arenot_classmanifests/api_1.scala b/tests/neg/interop_abstypetags_arenot_classmanifests/api_1.scala new file mode 100644 index 000000000000..6590e7eac4f1 --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_classmanifests/api_1.scala @@ -0,0 +1,8 @@ +package scala.reflect.api + +trait TypeTags { self: Universe => + trait WeakTypeTag[T] + trait TypeTag[T] extends WeakTypeTag[T] +} + +abstract class Universe extends TypeTags diff --git a/tests/neg/interop_abstypetags_arenot_classmanifests/universe_2.scala b/tests/neg/interop_abstypetags_arenot_classmanifests/universe_2.scala new file mode 100644 index 000000000000..a40d7208651d --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_classmanifests/universe_2.scala @@ -0,0 +1,7 @@ +package scala.reflect + +package object runtime { + + lazy val universe: api.Universe = new api.Universe {} + +} diff --git a/tests/neg/interop_abstypetags_arenot_classtags.check b/tests/neg/interop_abstypetags_arenot_classtags.check new file mode 100644 index 000000000000..6cfabe7d547b --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_classtags.check @@ -0,0 +1,6 @@ + + +-- Error: tests/neg/interop_abstypetags_arenot_classtags/Test_3.scala:6:23 --------------------------------------------- +6 | println(classTag[T]) // error + | ^ + | No ClassTag available for T diff --git a/tests/neg/interop_abstypetags_arenot_classtags/Test_3.scala b/tests/neg/interop_abstypetags_arenot_classtags/Test_3.scala new file mode 100644 index 000000000000..cd1261ce397b --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_classtags/Test_3.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.classTag + +object Test extends App { + def weakTypeTagIsnotClassTag[T: WeakTypeTag] = { + println(classTag[T]) // error + } + + // weakTypeTagIsnotClassTag[Int] + // weakTypeTagIsnotClassTag[String] + // weakTypeTagIsnotClassTag[Array[Int]] +} diff --git a/tests/neg/interop_abstypetags_arenot_classtags/api_1.scala b/tests/neg/interop_abstypetags_arenot_classtags/api_1.scala new file mode 100644 index 000000000000..6590e7eac4f1 --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_classtags/api_1.scala @@ -0,0 +1,8 @@ +package scala.reflect.api + +trait TypeTags { self: Universe => + trait WeakTypeTag[T] + trait TypeTag[T] extends WeakTypeTag[T] +} + +abstract class Universe extends TypeTags diff --git a/tests/neg/interop_abstypetags_arenot_classtags/universe_2.scala b/tests/neg/interop_abstypetags_arenot_classtags/universe_2.scala new file mode 100644 index 000000000000..a40d7208651d --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_classtags/universe_2.scala @@ -0,0 +1,7 @@ +package scala.reflect + +package object runtime { + + lazy val universe: api.Universe = new api.Universe {} + +} diff --git a/tests/neg/interop_abstypetags_arenot_manifests.check b/tests/neg/interop_abstypetags_arenot_manifests.check new file mode 100644 index 000000000000..6ce23a87ea2a --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_manifests.check @@ -0,0 +1,6 @@ + + +-- Error: tests/neg/interop_abstypetags_arenot_manifests/Test_3.scala:5:23 --------------------------------------------- +5 | println(manifest[T]) // error + | ^ + | No Manifest available for T. diff --git a/tests/neg/interop_abstypetags_arenot_manifests/Test_3.scala b/tests/neg/interop_abstypetags_arenot_manifests/Test_3.scala new file mode 100644 index 000000000000..c5de20dc9616 --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_manifests/Test_3.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + def weakTypeTagIsnotManifest[T: WeakTypeTag] = { + println(manifest[T]) // error + } + + // weakTypeTagIsnotManifest[Int] + // weakTypeTagIsnotManifest[String] + // weakTypeTagIsnotManifest[Array[Int]] +} diff --git a/tests/neg/interop_abstypetags_arenot_manifests/api_1.scala b/tests/neg/interop_abstypetags_arenot_manifests/api_1.scala new file mode 100644 index 000000000000..6590e7eac4f1 --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_manifests/api_1.scala @@ -0,0 +1,8 @@ +package scala.reflect.api + +trait TypeTags { self: Universe => + trait WeakTypeTag[T] + trait TypeTag[T] extends WeakTypeTag[T] +} + +abstract class Universe extends TypeTags diff --git a/tests/neg/interop_abstypetags_arenot_manifests/universe_2.scala b/tests/neg/interop_abstypetags_arenot_manifests/universe_2.scala new file mode 100644 index 000000000000..a40d7208651d --- /dev/null +++ b/tests/neg/interop_abstypetags_arenot_manifests/universe_2.scala @@ -0,0 +1,7 @@ +package scala.reflect + +package object runtime { + + lazy val universe: api.Universe = new api.Universe {} + +} diff --git a/tests/neg/interop_classtags_arenot_manifests.check b/tests/neg/interop_classtags_arenot_manifests.check new file mode 100644 index 000000000000..52b019acd600 --- /dev/null +++ b/tests/neg/interop_classtags_arenot_manifests.check @@ -0,0 +1,4 @@ +-- Error: tests/neg/interop_classtags_arenot_manifests.scala:5:23 ------------------------------------------------------ +5 | println(manifest[T]) // error + | ^ + | No Manifest available for T. diff --git a/tests/disabled/reflect/neg/interop_classtags_arenot_manifests.scala b/tests/neg/interop_classtags_arenot_manifests.scala similarity index 86% rename from tests/disabled/reflect/neg/interop_classtags_arenot_manifests.scala rename to tests/neg/interop_classtags_arenot_manifests.scala index 3555118d62dd..6281c782f171 100644 --- a/tests/disabled/reflect/neg/interop_classtags_arenot_manifests.scala +++ b/tests/neg/interop_classtags_arenot_manifests.scala @@ -2,7 +2,7 @@ import scala.reflect.{ClassTag, classTag} object Test extends App { def classTagIsnotManifest[T: ClassTag] = { - println(manifest[T]) + println(manifest[T]) // error } classTagIsnotManifest[Int] diff --git a/tests/neg/interop_typetags_arenot_classmanifests.check b/tests/neg/interop_typetags_arenot_classmanifests.check new file mode 100644 index 000000000000..92e78a2e6971 --- /dev/null +++ b/tests/neg/interop_typetags_arenot_classmanifests.check @@ -0,0 +1,6 @@ + + +-- Error: tests/neg/interop_typetags_arenot_classmanifests/Test_3.scala:6:40 ------------------------------------------- +6 | println(implicitly[ClassManifest[T]]) // error + | ^ + | No ClassManifest available for T. diff --git a/tests/neg/interop_typetags_arenot_classmanifests/Test_3.scala b/tests/neg/interop_typetags_arenot_classmanifests/Test_3.scala new file mode 100644 index 000000000000..c01b76f24bb4 --- /dev/null +++ b/tests/neg/interop_typetags_arenot_classmanifests/Test_3.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.ClassManifest + +object Test extends App { + def typeTagIsnotClassManifest[T: TypeTag] = { + println(implicitly[ClassManifest[T]]) // error + } + + // typeTagIsnotClassManifest[Int] + // typeTagIsnotClassManifest[String] + // typeTagIsnotClassManifest[Array[Int]] +} diff --git a/tests/neg/interop_typetags_arenot_classmanifests/api_1.scala b/tests/neg/interop_typetags_arenot_classmanifests/api_1.scala new file mode 100644 index 000000000000..6590e7eac4f1 --- /dev/null +++ b/tests/neg/interop_typetags_arenot_classmanifests/api_1.scala @@ -0,0 +1,8 @@ +package scala.reflect.api + +trait TypeTags { self: Universe => + trait WeakTypeTag[T] + trait TypeTag[T] extends WeakTypeTag[T] +} + +abstract class Universe extends TypeTags diff --git a/tests/neg/interop_typetags_arenot_classmanifests/universe_2.scala b/tests/neg/interop_typetags_arenot_classmanifests/universe_2.scala new file mode 100644 index 000000000000..a40d7208651d --- /dev/null +++ b/tests/neg/interop_typetags_arenot_classmanifests/universe_2.scala @@ -0,0 +1,7 @@ +package scala.reflect + +package object runtime { + + lazy val universe: api.Universe = new api.Universe {} + +} diff --git a/tests/neg/interop_typetags_arenot_classtags.check b/tests/neg/interop_typetags_arenot_classtags.check new file mode 100644 index 000000000000..63e7ed29953f --- /dev/null +++ b/tests/neg/interop_typetags_arenot_classtags.check @@ -0,0 +1,6 @@ + + +-- Error: tests/neg/interop_typetags_arenot_classtags/Test_3.scala:6:23 ------------------------------------------------ +6 | println(classTag[T]) // error + | ^ + | No ClassTag available for T diff --git a/tests/neg/interop_typetags_arenot_classtags/Test_3.scala b/tests/neg/interop_typetags_arenot_classtags/Test_3.scala new file mode 100644 index 000000000000..8a1929ab9cfa --- /dev/null +++ b/tests/neg/interop_typetags_arenot_classtags/Test_3.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.classTag + +object Test extends App { + def typeTagIsnotClassTag[T: TypeTag] = { + println(classTag[T]) // error + } + + // typeTagIsnotClassTag[Int] + // typeTagIsnotClassTag[String] + // typeTagIsnotClassTag[Array[Int]] +} diff --git a/tests/neg/interop_typetags_arenot_classtags/api_1.scala b/tests/neg/interop_typetags_arenot_classtags/api_1.scala new file mode 100644 index 000000000000..5484d6816e3d --- /dev/null +++ b/tests/neg/interop_typetags_arenot_classtags/api_1.scala @@ -0,0 +1,7 @@ +package scala.reflect.api + +trait TypeTags { self: Universe => + trait TypeTag[T] +} + +abstract class Universe extends TypeTags diff --git a/tests/neg/interop_typetags_arenot_classtags/universe_2.scala b/tests/neg/interop_typetags_arenot_classtags/universe_2.scala new file mode 100644 index 000000000000..a40d7208651d --- /dev/null +++ b/tests/neg/interop_typetags_arenot_classtags/universe_2.scala @@ -0,0 +1,7 @@ +package scala.reflect + +package object runtime { + + lazy val universe: api.Universe = new api.Universe {} + +} diff --git a/tests/neg/interop_typetags_without_classtags_arenot_manifests.check b/tests/neg/interop_typetags_without_classtags_arenot_manifests.check new file mode 100644 index 000000000000..c5cbad643697 --- /dev/null +++ b/tests/neg/interop_typetags_without_classtags_arenot_manifests.check @@ -0,0 +1,10 @@ + + +-- Error: tests/neg/interop_typetags_without_classtags_arenot_manifests/Test_3.scala:5:23 ------------------------------ +5 | println(manifest[T]) // error + | ^ + | To create a Manifest here, it is necessary to interoperate with the + | TypeTag `evidence$1` in scope. However TypeTag to Manifest conversion requires a + | ClassTag for the corresponding type to be present. + | To proceed add a ClassTag for the type `T` (e.g. by introducing a context bound) + | and recompile. diff --git a/tests/neg/interop_typetags_without_classtags_arenot_manifests/Test_3.scala b/tests/neg/interop_typetags_without_classtags_arenot_manifests/Test_3.scala new file mode 100644 index 000000000000..d2c5e01df31b --- /dev/null +++ b/tests/neg/interop_typetags_without_classtags_arenot_manifests/Test_3.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + def typeTagWithoutClassTagIsnotManifest[T: TypeTag] = { + println(manifest[T]) // error + } + + // typeTagWithoutClassTagIsnotManifest[Int] + // typeTagWithoutClassTagIsnotManifest[String] + // typeTagWithoutClassTagIsnotManifest[Array[Int]] +} diff --git a/tests/neg/interop_typetags_without_classtags_arenot_manifests/api_1.scala b/tests/neg/interop_typetags_without_classtags_arenot_manifests/api_1.scala new file mode 100644 index 000000000000..5484d6816e3d --- /dev/null +++ b/tests/neg/interop_typetags_without_classtags_arenot_manifests/api_1.scala @@ -0,0 +1,7 @@ +package scala.reflect.api + +trait TypeTags { self: Universe => + trait TypeTag[T] +} + +abstract class Universe extends TypeTags diff --git a/tests/neg/interop_typetags_without_classtags_arenot_manifests/universe_2.scala b/tests/neg/interop_typetags_without_classtags_arenot_manifests/universe_2.scala new file mode 100644 index 000000000000..a40d7208651d --- /dev/null +++ b/tests/neg/interop_typetags_without_classtags_arenot_manifests/universe_2.scala @@ -0,0 +1,7 @@ +package scala.reflect + +package object runtime { + + lazy val universe: api.Universe = new api.Universe {} + +} diff --git a/tests/pos/i9482.scala b/tests/pos/i9482.scala new file mode 100644 index 000000000000..6549539e49a7 --- /dev/null +++ b/tests/pos/i9482.scala @@ -0,0 +1,11 @@ +import scala.reflect.OptManifest + +object Ref { + def make[A: OptManifest]: Ref[A] = ??? +} +trait Ref[A] + +trait Foo[A] { + val bar = Ref.make[Int] + val baz: Ref[A] = Ref.make +} diff --git a/tests/disabled/reflect/run/interop_typetags_are_manifests.scala b/tests/pos/interop_typetags_are_manifests/Test_3.scala similarity index 54% rename from tests/disabled/reflect/run/interop_typetags_are_manifests.scala rename to tests/pos/interop_typetags_are_manifests/Test_3.scala index 071c3ff25f5c..817b3f3b0bb9 100644 --- a/tests/disabled/reflect/run/interop_typetags_are_manifests.scala +++ b/tests/pos/interop_typetags_are_manifests/Test_3.scala @@ -1,13 +1,12 @@ import scala.reflect.runtime.universe._ import scala.reflect.ClassTag -import internal._ -object Test extends App { +object Test { def typeTagIsManifest[T: TypeTag : ClassTag] = { println(manifest[T]) } - typeTagIsManifest[Int] - typeTagIsManifest[String] - typeTagIsManifest[Array[Int]] + // typeTagIsManifest[Int] + // typeTagIsManifest[String] + // typeTagIsManifest[Array[Int]] } diff --git a/tests/pos/interop_typetags_are_manifests/api_1.scala b/tests/pos/interop_typetags_are_manifests/api_1.scala new file mode 100644 index 000000000000..d192e38588b2 --- /dev/null +++ b/tests/pos/interop_typetags_are_manifests/api_1.scala @@ -0,0 +1,22 @@ +package scala.reflect.api + +import scala.reflect.{Manifest, ClassTag} + +trait TypeTags { self: Universe => + trait TypeTag[T] +} + +trait Internals { self: Universe => + + object internal { + def typeTagToManifest[T: ClassTag](mirror: Any, tag: Universe#TypeTag[T]): Manifest[T] = ??? + } + +} + +abstract class Universe extends TypeTags + with Internals + +abstract class JavaUniverse extends Universe { + def runtimeMirror(cl: ClassLoader): Any = ??? +} diff --git a/tests/pos/interop_typetags_are_manifests/universe_2.scala b/tests/pos/interop_typetags_are_manifests/universe_2.scala new file mode 100644 index 000000000000..d19b5bcfbcb4 --- /dev/null +++ b/tests/pos/interop_typetags_are_manifests/universe_2.scala @@ -0,0 +1,9 @@ +package scala.reflect + +import scala.reflect.api + +package object runtime { + + lazy val universe: api.JavaUniverse = new api.JavaUniverse {} + +} diff --git a/tests/disabled/reflect/pos/manifest1-old.scala b/tests/pos/manifest1-old.scala similarity index 100% rename from tests/disabled/reflect/pos/manifest1-old.scala rename to tests/pos/manifest1-old.scala diff --git a/tests/pending/pos/nothing_manifest_disambig-old.scala b/tests/pos/nothing_manifest_disambig-old.scala similarity index 100% rename from tests/pending/pos/nothing_manifest_disambig-old.scala rename to tests/pos/nothing_manifest_disambig-old.scala diff --git a/tests/run/interop_classtags_are_classmanifests.scala b/tests/run/interop_classtags_are_classmanifests.scala new file mode 100644 index 000000000000..ef59354cf98d --- /dev/null +++ b/tests/run/interop_classtags_are_classmanifests.scala @@ -0,0 +1,12 @@ + +@deprecated("Suppress warnings", since="2.11") +object Test extends App { + import scala.reflect.{ClassManifest, ClassTag} + def classTagIsClassManifest[T: ClassTag] = { + println(implicitly[ClassManifest[T]]) + } + + classTagIsClassManifest[Int] + classTagIsClassManifest[String] + classTagIsClassManifest[Array[Int]] +} diff --git a/tests/disabled/reflect/run/interop_manifests_are_classtags.check b/tests/run/interop_manifests_are_classtags.check similarity index 100% rename from tests/disabled/reflect/run/interop_manifests_are_classtags.check rename to tests/run/interop_manifests_are_classtags.check diff --git a/tests/disabled/reflect/run/interop_manifests_are_classtags.scala b/tests/run/interop_manifests_are_classtags.scala similarity index 90% rename from tests/disabled/reflect/run/interop_manifests_are_classtags.scala rename to tests/run/interop_manifests_are_classtags.scala index 705038ece7cb..a2666a566944 100644 --- a/tests/disabled/reflect/run/interop_manifests_are_classtags.scala +++ b/tests/run/interop_manifests_are_classtags.scala @@ -1,4 +1,4 @@ -import scala.reflect.{ClassTag, classTag} +import scala.reflect.{ClassTag, classTag, ClassManifest} @deprecated("Suppress warnings", since="2.11") object Test extends App { diff --git a/tests/pending/run/manifests-old.scala b/tests/run/manifests-old.scala similarity index 88% rename from tests/pending/run/manifests-old.scala rename to tests/run/manifests-old.scala index d8b1e751d4c1..78822d457087 100644 --- a/tests/pending/run/manifests-old.scala +++ b/tests/run/manifests-old.scala @@ -111,22 +111,22 @@ object Test assertNoRelationship[List[Int], List[AnyRef]] // Nothing - assertSubType[Nothing, Any] - assertSubType[Nothing, AnyVal] - assertSubType[Nothing, AnyRef] - assertSubType[Nothing, String] - assertSubType[Nothing, List[String]] - assertSubType[Nothing, Null] - assertSameType[Nothing, Nothing] + // assertSubType[Nothing, Any] + // assertSubType[Nothing, AnyVal] + // assertSubType[Nothing, AnyRef] + // assertSubType[Nothing, String] + // assertSubType[Nothing, List[String]] + // assertSubType[Nothing, Null] + // assertSameType[Nothing, Nothing] // Null - assertSubType[Null, Any] - assertNoRelationship[Null, AnyVal] - assertSubType[Null, AnyRef] - assertSubType[Null, String] - assertSubType[Null, List[String]] - assertSameType[Null, Null] - assertSuperType[Null, Nothing] + // assertSubType[Null, Any] + // assertNoRelationship[Null, AnyVal] + // assertSubType[Null, AnyRef] + // assertSubType[Null, String] + // assertSubType[Null, List[String]] + // assertSameType[Null, Null] + // assertSuperType[Null, Nothing] // Any assertSameType[Any, Any] @@ -134,8 +134,8 @@ object Test assertSuperType[Any, AnyRef] assertSuperType[Any, String] assertSuperType[Any, List[String]] - assertSuperType[Any, Null] - assertSuperType[Any, Nothing] + // assertSuperType[Any, Null] + // assertSuperType[Any, Nothing] // Misc unrelated types assertNoRelationship[Unit, AnyRef] diff --git a/tests/disabled/reflect/run/manifests-undeprecated-in-2.10.0.scala b/tests/run/manifests-undeprecated-in-2.10.0.scala similarity index 100% rename from tests/disabled/reflect/run/manifests-undeprecated-in-2.10.0.scala rename to tests/run/manifests-undeprecated-in-2.10.0.scala diff --git a/tests/run/summon-classmanifest.check b/tests/run/summon-classmanifest.check new file mode 100644 index 000000000000..d75686b9641e --- /dev/null +++ b/tests/run/summon-classmanifest.check @@ -0,0 +1,2 @@ +scala.collection.immutable.List[scala.Option[Int]] +Array[java.lang.String] diff --git a/tests/run/summon-classmanifest.scala b/tests/run/summon-classmanifest.scala new file mode 100644 index 000000000000..7d69df4f4cac --- /dev/null +++ b/tests/run/summon-classmanifest.scala @@ -0,0 +1,12 @@ +import scala.reflect.{ClassManifest, ClassTag} + +type CM[T] = reflect.ClassManifest[T] @annotation.nowarn("msg=deprecated") +type CManifest[T] = CM[T] // test dealiasing mixed with annotated types + +@main def Test = + // manifests are ClassTags + val manifestListOptionInt: ClassTag[List[Option[Int]]] = summon[CManifest[List[Option[Int]]]] + val manifestArrayString: ClassTag[Array[String]] = summon[CManifest[Array[String]]] + + println(manifestListOptionInt) // should print arguments to List + println(manifestArrayString) diff --git a/tests/pending/run/valueclasses-manifest-basic.check b/tests/run/valueclasses-manifest-basic.check similarity index 100% rename from tests/pending/run/valueclasses-manifest-basic.check rename to tests/run/valueclasses-manifest-basic.check diff --git a/tests/pending/run/valueclasses-manifest-basic.scala b/tests/run/valueclasses-manifest-basic.scala similarity index 100% rename from tests/pending/run/valueclasses-manifest-basic.scala rename to tests/run/valueclasses-manifest-basic.scala diff --git a/tests/pending/run/valueclasses-manifest-existential.check b/tests/run/valueclasses-manifest-existential.check similarity index 100% rename from tests/pending/run/valueclasses-manifest-existential.check rename to tests/run/valueclasses-manifest-existential.check diff --git a/tests/pending/run/valueclasses-manifest-existential.scala b/tests/run/valueclasses-manifest-existential.scala similarity index 100% rename from tests/pending/run/valueclasses-manifest-existential.scala rename to tests/run/valueclasses-manifest-existential.scala diff --git a/tests/pending/run/valueclasses-manifest-generic.check b/tests/run/valueclasses-manifest-generic.check similarity index 100% rename from tests/pending/run/valueclasses-manifest-generic.check rename to tests/run/valueclasses-manifest-generic.check diff --git a/tests/pending/run/valueclasses-manifest-generic.scala b/tests/run/valueclasses-manifest-generic.scala similarity index 100% rename from tests/pending/run/valueclasses-manifest-generic.scala rename to tests/run/valueclasses-manifest-generic.scala