diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2007-01-29 14:03:26 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2007-01-29 14:03:26 +0000 |
commit | 5833fcd8c74b8aae30b47529f0936b4880321a74 (patch) | |
tree | 9036dfbafe86c4cf744f9a948e49d44c158e64c8 /src/compiler | |
parent | d684e5c0717e8cd3389fc0bc810e26ac8f765d0e (diff) | |
download | scala-5833fcd8c74b8aae30b47529f0936b4880321a74.tar.gz scala-5833fcd8c74b8aae30b47529f0936b4880321a74.tar.bz2 scala-5833fcd8c74b8aae30b47529f0936b4880321a74.zip |
Fixed crash for 'return' in finally
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 03848e7439..49d94f5ff7 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -76,10 +76,10 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable val global: Global.this.type = Global.this } -/* object icodeReader extends ICodeReader { + object icodeReader extends ICodeReader { val global: Global.this.type = Global.this } -*/ + object analysis extends TypeFlowAnalysis { val global: Global.this.type = Global.this } @@ -551,7 +551,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable if (settings.Xscript.value && filenames.length != 1) error("can only compile one script at a time") val sources = filenames map ( - if (settings.Xscript.value) {x => ScriptRunner.wrappedScript(x, &Global.this.getSourceFile)} else getSourceFile) + /* if (settings.Xscript.value) {x => ScriptRunner.wrappedScript(x, &Global.this.getSourceFile)} else */ getSourceFile) compileSources(sources) } catch { case ex: IOException => error(ex.getMessage()) @@ -650,7 +650,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable val posConfig : PositionConfiguration = positionConfiguration; posConfig.FirstPos.asInstanceOf[PositionType]; } - final val NoPos = positionConfiguration.NoPos + final def NoPos = positionConfiguration.NoPos final def coerceIntToPos(pos: Int): PositionType = positionConfiguration.coerceIntToPos(pos) implicit final def coercePosToInt(pos: PositionType): Int = diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index b2208a89cc..a30d1f1d38 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -460,7 +460,11 @@ abstract class GenICode extends SubComponent { ctx1.bb.emit(LOAD_LOCAL(m)) ctx1.bb.emit(MONITOR_EXIT()) case Finalizer(f) => - ctx1 = genLoad(f, ctx1, UNIT) + // we have to run this without the same finalizer in + // the list, otherwise infinite recursion happens for + // finalizers that contain 'return' + ctx1 = genLoad(f, ctx1.removeFinalizer(f), UNIT) + ctx1.addFinalizer(f) } ctx1.bb.emit(RETURN(returnedKind), tree.pos) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 3b3c02ce5b..a90472d56b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2450,7 +2450,7 @@ trait Typers requires Analyzer { val best = (NoImplicitInfo /: applicable) ((best, alt) => if (improves(alt, best)) alt else best) if (best == NoImplicitInfo) EmptyTree else { - val competing = applicable dropWhile (alt => best == alt || improves(best, alt)) + val competing = applicable dropWhile (alt => best == alt || improves(best, alt) || alt.sym.owner == PredefModule.moduleClass) if (!competing.isEmpty) ambiguousImplicitError(best, competing.head, "both", "and", "") for (val alt <- applicable) if (alt.sym.owner != best.sym.owner && isSubClassOrObject(alt.sym.owner, best.sym.owner)) { |