Binary and unary expression support
This commit is contained in:
@@ -641,6 +641,7 @@ public class JetPsiUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static int getPriority(@NotNull JetExpression expression) {
|
||||
int maxPriority = JetExpressionParsing.Precedence.values().length + 1;
|
||||
|
||||
@@ -1033,4 +1034,14 @@ public class JetPsiUtil {
|
||||
public static boolean isLocal(@NotNull JetNamedDeclaration declaration) {
|
||||
return getEnclosingBlockForLocalDeclaration(declaration) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetToken getOperationToken(@NotNull JetOperationExpression expression) {
|
||||
JetSimpleNameExpression operationExpression = expression.getOperationReference();
|
||||
IElementType elementType = operationExpression.getReferencedNameElementType();
|
||||
assert elementType == null || elementType instanceof JetToken :
|
||||
"JetOperationExpression should have operation token of type JetToken: " +
|
||||
expression;
|
||||
return (JetToken) elementType;
|
||||
}
|
||||
}
|
||||
|
||||
+19
-8
@@ -35,6 +35,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.InlineUtil;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -103,21 +104,31 @@ public class InlineCallResolverExtension implements CallResolverExtension {
|
||||
while (parent != null) {
|
||||
if (parent instanceof JetValueArgument ||
|
||||
parent instanceof JetBinaryExpression ||
|
||||
parent instanceof JetUnaryExpression ||
|
||||
parent instanceof JetDotQualifiedExpression ||
|
||||
parent instanceof JetCallExpression) {
|
||||
parent instanceof JetCallExpression ||
|
||||
parent instanceof JetArrayAccessExpression ||
|
||||
parent instanceof JetMultiDeclaration) {
|
||||
|
||||
if (parent instanceof JetPrefixExpression) {
|
||||
if (JetPsiUtil.isLabeledExpression((JetPrefixExpression) parent)) {
|
||||
parent = parent.getParent();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (parent instanceof JetBinaryExpression) {
|
||||
if (JetPsiUtil.getOperationToken((JetOperationExpression) parent) == JetTokens.EQ) {
|
||||
//assignment
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//check that it's in inlineable call would be in resolve call of parent
|
||||
return true;
|
||||
}
|
||||
else if (parent instanceof JetParenthesizedExpression || parent instanceof JetBinaryExpressionWithTypeRHS) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
else if (parent instanceof JetPrefixExpression) {
|
||||
boolean isLabeled = JetPsiUtil.isLabeledExpression((JetPrefixExpression) parent);
|
||||
if (!isLabeled) {
|
||||
return false;
|
||||
}
|
||||
parent = parent.getParent();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
|
||||
inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
|
||||
var d = <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
d = <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
|
||||
var e = <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
e = <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}
|
||||
|
||||
|
||||
inline fun Function1<Int, Unit>.inlineExt() {
|
||||
var d = <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
d = <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
|
||||
inline fun <T, U> Function1<T, U>.get(index : Int) {
|
||||
|
||||
}
|
||||
|
||||
inline fun <T, U, V> ExtensionFunction1<T, U, V>.get(index : Int) {
|
||||
|
||||
}
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
|
||||
s[1]
|
||||
ext[1]
|
||||
}
|
||||
|
||||
//noinline
|
||||
fun <T, U, V> Function2<T, U, V>.get(index : Int) {
|
||||
|
||||
}
|
||||
|
||||
fun <T, U, V, W> ExtensionFunction2<T, U, V, W>.get(index : Int) {
|
||||
|
||||
}
|
||||
|
||||
inline fun <T, U, V, W> inlineFunWithInvoke(s: (p: T, l: U) -> V, ext: T.(p: U, l: V) -> W) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!>[1]
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!>[1]
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
|
||||
|
||||
fun <T, U> Function1<T, U>.minusAssign(p: Function1<T, U>) {}
|
||||
|
||||
inline fun <T, U> Function1<T, U>.modAssign(p: Function1<T, U>) = {
|
||||
this += p
|
||||
p += this
|
||||
}
|
||||
|
||||
inline fun <T, U> Function1<T, U>.plusAssign(p: Function1<T, U>) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!> -= <!USAGE_IS_NOT_INLINABLE!>p<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>p<!> -= <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
}
|
||||
|
||||
fun <T, U, V> ExtensionFunction1<T, U, V>.minusAssign(ext : ExtensionFunction1<T, U, V>) {}
|
||||
|
||||
inline fun <T, U, V> ExtensionFunction1<T, U, V>.modAssign(ext : ExtensionFunction1<T, U, V>) = {
|
||||
this += ext
|
||||
ext += this
|
||||
}
|
||||
|
||||
inline fun <T, U, V> ExtensionFunction1<T, U, V>.plusAssign(ext : ExtensionFunction1<T, U, V>) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!> -= <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!> -= <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
}
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
|
||||
s += s
|
||||
ext += ext
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
|
||||
|
||||
inline fun <T, U> Function1<T, U>.compareTo(p: Function1<T, U>) = 1
|
||||
inline fun <T, U, V> ExtensionFunction1<T, U, V>.compareTo(index : ExtensionFunction1<T, U, V>) = 1
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
|
||||
s < s
|
||||
s <= s
|
||||
s > s
|
||||
s >= s
|
||||
|
||||
ext < ext
|
||||
ext > ext
|
||||
ext <= ext
|
||||
ext >= ext
|
||||
}
|
||||
|
||||
//noinline
|
||||
fun <T, U, V> Function2<T, U, V>.compareTo(index : Function2<T, U, V>) = 1
|
||||
fun <T, U, V, W> ExtensionFunction2<T, U, V, W>.compareTo(index : ExtensionFunction2<T, U, V, W>) = 1
|
||||
|
||||
inline fun <T, U, V, W> inlineFunWithInvoke(s: (p: T, l: U) -> V, ext: T.(p: U, l: V) -> W) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!> < <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!> <= <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!> > <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!> >= <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!> < <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!> > <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!> <= <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!> >= <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
|
||||
inline fun <T, U> Function1<T, U>.component1() = 1
|
||||
inline fun <T, U> Function1<T, U>.component2() = 2
|
||||
|
||||
inline fun <T, U, V> ExtensionFunction1<T, U, V>.component1() = 1
|
||||
inline fun <T, U, V> ExtensionFunction1<T, U, V>.component2() = 2
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
|
||||
val (d1, e1) = s
|
||||
val (d2, e2) = ext
|
||||
}
|
||||
|
||||
fun <T, U, V> Function2<T, U, V>.component1() = 1
|
||||
fun <T, U, V> Function2<T, U, V>.component2() = 2
|
||||
|
||||
fun <T, U, V, W> ExtensionFunction2<T, U, V, W>.component1() = 1
|
||||
fun <T, U, V, W> ExtensionFunction2<T, U, V, W>.component2() = 2
|
||||
|
||||
inline fun <T, U, V, W> inlineFunWithInvoke(s: (p: T, l: U) -> V, ext: T.(p: U, l: V) -> W) {
|
||||
val (d1, e1) = <!USAGE_IS_NOT_INLINABLE, USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
val (d2, e2) = <!USAGE_IS_NOT_INLINABLE, USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
|
||||
inline fun <T, U> Function1<T, U>.contains(p: Function1<T, U>): Boolean {
|
||||
this in p
|
||||
p in this
|
||||
return false
|
||||
}
|
||||
|
||||
inline fun <T, U, V> ExtensionFunction1<T, U, V>.contains(ext: ExtensionFunction1<T, U, V>): Boolean {
|
||||
ext in this
|
||||
this in ext
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
|
||||
s in s
|
||||
s !in s
|
||||
|
||||
ext in ext
|
||||
ext !in ext
|
||||
}
|
||||
|
||||
|
||||
fun <T, U, V> Function2<T, U, V>.contains(p: Function2<T, U, V>): Boolean = false
|
||||
|
||||
fun <T, U, V, W> ExtensionFunction2<T, U, V, W>.contains(ext: ExtensionFunction2<T, U, V, W>): Boolean = false
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T, l: U) -> U, ext: T.(p: U, l: U) -> V) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!> in <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!> !in <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!> in <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!> !in <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
|
||||
fun <T, U> Function1<T, U>.minus(p: Function1<T, U>) {
|
||||
|
||||
}
|
||||
|
||||
fun <T, U, V> ExtensionFunction1<T, U, V>.minus(p: T.(p: U) -> V) {
|
||||
|
||||
}
|
||||
|
||||
inline fun <T, U> Function1<T, U>.plus(p: Function1<T, U>) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!> - <!USAGE_IS_NOT_INLINABLE!>p<!>
|
||||
}
|
||||
|
||||
inline fun <T, U, V> ExtensionFunction1<T, U, V>.plus(p: T.(p: U) -> V) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!> - <!USAGE_IS_NOT_INLINABLE!>p<!>
|
||||
}
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
|
||||
s + s
|
||||
ext + ext
|
||||
}
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
|
||||
s + s
|
||||
ext + ext
|
||||
}
|
||||
|
||||
inline fun <T, U> Function1<T, U>.submit() {
|
||||
this + this
|
||||
}
|
||||
|
||||
inline fun <T, U, V> ExtensionFunction1<T, U, V>.submit() {
|
||||
this + this
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
|
||||
|
||||
inline fun <T, U> Function1<T, U>.rangeTo(p: Function1<T, U>): Range<Int> {
|
||||
this..p
|
||||
p..this
|
||||
return 1..2
|
||||
}
|
||||
|
||||
inline fun <T, U, V> ExtensionFunction1<T, U, V>.rangeTo(ext: ExtensionFunction1<T, U, V>): Range<Int> {
|
||||
ext..this
|
||||
this..ext
|
||||
return 1..2
|
||||
}
|
||||
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) {
|
||||
s..s
|
||||
s..s
|
||||
|
||||
ext..ext
|
||||
ext..ext
|
||||
}
|
||||
|
||||
|
||||
fun <T, U, V> Function2<T, U, V>.rangeTo(p: Function2<T, U, V>): Range<Int> {
|
||||
return 1..2
|
||||
}
|
||||
|
||||
fun <T, U, V, W> ExtensionFunction2<T, U, V, W>.rangeTo(ext: ExtensionFunction2<T, U, V, W>): Range<Int> {
|
||||
return 1..2
|
||||
}
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T, l: U) -> U, ext: T.(p: U, l: U) -> V) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!>..<!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!>..<!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!>..<!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!>..<!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNNECESSARY_SAFE_CALL -UNNECESSARY_NOT_NULL_ASSERTION
|
||||
inline fun String.submit(action: Function1<Int, Int>) {
|
||||
|
||||
}
|
||||
|
||||
inline fun Function1<Int, Int>.submit() {
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!>?.invoke(11)
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!>!!.invoke(11)
|
||||
|
||||
submit(<!USAGE_IS_NOT_INLINABLE!>this<!>!!)
|
||||
}
|
||||
|
||||
inline fun submit(action: Function1<Int, Int>) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>action<!>?.invoke(10)
|
||||
<!USAGE_IS_NOT_INLINABLE!>action<!>!!.invoke(10)
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -VAL_REASSIGNMENT -UNUSED_CHANGED_VALUE -VARIABLE_EXPECTED
|
||||
|
||||
inline fun <T, V> Function1<T, V>.plus() = <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
fun <T, V> Function1<T, V>.minus() = this
|
||||
inline fun <T, V> Function1<T, V>.inc() = <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
fun <T, V> Function1<T, V>.dec() = this
|
||||
|
||||
inline fun <T, V> ExtensionFunction1<T, T, V>.plus(){}
|
||||
fun <T, V> ExtensionFunction1<T, T, V>.minus(){}
|
||||
inline fun <T, V> ExtensionFunction1<T, T, V>.inc() = <!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
fun <T, V> ExtensionFunction1<T, T, V>.dec() = this
|
||||
|
||||
inline fun <T, V> inlineFunWithInvoke(s: (p: T) -> V, ext: T.(p: T) -> V) {
|
||||
+s
|
||||
-<!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
s++
|
||||
++s
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!>--
|
||||
--<!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
+ext
|
||||
-<!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
ext++
|
||||
++ext
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!>--
|
||||
--<!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}
|
||||
|
||||
inline fun <T, V> Function1<T, V>.inlineFunWithInvoke() {
|
||||
+this
|
||||
-<!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
this++
|
||||
++this
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!>--
|
||||
--<!USAGE_IS_NOT_INLINABLE!>this<!>
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
|
||||
inline fun <T, V> Function1<T, V>.not() : Boolean {
|
||||
return !this
|
||||
}
|
||||
|
||||
inline fun <T, V> ExtensionFunction1<T, T, V>.not() : Boolean {
|
||||
return !this
|
||||
}
|
||||
|
||||
inline fun <T, V> inlineFunWithInvoke(s: (p: T) -> V, ext: T.(p: T) -> V) {
|
||||
!s
|
||||
!ext
|
||||
}
|
||||
|
||||
fun <T, U, V> Function2<T, U, V>.not() : Boolean {
|
||||
return !this
|
||||
}
|
||||
|
||||
fun <T, U, V, W> ExtensionFunction2<T, U, V, W>.not() : Boolean {
|
||||
return !this
|
||||
}
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T, l: U) -> V, ext: T.(p: T, l : U) -> V) {
|
||||
!<!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
!<!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -NOTHING_TO_INLINE -USELESS_ELVIS
|
||||
|
||||
inline fun inlineFunWrongUsage(s: (p: Int) -> Unit) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
|
||||
if (true) <!USAGE_IS_NOT_INLINABLE!>s<!> else 0
|
||||
|
||||
var c = <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
c = <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!> ?: <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
}
|
||||
|
||||
inline fun inlineFunWrongUsageExt(ext: Int.(p: Int) -> Unit) {
|
||||
@@ -14,8 +13,7 @@ inline fun inlineFunWrongUsageExt(ext: Int.(p: Int) -> Unit) {
|
||||
|
||||
if (true) <!USAGE_IS_NOT_INLINABLE!>ext<!> else 0
|
||||
|
||||
var c = <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
c = <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!> ?: <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}
|
||||
|
||||
inline fun inlineFunWrongUsageInClosure(s: (p: Int) -> Unit) {
|
||||
@@ -24,8 +22,7 @@ inline fun inlineFunWrongUsageInClosure(s: (p: Int) -> Unit) {
|
||||
|
||||
if (true) <!USAGE_IS_NOT_INLINABLE!>s<!> else 0
|
||||
|
||||
var c = <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
c = <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!> ?: <!USAGE_IS_NOT_INLINABLE!>s<!>
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -35,21 +32,20 @@ inline fun inlineFunWrongUsageInClosureExt(ext: Int.(p: Int) -> Unit) {
|
||||
|
||||
if (true) <!USAGE_IS_NOT_INLINABLE!>ext<!> else 0
|
||||
|
||||
var c = <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
c = <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
<!USAGE_IS_NOT_INLINABLE!>ext<!> ?: <!USAGE_IS_NOT_INLINABLE!>ext<!>
|
||||
}()
|
||||
}
|
||||
|
||||
inline fun inlineFunNoInline(noinline s: (p: Int) -> Unit) {
|
||||
s
|
||||
if (true) s else 0
|
||||
var c = s
|
||||
c = s
|
||||
|
||||
s ?: s
|
||||
}
|
||||
|
||||
inline fun inlineFunNoInline(noinline ext: Int.(p: Int) -> Unit) {
|
||||
ext
|
||||
if (true) ext else 0
|
||||
var c = ext
|
||||
c = ext
|
||||
}
|
||||
|
||||
ext ?: ext
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -UNNECESSARY_SAFE_CALL -UNNECESSARY_NOT_NULL_ASSERTION
|
||||
|
||||
public inline fun assertNot(message: String, block: ()-> Boolean) {}
|
||||
|
||||
public inline fun assertNot(block: ()-> Boolean) : Unit = assertNot(<!USAGE_IS_NOT_INLINABLE!>block<!>.toString(), block)
|
||||
|
||||
|
||||
public fun <T> callable(action: ()-> T) {
|
||||
|
||||
}
|
||||
|
||||
public inline fun <T> String.submit(action: ()->T) {
|
||||
callable(<!USAGE_IS_NOT_INLINABLE!>action<!>)
|
||||
}
|
||||
|
||||
public inline fun <T> Function1<Int, Int>.submit() {
|
||||
<!USAGE_IS_NOT_INLINABLE!>this<!>?.invoke(11)
|
||||
<!USAGE_IS_NOT_INLINABLE, USAGE_IS_NOT_INLINABLE!>this<!>!!.invoke(11)
|
||||
}
|
||||
|
||||
public inline fun <T> submit(action: Function1<Int, Int>) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>action<!>?.invoke(10)
|
||||
<!USAGE_IS_NOT_INLINABLE, USAGE_IS_NOT_INLINABLE!>action<!>!!.invoke(10)
|
||||
}
|
||||
@@ -3751,12 +3751,17 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inline")
|
||||
@InnerTestClasses({Inline.NonPublicMember.class})
|
||||
@InnerTestClasses({Inline.BinaryExpressions.class, Inline.NonPublicMember.class, Inline.UnaryExpressions.class})
|
||||
public static class Inline extends AbstractDiagnosticsTestWithEagerResolve {
|
||||
public void testAllFilesPresentInInline() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/inline"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("assignment.kt")
|
||||
public void testAssignment() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/assignment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capture.kt")
|
||||
public void testCapture() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/capture.kt");
|
||||
@@ -3782,21 +3787,26 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/inline/invoke.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonVirtualMembersWithInline.kt")
|
||||
public void testNonVirtualMembersWithInline() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/nonVirtualMembersWithInline.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("labeled.kt")
|
||||
public void testLabeled() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/labeled.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonVirtualMembersWithInline.kt")
|
||||
public void testNonVirtualMembersWithInline() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/nonVirtualMembersWithInline.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nothingToInline.kt")
|
||||
public void testNothingToInline() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/nothingToInline.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullabilityOperations.kt")
|
||||
public void testNullabilityOperations() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/nullabilityOperations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableFunction.kt")
|
||||
public void testNullableFunction() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/nullableFunction.kt");
|
||||
@@ -3837,9 +3847,47 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/inline/wrongUsage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("wrongUsage2.kt")
|
||||
public void testWrongUsage2() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/wrongUsage2.kt");
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inline/binaryExpressions")
|
||||
public static class BinaryExpressions extends AbstractDiagnosticsTestWithEagerResolve {
|
||||
public void testAllFilesPresentInBinaryExpressions() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/inline/binaryExpressions"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayAccess.kt")
|
||||
public void testArrayAccess() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/binaryExpressions/arrayAccess.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("assignment.kt")
|
||||
public void testAssignment() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/binaryExpressions/assignment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("comparison.kt")
|
||||
public void testComparison() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/binaryExpressions/comparison.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("componentAccess.kt")
|
||||
public void testComponentAccess() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/binaryExpressions/componentAccess.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("contains.kt")
|
||||
public void testContains() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/binaryExpressions/contains.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mathOperations.kt")
|
||||
public void testMathOperations() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/binaryExpressions/mathOperations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("rangeTo.kt")
|
||||
public void testRangeTo() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/binaryExpressions/rangeTo.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inline/nonPublicMember")
|
||||
@@ -3875,10 +3923,30 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inline/unaryExpressions")
|
||||
public static class UnaryExpressions extends AbstractDiagnosticsTestWithEagerResolve {
|
||||
public void testAllFilesPresentInUnaryExpressions() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/inline/unaryExpressions"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("mathOperation.kt")
|
||||
public void testMathOperation() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/unaryExpressions/mathOperation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notOperation.kt")
|
||||
public void testNotOperation() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/unaryExpressions/notOperation.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test innerSuite() {
|
||||
TestSuite suite = new TestSuite("Inline");
|
||||
suite.addTestSuite(Inline.class);
|
||||
suite.addTestSuite(BinaryExpressions.class);
|
||||
suite.addTestSuite(NonPublicMember.class);
|
||||
suite.addTestSuite(UnaryExpressions.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user