Specificity by receiver fixed. Test updated
This commit is contained in:
@@ -59,6 +59,12 @@ import java.util.Set;
|
|||||||
if (overrides(f, g)) return true;
|
if (overrides(f, g)) return true;
|
||||||
if (overrides(g, f)) return false;
|
if (overrides(g, f)) return false;
|
||||||
|
|
||||||
|
JetType receiverTypeOfF = f.getReceiverType();
|
||||||
|
JetType receiverTypeOfG = g.getReceiverType();
|
||||||
|
if (receiverTypeOfF != null && receiverTypeOfG != null) {
|
||||||
|
if (!typeMoreSpecific(receiverTypeOfF, receiverTypeOfG)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
List<ValueParameterDescriptor> fParams = f.getValueParameters();
|
List<ValueParameterDescriptor> fParams = f.getValueParameters();
|
||||||
List<ValueParameterDescriptor> gParams = g.getValueParameters();
|
List<ValueParameterDescriptor> gParams = g.getValueParameters();
|
||||||
|
|
||||||
@@ -68,9 +74,7 @@ import java.util.Set;
|
|||||||
JetType fParamType = fParams.get(i).getOutType();
|
JetType fParamType = fParams.get(i).getOutType();
|
||||||
JetType gParamType = gParams.get(i).getOutType();
|
JetType gParamType = gParams.get(i).getOutType();
|
||||||
|
|
||||||
if (!semanticServices.getTypeChecker().isSubtypeOf(fParamType, gParamType)
|
if (!typeMoreSpecific(fParamType, gParamType)) {
|
||||||
&& !numericTypeMoreSpecific(fParamType, gParamType)
|
|
||||||
) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,6 +96,11 @@ import java.util.Set;
|
|||||||
return !f.getOriginal().getTypeParameters().isEmpty();
|
return !f.getOriginal().getTypeParameters().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean typeMoreSpecific(@NotNull JetType specific, @NotNull JetType general) {
|
||||||
|
return semanticServices.getTypeChecker().isSubtypeOf(specific, general) ||
|
||||||
|
numericTypeMoreSpecific(specific, general);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean numericTypeMoreSpecific(@NotNull JetType specific, @NotNull JetType general) {
|
private boolean numericTypeMoreSpecific(@NotNull JetType specific, @NotNull JetType general) {
|
||||||
JetStandardLibrary standardLibrary = semanticServices.getStandardLibrary();
|
JetStandardLibrary standardLibrary = semanticServices.getStandardLibrary();
|
||||||
JetType _double = standardLibrary.getDoubleType();
|
JetType _double = standardLibrary.getDoubleType();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class A
|
|||||||
fun A.plus(a : Any) {
|
fun A.plus(a : Any) {
|
||||||
|
|
||||||
1.foo()
|
1.foo()
|
||||||
true.foo<error>()</error>
|
true.<error>foo()</error>
|
||||||
|
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
@@ -57,8 +57,8 @@ namespace null_safety {
|
|||||||
|
|
||||||
command<error>.</error>foo
|
command<error>.</error>foo
|
||||||
|
|
||||||
command<error>.</error>equals(null)
|
command.equals(null)
|
||||||
command?.equals(null)
|
command<warning>?.</warning>equals(null)
|
||||||
command.equals1(null)
|
command.equals1(null)
|
||||||
command<warning>?.</warning>equals1(null)
|
command<warning>?.</warning>equals1(null)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun Any.equals(other : Any?) : Boolean
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
|
||||||
|
val command : Any = 1
|
||||||
|
|
||||||
|
command<warning>?.<?warning>equals(null)
|
||||||
|
command.equals(null)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user