Implement property uses throw UnsupportedOperationException() instead of default value or ?

This commit is contained in:
Valentin Kipyatkov
2014-12-18 16:39:54 +03:00
parent 367b99a156
commit 5f2446d889
11 changed files with 22 additions and 23 deletions
@@ -203,8 +203,7 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
newDescriptor.addOverriddenDescriptor(descriptor); newDescriptor.addOverriddenDescriptor(descriptor);
StringBuilder body = new StringBuilder(); StringBuilder body = new StringBuilder();
String defaultInitializer = CodeInsightUtils.defaultInitializer(descriptor.getType()); String initializer = " = throw UnsupportedOperationException()";
String initializer = defaultInitializer != null ? " = " + defaultInitializer : " = ?";
body.append("\nget()"); body.append("\nget()");
body.append(initializer); body.append(initializer);
if (descriptor.isVar()) { if (descriptor.isVar()) {
@@ -22,7 +22,7 @@ class C : Base<String, C, Unit>() {
} }
override val method: (String?) -> String override val method: (String?) -> String
get() = ? get() = throw UnsupportedOperationException()
override fun toString(): String { override fun toString(): String {
return super.toString() return super.toString()
@@ -4,9 +4,9 @@ trait A {
} }
fun some() : A { fun some() : A {
return object : A {<caret> return object : A {
override val method: () -> Unit? override val method: () -> Unit?
get() = ? get() = <selection><caret>throw UnsupportedOperationException()</selection>
} }
} }
@@ -24,21 +24,21 @@ class C : A(), B {
} }
override val internalProperty: Int override val internalProperty: Int
get() = 0 get() = throw UnsupportedOperationException()
override fun protectedFun() { override fun protectedFun() {
super<A>.protectedFun() super<A>.protectedFun()
} }
override val protectedProperty: Int override val protectedProperty: Int
get() = 0 get() = throw UnsupportedOperationException()
override fun publicFun() { override fun publicFun() {
super<A>.publicFun() super<A>.publicFun()
} }
override val publicProperty: Int override val publicProperty: Int
get() = 0 get() = throw UnsupportedOperationException()
override fun toString(): String { override fun toString(): String {
return super<A>.toString() return super<A>.toString()
@@ -4,5 +4,5 @@ trait A {
class B : A { class B : A {
override val String.prop: Int override val String.prop: Int
get() = <selection><caret>0</selection> get() = <selection><caret>throw UnsupportedOperationException()</selection>
} }
@@ -3,9 +3,9 @@ open class A() {
} }
fun some() : A { fun some() : A {
return object : A() {<caret> return object : A() {
override val method: () -> Unit? override val method: () -> Unit?
get() = ? get() = <selection><caret>throw UnsupportedOperationException()</selection>
} }
} }
@@ -4,7 +4,7 @@ trait A {
class B : A { class B : A {
override var Int.foo: Double override var Int.foo: Double
get() = <selection><caret>0.0</selection> get() = <selection><caret>throw UnsupportedOperationException()</selection>
set(value) { set(value) {
} }
} }
@@ -11,19 +11,19 @@ trait T {
class C : T { class C : T {
override val a1: Byte override val a1: Byte
get() = <selection><caret>0</selection> get() = <selection><caret>throw UnsupportedOperationException()</selection>
override val a2: Short override val a2: Short
get() = 0 get() = throw UnsupportedOperationException()
override val a3: Int override val a3: Int
get() = 0 get() = throw UnsupportedOperationException()
override val a4: Long override val a4: Long
get() = 0 get() = throw UnsupportedOperationException()
override val a5: Float override val a5: Float
get() = 0.0f get() = throw UnsupportedOperationException()
override val a6: Double override val a6: Double
get() = 0.0 get() = throw UnsupportedOperationException()
override val a7: Char override val a7: Char
get() = '\u0000' get() = throw UnsupportedOperationException()
override val a8: Boolean override val a8: Boolean
get() = false get() = throw UnsupportedOperationException()
} }
@@ -7,7 +7,7 @@ class C : A() {
val constant = 42 val constant = 42
// Some comment // Some comment
override val bar: Int override val bar: Int
get() = <selection><caret>0</selection> get() = <selection><caret>throw UnsupportedOperationException()</selection>
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
return super.equals(other) return super.equals(other)
@@ -4,5 +4,5 @@ trait T {
class GC() : T { class GC() : T {
override val v: Int override val v: Int
get() = <selection><caret>0</selection> get() = <selection><caret>throw UnsupportedOperationException()</selection>
} }
@@ -10,7 +10,7 @@ class SomeTest : Test {
} }
override val testProp: Int override val testProp: Int
get() = 0 get() = throw UnsupportedOperationException()
/** /**
* test * test