Skip to content

Commit

Permalink
Fix tests: "Placing function type parameters after the function name"…
Browse files Browse the repository at this point in the history
… error
  • Loading branch information
yanex committed Nov 27, 2015
1 parent 3001af5 commit a3ff3ff
Show file tree
Hide file tree
Showing 435 changed files with 550 additions and 569 deletions.
2 changes: 1 addition & 1 deletion compiler/testData/codegen/box/elvis/genericNull.kt
@@ -1,4 +1,4 @@
fun foo<T: Number?>(t: T) {
fun <T: Number?> foo(t: T) {
(t ?: 42).toInt()
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/testData/codegen/box/safeCall/genericNull.kt
@@ -1,4 +1,4 @@
fun foo<T : Number?>(t: T) {
fun <T : Number?> foo(t: T) {
t?.toInt()
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/testData/codegen/box/unit/nullableUnit.kt
@@ -1,6 +1,6 @@
fun isNull(x: Unit?) = x == null

fun isNullGeneric<T : Any>(x: T?) = x == null
fun <T : Any> isNullGeneric(x: T?) = x == null

fun deepIsNull0(x: Unit?) = isNull(x)
fun deepIsNull(x: Unit?) = deepIsNull0(x)
Expand Down
4 changes: 2 additions & 2 deletions compiler/testData/codegen/boxInline/builders/builders.2.kt
Expand Up @@ -23,7 +23,7 @@ abstract class Tag(val name: String) : Element() {
val children = ArrayList<Element>()
val attributes = HashMap<String, String>()

inline protected fun initTag<T : Element>(tag: T, init: T.() -> Unit): T {
inline protected fun <T : Element> initTag(tag: T, init: T.() -> Unit): T {
tag.init()
children.add(tag)
return tag
Expand All @@ -47,7 +47,7 @@ abstract class Tag(val name: String) : Element() {
}

abstract class TagWithText(name: String) : Tag(name) {
fun String.plus() {
operator fun String.unaryPlus() {
children.add(TextElement(this))
}
}
Expand Down
Expand Up @@ -23,7 +23,7 @@ abstract class Tag(val name: String) : Element() {
val children = ArrayList<Element>()
val attributes = HashMap<String, String>()

inline protected fun initTag<T : Element>(tag: T, init: T.() -> Unit): T {
inline protected fun <T : Element> initTag(tag: T, init: T.() -> Unit): T {
tag.init()
children.add(tag)
return tag
Expand All @@ -47,7 +47,7 @@ abstract class Tag(val name: String) : Element() {
}

abstract class TagWithText(name: String) : Tag(name) {
fun String.plus() {
operator fun String.unaryPlus() {
children.add(TextElement(this))
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/testData/codegen/boxInline/reified/kt7017.2.kt
@@ -1,6 +1,6 @@
package test

inline fun test<reified T>(x: Any): Boolean {
inline fun <reified T> test(x: Any): Boolean {
val x = object {
val y = x is T
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/testData/codegen/boxInline/reified/kt8047.2.kt
@@ -1,5 +1,5 @@
package test

inline fun f<reified T>(x : () -> Unit) {
inline fun <reified T> f(x : () -> Unit) {
object { init { arrayOf<T>() } }
}
Expand Up @@ -4,7 +4,7 @@ fun <T> test2(): T {
return a as T
}

fun test3<T: Any>() = null as T
fun <T: Any> test3() = null as T

fun box(): String {
if (test1<Int?>() != null) return "fail: test1"
Expand Down
@@ -1,5 +1,5 @@

inline fun calc<T, R>(value : T, fn: (T)->R) : R = fn(value)
inline fun <T, R> calc(value : T, fn: (T) -> R) : R = fn(value)
inline fun <T> identity(value : T) : T = calc(value) {
if (1 == 1) return it
it
Expand Down
@@ -1 +1 @@
fun foo<T : Any>(t: T) = t
fun <T : Any> foo(t: T) = t
2 changes: 1 addition & 1 deletion compiler/testData/constraintSystem/declarations.kt
@@ -1,4 +1,4 @@
fun foo<T, P, E>() = 42
fun <T, P, E> foo() = 42

interface A
interface B : A
Expand Down
Expand Up @@ -8,7 +8,7 @@ class FC1: OC2(), T3
interface T4: <!INTERFACE_WITH_SUPERCLASS!>OC1<!>
interface T5: T2

fun test<TP1: OC1, TP2: T2, TP3: OC2>(
fun <TP1: OC1, TP2: T2, TP3: OC2> test(
t2: T2,
t4: T4,
fc1: FC1,
Expand Down
Expand Up @@ -6,7 +6,7 @@ open class OClass2
class FClass1
class FClass2

fun test<TP1: OClass1, TP2: OClass2>(
fun <TP1: OClass1, TP2: OClass2> test(
t1: Trait1,
oc1: OClass1,
fc1: FClass1,
Expand Down
Expand Up @@ -2,7 +2,7 @@ package test

class MembersReferenceOuterTP<P> {
inner class Inner {
fun f<Q : P>() {}
fun <Q : P> f() {}
fun g(p: P): P = null!!

val v: P = null!!
Expand Down
2 changes: 1 addition & 1 deletion compiler/testData/psi/examples/With.kt
@@ -1,4 +1,4 @@
inline fun with<T>(receiver : T, body : T.() -> Unit) = receiver.body()
inline fun <T> with(receiver : T, body : T.() -> Unit) = receiver.body()

fun example() {

Expand Down
3 changes: 2 additions & 1 deletion compiler/testData/psi/examples/With.txt
Expand Up @@ -9,12 +9,13 @@ JetFile: With.kt
PsiWhiteSpace(' ')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('with')
TYPE_PARAMETER_LIST
PsiElement(LT)('<')
TYPE_PARAMETER
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('with')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
Expand Down
2 changes: 1 addition & 1 deletion compiler/testData/psi/examples/io/IOSamples.kt
Expand Up @@ -8,7 +8,7 @@ open class ICloseable {

abstract class JavaCloseableWrapper(closeable : java.io.Closeable) : ICloseable(closeable)

fun streamCopy<T>(from : IIterable<T>, to : IAdder<T>) {
fun <T> streamCopy(from : IIterable<T>, to : IAdder<T>) {
for (item in from) t.add(item)
}

Expand Down
5 changes: 3 additions & 2 deletions compiler/testData/psi/examples/io/IOSamples.txt
Expand Up @@ -117,12 +117,13 @@ JetFile: IOSamples.kt
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('streamCopy')
TYPE_PARAMETER_LIST
PsiElement(LT)('<')
TYPE_PARAMETER
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('streamCopy')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
Expand Down Expand Up @@ -599,4 +600,4 @@ JetFile: IOSamples.kt
PsiWhiteSpace(' ')
PsiComment(EOL_COMMENT)('// throws IOException, you must catch or rethrow explicitly')
PsiWhiteSpace('\n\n')
PsiElement(RBRACE)('}')
PsiElement(RBRACE)('}')
2 changes: 1 addition & 1 deletion compiler/testData/psi/examples/util/Comparison.kt
Expand Up @@ -10,7 +10,7 @@ enum class ComparisonResult {

typealias MatchableComparison<in T> = (T, T) -> ComparisonResult

fun asMatchableComparison<T>(cmp : Comparison<T>) : MatchableComparison<T> = {a, b ->
fun <T> asMatchableComparison(cmp : Comparison<T>) : MatchableComparison<T> = {a, b ->
val res = cmp(a, b)
if (res == 0) return ComparisonResult.EQ
if (res < 0) return ComparisonResult.LS
Expand Down
3 changes: 2 additions & 1 deletion compiler/testData/psi/examples/util/Comparison.txt
Expand Up @@ -273,12 +273,13 @@ JetFile: Comparison.kt
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('asMatchableComparison')
TYPE_PARAMETER_LIST
PsiElement(LT)('<')
TYPE_PARAMETER
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('asMatchableComparison')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
Expand Down
Expand Up @@ -7,5 +7,5 @@ fun ((T) -> G)?.foo()
fun ((T) -> G)??.foo()

//--------------
fun f<T>()
fun <T> f()
a.b class C
Expand Up @@ -418,12 +418,13 @@ JetFile: FunctionsWithFunctionReceivers.kt
PsiWhiteSpace('\n')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
TYPE_PARAMETER_LIST
PsiElement(LT)('<')
TYPE_PARAMETER
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
Expand All @@ -438,4 +439,4 @@ JetFile: FunctionsWithFunctionReceivers.kt
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('C')
PsiElement(IDENTIFIER)('C')
Expand Up @@ -19,7 +19,7 @@ c<t>.

//-----------
class A<X> {
fun foo<Y>() {
fun <Y> foo() {
}
}

Expand Down
Expand Up @@ -537,12 +537,13 @@ JetFile: FunctionsWithFunctionReceiversRecovery.kt
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
TYPE_PARAMETER_LIST
PsiElement(LT)('<')
TYPE_PARAMETER
PsiElement(IDENTIFIER)('Y')
PsiElement(GT)('>')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
Expand Down Expand Up @@ -600,4 +601,4 @@ JetFile: FunctionsWithFunctionReceiversRecovery.kt
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiElement(RBRACE)('}')
54 changes: 27 additions & 27 deletions compiler/tests/org/jetbrains/kotlin/types/KotlinOverloadTest.java
Expand Up @@ -65,20 +65,20 @@ public void testBasic() throws Exception {
"fun a() : Any");

assertNotOverloadable(
"fun a<T1>() : T1",
"fun a<T>() : T");
"fun <T1> a() : T1",
"fun <T> a() : T");

assertNotOverloadable(
"fun a<T1>(a : T1) : T1",
"fun a<T>(a : T) : T");
"fun <T1> a(a : T1) : T1",
"fun <T> a(a : T) : T");

assertNotOverloadable(
"fun a<T1, X : T1>(a : T1) : T1",
"fun a<T, Y : T>(a : T) : T");
"fun <T1, X : T1> a(a : T1) : T1",
"fun <T, Y : T> a(a : T) : T");

assertNotOverloadable(
"fun a<T1, X : T1>(a : T1) : T1",
"fun a<T, Y : T>(a : T) : Y");
"fun <T1, X : T1> a(a : T1) : T1",
"fun <T, Y : T> a(a : T) : Y");

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Expand All @@ -100,50 +100,50 @@ public void testBasic() throws Exception {
"fun a(a : Int) : Int");

assertNotOverloadable(
"fun a<T>(a : Int) : Int",
"fun <T> a(a : Int) : Int",
"fun a(a : Int) : Int");

// TODO
/*
assertOverloadable(
"fun a<T1, X : T1>(a : T1) : T1",
"fun a<T, Y>(a : T) : T");
"fun <T1, X : T1> a(a : T1) : T1",
"fun <T, Y> a(a : T) : T");
*/

assertOverloadable(
"fun a<T1, X : T1>(a : T1) : T1",
"fun a<T, Y : T>(a : Y) : T");
"fun <T1, X : T1> a(a : T1) : T1",
"fun <T, Y : T> a(a : Y) : T");

assertNotOverloadable(
"fun a<T1, X : T1>(a : T1) : X",
"fun a<T, Y : T>(a : T) : T");
"fun <T1, X : T1> a(a : T1) : X",
"fun <T, Y : T> a(a : T) : T");

// TODO
/*
assertNotOverloadable(
"fun a<T1, X : Array<out T1>>(a : Array<in T1>) : T1",
"fun a<T, Y : Array<out T>>(a : Array<in T>) : T");
"fun <T1, X : Array<out T1>> a(a : Array<in T1>) : T1",
"fun <T, Y : Array<out T>> a(a : Array<in T>) : T");
*/

assertOverloadable(
"fun a<T1, X : Array<T1>>(a : Array<in T1>) : T1",
"fun a<T, Y : Array<out T>>(a : Array<in T>) : T");
"fun <T1, X : Array<T1>> a(a : Array<in T1>) : T1",
"fun <T, Y : Array<out T>> a(a : Array<in T>) : T");

assertOverloadable(
"fun a<T1, X : Array<out T1>>(a : Array<in T1>) : T1",
"fun a<T, Y : Array<in T>>(a : Array<in T>) : T");
"fun <T1, X : Array<out T1>> a(a : Array<in T1>) : T1",
"fun <T, Y : Array<in T>> a(a : Array<in T>) : T");

assertOverloadable(
"fun a<T1, X : Array<out T1>>(a : Array<in T1>) : T1",
"fun a<T, Y : Array<*>>(a : Array<in T>) : T");
"fun <T1, X : Array<out T1>> a(a : Array<in T1>) : T1",
"fun <T, Y : Array<*>> a(a : Array<in T>) : T");

assertOverloadable(
"fun a<T1, X : Array<out T1>>(a : Array<in T1>) : T1",
"fun a<T, Y : Array<out T>>(a : Array<out T>) : T");
"fun <T1, X : Array<out T1>> a(a : Array<in T1>) : T1",
"fun <T, Y : Array<out T>> a(a : Array<out T>) : T");

assertOverloadable(
"fun a<T1, X : Array<out T1>>(a : Array<*>) : T1",
"fun a<T, Y : Array<out T>>(a : Array<in T>) : T");
"fun <T1, X : Array<out T1>> a(a : Array<*>) : T1",
"fun <T, Y : Array<out T>> a(a : Array<in T>) : T");

assertOverloadable(
"fun ff() : Int",
Expand Down

0 comments on commit a3ff3ff

Please sign in to comment.