diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-11-24 15:36:20 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-11-24 15:36:20 +0100 |
commit | c52ffd7c9cb189f168470b9004cfb2dd554e3cc8 (patch) | |
tree | 19dd9714d81372094156fa2ee6f3ec6654e62b1a /compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala | |
parent | 08e17339a36a8dddb65c35a23fa045d4af1b67b1 (diff) | |
download | dotty-c52ffd7c9cb189f168470b9004cfb2dd554e3cc8.tar.gz dotty-c52ffd7c9cb189f168470b9004cfb2dd554e3cc8.tar.bz2 dotty-c52ffd7c9cb189f168470b9004cfb2dd554e3cc8.zip |
Make `findTypes` take the `resultType` of `MethodType`
This is done so that we can use show for the entire method except for
the ascribed type added by the compiler on success.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala b/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala index 00f24845e..f269fef64 100644 --- a/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala +++ b/compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala @@ -443,7 +443,10 @@ class CompilingInterpreter( } // the types are all =>T; remove the => - val cleanedType = rawType.widenExpr + val cleanedType = rawType.widenExpr match { + case tp: MethodType => tp.resultType + case tp => tp + } map + (name -> ctx.atPhase(ctx.typerPhase.next) { implicit ctx => @@ -747,19 +750,21 @@ class CompilingInterpreter( * @see `def findTypes` for an explanation of what should be done */ if (!defDef.mods.is(Flags.AccessFlags)) { + // Take the DefDef and remove the `rhs` and ascribed type `tpt` + val copy = ast.untpd.cpy.DefDef(defDef)( + rhs = EmptyTree, + tpt = TypeTree + ) + val tpt = defDef.tpt match { // ascribed TypeExpr e.g: `def foo: Int = 5` case Ident(tpt) if defDef.vparamss.isEmpty => ": " + tpt.show - // inferred TypeExpr e.g: `def foo = 5` - case tpt if defDef.vparamss.isEmpty => + case tpt => ": " + req.typeOf(defDef.name) - // Inferred or ascribed MethodType with parameter list - case _ => - req.typeOf(defDef.name) } code.print { - "+\"def " + string2code(defDef.name.toString) + tpt + "\\n\"" + "+\"" + string2code(copy.show) + tpt + "\\n\"" } } } |