diff options
author | Dan Rosen <dr@mergeconflict.com> | 2013-03-02 13:43:30 -0800 |
---|---|---|
committer | Dan Rosen <dr@mergeconflict.com> | 2013-03-02 13:43:30 -0800 |
commit | 1b9c2f51d0fc37b1f2065a2b7c575cbfcd4665cd (patch) | |
tree | 885cdfbcc371c48bd812dde6bd598cfbf76531c7 /src | |
parent | daa9c4114f3698833bfc06f5822bbfaa93b8fbf9 (diff) | |
download | scala-1b9c2f51d0fc37b1f2065a2b7c575cbfcd4665cd.tar.gz scala-1b9c2f51d0fc37b1f2065a2b7c575cbfcd4665cd.tar.bz2 scala-1b9c2f51d0fc37b1f2065a2b7c575cbfcd4665cd.zip |
SI-7132 - don't discard Unit type in interpreter
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala b/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala index b087547cf8..9edd54b939 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala @@ -49,15 +49,13 @@ trait ExprTyper { // Typing it with a lazy val would give us the right type, but runs // into compiler bugs with things like existentials, so we compile it // behind a def and strip the NullaryMethodType which wraps the expr. - val line = "def " + name + " = {\n" + code + "\n}" + val line = "def " + name + " = " + code interpretSynthetic(line) match { case IR.Success => val sym0 = symbolOfTerm(name) // drop NullaryMethodType - val sym = sym0.cloneSymbol setInfo exitingTyper(sym0.info.finalResultType) - if (sym.info.typeSymbol eq UnitClass) NoSymbol - else sym + sym0.cloneSymbol setInfo exitingTyper(sym0.info.finalResultType) case _ => NoSymbol } } @@ -74,7 +72,11 @@ trait ExprTyper { case _ => NoSymbol } } - beQuietDuring(asExpr()) orElse beQuietDuring(asDefn()) + def asError(): Symbol = { + interpretSynthetic(code) + NoSymbol + } + beSilentDuring(asExpr()) orElse beSilentDuring(asDefn()) orElse asError() } private var typeOfExpressionDepth = 0 |