compiler testdata: s/trait/interface

This commit is contained in:
Dmitry Jemerov
2015-05-12 12:38:49 +02:00
parent a5ed5d4269
commit 4bdf598bfe
803 changed files with 1456 additions and 1456 deletions
@@ -23,7 +23,7 @@ final class Final
// Special // Special
annotation class Annotation annotation class Annotation
enum class Enum enum class Enum
trait Trait interface Trait
// Deprecation // Deprecation
deprecated("") class Deprecated deprecated("") class Deprecated
@@ -7,5 +7,5 @@ class Generic2<A, B>
class Generic2WithBounds<A, B> where A: Bound1, A: Bound2, B: Generic1<A> class Generic2WithBounds<A, B> where A: Bound1, A: Bound2, B: Generic1<A>
class Bound1 class Bound1
trait Bound2 interface Bound2
@@ -1,6 +1,6 @@
// Derived // Derived
trait Base { interface Base {
fun baz(s: String): String fun baz(s: String): String
} }
@@ -1,6 +1,6 @@
// Derived // Derived
trait Base { interface Base {
val boo: String val boo: String
} }
@@ -1,6 +1,6 @@
// Generic // Generic
trait Generic<N, NN: Any> { interface Generic<N, NN: Any> {
fun a(n: N): N fun a(n: N): N
fun b(nn: NN): NN fun b(nn: NN): NN
@@ -1,6 +1,6 @@
// C // C
trait Tr { interface Tr {
fun foo(): Any fun foo(): Any
val v: Any val v: Any
} }
@@ -1,6 +1,6 @@
// C // C
trait Base { interface Base {
fun foo(): Any fun foo(): Any
} }
@@ -1,6 +1,6 @@
// Primitives // Primitives
trait Primitives { interface Primitives {
fun int(x: Int): Int fun int(x: Int): Int
val nullableBool: Boolean? val nullableBool: Boolean?
@@ -1,6 +1,6 @@
// PrivateInTrait // PrivateInTrait
trait PrivateInTrait { interface PrivateInTrait {
private var nn: String private var nn: String
get() = "" get() = ""
set(value) {} set(value) {}
@@ -3,7 +3,7 @@
import org.jetbrains.annotations.NotNull import org.jetbrains.annotations.NotNull
import org.jetbrains.annotations.Nullable import org.jetbrains.annotations.Nullable
trait Trait { interface Trait {
fun notNull(a: String): String fun notNull(a: String): String
fun nullable(a: String?): String? fun nullable(a: String?): String?
@@ -1,6 +1,6 @@
// TraitClassObjectField // TraitClassObjectField
trait TraitClassObjectField { interface TraitClassObjectField {
companion object { companion object {
val x: String? = "" val x: String? = ""
private val y: String? = "" private val y: String? = ""
@@ -1,6 +1,6 @@
// C // C
trait Base<T> { interface Base<T> {
fun foo(t: T): T fun foo(t: T): T
} }
@@ -51,7 +51,7 @@ sink:
<SINK> INIT: in: {foo=ID} out: {foo=ID} USE: in: {} out: {} <SINK> INIT: in: {foo=ID} out: {foo=ID} USE: in: {} out: {}
===================== =====================
== Foo == == Foo ==
trait Foo { interface Foo {
var c: Int var c: Int
} }
--------------------- ---------------------
@@ -11,6 +11,6 @@ fun bar(foo: Foo) {
42 42
} }
trait Foo { interface Foo {
var c: Int var c: Int
} }
@@ -28,7 +28,7 @@ foo <v3>: {<: Foo} NEW: r(foo) -> <v3>
{ foo.c foo.c = 2 42 } <v5>: * COPY { foo.c foo.c = 2 42 } <v5>: * COPY
===================== =====================
== Foo == == Foo ==
trait Foo { interface Foo {
var c: Int var c: Int
} }
--------------------- ---------------------
@@ -1,5 +1,5 @@
== T == == T ==
trait T interface T
--------------------- ---------------------
L0: L0:
1 <START> 1 <START>
@@ -1,4 +1,4 @@
trait T interface T
class A(a: Int, b: Int): T class A(a: Int, b: Int): T
@@ -1,5 +1,5 @@
== T == == T ==
trait T interface T
--------------------- ---------------------
===================== =====================
== A == == A ==
@@ -1,5 +1,5 @@
== A == == A ==
trait A { interface A {
fun foo() : Int fun foo() : Int
} }
--------------------- ---------------------
@@ -1,4 +1,4 @@
trait A { interface A {
fun foo() : Int fun foo() : Int
} }
@@ -1,5 +1,5 @@
== A == == A ==
trait A { interface A {
fun foo() : Int fun foo() : Int
} }
--------------------- ---------------------
@@ -1,7 +1,7 @@
trait A { interface A {
public val c: Int public val c: Int
} }
trait B: A { interface B: A {
override protected private val c: Int override protected private val c: Int
} }
+1 -1
View File
@@ -12,7 +12,7 @@ class A : B() {
fun getB(): Int = 1 fun getB(): Int = 1
val b: Int = 1 val b: Int = 1
trait Tr { interface Tr {
fun getTr() = 1 fun getTr() = 1
} }
@@ -1,5 +1,5 @@
package wrong package wrong
trait TraitWithDefault { interface TraitWithDefault {
fun foo() = 1 fun foo() = 1
} }
+1 -1
View File
@@ -5,6 +5,6 @@ fun foo(p: Int??) {
} }
trait T { interface T {
abstract fun foo() abstract fun foo()
} }
@@ -2,13 +2,13 @@ open class A {
open fun foo(): Any = "A" open fun foo(): Any = "A"
} }
trait B : A interface B : A
open class C : A() { open class C : A() {
override fun foo(): Int = 222 override fun foo(): Int = 222
} }
trait D { interface D {
fun foo(): Number fun foo(): Number
} }
@@ -5,13 +5,13 @@ abstract class A {
abstract fun foo(): List<String> abstract fun foo(): List<String>
} }
trait B { interface B {
fun foo(): ArrayList<String> = ArrayList(Arrays.asList("B")) fun foo(): ArrayList<String> = ArrayList(Arrays.asList("B"))
} }
open class C : A(), B open class C : A(), B
trait D { interface D {
fun foo(): Collection<String> fun foo(): Collection<String>
} }
@@ -1,4 +1,4 @@
trait A<T> { interface A<T> {
fun foo(): T fun foo(): T
} }
@@ -1,4 +1,4 @@
trait A<T> { interface A<T> {
var result: T var result: T
} }
@@ -1,10 +1,10 @@
trait A<T, U> { interface A<T, U> {
fun foo(t: T, u: U) = "A" fun foo(t: T, u: U) = "A"
} }
trait B<U> : A<String, U> interface B<U> : A<String, U>
trait C<T> : A<T, Int> interface C<T> : A<T, Int>
class Z : B<Int>, C<String> { class Z : B<Int>, C<String> {
override fun foo(t: String, u: Int) = "Z" override fun foo(t: String, u: Int) = "Z"
@@ -1,6 +1,6 @@
// KT-4145 // KT-4145
trait A { interface A {
fun foo(): Any fun foo(): Any
} }
@@ -1,8 +1,8 @@
trait A<T> { interface A<T> {
fun foo(t: T): String fun foo(t: T): String
} }
trait B { interface B {
fun foo(t: Int) = "B" fun foo(t: Int) = "B"
} }
@@ -1,8 +1,8 @@
trait A<T> { interface A<T> {
fun foo(t: T): String fun foo(t: T): String
} }
trait B<T : Number> { interface B<T : Number> {
fun foo(a: T) = "B" fun foo(a: T) = "B"
} }
@@ -1,6 +1,6 @@
// KT-3985 // KT-3985
trait Trait<T> { interface Trait<T> {
fun f(): T fun f(): T
} }
@@ -1,8 +1,8 @@
trait A<T> { interface A<T> {
fun foo(t: T): String fun foo(t: T): String
} }
trait B { interface B {
fun foo(t: Int) = "B" fun foo(t: Int) = "B"
} }
@@ -2,11 +2,11 @@ abstract class A {
abstract fun foo(): Any abstract fun foo(): Any
} }
trait B { interface B {
fun foo(): String = "B" fun foo(): String = "B"
} }
trait C : A, B interface C : A, B
class D : A(), C class D : A(), C
@@ -1,6 +1,6 @@
var result = "" var result = ""
trait A { interface A {
var foo: String var foo: String
get() = result get() = result
set(value) { set(value) {
@@ -1,15 +1,15 @@
var result = "" var result = ""
trait D1 { interface D1 {
fun foo(): D1 { fun foo(): D1 {
result += "D1" result += "D1"
return this return this
} }
} }
trait F2 : D1 interface F2 : D1
trait D3 : F2 { interface D3 : F2 {
override fun foo(): D3 { override fun foo(): D3 {
result += "D3" result += "D3"
return this return this
@@ -1,8 +1,8 @@
trait A { interface A {
fun foo(): String = "A" fun foo(): String = "A"
} }
trait B { interface B {
fun foo(): Any fun foo(): Any
} }
@@ -1,12 +1,12 @@
trait D1 { interface D1 {
fun foo(): Any fun foo(): Any
} }
trait D2 { interface D2 {
fun foo(): Number fun foo(): Number
} }
trait F3 : D1, D2 interface F3 : D1, D2
open class D4 { open class D4 {
fun foo(): Int = 42 fun foo(): Int = 42
@@ -1,6 +1,6 @@
open data class A(val value: String) open data class A(val value: String)
trait B { interface B {
fun component1(): Any fun component1(): Any
} }
@@ -2,7 +2,7 @@ abstract class Foo<T> {
fun hello(id: T) = "Hi $id" fun hello(id: T) = "Hi $id"
} }
trait Tr { interface Tr {
fun hello(s : String) fun hello(s : String)
} }
@@ -1,10 +1,10 @@
package test package test
public trait FunDependencyEdge { public interface FunDependencyEdge {
val from: FunctionNode val from: FunctionNode
} }
public trait FunctionNode public interface FunctionNode
public class FunctionNodeImpl : FunctionNode public class FunctionNodeImpl : FunctionNode
@@ -1,4 +1,4 @@
trait Tr<T> { interface Tr<T> {
val v: T val v: T
} }
@@ -1,9 +1,9 @@
var result = "" var result = ""
trait Base interface Base
open class Child : Base open class Child : Base
trait A<T : Base> { interface A<T : Base> {
fun <E : T> foo(a : E) { fun <E : T> foo(a : E) {
result += "A" result += "A"
} }
@@ -1,4 +1,4 @@
trait A<T, U> { interface A<T, U> {
fun foo(t: T, u: U) = "A" fun foo(t: T, u: U) = "A"
} }
@@ -1,11 +1,11 @@
import java.util.ArrayList import java.util.ArrayList
import java.util.Arrays import java.util.Arrays
trait A { interface A {
fun foo(): Collection<String> fun foo(): Collection<String>
} }
trait B : A { interface B : A {
override fun foo(): MutableCollection<String> override fun foo(): MutableCollection<String>
} }
@@ -1,7 +1,7 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
import java.util.HashSet import java.util.HashSet
trait A : Set<String> interface A : Set<String>
class B : A, HashSet<String>() { class B : A, HashSet<String>() {
override fun clone(): B = throw AssertionError() override fun clone(): B = throw AssertionError()
@@ -1,11 +1,11 @@
trait A<O, K> { interface A<O, K> {
val o: O val o: O
val k: K val k: K
} }
trait B<K> : A<String, K> interface B<K> : A<String, K>
trait C<O> : A<O, String> interface C<O> : A<O, String>
class D : B<String>, C<String> { class D : B<String>, C<String> {
override val o = "O" override val o = "O"
@@ -1,4 +1,4 @@
trait A<T> { interface A<T> {
var x: T var x: T
} }
@@ -1,4 +1,4 @@
trait A<T> { interface A<T> {
var v: T var v: T
} }
@@ -1,4 +1,4 @@
trait A<T> { interface A<T> {
open fun foo(t: T) = "A" open fun foo(t: T) = "A"
} }
@@ -1,4 +1,4 @@
trait A<T> { interface A<T> {
fun foo(t: T) = "A" fun foo(t: T) = "A"
} }
@@ -1,4 +1,4 @@
trait A<T> { interface A<T> {
fun id(t: T): T fun id(t: T): T
} }
@@ -1,8 +1,8 @@
trait A<T> { interface A<T> {
open fun foo(t: T) = "A" open fun foo(t: T) = "A"
} }
trait B : A<String> interface B : A<String>
enum class Z(val name: String) : B { enum class Z(val name: String) : B {
Z1 : Z("Z1") Z1 : Z("Z1")
@@ -1,8 +1,8 @@
trait A { interface A {
fun foo(): Any = "A" fun foo(): Any = "A"
} }
trait B : A { interface B : A {
override fun foo(): String = "B" override fun foo(): String = "B"
} }
@@ -2,7 +2,7 @@ open class A {
open fun foo(): Any = "A" open fun foo(): Any = "A"
} }
trait B : A { interface B : A {
override fun foo(): String = "B" override fun foo(): String = "B"
} }
@@ -1,8 +1,8 @@
trait A<T> { interface A<T> {
fun foo(t: T, u: Int) = "A" fun foo(t: T, u: Int) = "A"
} }
trait B<T, U> { interface B<T, U> {
fun foo(t: T, u: U) = "B" fun foo(t: T, u: U) = "B"
} }
@@ -1,8 +1,8 @@
trait A<T> { interface A<T> {
fun foo(t: T) = "A" fun foo(t: T) = "A"
} }
trait B<T> { interface B<T> {
fun foo(t: T) = "B" fun foo(t: T) = "B"
} }
@@ -1,10 +1,10 @@
trait A : Collection<String> interface A : Collection<String>
trait B : List<String> interface B : List<String>
trait C : Map<Long, Double> interface C : Map<Long, Double>
trait D : Map.Entry<Any, Nothing> interface D : Map.Entry<Any, Nothing>
trait E : Iterator<Int> interface E : Iterator<Int>
fun box(): String { fun box(): String {
trait F : A, B, C, D, E interface F : A, B, C, D, E
return "OK" return "OK"
} }
@@ -1,4 +1,4 @@
trait Addable { interface Addable {
fun add(s: String): Boolean = true fun add(s: String): Boolean = true
} }
@@ -1,6 +1,6 @@
// EA-38323 - Illegal field modifiers in class: classObject field in C must be static and final // EA-38323 - Illegal field modifiers in class: classObject field in C must be static and final
trait C { interface C {
companion object { companion object {
public val FOO: String = "OK" public val FOO: String = "OK"
} }
@@ -1,8 +1,8 @@
trait Trait1 { interface Trait1 {
fun foo() : String fun foo() : String
} }
trait Trait2 { interface Trait2 {
fun bar() : String fun bar() : String
} }
@@ -1,8 +1,8 @@
trait One { interface One {
public open fun foo() : Int public open fun foo() : Int
public open fun faz() : Int = 10 public open fun faz() : Int = 10
} }
trait Two { interface Two {
public open fun foo() : Int public open fun foo() : Int
public open fun quux() : Int = 100 public open fun quux() : Int = 100
} }
@@ -1,8 +1,8 @@
open trait First { open interface First {
public open fun foo() : Int public open fun foo() : Int
} }
open trait Second : First { open interface Second : First {
public open fun bar() : Int public open fun bar() : Int
} }
@@ -1,4 +1,4 @@
trait A<T> { interface A<T> {
fun foo(t: T): String fun foo(t: T): String
} }
@@ -1,4 +1,4 @@
trait A<T: Number> { interface A<T: Number> {
fun foo(t: T): String fun foo(t: T): String
} }
@@ -1,4 +1,4 @@
trait A<T, U> { interface A<T, U> {
fun foo(t: T, u: U): String fun foo(t: T, u: U): String
} }
@@ -1,14 +1,14 @@
package test package test
trait TextField { interface TextField {
fun getText(): String fun getText(): String
} }
trait InputTextField : TextField { interface InputTextField : TextField {
fun setText(text: String) fun setText(text: String)
} }
trait MooableTextField : InputTextField { interface MooableTextField : InputTextField {
fun moo(a: Int, b: Int, c: Int): Int fun moo(a: Int, b: Int, c: Int): Int
} }
@@ -5,7 +5,7 @@ open class Base() {
} }
open class Left() : Base() {} open class Left() : Base() {}
trait Right : Base {} interface Right : Base {}
class D() : Left(), Right class D() : Left(), Right
@@ -2,7 +2,7 @@ open class Base() {
fun n(n : Int) : Int = n + 1 fun n(n : Int) : Int = n + 1
} }
trait Abstract {} interface Abstract {}
class Derived1() : Base(), Abstract {} class Derived1() : Base(), Abstract {}
class Derived2() : Abstract, Base() {} class Derived2() : Abstract, Base() {}
@@ -1,6 +1,6 @@
import java.util.HashSet import java.util.HashSet
trait A : Set<String> interface A : Set<String>
class B : A, HashSet<String>() class B : A, HashSet<String>()
@@ -1,7 +1,7 @@
// Changed when traits were introduced. May not make sense any more // Changed when traits were introduced. May not make sense any more
open class X(val x : Int) {} open class X(val x : Int) {}
trait Y { interface Y {
abstract val y : Int abstract val y : Int
} }
@@ -11,7 +11,7 @@ class Point(x : Int, yy : Int) : X(x) , Y {
override val y : Int = yy override val y : Int = yy
} }
trait Abstract {} interface Abstract {}
class P1(x : Int, yy : Y) : Abstract, X(x), Y by yy {} class P1(x : Int, yy : Y) : Abstract, X(x), Y by yy {}
class P2(x : Int, yy : Y) : X(x), Abstract, Y by yy {} class P2(x : Int, yy : Y) : X(x), Abstract, Y by yy {}
@@ -1,10 +1,10 @@
trait Creator<T> { interface Creator<T> {
fun create() : T fun create() : T
} }
class Actor(val code: String = "OK") class Actor(val code: String = "OK")
trait Factory : Creator<Actor> interface Factory : Creator<Actor>
class MyFactory() : Factory { class MyFactory() : Factory {
override fun create(): Actor = Actor() override fun create(): Actor = Actor()
@@ -1,7 +1,7 @@
class Bar { class Bar {
} }
trait Foo { interface Foo {
fun xyzzy(x: Any?): String fun xyzzy(x: Any?): String
} }
@@ -1,4 +1,4 @@
trait A { interface A {
fun foo(): Int fun foo(): Int
} }
@@ -5,18 +5,18 @@ class JsonObject() {
class JsonArray() { class JsonArray() {
} }
public trait Formatter<in IN: Any, out OUT: Any> { public interface Formatter<in IN: Any, out OUT: Any> {
public fun format(source: IN?): OUT public fun format(source: IN?): OUT
} }
public trait MultiFormatter <in IN: Any, out OUT: Any> { public interface MultiFormatter <in IN: Any, out OUT: Any> {
public fun format(source: Collection<IN>): OUT public fun format(source: Collection<IN>): OUT
} }
public class Project() { public class Project() {
} }
public trait JsonFormatter<in IN: Any>: Formatter<IN, JsonObject>, MultiFormatter<IN, JsonArray> { public interface JsonFormatter<in IN: Any>: Formatter<IN, JsonObject>, MultiFormatter<IN, JsonArray> {
public override fun format(source: Collection<IN>): JsonArray { public override fun format(source: Collection<IN>): JsonArray {
return JsonArray(); return JsonArray();
} }
@@ -1,4 +1,4 @@
public trait LoggerAware { public interface LoggerAware {
public val logger: StringBuilder public val logger: StringBuilder
} }
@@ -1,11 +1,11 @@
package test package test
trait A { interface A {
public val c: String public val c: String
get() = "OK" get() = "OK"
} }
trait B { interface B {
protected val c: String protected val c: String
} }
@@ -1,6 +1,6 @@
package foo package foo
trait B { interface B {
val c: Int val c: Int
get() = 2 get() = 2
} }
@@ -6,7 +6,7 @@ open class B : A() {
override fun foo() = super.foo() override fun foo() = super.foo()
} }
trait I interface I
class C : I, B() { class C : I, B() {
override fun foo() = super<B>.foo() override fun foo() = super<B>.foo()
@@ -1,4 +1,4 @@
trait Trait { interface Trait {
fun foo() = "O" fun foo() = "O"
override fun toString() = "K" override fun toString() = "K"
} }
@@ -1,4 +1,4 @@
trait A { interface A {
val result: String val result: String
} }
@@ -1,8 +1,8 @@
trait A { interface A {
fun foo(): Int fun foo(): Int
} }
trait B { interface B {
fun foo(): Int fun foo(): Int
} }
@@ -1,12 +1,12 @@
trait A { interface A {
fun test(): String fun test(): String
} }
trait B { interface B {
fun test(): String fun test(): String
} }
trait C: A, B interface C: A, B
class Z(val param: String): C { class Z(val param: String): C {
@@ -2,7 +2,7 @@ open class A<T> {
open fun foo(a: T): Int = 2 open fun foo(a: T): Int = 2
} }
trait B<T> : A<T> { interface B<T> : A<T> {
override fun foo(a: T): Int = 1 override fun foo(a: T): Int = 1
} }
@@ -10,7 +10,7 @@ open class Base() {
} }
} }
trait Abstract {} interface Abstract {}
class Derived1() : Base(), Abstract {} class Derived1() : Base(), Abstract {}
class Derived2() : Abstract, Base() {} class Derived2() : Abstract, Base() {}
@@ -1,6 +1,6 @@
// Changed when traits were introduced. May not make sense any more // Changed when traits were introduced. May not make sense any more
trait Left {} interface Left {}
open class Right() { open class Right() {
open fun f() = 42 open fun f() = 42
} }
@@ -1,4 +1,4 @@
trait A<T> { interface A<T> {
var zzzValue : T var zzzValue : T
fun zzz() : T fun zzz() : T
} }
@@ -1,4 +1,4 @@
trait T { interface T {
fun result(): String fun result(): String
} }
@@ -1,4 +1,4 @@
trait T { interface T {
fun result(): String fun result(): String
} }
@@ -1,4 +1,4 @@
trait T { interface T {
fun result(): String fun result(): String
} }
@@ -1,4 +1,4 @@
trait T { interface T {
fun result(): String fun result(): String
} }
@@ -1,4 +1,4 @@
trait T { interface T {
fun result(): String fun result(): String
} }
@@ -1,4 +1,4 @@
trait T { interface T {
fun result(): String fun result(): String
} }
@@ -24,7 +24,7 @@ class LI : ListTag() {}
public fun ListTag.item(body: LI.() -> Unit): Unit {} public fun ListTag.item(body: LI.() -> Unit): Unit {}
fun HtmlTag.a(contents: A.() -> Unit) {} fun HtmlTag.a(contents: A.() -> Unit) {}
trait A : HtmlTag { interface A : HtmlTag {
public var text: String public var text: String
} }
@@ -1,6 +1,6 @@
var index = 0 var index = 0
trait IterableIterator : Iterator<Int> { interface IterableIterator : Iterator<Int> {
fun iterator(): Iterator<Int> = this fun iterator(): Iterator<Int> = this
} }
@@ -1,4 +1,4 @@
trait Foo { interface Foo {
fun foo(a: Double = 1.0): Double fun foo(a: Double = 1.0): Double
} }
@@ -1,5 +1,5 @@
trait Base { interface Base {
fun bar(a: String = "abc"): String = a + " from trait" fun bar(a: String = "abc"): String = a + " from interface"
} }
class Derived: Base { class Derived: Base {
@@ -2,7 +2,7 @@ class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int = 1 fun get(t: Any?, p: PropertyMetadata): Int = 1
} }
trait A { interface A {
val prop: Int val prop: Int
} }

Some files were not shown because too many files have changed in this diff Show More