Very basic property resolve

This commit is contained in:
Andrey Breslav
2011-02-09 15:36:17 +03:00
parent 575b5b3ebe
commit c6964220f0
4 changed files with 21 additions and 4 deletions
@@ -57,11 +57,11 @@ public class ClassDescriptorResolver {
}
if (declaration instanceof JetProperty) {
JetProperty property = (JetProperty) declaration;
// TODO : Caution: a cyclic dependency possible
if (property.getPropertyTypeRef() != null) {
return resolvePropertyDescriptor(JetScope.EMPTY, property);
return resolvePropertyDescriptor(outerScope, property);
} else {
// TODO : Caution: a cyclic dependency possible
throw new UnsupportedOperationException();
}
}
@@ -41,7 +41,7 @@ public class TypeResolver {
typeConstructor,
nullable,
resolveTypeProjections(scope, typeConstructor, type.getTypeArguments()),
JetStandardClasses.STUB
classDescriptor.getMemberDomain()
);
}
else if (type.getTypeArguments().isEmpty()) {
@@ -52,6 +52,7 @@ public class TypeResolver {
typeParameterDescriptor.getTypeConstructor(),
nullable || hasNullableBound(typeParameterDescriptor),
Collections.<TypeProjection>emptyList(),
// TODO : joint domain
JetStandardClasses.STUB
);
}
@@ -255,6 +255,13 @@ public class JetTypeChecker {
result[0] = JetStandardClasses.getUnitType();
}
@Override
public void visitNewExpression(JetNewExpression expression) {
// TODO : type argument inference
JetTypeReference typeReference = expression.getTypeReference();
result[0] = TypeResolver.INSTANCE.resolveType(scope, typeReference);
}
@Override
public void visitDotQualifiedExpression(JetDotQualifiedExpression expression) {
JetExpression receiverExpression = expression.getReceiverExpression();
@@ -304,7 +304,15 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
assertType("if (1) {() => val a = 1; a; var b = a; b} else null", "Function0<Int>?");
}
// public void testImplicitConversions() throws Exception {
public void testNew() throws Exception {
assertType("new Base_T<Int>()", "Base_T<Int>");
}
public void testPropertiesInClasses() throws Exception {
assertType("new Properties().p", "Int");
}
// public void testImplicitConversions() throws Exception {
// assertConvertibleTo("1", JetStandardClasses.getByteType());
// }
//
@@ -399,6 +407,7 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
"open class Derived_inT<in T> : Base_inT<T>",
"open class Base_outT<out T>",
"open class Derived_outT<out T> : Base_outT<T>",
"class Properties { val p : Int }"
};
public static JetScope BASIC_SCOPE = new JetScopeAdapter(JetStandardClasses.STANDARD_CLASSES) {