KT-5068: Introduce a special diagnostic message for TYPE_MISMATCH cases such as 'fun f(): Int = { 1 }'.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
// KT-5068 Add special error for scala-like syntax 'fun foo(): Int = { 1 }'
|
||||
|
||||
fun test1(): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ <!RETURN_NOT_ALLOWED!>return 1<!> }<!>
|
||||
fun test2(): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ 1 }<!>
|
||||
val test3: () -> Int = fun (): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ <!RETURN_NOT_ALLOWED!>return 1<!> }<!>
|
||||
val test4: () -> Int = fun (): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ 1 }<!>
|
||||
fun test5(): Int { return <!TYPE_MISMATCH!>{ 1 }<!> }
|
||||
fun test6(): Int = <!TYPE_MISMATCH!>fun (): Int = 1<!>
|
||||
|
||||
fun outer() {
|
||||
fun test1(): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ <!RETURN_NOT_ALLOWED!>return 1<!> }<!>
|
||||
fun test2(): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ 1 }<!>
|
||||
val test3: () -> Int = fun (): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ <!RETURN_NOT_ALLOWED!>return 1<!> }<!>
|
||||
val test4: () -> Int = fun (): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ 1 }<!>
|
||||
fun test5(): Int { return <!TYPE_MISMATCH!>{ 1 }<!> }
|
||||
fun test6(): Int = <!TYPE_MISMATCH!>fun (): Int = 1<!>
|
||||
}
|
||||
|
||||
class Outer {
|
||||
fun test1(): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ <!RETURN_NOT_ALLOWED!>return 1<!> }<!>
|
||||
fun test2(): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ 1 }<!>
|
||||
val test3: () -> Int = fun (): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ <!RETURN_NOT_ALLOWED!>return 1<!> }<!>
|
||||
val test4: () -> Int = fun (): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ 1 }<!>
|
||||
fun test5(): Int { return <!TYPE_MISMATCH!>{ 1 }<!> }
|
||||
fun test6(): Int = <!TYPE_MISMATCH!>fun (): Int = 1<!>
|
||||
|
||||
class Nested {
|
||||
fun test1(): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ <!RETURN_NOT_ALLOWED!>return 1<!> }<!>
|
||||
fun test2(): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ 1 }<!>
|
||||
val test3: () -> Int = fun (): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ <!RETURN_NOT_ALLOWED!>return 1<!> }<!>
|
||||
val test4: () -> Int = fun (): Int = <!TYPE_MISMATCH_DUE_TO_EQUALS_LAMBDA_IN_FUN!>{ 1 }<!>
|
||||
fun test5(): Int { return <!TYPE_MISMATCH!>{ 1 }<!> }
|
||||
fun test6(): Int = <!TYPE_MISMATCH!>fun (): Int = 1<!>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package
|
||||
|
||||
public val test3: () -> kotlin.Int
|
||||
public val test4: () -> kotlin.Int
|
||||
public fun outer(): kotlin.Unit
|
||||
public fun test1(): kotlin.Int
|
||||
public fun test2(): kotlin.Int
|
||||
public fun test5(): kotlin.Int
|
||||
public fun test6(): kotlin.Int
|
||||
|
||||
public final class Outer {
|
||||
public constructor Outer()
|
||||
public final val test3: () -> kotlin.Int
|
||||
public final val test4: () -> kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun test1(): kotlin.Int
|
||||
public final fun test2(): kotlin.Int
|
||||
public final fun test5(): kotlin.Int
|
||||
public final fun test6(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final class Nested {
|
||||
public constructor Nested()
|
||||
public final val test3: () -> kotlin.Int
|
||||
public final val test4: () -> kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun test1(): kotlin.Int
|
||||
public final fun test2(): kotlin.Int
|
||||
public final fun test5(): kotlin.Int
|
||||
public final fun test6(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user