From f03ce0795e444f127d500aa6b864aa213509e06b Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Fri, 25 May 2012 14:04:32 +0400 Subject: [PATCH] KT-2096 Abstract property with no type specified causes compiler to crash #KT-2096 fixed --- .../jetbrains/jet/lang/resolve/DeclarationsChecker.java | 8 +++++++- .../diagnostics/tests/declarationChecks/kt2096.jet | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/declarationChecks/kt2096.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java index 29592beb7c3..aba3fac6caf 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationsChecker.java @@ -211,7 +211,13 @@ public class DeclarationsChecker { JetPropertyAccessor setter = property.getSetter(); boolean hasAccessorImplementation = (getter != null && getter.getBodyExpression() != null) || (setter != null && setter.getBodyExpression() != null); - if (propertyDescriptor.getModality() == Modality.ABSTRACT) return; + + if (propertyDescriptor.getModality() == Modality.ABSTRACT) { + if (property.getInitializer() == null && property.getPropertyTypeRef() == null) { + trace.report(PROPERTY_WITH_NO_TYPE_NO_INITIALIZER.on(property)); + } + return; + } boolean inTrait = classDescriptor != null && classDescriptor.getKind() == ClassKind.TRAIT; JetExpression initializer = property.getInitializer(); diff --git a/compiler/testData/diagnostics/tests/declarationChecks/kt2096.jet b/compiler/testData/diagnostics/tests/declarationChecks/kt2096.jet new file mode 100644 index 00000000000..f51c275607f --- /dev/null +++ b/compiler/testData/diagnostics/tests/declarationChecks/kt2096.jet @@ -0,0 +1,7 @@ +//KT-2096 Abstract property with no type specified causes compiler to crash + +package c + +abstract class Foo{ + protected abstract val prop +} \ No newline at end of file