diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-02-17 23:18:50 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-18 09:23:38 +0100 |
commit | afecfe90cd98a657ce83f3e833c940518563064e (patch) | |
tree | 23f0dd8d4a1a9aebf47f098c65c83746da4f0efc | |
parent | 34532d7e92b8ed2a9411260007fcfcc00f377ccc (diff) | |
download | scala-afecfe90cd98a657ce83f3e833c940518563064e.tar.gz scala-afecfe90cd98a657ce83f3e833c940518563064e.tar.bz2 scala-afecfe90cd98a657ce83f3e833c940518563064e.zip |
reverses SI-6484
Unfortunately I have to revert b017629 because of SI-8303. There are projects
(e.g. slick) that use typeOf in annotations, which effectively means bye-bye.
-rw-r--r-- | src/compiler/scala/reflect/reify/phases/Reshape.scala | 26 | ||||
-rw-r--r-- | src/reflect/scala/reflect/api/TypeTags.scala | 16 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/StdNames.scala | 2 | ||||
-rw-r--r-- | src/reflect/scala/reflect/macros/Aliases.scala | 12 | ||||
-rw-r--r-- | test/pending/reify_typeof.check (renamed from test/files/run/reify_typeof.check) | 0 | ||||
-rw-r--r-- | test/pending/reify_typeof.scala (renamed from test/files/run/reify_typeof.scala) | 0 | ||||
-rw-r--r-- | test/pending/typetags_typeof_x.check (renamed from test/files/run/typetags_typeof_x.check) | 0 | ||||
-rw-r--r-- | test/pending/typetags_typeof_x.scala (renamed from test/files/run/typetags_typeof_x.scala) | 0 |
8 files changed, 5 insertions, 51 deletions
diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index 9a54632796..6c073c0b4c 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -78,7 +78,7 @@ trait Reshape { super.transform(preTyper) } - private def undoMacroExpansion(tree: Tree): Tree = { + private def undoMacroExpansion(tree: Tree): Tree = tree.attachments.get[analyzer.MacroExpansionAttachment] match { case Some(analyzer.MacroExpansionAttachment(original, _)) => def mkImplicitly(tp: Type) = atPos(tree.pos)( @@ -96,30 +96,8 @@ trait Reshape { case Apply(TypeApply(_, List(tt)), List(pre)) if sym == materializeTypeTag => mkImplicitly(typeRef(pre.tpe, TypeTagClass, List(tt.tpe))) case _ => original } - case None => - // `typeOf[T]` calls get translated into `typeOf[T](Predef.implicitly)` by Reshape - // unfortunately, this doesn't work well with the recently introduced `def typeOf[T: TypeTag](x: T)` overload - // somehow the typechecker is now longer able to make sense of targless implicitly failing with: - // ambiguous implicit values: - // both value StringCanBuildFrom in object Predef of type => scala.collection.generic.CanBuildFrom[String,Char,String] - // and method conforms in object Predef of type [A]=> <:<[A,A] - // match expected type T - // could not find implicit value for parameter e: T - // overloaded method value typeOf with alternatives: - // (x: => List[Int])(implicit evidence$2: ru.TypeTag[List[Int]])ru.Type <and> - // (implicit ttag: ru.TypeTag[List[Int]])ru.Type - // cannot be applied to (Unit) - // therefore here we give the calls to `weakTypeOf` and `typeOf` a bit of extra helping - // erasing synthetic implicit arguments altogether, so that this weird tree shape doesn't appear in the reifee in the first place - def isTypeOf(sym: Symbol): Boolean = { - sym != null && (sym.name == nme.typeOf || sym.name == nme.weakTypeOf) && sym.owner == TypeTagsClass - } - tree match { - case Apply(fun, args) if !tree.tpe.isInstanceOf[MethodType] && isTypeOf(fun.symbol) => fun - case _ => tree - } + case _ => tree } - } override def transformModifiers(mods: Modifiers) = { val mods1 = toPreTyperModifiers(mods, currentSymbol) diff --git a/src/reflect/scala/reflect/api/TypeTags.scala b/src/reflect/scala/reflect/api/TypeTags.scala index 1d5bf5d28b..1dfc84be69 100644 --- a/src/reflect/scala/reflect/api/TypeTags.scala +++ b/src/reflect/scala/reflect/api/TypeTags.scala @@ -326,25 +326,13 @@ trait TypeTags { self: Universe => * Shortcut for `implicitly[WeakTypeTag[T]].tpe` * @group TypeTags */ - def weakTypeOf[T](implicit attag: WeakTypeTag[T]): Type = if (attag != null) attag.tpe else typeOf[Null] - - /** - * Type of `x` as derived from a weak type tag. - * @group TypeTags - */ - def weakTypeOf[T: WeakTypeTag](x: => T): Type = weakTypeOf[T] + def weakTypeOf[T](implicit attag: WeakTypeTag[T]): Type = attag.tpe /** * Shortcut for `implicitly[TypeTag[T]].tpe` * @group TypeTags */ - def typeOf[T](implicit ttag: TypeTag[T]): Type = if (ttag != null) ttag.tpe else typeOf[Null] - - /** - * Type of `x` as derived from a type tag. - * @group TypeTags - */ - def typeOf[T: TypeTag](x: => T): Type = typeOf[T] + def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe /** * Type symbol of `x` as derived from a type tag. diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index b95c83d6cb..0c28c4fba4 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -787,7 +787,6 @@ trait StdNames { val tree : NameType = "tree" val true_ : NameType = "true" val typedProductIterator: NameType = "typedProductIterator" - val typeOf: NameType = "typeOf" val TypeName: NameType = "TypeName" val typeTagToManifest: NameType = "typeTagToManifest" val unapply: NameType = "unapply" @@ -802,7 +801,6 @@ trait StdNames { val valueOf : NameType = "valueOf" val values : NameType = "values" val wait_ : NameType = "wait" - val weakTypeOf: NameType = "weakTypeOf" val withFilter: NameType = "withFilter" val zero: NameType = "zero" diff --git a/src/reflect/scala/reflect/macros/Aliases.scala b/src/reflect/scala/reflect/macros/Aliases.scala index bd918bbe56..64819a8601 100644 --- a/src/reflect/scala/reflect/macros/Aliases.scala +++ b/src/reflect/scala/reflect/macros/Aliases.scala @@ -110,12 +110,7 @@ trait Aliases { /** * Shortcut for `implicitly[WeakTypeTag[T]].tpe` */ - def weakTypeOf[T](implicit attag: WeakTypeTag[T]): Type = if (attag != null) attag.tpe else typeOf[Null] - - /** - * Type of `x` as derived from a weak type tag. - */ - def weakTypeOf[T: WeakTypeTag](x: => T): Type = weakTypeOf[T] + def weakTypeOf[T](implicit attag: WeakTypeTag[T]): Type = attag.tpe /** * Shortcut for `implicitly[TypeTag[T]].tpe` @@ -123,11 +118,6 @@ trait Aliases { def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe /** - * Type of `x` as derived from a type tag. - */ - def typeOf[T: TypeTag](x: => T): Type = typeOf[T] - - /** * Type symbol of `x` as derived from a type tag. */ def symbolOf[T: WeakTypeTag]: universe.TypeSymbol = universe.symbolOf[T] diff --git a/test/files/run/reify_typeof.check b/test/pending/reify_typeof.check index 670f76faa4..670f76faa4 100644 --- a/test/files/run/reify_typeof.check +++ b/test/pending/reify_typeof.check diff --git a/test/files/run/reify_typeof.scala b/test/pending/reify_typeof.scala index 985c57b9ab..985c57b9ab 100644 --- a/test/files/run/reify_typeof.scala +++ b/test/pending/reify_typeof.scala diff --git a/test/files/run/typetags_typeof_x.check b/test/pending/typetags_typeof_x.check index 832a8bc63c..832a8bc63c 100644 --- a/test/files/run/typetags_typeof_x.check +++ b/test/pending/typetags_typeof_x.check diff --git a/test/files/run/typetags_typeof_x.scala b/test/pending/typetags_typeof_x.scala index 08be6d4527..08be6d4527 100644 --- a/test/files/run/typetags_typeof_x.scala +++ b/test/pending/typetags_typeof_x.scala |