lazy vals cannot override strict vals and vice versa; fixed initialization bugs that caused scala and fsc to fail.
git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@15427 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
52ac3661d3
commit
829c6405b4
|
@ -123,10 +123,10 @@ INITIALISATION
|
|||
<condition property="os.win">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<!-- Finding out SVN revision -->
|
||||
<!-- Finding out SVN revision
|
||||
<exec executable="svn" outputproperty="svn.out">
|
||||
<arg line=" info ${basedir}"/>
|
||||
</exec>
|
||||
</exec> -->
|
||||
<propertyregex
|
||||
property="svn.number" input="${svn.out}" select="\1"
|
||||
regexp="Revision: ([0-9]+)"
|
||||
|
|
|
@ -8,8 +8,6 @@ package scala.tools.nsc
|
|||
|
||||
import java.io.{BufferedReader, File, InputStreamReader, PrintWriter}
|
||||
|
||||
import scala.tools.util.StringOps
|
||||
|
||||
/** The client part of the fsc offline compiler. Instead of compiling
|
||||
* things itself, it send requests to a CompileServer.
|
||||
*/
|
||||
|
@ -39,12 +37,12 @@ class StandardCompileClient {
|
|||
val fileEnding = Properties.fileEndingString
|
||||
|
||||
protected def normalize(args: Array[String]): (String, String) = {
|
||||
var i = 0
|
||||
var i = 0
|
||||
val vmArgs = new StringBuilder
|
||||
var serverAdr = ""
|
||||
while (i < args.length) {
|
||||
val arg = args(i)
|
||||
if (arg endsWith fileEnding) {
|
||||
if (fileEnding split ("\\|") exists (arg endsWith _)) {
|
||||
args(i) = absFileName(arg)
|
||||
} else if (arg startsWith "-J") {
|
||||
//see http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/javac.html#J
|
||||
|
|
|
@ -50,6 +50,8 @@ extends CompilerCommand(allargs, settings, error, false)
|
|||
}
|
||||
}
|
||||
|
||||
processArguments()
|
||||
|
||||
override def usageMsg = {
|
||||
cmdName + " [ <option> ]... [<torun> <arguments>]\n" +
|
||||
"\n" +
|
||||
|
|
|
@ -225,9 +225,9 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
|
|||
getSourceFile(ret.sourceFile)
|
||||
}
|
||||
|
||||
val loaders : SymbolLoaders { val global : Global.this.type } = new SymbolLoaders {//change?
|
||||
lazy val global: Global.this.type = Global.this
|
||||
}
|
||||
lazy val loaders : SymbolLoaders { val global : Global.this.type } = new {
|
||||
val global: Global.this.type = Global.this
|
||||
} with SymbolLoaders
|
||||
|
||||
def rootLoader: LazyType =
|
||||
if (forMSIL) new loaders.NamespaceLoader(classPath.root)
|
||||
|
|
|
@ -23,8 +23,9 @@ trait IdeSupport extends Global with symtab.IdeSupport {
|
|||
normalCompile(run.compileSources(source :: Nil))
|
||||
run.units.find(unit => unit.source == source)
|
||||
}
|
||||
object loaders1 extends scala.tools.nsc.symtab.SymbolLoaders {
|
||||
lazy val global : IdeSupport.this.type = IdeSupport.this
|
||||
object loaders1 extends {
|
||||
val global : IdeSupport.this.type = IdeSupport.this
|
||||
} with scala.tools.nsc.symtab.SymbolLoaders {
|
||||
import global._
|
||||
protected override def completeClassfile(root : global.Symbol, loader : ClassfileLoader)(f : => Unit) : Unit =
|
||||
global.normalCompile(f)
|
||||
|
|
|
@ -14,5 +14,5 @@ package scala.tools.nsc
|
|||
class InterpreterCommand(arguments: List[String], error: String => Unit)
|
||||
extends CompilerCommand(arguments, new Settings(error), error, false) {
|
||||
override val cmdName = "scala"
|
||||
override val fileEnding = ".scalaint"
|
||||
override lazy val fileEnding = ".scalaint"
|
||||
}
|
||||
|
|
|
@ -982,6 +982,8 @@ trait Namers { self: Analyzer =>
|
|||
context.error(sym.pos, "`override' modifier not allowed for constructors")
|
||||
if (sym.hasFlag(ABSOVERRIDE) && !sym.owner.isTrait)
|
||||
context.error(sym.pos, "`abstract override' modifier only allowed for members of traits")
|
||||
if (sym.hasFlag(LAZY) && sym.hasFlag(PRESUPER))
|
||||
context.error(sym.pos, "`lazy' definitions may not be initialized early")
|
||||
if (sym.info.typeSymbol == FunctionClass(0) &&
|
||||
sym.isValueParameter && sym.owner.isClass && sym.owner.hasFlag(CASE))
|
||||
context.error(sym.pos, "pass-by-name arguments not allowed for case class parameters");
|
||||
|
|
|
@ -186,9 +186,12 @@ abstract class RefChecks extends InfoTransform {
|
|||
overrideError("cannot override a mutable variable")
|
||||
} else if (other.isStable && !member.isStable) { // (1.4)
|
||||
overrideError("needs to be an immutable value")
|
||||
// } else if (other.isStable && !other.isDeferred && other.owner.isTrait && (member hasFlag OVERRIDE)) {
|
||||
// overrideError("cannot override a value or variable definition in a trait " +
|
||||
// "\n (this is an implementation restriction)")
|
||||
} else if (member.isValue && (member hasFlag LAZY) &&
|
||||
other.isValue && !other.isSourceMethod && !other.isDeferred && !(other hasFlag LAZY)) {
|
||||
overrideError("cannot override a concrete non-lazy value")
|
||||
} else if (other.isValue && (other hasFlag LAZY) && !other.isSourceMethod && !other.isDeferred &&
|
||||
member.isValue && !(member hasFlag LAZY)) {
|
||||
overrideError("must be declared lazy to override a concrete lazy value")
|
||||
} else {
|
||||
if (other.isAliasType) {
|
||||
//if (!member.typeParams.isEmpty) // (1.5) @MAT
|
||||
|
|
|
@ -331,7 +331,8 @@ trait Typers { self: Analyzer =>
|
|||
}
|
||||
|
||||
def checkRegPatOK(pos: Position, mode: Int) =
|
||||
if ((mode & REGPATmode) == 0)
|
||||
if ((mode & REGPATmode) == 0 &&
|
||||
phase.id <= currentRun.typerPhase.id) // fixes t1059
|
||||
error(pos, "no regular expression pattern allowed here\n"+
|
||||
"(regular expression patterns are only allowed in arguments to *-parameters)")
|
||||
|
||||
|
|
|
@ -24,3 +24,23 @@ class Lazy {
|
|||
// no lazy modifiers in class parameters
|
||||
class A(lazy val obj: Object) {}
|
||||
}
|
||||
|
||||
object T2 {
|
||||
class A {
|
||||
val x: Int = { print("/*A.x*/"); 2 }
|
||||
lazy val y: Int = { print("/*A.y*/"); 2 }
|
||||
}
|
||||
|
||||
|
||||
class B extends A {
|
||||
// lazy overrides strict val
|
||||
override lazy val x: Int = { print("/*B.x*/"); 3 }
|
||||
// strict val overrides lazy
|
||||
override val y: Int = { print("/*B.y*/"); 3 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
/*A.x*/a.x=2
|
||||
/*A.x*//*B.y*/b.x=/*B.x*/3
|
||||
a.x=/*A.x*/2
|
||||
b.x=/*B.x*/3
|
||||
b.z=/*B.z/3
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
class A {
|
||||
val x: Int = { print("/*A.x*/"); 2 }
|
||||
lazy val x: Int = { print("/*A.x*/"); 2 }
|
||||
lazy val y: Int = { print("/*A.y*/"); 2 }
|
||||
lazy val z: Int = { print("/*A.z*/"); 2 }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
// lazy overrides strict val
|
||||
override lazy val x: Int = { print("/*B.x*/"); 3 }
|
||||
// strict val overrides lazy
|
||||
override val y: Int = { print("/*B.y*/"); 3 }
|
||||
// lazy overrides lazy
|
||||
override lazy val y: Int = { print("/*B.y*/"); 3 }
|
||||
override lazy val z: Int = { print("/*B.z/"); 3 }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue