-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preparations: always explicitly provide type tags
In our codebase we now explicitly provide type tags even if they can be materialized. This is necessary to ease the upcoming reflection refactoring (or refactorings :)).
- Loading branch information
Showing
4 changed files
with
38 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,26 @@ | |||
package scala.tools | |||
package reflect | |||
|
|||
import java.lang.{Class => jClass} | |||
import scala.reflect.mirror._ | |||
|
|||
// [Eugene++] Before 2.10 is released, I suggest we don't rely on automated type tag generation | |||
// sure, it's convenient, but then refactoring reflection / reification becomes a pain | |||
// `ClassTag` tags are fine, because they don't need a reifier to be generated | |||
|
|||
object StdTags { | |||
lazy val tagOfString = TypeTag.String | |||
lazy val tagOfListOfString = TypeTag[List[String]]({ | |||
val pre = ThisType(staticModule("scala.collection.immutable").moduleClass) | |||
TypeRef(pre, definitions.ListClass, List(definitions.StringClass.asTypeConstructor)) | |||
}, classOf[List[String]]) | |||
|
|||
private def tagOfStaticClass[T: ClassTag] = TypeTag[T](staticClass(classTag[T].erasure.getName).asTypeConstructor, classTag[T].erasure) | |||
lazy val tagOfInt = TypeTag.Int | |||
lazy val tagOfFile = tagOfStaticClass[scala.tools.nsc.io.File] | |||
lazy val tagOfDirectory = tagOfStaticClass[scala.tools.nsc.io.Directory] | |||
lazy val tagOfStdReplVals = tagOfStaticClass[scala.tools.nsc.interpreter.StdReplVals] | |||
lazy val tagOfIMain = tagOfStaticClass[scala.tools.nsc.interpreter.IMain] | |||
lazy val tagOfThrowable = tagOfStaticClass[java.lang.Throwable] | |||
lazy val tagOfClassLoader = tagOfStaticClass[java.lang.ClassLoader] | |||
} |