提交 c1dbe9ee 编写于 作者: A Andrey Breslav

Specificity by receiver fixed. Test updated

上级 c02c5071
......@@ -59,6 +59,12 @@ import java.util.Set;
if (overrides(f, g)) return true;
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> gParams = g.getValueParameters();
......@@ -68,9 +74,7 @@ import java.util.Set;
JetType fParamType = fParams.get(i).getOutType();
JetType gParamType = gParams.get(i).getOutType();
if (!semanticServices.getTypeChecker().isSubtypeOf(fParamType, gParamType)
&& !numericTypeMoreSpecific(fParamType, gParamType)
) {
if (!typeMoreSpecific(fParamType, gParamType)) {
return false;
}
}
......@@ -92,6 +96,11 @@ import java.util.Set;
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) {
JetStandardLibrary standardLibrary = semanticServices.getStandardLibrary();
JetType _double = standardLibrary.getDoubleType();
......
......@@ -16,7 +16,7 @@ class A
fun A.plus(a : Any) {
1.foo()
true.foo<error>()</error>
true.<error>foo()</error>
1
}
......@@ -57,8 +57,8 @@ namespace null_safety {
command<error>.</error>foo
command<error>.</error>equals(null)
command?.equals(null)
command.equals(null)
command<warning>?.</warning>equals(null)
command.equals1(null)
command<warning>?.</warning>equals1(null)
......
fun Any.equals(other : Any?) : Boolean
fun main(args: Array<String>) {
val command : Any = 1
command<warning>?.<?warning>equals(null)
command.equals(null)
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册