Fix Quickfix for missing operator adds infix modifier to created function (#1012)
Fixes #KT-14907
This commit is contained in:
committed by
Dmitry Jemerov
parent
af1ed78e17
commit
406bac684c
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||
import java.util.*
|
||||
|
||||
object CreateBinaryOperationActionFactory: CreateCallableMemberFromUsageFactory<KtBinaryExpression>() {
|
||||
object CreateBinaryOperationActionFactory : CreateCallableMemberFromUsageFactory<KtBinaryExpression>() {
|
||||
override fun getElementOfInterest(diagnostic: Diagnostic): KtBinaryExpression? {
|
||||
return diagnostic.psiElement.parent as? KtBinaryExpression
|
||||
}
|
||||
@@ -54,8 +54,9 @@ object CreateBinaryOperationActionFactory: CreateCallableMemberFromUsageFactory<
|
||||
else -> TypeInfo(element, Variance.OUT_VARIANCE)
|
||||
}
|
||||
val parameters = Collections.singletonList(ParameterInfo(TypeInfo(argumentExpr, Variance.IN_VARIANCE)))
|
||||
val isOperator = token != KtTokens.IDENTIFIER
|
||||
return FunctionInfo(operationName, receiverType, returnType, parameterInfos = parameters,
|
||||
isOperator = token != KtTokens.IDENTIFIER,
|
||||
isInfix = true)
|
||||
isOperator = isOperator,
|
||||
isInfix = !isOperator)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create member function 'A.compareTo'" "true"
|
||||
|
||||
class A<T>(val n: T) {
|
||||
infix operator fun compareTo(t: T): Int {
|
||||
operator fun compareTo(t: T): Int {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create member function 'A.contains'" "true"
|
||||
|
||||
class A<T>(val n: T) {
|
||||
infix operator fun contains(t: T): Boolean {
|
||||
operator fun contains(t: T): Boolean {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create member function 'A.compareTo'" "true"
|
||||
|
||||
class A<T>(val n: T) {
|
||||
infix operator fun compareTo(t: T): Int {
|
||||
operator fun compareTo(t: T): Int {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create member function 'A.contains'" "true"
|
||||
|
||||
class A<T>(val n: T) {
|
||||
infix operator fun contains(t: T): Boolean {
|
||||
operator fun contains(t: T): Boolean {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
idea/testData/quickfix/createFromUsage/createFunction/binaryOperations/plusAssignOnUserType.kt.after
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create member function 'A.plusAssign'" "true"
|
||||
|
||||
class A<T>(val n: T) {
|
||||
infix operator fun plusAssign(t: T) {
|
||||
operator fun plusAssign(t: T) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
class A<T>(val n: T) {
|
||||
operator fun unaryPlus(): A<T> = throw Exception()
|
||||
infix operator fun plus(t: T): A<T> {
|
||||
operator fun plus(t: T): A<T> {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create member function 'A.plus'" "true"
|
||||
|
||||
class A<T>(val n: T) {
|
||||
infix operator fun plus(t: T): A<T> {
|
||||
operator fun plus(t: T): A<T> {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
class A<T>(val n: T) {
|
||||
fun plus(i: Int, s: String): A<T> = throw Exception()
|
||||
infix operator fun plus(t: T): A<T> {
|
||||
operator fun plus(t: T): A<T> {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -7,6 +7,6 @@ fun test() {
|
||||
val a: A<Int> = 2 + A(1)
|
||||
}
|
||||
|
||||
private infix operator fun Int.plus(a: A<Int>): A<Int> {
|
||||
private operator fun Int.plus(a: A<Int>): A<Int> {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create member function 'A.plus'" "true"
|
||||
|
||||
class A<T>(val n: T) {
|
||||
infix operator fun plus(t: T): A<T> {
|
||||
operator fun plus(t: T): A<T> {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create member function 'A.plus'" "true"
|
||||
|
||||
class A<T>(val n: T) {
|
||||
infix operator fun plus(i: Int): A<T> {
|
||||
operator fun plus(i: Int): A<T> {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -7,6 +7,6 @@ fun test() {
|
||||
A() * "1"
|
||||
}
|
||||
|
||||
private infix operator fun A.times(s: String) {
|
||||
private operator fun A.times(s: String) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create member function 'A.contains'" "true"
|
||||
|
||||
class A<T>(val n: T) {
|
||||
infix operator fun contains(t: T): Boolean {
|
||||
operator fun contains(t: T): Boolean {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Create member function 'A.contains'" "true"
|
||||
|
||||
class A<T>(val n: T) {
|
||||
infix operator fun contains(t: T): Boolean {
|
||||
operator fun contains(t: T): Boolean {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user