summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorAntonio Cunei <antonio.cunei@epfl.ch>2008-11-25 18:05:48 +0000
committerAntonio Cunei <antonio.cunei@epfl.ch>2008-11-25 18:05:48 +0000
commitaf47e5b433ea538bf096a176c88f3c91116e09cd (patch)
treeb3e66e93fb653570ebbef16183cf4f2be2111c12 /src/compiler
parent2d61f09332dbc6038f869c6a23a95dca1bc3b6c7 (diff)
downloadscala-af47e5b433ea538bf096a176c88f3c91116e09cd.tar.gz
scala-af47e5b433ea538bf096a176c88f3c91116e09cd.tar.bz2
scala-af47e5b433ea538bf096a176c88f3c91116e09cd.zip
Merging everything from the 2.8.x development b...
Merging everything from the 2.8.x development branch back to trunk. - If you were working on trunk, please keep working on trunk If you were - working on 2.8-devel, please switch to trunk now
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/Settings.scala1
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala48
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Flags.scala149
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala1
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala9
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala9
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala9
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala9
-rw-r--r--src/compiler/scala/tools/nsc/util/ShowPickled.scala8
11 files changed, 189 insertions, 64 deletions
diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala
index add169ad53..7a6452709e 100644
--- a/src/compiler/scala/tools/nsc/Settings.scala
+++ b/src/compiler/scala/tools/nsc/Settings.scala
@@ -155,6 +155,7 @@ class Settings(error: String => Unit) {
val XnoVarargsConversion = BooleanSetting("-Xno-varargs-conversion", "disable varags conversion")
val selfInAnnots = BooleanSetting ("-Yself-in-annots", "Include a \"self\" identifier inside of annotations")
+ val suppressVTWarn = BooleanSetting ("-Ysuppress-vt-typer-warnings", "Suppress warnings from the typer when testing the virtual class encoding, NOT FOR FINAL!")
/** A list of all settings */
def allSettings: List[Setting] = allsettings.reverse
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 94f6039737..b0b55c5528 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2007 LAMP/EPFL
+ * Copyright 2005-2008 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@@ -150,7 +150,7 @@ trait Parsers extends NewScanners with MarkupParsers {
t
}
-/////////// PLACEHOLDERS ///////////////////////////////////////////////////////
+/* -------- PLACEHOLDERS ------------------------------------------- */
/** The implicit parameters introduced by `_' in the current expression.
* Parameters appear in reverse order
@@ -200,7 +200,7 @@ trait Parsers extends NewScanners with MarkupParsers {
t
}
-/////// ERROR HANDLING //////////////////////////////////////////////////////
+/* -------- ERROR HANDLING ------------------------------------------- */
protected def skip() {
var nparens = 0
@@ -326,7 +326,7 @@ trait Parsers extends NewScanners with MarkupParsers {
def errorTermTree = Literal(Constant(null)).setPos((inCurrentPos))
def errorPatternTree = Ident(nme.WILDCARD).setPos((inCurrentPos))
-/////// TOKEN CLASSES //////////////////////////////////////////////////////
+/* -------- TOKEN CLASSES ------------------------------------------- */
def isModifier: Boolean = inToken match {
case ABSTRACT | FINAL | SEALED | PRIVATE | PROTECTED | OVERRIDE | IMPLICIT | LAZY => true
@@ -374,7 +374,7 @@ trait Parsers extends NewScanners with MarkupParsers {
def isStatSep: Boolean = isStatSep(inToken)
-/////// COMMENT AND ATTRIBUTE COLLECTION //////////////////////////////////////
+/* -------- COMMENT AND ATTRIBUTE COLLECTION ------------------------------------------- */
/** Join the comment associated with a definition
*/
@@ -384,7 +384,7 @@ trait Parsers extends NewScanners with MarkupParsers {
else trees
}
-/////// TREE CONSTRUCTION ////////////////////////////////////////////////////
+/* -------- TREE CONSTRUCTION ------------------------------------------- */
/** Convert tree to formal parameter list
*/
@@ -448,7 +448,7 @@ trait Parsers extends NewScanners with MarkupParsers {
Function(List(makeSyntheticParam(pname)), insertParam(tree))
}
-/////// OPERAND/OPERATOR STACK /////////////////////////////////////////////////
+/* -------- OPERAND/OPERATOR STACK ------------------------------------------- */
var opstack: List[OpInfo] = Nil
@@ -499,7 +499,7 @@ trait Parsers extends NewScanners with MarkupParsers {
top
}
-/////// IDENTIFIERS AND LITERALS ////////////////////////////////////////////////////////////
+/* -------- IDENTIFIERS AND LITERALS ------------------------------------------- */
def ident(): Name =
@@ -659,7 +659,7 @@ trait Parsers extends NewScanners with MarkupParsers {
if (inToken == NEWLINE && p(inNextTokenCode)) newLineOpt()
}
-//////// TYPES ///////////////////////////////////////////////////////////////
+/* -------- TYPES ------------------------------------------- */
/** TypedOpt ::= [`:' Type]
*/
@@ -900,7 +900,7 @@ trait Parsers extends NewScanners with MarkupParsers {
typ()
}
-//////// EXPRESSIONS ////////////////////////////////////////////////////////
+/* -------- EXPRESSIONS ------------------------------------------- */
/** EqualsExpr ::= `=' Expr
*/
@@ -1317,7 +1317,7 @@ trait Parsers extends NewScanners with MarkupParsers {
}
//def p2i(pos : ScanPosition) : Int;
-//////// PATTERNS ////////////////////////////////////////////////////////////
+/* -------- PATTERNS ------------------------------------------- */
/** Patterns ::= Pattern { `,' Pattern }
* SeqPatterns ::= SeqPattern { `,' SeqPattern }
@@ -1493,7 +1493,7 @@ trait Parsers extends NewScanners with MarkupParsers {
ps
}
-////////// MODIFIERS and ANNOTATIONS /////////////////////////////////////////////////
+/* -------- MODIFIERS and ANNOTATIONS ------------------------------------------- */
private def normalize(mods: Modifiers): Modifiers =
if ((mods hasFlag Flags.PRIVATE) && mods.privateWithin != nme.EMPTY.toTypeName)
@@ -1629,7 +1629,7 @@ trait Parsers extends NewScanners with MarkupParsers {
Annotation(constr, nameValuePairs) setPos pos
}
-//////// PARAMETERS //////////////////////////////////////////////////////////
+/* -------- PARAMETERS ------------------------------------------- */
/** ParamClauses ::= {ParamClause} [[nl] `(' implicit Params `)']
* ParamClause ::= [nl] `(' [Params] ')'
@@ -1807,7 +1807,7 @@ trait Parsers extends NewScanners with MarkupParsers {
if (inToken == tok) { inNextToken; typ() }
else scalaDot(default.toTypeName)
-//////// DEFS ////////////////////////////////////////////////////////////////
+/* -------- DEFS ------------------------------------------- */
/** Import ::= import ImportExpr {`,' ImportExpr}
@@ -2141,7 +2141,7 @@ trait Parsers extends NewScanners with MarkupParsers {
/** TmplDef ::= [case] class ClassDef
* | [case] object ObjectDef
- * | trait TraitDef
+ * | [override] trait TraitDef
*/
def tmplDef(mods: Modifiers): Tree = {
if (mods.hasFlag(Flags.LAZY)) syntaxError("classes cannot be lazy", false)
@@ -2185,7 +2185,8 @@ trait Parsers extends NewScanners with MarkupParsers {
if (mods.hasFlag(Flags.TRAIT)) (Modifiers(Flags.TRAIT), List())
else (accessModifierOpt(), paramClauses(name, implicitClassViews, mods.hasFlag(Flags.CASE)))
val thistpe = requiresTypeOpt()
- var mods1 = if (inToken == SUBTYPE) mods | Flags.DEFERRED else mods
+ var mods1 = if (mods.hasFlag( Flags.TRAIT )) if (inToken == SUBTYPE) mods | Flags.DEFERRED else mods
+ else if (inToken == SUBTYPE) { syntaxError("classes are not allowed to be virtual", false); mods } else mods
var template = templateOpt(mods1, name, constrMods withAnnotations constrAnnots, vparamss)
if (!thistpe.isEmpty) {
if (template.self.isEmpty) {
@@ -2267,9 +2268,9 @@ trait Parsers extends NewScanners with MarkupParsers {
def isInterface(mods: Modifiers, body: List[Tree]) =
(mods.hasFlag(Flags.TRAIT) && (body forall treeInfo.isInterfaceMember))
- /** ClassTemplateOpt ::= Extends ClassTemplate | [[Extends] TemplateBody]
- * TraitTemplateOpt ::= Extends TraitTemplate | [[Extends] TemplateBody]
- * Extends ::= extends | `<:'
+ /** ClassTemplateOpt ::= 'extends' ClassTemplate | [['extends'] TemplateBody]
+ * TraitTemplateOpt ::= TraitExtends TraitTemplate | [['extends'] TemplateBody] | '<:' TemplateBody
+ * TraitExtends ::= 'extends' | `<:'
*/
def templateOpt(mods: Modifiers, name: Name, constrMods: Modifiers, vparamss: List[List[ValDef]]): Template = {
val pos = inCurrentPos;
@@ -2277,7 +2278,10 @@ trait Parsers extends NewScanners with MarkupParsers {
if (inToken == EXTENDS || settings.Xexperimental.value && (mods hasFlag Flags.TRAIT) && inToken == SUBTYPE) {
inNextToken
template(mods hasFlag Flags.TRAIT)
- } else {
+ } else if ((inToken == SUBTYPE) && (mods hasFlag Flags.TRAIT)) {
+ inNextToken
+ template(true)
+ } else {
newLineOptWhenFollowedBy(LBRACE)
val (self, body) = templateBodyOpt(false)
(List(), List(List()), self, body)
@@ -2296,7 +2300,7 @@ trait Parsers extends NewScanners with MarkupParsers {
// if (pos == inCurrentPos || inIDE) tree else atPos(pos) {tree}
}
-////////// TEMPLATES ////////////////////////////////////////////////////////////
+/* -------- TEMPLATES ------------------------------------------- */
/** TemplateBody ::= [nl] `{' TemplateStatSeq `}'
* @param isPre specifies whether in early initializer (true) or not (false)
@@ -2328,7 +2332,7 @@ trait Parsers extends NewScanners with MarkupParsers {
body
}
-/////// STATSEQS //////////////////////////////////////////////////////////////
+/* -------- STATSEQS ------------------------------------------- */
/** Packaging ::= package QualId [nl] `{' TopStatSeq `}'
*/
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index 3da23547af..9e2edfab64 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -44,7 +44,7 @@ trait Definitions {
var NullClass: Symbol = _
var NothingClass: Symbol = _
var SingletonClass: Symbol = _
- lazy val uncheckedStableClass = getClass("scala.uncheckedStable") // todo: move to annotation.unchecked
+ lazy val uncheckedStableClass = getClass("scala.annotation.unchecked.uncheckedStable")
lazy val uncheckedVarianceClass = getClass("scala.annotation.unchecked.uncheckedVariance")
lazy val ClassClass: Symbol = getClass(sn.Class)
diff --git a/src/compiler/scala/tools/nsc/symtab/Flags.scala b/src/compiler/scala/tools/nsc/symtab/Flags.scala
index 4d4bb4c70f..c387feefea 100644
--- a/src/compiler/scala/tools/nsc/symtab/Flags.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Flags.scala
@@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2007 LAMP/EPFL
+ * Copyright 2005-2008 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@@ -9,22 +9,23 @@ package scala.tools.nsc.symtab
object Flags extends Enumeration {
// modifiers
- final val IMPLICIT = 0x00000001
- final val FINAL = 0x00000002
+ final val IMPLICIT = 0x00000200
+ final val FINAL = 0x00000020
final val PRIVATE = 0x00000004
- final val PROTECTED = 0x00000008
+ final val PROTECTED = 0x00000001
- final val SEALED = 0x00000010
- final val OVERRIDE = 0x00000020
- final val CASE = 0x00000040
- final val ABSTRACT = 0x00000080 // abstract class, or used in conjunction
+ final val SEALED = 0x00000400
+ final val OVERRIDE = 0x00000002
+ final val CASE = 0x00000800
+ final val ABSTRACT = 0x00000008 // abstract class, or used in conjunction
// with abstract override.
// Note difference to DEFERRED!
- final val DEFERRED = 0x00000100 // was `abstract' for members
- final val METHOD = 0x00000200 // a method
- final val MODULE = 0x00000400 // symbol is module or class implementing a module
- final val INTERFACE = 0x00000800 // symbol is an interface (i.e. a trait which defines only abstract methods)
+ final val DEFERRED = 0x00000010 // was `abstract' for members | trait is virtual
+ final val METHOD = 0x00000040 // a method
+ final val MODULE = 0x00000100 // symbol is module or class implementing a module
+ final val INTERFACE = 0x00000080 // symbol is an interface (i.e. a trait which defines only abstract methods)
+
final val MUTABLE = 0x00001000 // symbol is a mutable variable.
final val PARAM = 0x00002000 // symbol is a (value or type) parameter to a method
@@ -80,11 +81,11 @@ object Flags extends Enumeration {
final val LOCKED = 0x8000000000L // temporary flag to catch cyclic dependencies
- final val InitialFlags = 0x000000FFFFFFFFFFL // flags that are enabled from phase 1.
- final val LateFlags = 0x000FFF0000000000L // flags that override flags in 0xFFF.
- final val AntiFlags = 0x7FF0000000000000L // flags that cancel flags in 0x7FF
- final val LateShift = 40L
- final val AntiShift = 52L
+ final val InitialFlags = 0x0001FFFFFFFFFFFFL // flags that are enabled from phase 1.
+ final val LateFlags = 0x00FE000000000000L // flags that override flags in 0x1FC.
+ final val AntiFlags = 0x7F00000000000000L // flags that cancel flags in 0x07F
+ final val LateShift = 47L
+ final val AntiShift = 56L
// late flags (set by a transformer phase)
final val latePRIVATE = (PRIVATE: Long) << LateShift
@@ -104,6 +105,118 @@ object Flags extends Enumeration {
final val notMETHOD = (METHOD: Long) << AntiShift
+ // The flags from 0x001 to 0x800 are different in the raw flags
+ // and in the pickled format.
+
+ private final val IMPLICIT_PKL = 0x00000001
+ private final val FINAL_PKL = 0x00000002
+ private final val PRIVATE_PKL = 0x00000004
+ private final val PROTECTED_PKL = 0x00000008
+
+ private final val SEALED_PKL = 0x00000010
+ private final val OVERRIDE_PKL = 0x00000020
+ private final val CASE_PKL = 0x00000040
+ private final val ABSTRACT_PKL = 0x00000080
+
+ private final val DEFERRED_PKL = 0x00000100
+ private final val METHOD_PKL = 0x00000200
+ private final val MODULE_PKL = 0x00000400
+ private final val INTERFACE_PKL = 0x00000800
+
+ private final val PKL_MASK = 0x00000FFF
+
+
+ private val r2p = {
+ def rawFlagsToPickledAux(flags:Int) = {
+ var pflags=0
+ if ((flags & IMPLICIT )!=0) pflags|=IMPLICIT_PKL
+ if ((flags & FINAL )!=0) pflags|=FINAL_PKL
+ if ((flags & PRIVATE )!=0) pflags|=PRIVATE_PKL
+ if ((flags & PROTECTED)!=0) pflags|=PROTECTED_PKL
+ if ((flags & SEALED )!=0) pflags|=SEALED_PKL
+ if ((flags & OVERRIDE )!=0) pflags|=OVERRIDE_PKL
+ if ((flags & CASE )!=0) pflags|=CASE_PKL
+ if ((flags & ABSTRACT )!=0) pflags|=ABSTRACT_PKL
+ if ((flags & DEFERRED )!=0) pflags|=DEFERRED_PKL
+ if ((flags & METHOD )!=0) pflags|=METHOD_PKL
+ if ((flags & MODULE )!=0) pflags|=MODULE_PKL
+ if ((flags & INTERFACE)!=0) pflags|=INTERFACE_PKL
+ pflags
+ }
+ val v=new Array[Int](PKL_MASK+1)
+ var i=0
+ while (i<=PKL_MASK) {
+ v(i)=rawFlagsToPickledAux(i)
+ i+=1
+ }
+ v
+ }
+
+ private val p2r = {
+ def pickledToRawFlagsAux(pflags:Int) = {
+ var flags=0
+ if ((pflags & IMPLICIT_PKL )!=0) flags|=IMPLICIT
+ if ((pflags & FINAL_PKL )!=0) flags|=FINAL
+ if ((pflags & PRIVATE_PKL )!=0) flags|=PRIVATE
+ if ((pflags & PROTECTED_PKL)!=0) flags|=PROTECTED
+ if ((pflags & SEALED_PKL )!=0) flags|=SEALED
+ if ((pflags & OVERRIDE_PKL )!=0) flags|=OVERRIDE
+ if ((pflags & CASE_PKL )!=0) flags|=CASE
+ if ((pflags & ABSTRACT_PKL )!=0) flags|=ABSTRACT
+ if ((pflags & DEFERRED_PKL )!=0) flags|=DEFERRED
+ if ((pflags & METHOD_PKL )!=0) flags|=METHOD
+ if ((pflags & MODULE_PKL )!=0) flags|=MODULE
+ if ((pflags & INTERFACE_PKL)!=0) flags|=INTERFACE
+ flags
+ }
+ val v=new Array[Int](PKL_MASK+1)
+ var i=0
+ while (i<=PKL_MASK) {
+ v(i)=pickledToRawFlagsAux(i)
+ i+=1
+ }
+ v
+ }
+
+ def rawFlagsToPickled(flags:Long):Long =
+ (flags & ~PKL_MASK) | r2p(flags.toInt & PKL_MASK)
+
+ def pickledToRawFlags(pflags:Long):Long =
+ (pflags & ~PKL_MASK) | p2r(pflags.toInt & PKL_MASK)
+
+ // List of the raw flags, in pickled order
+ private val pickledListOrder = {
+ def findBit(m:Long):Int = {
+ var mask=m
+ var i=0
+ while (i <= 62) {
+ if ((mask&1) == 1) return i
+ mask >>= 1
+ i += 1
+ }
+ throw new FatalError("Internal error: mask is zero")
+ }
+ val v=new Array[Long](63)
+ v(findBit(IMPLICIT_PKL ))=IMPLICIT
+ v(findBit(FINAL_PKL ))=FINAL
+ v(findBit(PRIVATE_PKL ))=PRIVATE
+ v(findBit(PROTECTED_PKL))=PROTECTED
+ v(findBit(SEALED_PKL ))=SEALED
+ v(findBit(OVERRIDE_PKL ))=OVERRIDE
+ v(findBit(CASE_PKL ))=CASE
+ v(findBit(ABSTRACT_PKL ))=ABSTRACT
+ v(findBit(DEFERRED_PKL ))=DEFERRED
+ v(findBit(METHOD_PKL ))=METHOD
+ v(findBit(MODULE_PKL ))=MODULE
+ v(findBit(INTERFACE_PKL))=INTERFACE
+ var i=findBit(PKL_MASK+1)
+ while (i <= 62) {
+ v(i)=1L << i
+ i += 1
+ }
+ v.toList
+ }
+
// masks
/** This flags can be set when class or module symbol is first created. */
final val TopLevelCreationFlags: Long =
@@ -134,7 +247,7 @@ object Flags extends Enumeration {
ss.filter("" !=).mkString("", " ", "")
def flagsToString(flags: Long): String =
- listToString(for (i <- List.range(0, 63)) yield flagToString(flags & (1L << i)))
+ listToString(for (mask <- pickledListOrder) yield flagToString(flags & mask))
def flagsToString(flags: Long, privateWithin: String): String = {
var f = flags
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 81a4258b06..85e19a2b6b 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -976,6 +976,7 @@ trait Types {
underlyingCache
}
+ override def isVolatile : Boolean = underlying.isVolatile && (!sym.isStable)
/*
override def narrow: Type = {
if (phase.erasedTypes) this
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
index c318c08ffb..1d1dc2e857 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2007 LAMP/EPFL
+ * Copyright 2005-2008 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@@ -470,7 +470,7 @@ abstract class Pickler extends SubComponent {
var posOffset = 0
writeRef(sym.name)
writeRef(normalizedOwner(sym))
- writeNat((sym.flags & PickledFlags).asInstanceOf[Int])
+ writeNat((rawFlagsToPickled(sym.flags & PickledFlags)).asInstanceOf[Int])
if (sym.privateWithin != NoSymbol) writeRef(sym.privateWithin)
writeRef(sym.info)
posOffset
@@ -917,8 +917,9 @@ abstract class Pickler extends SubComponent {
case Modifiers(flags, privateWithin, annotations) =>
- writeNat((flags >> 32).toInt)
- writeNat((flags & 0xFFFFFFFF).toInt)
+ val pflags = rawFlagsToPickled(flags)
+ writeNat((pflags >> 32).toInt)
+ writeNat((pflags & 0xFFFFFFFF).toInt)
writeRef(privateWithin)
writeRefs(annotations)
MODIFIERS
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
index 625dd820ed..76aa52b306 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
@@ -182,7 +182,7 @@ abstract class UnPickler {
}
val name = readNameRef()
val owner = readSymbolRef()
- val flags = readNat()
+ val flags = pickledToRawFlags(readNat())
var privateWithin: Symbol = NoSymbol
var inforef = readNat()
if (isSymbolRef(inforef)) {
@@ -701,9 +701,10 @@ abstract class UnPickler {
if (tag != MODIFIERS)
errorBadSignature("expected a modifiers tag (" + tag + ")")
val end = readNat() + readIndex
- val flagsHi = readNat()
- val flagsLo = readNat()
- val flags = (flagsHi.toLong << 32) + flagsLo
+ val pflagsHi = readNat()
+ val pflagsLo = readNat()
+ val pflags = (pflagsHi.toLong << 32) + pflagsLo
+ val flags = pickledToRawFlags(pflags)
val privateWithin = readNameRef()
val annotations = until(end, readAnnotationTreeRef)
Modifiers(flags, privateWithin, annotations)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 54ddcdb25d..d3f6689b6e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2007 LAMP/EPFL
+ * Copyright 2005-2008 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@@ -935,6 +935,7 @@ trait Namers { self: Analyzer =>
Flags.flagsToString(flag1) + " and " + Flags.flagsToString(flag2) +
" for: " + sym + Flags.flagsToString(sym.rawflags));
}
+
if (sym.hasFlag(IMPLICIT) && !sym.isTerm)
context.error(sym.pos, "`implicit' modifier can be used only for values, variables and methods")
if (sym.hasFlag(IMPLICIT) && sym.owner.isPackageClass && !inIDE)
@@ -942,7 +943,7 @@ trait Namers { self: Analyzer =>
if (sym.hasFlag(ABSTRACT) && !sym.isClass)
context.error(sym.pos, "`abstract' modifier can be used only for classes; " +
"\nit should be omitted for abstract members")
- if (sym.hasFlag(OVERRIDE | ABSOVERRIDE) && sym.isClass)
+ if (sym.hasFlag(OVERRIDE | ABSOVERRIDE) && !sym.hasFlag(TRAIT) && sym.isClass)
context.error(sym.pos, "`override' modifier not allowed for classes")
if (sym.hasFlag(OVERRIDE | ABSOVERRIDE) && sym.isConstructor)
context.error(sym.pos, "`override' modifier not allowed for constructors")
@@ -964,11 +965,12 @@ trait Namers { self: Analyzer =>
sym.resetFlag(DEFERRED)
}
}
+
checkNoConflict(DEFERRED, PRIVATE)
checkNoConflict(FINAL, SEALED)
checkNoConflict(PRIVATE, PROTECTED)
checkNoConflict(PRIVATE, OVERRIDE)
- //checkNoConflict(PRIVATE, FINAL) // can't do this because FINAL also means compile-time constant
+ /* checkNoConflict(PRIVATE, FINAL) // can't do this because FINAL also means compile-time constant */
checkNoConflict(DEFERRED, FINAL)
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index e18b3f6130..d1f0edc7c1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -134,7 +134,7 @@ abstract class RefChecks extends InfoTransform {
def overrideError(msg: String) {
if (other.tpe != ErrorType && member.tpe != ErrorType)
- unit.error(pos, "error overriding " + infoStringWithLocation(other) +
+ unit.error(pos, "overriding " + infoStringWithLocation(other) +
";\n " + infoString(member) + " " + msg +
(if ((other.owner isSubClass member.owner) &&
other.isDeferred && !member.isDeferred)
@@ -146,7 +146,7 @@ abstract class RefChecks extends InfoTransform {
def overrideTypeError() {
if (other.tpe != ErrorType && member.tpe != ErrorType) {
- overrideError("has incompatible type "+analyzer.underlying(member).tpe.normalize)
+ overrideError("has incompatible type")
}
}
@@ -455,8 +455,9 @@ abstract class RefChecks extends InfoTransform {
case ExistentialType(tparams, result) =>
validateVariances(tparams map (_.info), variance)
validateVariance(result, variance)
- case AnnotatedType(attribs, tp, selfsym) =>
- validateVariance(tp, variance)
+ case AnnotatedType(annots, tp, selfsym) =>
+ if (!(annots exists (_.atp.typeSymbol.isNonBottomSubClass(uncheckedVarianceClass))))
+ validateVariance(tp, variance)
}
def validateVariances(tps: List[Type], variance: Int) {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 3ca63f55d9..209760a66e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1033,7 +1033,8 @@ trait Typers { self: Analyzer =>
}
if (!(selfType <:< parent.tpe.typeOfThis) &&
!phase.erasedTypes &&
- !(context.owner hasFlag SYNTHETIC)) // don't do this check for synthetic concrete classes for virtuals (part of DEVIRTUALIZE)
+ !(context.owner hasFlag SYNTHETIC) && // don't do this check for synthetic concrete classes for virtuals (part of DEVIRTUALIZE)
+ !(settings.suppressVTWarn.value))
{
//Console.println(context.owner);//DEBUG
//Console.println(context.owner.unsafeTypeParams);//DEBUG
@@ -3344,7 +3345,7 @@ trait Typers { self: Analyzer =>
tree.tpe = null
if (tree.hasSymbol) tree.symbol = NoSymbol
}
- if (printTypings) println("typing "+tree+", "+context.undetparams+(mode & TYPEPATmode));//DEBUG
+ if (printTypings) println("typing "+tree+", "+context.undetparams+(mode & TYPEPATmode)); //DEBUG
def dropExistential(tp: Type): Type = tp match {
case ExistentialType(tparams, tpe) =>
if (settings.debug.value) println("drop ex "+tree+" "+tp)
@@ -3356,12 +3357,12 @@ trait Typers { self: Analyzer =>
case _ => tp
}
var tree1 = if (tree.tpe ne null) tree else typed1(tree, mode, dropExistential(pt))
- if (printTypings) println("typed "+tree1+":"+tree1.tpe+", "+context.undetparams+", pt = "+pt);//DEBUG
+ if (printTypings) println("typed "+tree1+":"+tree1.tpe+", "+context.undetparams+", pt = "+pt); //DEBUG
tree1.tpe = addAnnotations(tree1, tree1.tpe)
val result = if (tree1.isEmpty || (inIDE && tree1.tpe == null)) tree1 else adapt(tree1, mode, pt)
- if (printTypings) println("adapted "+tree1+":"+tree1.tpe+" to "+pt+", "+context.undetparams);//DEBUG
+ if (printTypings) println("adapted "+tree1+":"+tree1.tpe+" to "+pt+", "+context.undetparams); //DEBUG
// if ((mode & TYPEmode) != 0) println("type: "+tree1+" has type "+tree1.tpe)
result
} catch {
diff --git a/src/compiler/scala/tools/nsc/util/ShowPickled.scala b/src/compiler/scala/tools/nsc/util/ShowPickled.scala
index 3000e6d61a..7cbc21b814 100644
--- a/src/compiler/scala/tools/nsc/util/ShowPickled.scala
+++ b/src/compiler/scala/tools/nsc/util/ShowPickled.scala
@@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2007 LAMP/EPFL
+ * Copyright 2005-2008 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@@ -84,9 +84,9 @@ object ShowPickled extends Names {
def printSymInfo() {
printNameRef()
printSymbolRef()
- val flags = buf.readNat()
- out.print(" " + toHexString(flags) +
- "[" + Flags.flagsToString(flags) + "] ")
+ val pflags = buf.readNat()
+ out.print(" " + toHexString(pflags) +
+ "[" + Flags.flagsToString(Flags.pickledToRawFlags(pflags)) + "] ")
printTypeRef()
}