diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 18:09:27 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 18:09:47 +0100 |
commit | c511f89062adfbdbdb2fe6f9a84e3b40b0d10429 (patch) | |
tree | 43a27f69167297bfb44c02f196bba0b4b6843f94 /src/dotty/tools/dotc/transform/Erasure.scala | |
parent | 1a1f878c8d899c646ff7bcc2a2675ebf810dbf24 (diff) | |
download | dotty-c511f89062adfbdbdb2fe6f9a84e3b40b0d10429.tar.gz dotty-c511f89062adfbdbdb2fe6f9a84e3b40b0d10429.tar.bz2 dotty-c511f89062adfbdbdb2fe6f9a84e3b40b0d10429.zip |
Erasure postcondition: check that returned value conforms to method result type
Diffstat (limited to 'src/dotty/tools/dotc/transform/Erasure.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/Erasure.scala | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/transform/Erasure.scala b/src/dotty/tools/dotc/transform/Erasure.scala index 7fd5109c4..e5e2b409b 100644 --- a/src/dotty/tools/dotc/transform/Erasure.scala +++ b/src/dotty/tools/dotc/transform/Erasure.scala @@ -78,6 +78,13 @@ class Erasure extends Phase with DenotTransformer { thisTransformer => case res: tpd.This => assert(!ExplicitOuter.referencesOuter(ctx.owner.enclosingClass, res), i"Reference to $res from ${ctx.owner.showLocated}") + case ret: tpd.Return => + // checked only after erasure, as checking before erasure is complicated + // due presence of type params in returned types + val from = if (ret.from.isEmpty) ctx.owner.enclosingMethod else ret.from.symbol + val rType = from.info.finalResultType + assert(ret.expr.tpe <:< rType, + i"Returned value:${ret.expr} does not conform to result type(${ret.expr.tpe.widen} of method $from") case _ => } } |