quickfix to move type constraint to 'where' clause

This commit is contained in:
Dmitry Jemerov
2015-10-06 19:03:42 +02:00
parent 4c4030dfc1
commit 45d1129dbb
15 changed files with 114 additions and 10 deletions
@@ -268,7 +268,7 @@ public interface Errors {
DiagnosticFactory0<PsiElement> CYCLIC_GENERIC_UPPER_BOUND = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<JetTypeParameter> MISPLACED_TYPE_PARAMETER_CONSTRAITS = DiagnosticFactory0.create(WARNING);
DiagnosticFactory0<JetTypeParameter> MISPLACED_TYPE_PARAMETER_CONSTRAINTS = DiagnosticFactory0.create(WARNING);
// Members
@@ -496,7 +496,7 @@ public class DefaultErrorMessages {
MAP.put(DEPRECATED_TYPE_PARAMETER_SYNTAX, "Placing function type parameters after the function name is deprecated");
MAP.put(MISPLACED_TYPE_PARAMETER_CONSTRAITS, "If a type parameter has multiple constraints, they all need to be placed in the 'where' clause");
MAP.put(MISPLACED_TYPE_PARAMETER_CONSTRAINTS, "If a type parameter has multiple constraints, they all need to be placed in the 'where' clause");
MAP.put(TYPE_VARIANCE_CONFLICT, "Type parameter {0} is declared as ''{1}'' but occurs in ''{2}'' position in type {3}",
new MultiRenderer<VarianceConflictDiagnosticData>() {
@@ -342,7 +342,7 @@ public class DeclarationsChecker {
if (!constraints.isEmpty()) {
for (JetTypeParameter typeParameter : typeParameterListOwner.getTypeParameters()) {
if (typeParameter.getExtendsBound() != null && hasConstraints(typeParameter, constraints)) {
trace.report(MISPLACED_TYPE_PARAMETER_CONSTRAITS.on(typeParameter));
trace.report(MISPLACED_TYPE_PARAMETER_CONSTRAINTS.on(typeParameter));
}
}
}
@@ -1,9 +1,9 @@
class Foo<<!MISPLACED_TYPE_PARAMETER_CONSTRAITS!>T : Cloneable<!>> where T : Comparable<T> {
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAITS!>U : Cloneable<!>> foo(u: U): U where U: Comparable<U> {
class Foo<<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T : Cloneable<!>> where T : Comparable<T> {
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>U : Cloneable<!>> foo(u: U): U where U: Comparable<U> {
return u
}
val <<!MISPLACED_TYPE_PARAMETER_CONSTRAITS!>U : Cloneable<!>> U.foo: U? where U: Comparable<U>
val <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>U : Cloneable<!>> U.foo: U? where U: Comparable<U>
get() { return null }
}