summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-04-23 17:51:28 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-04-23 17:54:19 +0200
commit2b09d8caf5497c4e016a3e1179e5f7e842766176 (patch)
tree27c872f82fb8290b8cba6fa626ecd0b0dd627229 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent14df5d74b58505e082d6f7c0e42b51249d35eec4 (diff)
downloadscala-2b09d8caf5497c4e016a3e1179e5f7e842766176.tar.gz
scala-2b09d8caf5497c4e016a3e1179e5f7e842766176.tar.bz2
scala-2b09d8caf5497c4e016a3e1179e5f7e842766176.zip
rethinks tags
* introduces ArrayTag and ErasureTag * all type tags now feature erasure
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala50
1 files changed, 8 insertions, 42 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 54be9c9a87..ba6a363095 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -26,7 +26,7 @@ import util.Statistics._
* @author Martin Odersky
* @version 1.0
*/
-trait Typers extends Modes with Adaptations with PatMatVirtualiser {
+trait Typers extends Modes with Adaptations with Taggings with PatMatVirtualiser {
self: Analyzer =>
import global._
@@ -83,7 +83,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
private def isPastTyper = phase.id > currentRun.typerPhase.id
- abstract class Typer(context0: Context) extends TyperDiagnostics with Adaptation with TyperContextErrors {
+ abstract class Typer(context0: Context) extends TyperDiagnostics with Adaptation with Tagging with TyperContextErrors {
import context0.unit
import typeDebug.{ ptTree, ptBlock, ptLine }
import TyperErrorGen._
@@ -830,11 +830,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
context.undetparams = inferExprInstance(tree, context.extractUndetparams(), pt,
// approximate types that depend on arguments since dependency on implicit argument is like dependency on type parameter
mt.approximate,
- // if we are looking for a manifest, instantiate type to Nothing anyway,
- // as we would get ambiguity errors otherwise. Example
- // Looking for a manifest of Nil: This has many potential types,
- // so we need to instantiate to minimal type List[Nothing].
- keepNothings = false, // retract Nothing's that indicate failure, ambiguities in manifests are dealt with in manifestOfType
+ keepNothings = false,
useWeaklyCompatible = true) // #3808
}
@@ -3103,7 +3099,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
if (annInfo.atp.isErroneous) { hasError = true; None }
else Some(NestedAnnotArg(annInfo))
- // use of Array.apply[T: ClassManifest](xs: T*): Array[T]
+ // use of Array.apply[T: ArrayTag](xs: T*): Array[T]
// and Array.apply(x: Int, xs: Int*): Array[Int] (and similar)
case Apply(fun, args) =>
val typedFun = typed(fun, forFunMode(mode), WildcardType)
@@ -4840,12 +4836,12 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
// [Eugene] no more MaxArrayDims. ClassTags are flexible enough to allow creation of arrays of arbitrary dimensionality (w.r.t JVM restrictions)
val Some((level, componentType)) = erasure.GenericArray.unapply(tpt.tpe)
val tagType = List.iterate(componentType, level)(tpe => appliedType(ArrayClass.asType, List(tpe))).last
- val newArrayApp = atPos(tree.pos) {
- val tag = resolveClassTag(tree, tagType)
+ val newArrayApp = atPos(tree.pos) {
+ val tag = resolveArrayTag(tree.pos, tagType)
if (tag.isEmpty) MissingClassTagError(tree, tagType)
else new ApplyToImplicitArgs(Select(tag, nme.newArray), args)
- }
- typed(newArrayApp, mode, pt)
+ }
+ typed(newArrayApp, mode, pt)
case tree1 =>
tree1
}
@@ -5210,36 +5206,6 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
case None => typed(tree, mode, pt)
}
- // `tree` is only necessary here for its position
- // but that's invaluable for error reporting, so I decided to include it into this method's contract
- // before passing EmptyTree, please, consider passing something meaningful first
- def resolveClassTag(tree: Tree, tp: Type): Tree = beforeTyper {
- inferImplicit(
- EmptyTree,
- appliedType(ClassTagClass.typeConstructor, List(tp)),
- /*reportAmbiguous =*/ true,
- /*isView =*/ false,
- /*context =*/ context,
- /*saveAmbiguousDivergent =*/ true,
- /*pos =*/ tree.pos
- ).tree
- }
-
- // `tree` is only necessary here for its position
- // but that's invaluable for error reporting, so I decided to include it into this method's contract
- // before passing EmptyTree, please, consider passing something meaningful first
- def resolveTypeTag(tree: Tree, pre: Type, tp: Type, full: Boolean): Tree = beforeTyper {
- inferImplicit(
- EmptyTree,
- appliedType(singleType(pre, pre member (if (full) ConcreteTypeTagClass else TypeTagClass).name), List(tp)),
- /*reportAmbiguous =*/ true,
- /*isView =*/ false,
- /*context =*/ context,
- /*saveAmbiguousDivergent =*/ true,
- /*pos =*/ tree.pos
- ).tree
- }
-
/*
def convertToTypeTree(tree: Tree): Tree = tree match {
case TypeTree() => tree