Initial design for the TypeInfo class

This commit is contained in:
Andrey Breslav
2011-05-05 17:07:22 +04:00
parent 0e63fa3761
commit f84bdf0d54
4 changed files with 50 additions and 2 deletions
@@ -1,4 +1,9 @@
namespace jet.lang
namespace jet
class TypeInfo<T> {
fun isSubtypeOf(other : TypeInfo<*>) : Boolean
fun isInstance(obj : Any?) : Boolean
}
class Iterator<out T> {
fun next() : T
@@ -63,7 +63,7 @@ public class JetStandardLibrary {
private JetStandardLibrary(@NotNull Project project) {
// TODO : review
InputStream stream = JetStandardClasses.class.getClassLoader().getResourceAsStream("jet/lang/Library.jet");
InputStream stream = JetStandardClasses.class.getClassLoader().getResourceAsStream("jet/Library.jet");
try {
//noinspection IOResourceOpenedButNotSafelyClosed
JetFile file = (JetFile) PsiFileFactory.getInstance(project).createFileFromText("Library.jet",
+10
View File
@@ -0,0 +1,10 @@
package jet;
import jet.typeinfo.TypeInfo;
/**
* @author abreslav
*/
public interface JetObject {
TypeInfo<?> getTypeInfo();
}
+33
View File
@@ -0,0 +1,33 @@
package jet.typeinfo;
import jet.JetObject;
/**
* @author abreslav
*/
public class TypeInfo<T> implements JetObject {
private TypeInfo<?> typeInfo;
private final TypeInfo<?> typeArgument;
private TypeInfo(TypeInfo<?> typeArgument) {
this.typeArgument = typeArgument;
}
public boolean isInstance(Object obj) {
throw new UnsupportedOperationException(); // TODO
}
public boolean isSubtypeOf(TypeInfo<?> other) {
throw new UnsupportedOperationException(); // TODO
}
@Override
public TypeInfo<?> getTypeInfo() {
if (typeInfo == null) {
// TODO: Implementation must be lazy, otherwise the result would be of an infinite size
throw new UnsupportedOperationException(); // TODO
}
return typeInfo;
}
}