KT-251 fixed
This commit is contained in:
@@ -57,7 +57,7 @@ public class JetPropertyAccessor extends JetDeclaration implements JetDeclaratio
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasDeclaredReturnType() {
|
public boolean hasDeclaredReturnType() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -537,8 +537,8 @@ public class ClassDescriptorResolver {
|
|||||||
type = typeResolver.resolveType(scope, typeReference);
|
type = typeResolver.resolveType(scope, typeReference);
|
||||||
JetType inType = propertyDescriptor.getInType();
|
JetType inType = propertyDescriptor.getInType();
|
||||||
if (inType != null) {
|
if (inType != null) {
|
||||||
if (!semanticServices.getTypeChecker().isSubtypeOf(type, inType)) {
|
if (!semanticServices.getTypeChecker().equalTypes(type, inType)) {
|
||||||
trace.getErrorHandler().genericError(typeReference.getNode(), "Setter parameter type must be a subtype of the type of the property, i.e. " + inType);
|
trace.getErrorHandler().genericError(typeReference.getNode(), "Setter parameter type must be equal to the type of the property, i.e. " + inType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -572,10 +572,14 @@ public class ClassDescriptorResolver {
|
|||||||
if (getter != null) {
|
if (getter != null) {
|
||||||
List<AnnotationDescriptor> annotations = annotationResolver.resolveAnnotations(scope, getter.getModifierList());
|
List<AnnotationDescriptor> annotations = annotationResolver.resolveAnnotations(scope, getter.getModifierList());
|
||||||
|
|
||||||
JetType returnType = null;
|
JetType outType = propertyDescriptor.getOutType();
|
||||||
|
JetType returnType = outType;
|
||||||
JetTypeReference returnTypeReference = getter.getReturnTypeReference();
|
JetTypeReference returnTypeReference = getter.getReturnTypeReference();
|
||||||
if (returnTypeReference != null) {
|
if (returnTypeReference != null) {
|
||||||
returnType = typeResolver.resolveType(scope, returnTypeReference);
|
returnType = typeResolver.resolveType(scope, returnTypeReference);
|
||||||
|
if (outType != null && !semanticServices.getTypeChecker().equalTypes(returnType, outType)) {
|
||||||
|
trace.getErrorHandler().genericError(returnTypeReference.getNode(), "Getter return type must be equal to the type of the property, i.e. " + propertyDescriptor.getReturnType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getterDescriptor = new PropertyGetterDescriptor(
|
getterDescriptor = new PropertyGetterDescriptor(
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
class A() {
|
||||||
|
var x: Int = 0
|
||||||
|
get() = <error>"s"</error>
|
||||||
|
set(value: <error>String</error>) {
|
||||||
|
$x = <error>value</error>
|
||||||
|
}
|
||||||
|
val y: Int
|
||||||
|
get(): <error>String</error> = "s"
|
||||||
|
val z: Int
|
||||||
|
get() {
|
||||||
|
return <error>"s"</error>
|
||||||
|
}
|
||||||
|
|
||||||
|
var a: Any = 1
|
||||||
|
set(v: <error>String</error>) {
|
||||||
|
$a = v
|
||||||
|
}
|
||||||
|
val b: Int
|
||||||
|
get(): <error>Any</error> = "s"
|
||||||
|
val c: Int
|
||||||
|
get() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
val d = 1
|
||||||
|
get() {
|
||||||
|
return $d
|
||||||
|
}
|
||||||
|
val e = 1
|
||||||
|
get(): <error>String</error> {
|
||||||
|
return <error>$e</error>
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user