From 20d339e2da8d3efdd5783b3494c262c1bf07ecb5 Mon Sep 17 00:00:00 2001 From: svtk Date: Wed, 14 Dec 2011 14:27:07 +0400 Subject: [PATCH] KT-786 Exception on incomplete code with 'when' --- .../jetbrains/jet/lang/types/TypeUtils.java | 1 + .../tests/controlStructures/kt786.jet | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/controlStructures/kt786.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java index 2e3b5f83ede..6e6f3cfa7c9 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java @@ -361,6 +361,7 @@ public class TypeUtils { fullSubstitution.put(typeParameterDescriptor.getTypeConstructor(), substitutedTypeProjection); } } + if (JetStandardClasses.isNothingOrNullableNothing(context)) return; for (JetType supertype : context.getConstructor().getSupertypes()) { fillInDeepSubstitutor(supertype, substitutor, substitution, fullSubstitution); } diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt786.jet b/compiler/testData/diagnostics/tests/controlStructures/kt786.jet new file mode 100644 index 00000000000..665af148d31 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlStructures/kt786.jet @@ -0,0 +1,26 @@ +namespace kt786 + +//KT-786 Exception on incomplete code with 'when' +fun foo() : Int { + val d = 2 + var z = 0 + when(d) { + is 5, is 3 => z++ + else => { z = -1000 } + return z => 34 + } +} + +//test unreachable code +fun fff(): Int { + var d = 3 + when(d) { + is 4 => 21 + return 2 => return 47 + bar() => 45 + 444 => true + } + return 34 +} + +fun bar(): Int = 8 \ No newline at end of file