From 8de176f454d1e365b1297de21a0ed4a45c04a87f Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 31 Oct 2011 16:37:59 +0000 Subject: Clean result of function type. NullaryMethodType was escaping. Closes SI-5099, review by moors. --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 +- test/files/pos/t5099.scala | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/files/pos/t5099.scala diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index f9c5e843b1..89eb6f2e91 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1993,7 +1993,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { // } var body = typed(fun.body, respt) val formals = vparamSyms map (_.tpe) - val restpe = packedType(body, fun.symbol).deconst + val restpe = packedType(body, fun.symbol).deconst.resultType val funtpe = typeRef(clazz.tpe.prefix, clazz, formals :+ restpe) // body = checkNoEscaping.locals(context.scope, restpe, body) val fun1 = treeCopy.Function(fun, vparams, body).setType(funtpe) diff --git a/test/files/pos/t5099.scala b/test/files/pos/t5099.scala new file mode 100644 index 0000000000..178151259f --- /dev/null +++ b/test/files/pos/t5099.scala @@ -0,0 +1,14 @@ +class LazyValVsFunctionType[a] { + val f: a => a = x => { + lazy val _x: a = throw new java.lang.Error("todo") + _x // error: type mismatch +/* +[error] found : a => => a +[error] required: a => a +[error] val f: a => a = x => { +[error] ^ +[error] one error found +*/ + // _x: a // ok + } +} \ No newline at end of file -- cgit v1.2.3