summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-02-08 09:48:46 +0000
committerMartin Odersky <odersky@gmail.com>2007-02-08 09:48:46 +0000
commitf045549b48e6e22a1f705a2b913f1e3c8d5f68e8 (patch)
treea529591462a44dbbe9c05e527bd531958faf9d2e /src/compiler/scala/tools
parent67cf4f5e32bc036788ff7a5426a5f5c0bb07fb70 (diff)
downloadscala-f045549b48e6e22a1f705a2b913f1e3c8d5f68e8.tar.gz
scala-f045549b48e6e22a1f705a2b913f1e3c8d5f68e8.tar.bz2
scala-f045549b48e6e22a1f705a2b913f1e3c8d5f68e8.zip
changed exhaustivity check suppression to attri...
changed exhaustivity check suppression to attribute.
Diffstat (limited to 'src/compiler/scala/tools')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala19
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
4 files changed, 18 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index aef8f96181..557f4376a0 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -229,6 +229,9 @@ trait Parsers requires SyntaxAnalyzer {
case _ => false
}
+ def isTypeIntro: boolean = isTypeIntroToken(in.token)
+
+
/////// COMMENT AND ATTRIBUTE COLLECTION //////////////////////////////////////
/** Join the comment associated with a definition
@@ -661,7 +664,6 @@ trait Parsers requires SyntaxAnalyzer {
*/
def simpleType(isPattern: boolean): Tree = {
val attribs = typeAttributes()
-
val pos = in.currentPos
var t: Tree =
if (in.token == LPAREN && !isPattern) {
@@ -703,11 +705,8 @@ trait Parsers requires SyntaxAnalyzer {
} else
done=true
}
-
if (settings.Xplugtypes.value) t.withAttributes(attribs)
- else (t /: attribs) ((t, attr) => attr match {
- case Attribute(constr, elements) => Attributed(constr, elements, t)
- })
+ else (t /: attribs) (makeAttributed)
}
/** TypeArgs ::= `[' ArgTypes `]'
@@ -933,6 +932,7 @@ trait Parsers requires SyntaxAnalyzer {
}
} else if (in.token == COLON) {
val pos = in.skipToken()
+ val attribs = typeAttributes()
if ((mode & IsArgument) != 0 && in.token == USCORE) {
val pos1 = in.skipToken()
if (isIdent && in.name == nme.STAR) {
@@ -945,12 +945,15 @@ trait Parsers requires SyntaxAnalyzer {
} else {
syntaxErrorOrIncomplete("`*' expected", true)
}
- } else {
+ } else if (attribs.isEmpty || isTypeIntro) {
t = atPos(pos) {
- Typed(t, if ((mode & IsInBlock) != 0) compoundType(false) else typ())
+ val tpt = if ((mode & IsInBlock) != 0) compoundType(false) else typ()
// this does not correspond to syntax, but is necessary to
- // accept closures. We should restrict closures to be between {...} only!
+ // accept closures. We might restrict closures to be between {...} only!
+ Typed(t, (tpt /: attribs) (makeAttributed))
}
+ } else {
+ t = (t /: attribs) (makeAttributed)
}
} else if (in.token == MATCH) {
t = atPos(in.skipToken()) {
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index f6cbead3ca..cf6faf7e41 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -103,6 +103,10 @@ abstract class TreeBuilder {
case _ => AppliedTypeTree(scalaDot(newTypeName("Tuple" + trees.length)), trees)
}
+ def makeAttributed(t: Tree, attr: Tree): Tree = attr match {
+ case Attribute(constr, elements) => Attributed(constr, elements, t) setPos attr.pos
+ }
+
/** If tree is a variable pattern, return Some("its name and type").
* Otherwise return none */
private def matchVarPattern(tree: Tree): Option[{Name, Tree}] = tree match {
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 0f860ee5f3..7ee6d667e7 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -1120,9 +1120,9 @@ trait Types requires SymbolTable {
// ---------------- methods forwarded to tp ------------------ \\
override def symbol: Symbol = tp.symbol
- override def singleDeref: Type = maybeRewrap(tp.singleDeref)
+ override def singleDeref: Type = tp.singleDeref
override def widen: Type = tp.widen
- override def deconst: Type = maybeRewrap(tp.deconst)
+ override def deconst: Type = tp.deconst
override def bounds: TypeBounds = {
val oftp = tp.bounds
oftp match {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 9b905f6319..dff9b8d6c2 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2140,7 +2140,7 @@ trait Typers requires Analyzer {
case Typed(expr, tpt) =>
val tpt1 = typedType(tpt)
- val expr1 = typed(expr, mode & stickyModes, tpt1.tpe)
+ val expr1 = typed(expr, mode & stickyModes, tpt1.tpe.deconst)
val owntype = if ((mode & PATTERNmode) != 0) inferTypedPattern(tpt1.pos, tpt1.tpe, widen(pt)) else tpt1.tpe
//Console.println(typed pattern: "+tree+":"+", tp = "+tpt1.tpe+", pt = "+pt+" ==> "+owntype)//DEBUG
copy.Typed(tree, expr1, tpt1) setType owntype