summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-08-11 14:15:52 +0000
committerMartin Odersky <odersky@gmail.com>2008-08-11 14:15:52 +0000
commit021fa2b31d07b327dd106a1d01f37b332f140a5d (patch)
tree080239b774d37d9f05c4fe0c1a9d6e1d8fbaf522
parentc84ba7f665c8d860da4de1b5a01e2b0a2d9f742b (diff)
downloadscala-021fa2b31d07b327dd106a1d01f37b332f140a5d.tar.gz
scala-021fa2b31d07b327dd106a1d01f37b332f140a5d.tar.bz2
scala-021fa2b31d07b327dd106a1d01f37b332f140a5d.zip
fixed #1196, #1197, #1203
-rwxr-xr-xsrc/compiler/scala/tools/nsc/javac/JavaParsers.scala17
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala6
-rw-r--r--src/compiler/scala/tools/nsc/util/SourceFile.scala5
3 files changed, 17 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
index 491d1d717e..000a90cb5b 100755
--- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
@@ -35,7 +35,7 @@ trait JavaParsers extends JavaScanners {
protected def posToReport: Int = in.p2g(in.currentPos)
protected def freshName(pos : Position, prefix : String): Name
protected implicit def i2p(offset : Int) : Position
- private implicit def p2i(pos : Position) = pos.offset.getOrElse(-1)
+ private implicit def p2i(pos : Position): Int = pos.offset.getOrElse(-1)
/** The simple name of the package of the currently parsed file */
private var thisPackageName: Name = nme.EMPTY
@@ -489,8 +489,6 @@ trait JavaParsers extends JavaScanners {
def termDecl(mods: Modifiers, parentToken: Int): List[Tree] = {
val inInterface = parentToken == INTERFACE || parentToken == AT
- var mods1 = mods
- if ((mods hasFlag Flags.ABSTRACT) || inInterface) mods1 = mods &~ Flags.ABSTRACT | Flags.DEFERRED
val tparams = if (in.token == LT) typeParams() else List()
val isVoid = in.token == VOID
var rtpt =
@@ -509,10 +507,12 @@ trait JavaParsers extends JavaScanners {
optThrows()
List {
atPos(pos) {
- DefDef(mods1, nme.CONSTRUCTOR, tparams, List(vparams), TypeTree(), methodBody())
+ DefDef(mods, nme.CONSTRUCTOR, tparams, List(vparams), TypeTree(), methodBody())
}
}
} else {
+ var mods1 = mods
+ if (mods hasFlag Flags.ABSTRACT) mods1 = mods &~ Flags.ABSTRACT | Flags.DEFERRED
pos = in.currentPos
val name = ident()
if (in.token == LPAREN) {
@@ -540,6 +540,7 @@ trait JavaParsers extends JavaScanners {
EmptyTree
}
}
+ if (inInterface) mods1 |= Flags.DEFERRED
List {
atPos(pos) {
DefDef(mods1, name, tparams, List(vparams), rtpt, body)
@@ -723,8 +724,12 @@ trait JavaParsers extends JavaScanners {
} else if (in.token == SEMI) {
in.nextToken
} else {
- if (in.token == ENUM) mods |= Flags.STATIC
- (if (mods hasFlag Flags.STATIC) statics else members) ++= memberDecl(mods, parentToken)
+ if (in.token == ENUM || in.token == INTERFACE) mods |= Flags.STATIC
+ val decls = memberDecl(mods, parentToken)
+ (if ((mods hasFlag Flags.STATIC) || inInterface && !(decls exists (_.isInstanceOf[DefDef])))
+ statics
+ else
+ members) ++= decls
}
}
(statics.toList, members.toList)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index c64aa4c36c..014676199f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -692,8 +692,10 @@ trait Typers { self: Analyzer =>
if (tree.isType) {
if ((mode & FUNmode) != 0) {
tree
- } else if (tree.hasSymbol && !tree.symbol.typeParams.isEmpty && (mode & HKmode) == 0) { // (7)
- // @M When not typing a higher-kinded type ((mode & HKmode) == 0), types must be of kind *,
+ } else if (tree.hasSymbol && !tree.symbol.typeParams.isEmpty && (mode & HKmode) == 0 &&
+ !(tree.symbol.hasFlag(JAVA) && context.unit.isJava)) { // (7)
+ // @M When not typing a higher-kinded type ((mode & HKmode) == 0)
+ // or raw type (tree.symbol.hasFlag(JAVA) && context.unit.isJava), types must be of kind *,
// and thus parameterised types must be applied to their type arguments
// @M TODO: why do kind-* tree's have symbols, while higher-kinded ones don't?
errorTree(tree, tree.symbol+" takes type parameters")
diff --git a/src/compiler/scala/tools/nsc/util/SourceFile.scala b/src/compiler/scala/tools/nsc/util/SourceFile.scala
index 315d3ad445..32e3d5768c 100644
--- a/src/compiler/scala/tools/nsc/util/SourceFile.scala
+++ b/src/compiler/scala/tools/nsc/util/SourceFile.scala
@@ -112,7 +112,7 @@ class BatchSourceFile(val file : AbstractFile, _content : Array[Char]) extends S
def find(toFind: Int, isIndex: Boolean): Int = {
if (toFind == 0) return 0
- if (!isIndex && (toFind >= content.length)) {
+ if (!isIndex && (toFind > content.length)) {
throw new Error(toFind + " not valid offset in " +
file.name + ":" + content.length)
}
@@ -128,7 +128,7 @@ class BatchSourceFile(val file : AbstractFile, _content : Array[Char]) extends S
if (isBackward && offset <= 0)
throw new Error(offset + " " + index + " " + toFind + " " + isIndex);
offset = offset + increment
- if (!isBackward) assert(offset < content.length);
+ if (!isBackward) assert(offset <= content.length);
if (isLineBreak(offset + (if (isBackward) 0 else -1))) {
index = index + increment
@@ -141,7 +141,6 @@ class BatchSourceFile(val file : AbstractFile, _content : Array[Char]) extends S
}
def offsetToLine(offset: Int): Int = line.find(offset, false)
def lineToOffset(index : Int): Int = line.find(index , true)
-
}