Skip to content

Commit

Permalink
Merge pull request #67 from burntcookie90/vr/inheritance-fix
Browse files Browse the repository at this point in the history
Inheritance should use :
  • Loading branch information
swankjesse committed May 18, 2017
2 parents 0f32b78 + 22254ff commit d309590
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 28 deletions.
21 changes: 3 additions & 18 deletions src/main/java/com/squareup/kotlinpoet/TypeSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,9 @@ class TypeSpec private constructor(builder: TypeSpec.Builder) {
implementsTypes = superinterfaces
}

if (!extendsTypes.isEmpty()) {
codeWriter.emit(" extends")
var firstType = true
for (type in extendsTypes) {
if (!firstType) codeWriter.emit(",")
codeWriter.emit(" %T", type)
firstType = false
}
}

if (!implementsTypes.isEmpty()) {
codeWriter.emit(" implements")
var firstType = true
for (type in implementsTypes) {
if (!firstType) codeWriter.emit(",")
codeWriter.emit(" %T", type)
firstType = false
}
(extendsTypes + implementsTypes).forEachIndexed { i, typeName ->
codeWriter.emit(if (i == 0) " :" else ",")
codeWriter.emit(" %T", typeName)
}

codeWriter.emit(" {\n")
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/squareup/kotlinpoet/KotlinFileTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ class KotlinFileTest {
|
|import com.squareup.wire.Message
|
|class Taco extends Message {
| class Builder extends Message.Builder {
|class Taco : Message {
| class Builder : Message.Builder {
| }
|}
|""".trimMargin())
Expand Down Expand Up @@ -534,7 +534,7 @@ class KotlinFileTest {
assertThat(source.toString()).isEqualTo("""
|package hello
|
|class World implements Test {
|class World : Test {
|}
|""".trimMargin())
}
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/com/squareup/kotlinpoet/TypeSpecTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ class TypeSpecTest {
|import java.lang.UnsupportedOperationException
|import kotlin.Int
|
|class Location<T, P : Number> implements Comparable<P> {
|class Location<T, P : Number> : Comparable<P> {
| val label: T
|
| val x: P
Expand Down Expand Up @@ -628,7 +628,7 @@ class TypeSpecTest {
|import java.lang.Comparable
|import java.util.AbstractSet
|
|abstract class Taco extends AbstractSet<Food> implements Serializable, Comparable<Taco> {
|abstract class Taco : AbstractSet<Food>, Serializable, Comparable<Taco> {
|}
|""".trimMargin())
}
Expand All @@ -647,7 +647,7 @@ class TypeSpecTest {
|
|import java.lang.Comparable
|
|class Taco extends org.fish.taco.Taco implements Comparable<Taco>, com.taco.bell.Taco {
|class Taco : org.fish.taco.Taco, Comparable<Taco>, com.taco.bell.Taco {
|}
|""".trimMargin())
}
Expand All @@ -669,7 +669,7 @@ class TypeSpecTest {
|
|import java.util.concurrent.Callable
|
|class Outer extends Callable<Outer.Inner> {
|class Outer : Callable<Outer.Inner> {
| inner class Inner {
| }
|}
Expand All @@ -689,7 +689,7 @@ class TypeSpecTest {
|import java.io.Serializable
|import java.lang.Cloneable
|
|enum Food implements Serializable, Cloneable {
|enum Food : Serializable, Cloneable {
| LEAN_GROUND_BEEF,
|
| SHREDDED_CHEESE
Expand All @@ -709,7 +709,7 @@ class TypeSpecTest {
|import java.io.Serializable
|import java.lang.Comparable
|
|interface Taco extends Serializable, Comparable<Taco> {
|interface Taco : Serializable, Comparable<Taco> {
|}
|""".trimMargin())
}
Expand Down Expand Up @@ -1684,7 +1684,7 @@ class TypeSpecTest {
|import java.io.Serializable
|import java.util.EventListener
|
|class Taco implements Serializable, EventListener {
|class Taco : Serializable, EventListener {
|}
|""".trimMargin())
}
Expand Down

0 comments on commit d309590

Please sign in to comment.