diff options
author | Dan Rosen <dr@mergeconflict.com> | 2013-03-09 12:56:38 -0800 |
---|---|---|
committer | Dan Rosen <dr@mergeconflict.com> | 2013-03-09 12:56:38 -0800 |
commit | eb365f9158f29c61410affde21c8f3cd0c6db08f (patch) | |
tree | 40ab4901cdde27b47125212398106f183ec79167 /src | |
parent | d4b46f6e42c8124c54af56c0a3c1ac39b46b2c52 (diff) | |
download | scala-eb365f9158f29c61410affde21c8f3cd0c6db08f.tar.gz scala-eb365f9158f29c61410affde21c8f3cd0c6db08f.tar.bz2 scala-eb365f9158f29c61410affde21c8f3cd0c6db08f.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 c4a672ac37..827ebe1678 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala @@ -57,15 +57,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 afterTyper(sym0.info.finalResultType) - if (sym.info.typeSymbol eq UnitClass) NoSymbol - else sym + sym0.cloneSymbol setInfo afterTyper(sym0.info.finalResultType) case _ => NoSymbol } } @@ -82,7 +80,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 |