Skip to content

Commit 049bdf2

Browse files
committed
use MetaType when creating IRType from IRTypeDeclaration
1 parent 9c6d057 commit 049bdf2

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/javascript/typeinfo/DefaultMetaType.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ public IRType toRType(ITypeSystem typeSystem, Type type) {
3232
return new RSimpleType(typeSystem, type);
3333
}
3434

35+
public IRType toRType(ITypeSystem typeSystem, IRTypeDeclaration declaration) {
36+
return new RSimpleType(typeSystem, declaration);
37+
}
38+
3539
}

plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/javascript/typeinfo/MetaType.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,15 @@ public interface MetaType {
3333
*/
3434
IRType toRType(ITypeSystem typeSystem, Type type);
3535

36+
/**
37+
* Creates the corresponding {@link IRType} for the specified
38+
* {@link IRTypeDeclaration} instance.
39+
*
40+
* @param typeSystem
41+
* the context for the operation, possible <code>null</code>
42+
* @param type
43+
* the type to wrap
44+
*/
45+
IRType toRType(ITypeSystem typeSystem, IRTypeDeclaration declaration);
46+
3647
}

plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/javascript/typeinfo/RTypes.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,13 @@ public static IRType simple(ITypeSystem typeSystem, Type type) {
161161
}
162162

163163
public static IRType simple(IRTypeDeclaration declaration) {
164-
return new RSimpleType(declaration);
164+
return declaration.getSource().getMetaType().toRType(null, declaration);
165165
}
166166

167167
public static IRType simple(ITypeSystem typeSystem,
168168
IRTypeDeclaration declaration) {
169-
return new RSimpleType(typeSystem, declaration);
169+
return declaration.getSource().getMetaType()
170+
.toRType(typeSystem, declaration);
170171
}
171172

172173
public static IRType simple(Type type) {

tests/org.eclipse.dltk.javascript.core.tests/src/org/eclipse/dltk/javascript/core/tests/typeinfo/MetaTypes.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import org.eclipse.dltk.javascript.typeinfo.DefaultMetaType;
1515
import org.eclipse.dltk.javascript.typeinfo.IRType;
16+
import org.eclipse.dltk.javascript.typeinfo.IRTypeDeclaration;
1617
import org.eclipse.dltk.javascript.typeinfo.ITypeSystem;
1718
import org.eclipse.dltk.javascript.typeinfo.MetaType;
1819
import org.eclipse.dltk.javascript.typeinfo.model.Type;
@@ -31,4 +32,9 @@ public IRType toRType(ITypeSystem typeSystem, Type type) {
3132
return DefaultMetaType.DEFAULT.toRType(typeSystem, type);
3233
}
3334

35+
@Override
36+
public IRType toRType(ITypeSystem typeSystem, IRTypeDeclaration declaration) {
37+
return DefaultMetaType.DEFAULT.toRType(typeSystem, declaration);
38+
}
39+
3440
}

tests/org.eclipse.dltk.javascript.core.tests/src/org/eclipse/dltk/javascript/core/tests/typeinfo/TestMetaType.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import org.eclipse.dltk.javascript.typeinfo.DefaultMetaType;
1515
import org.eclipse.dltk.javascript.typeinfo.IRType;
16+
import org.eclipse.dltk.javascript.typeinfo.IRTypeDeclaration;
1617
import org.eclipse.dltk.javascript.typeinfo.ITypeSystem;
1718
import org.eclipse.dltk.javascript.typeinfo.MetaType;
1819
import org.eclipse.dltk.javascript.typeinfo.model.Type;
@@ -31,4 +32,9 @@ public IRType toRType(ITypeSystem typeSystem, Type type) {
3132
return DefaultMetaType.DEFAULT.toRType(typeSystem, type);
3233
}
3334

35+
@Override
36+
public IRType toRType(ITypeSystem typeSystem, IRTypeDeclaration declaration) {
37+
return DefaultMetaType.DEFAULT.toRType(typeSystem, declaration);
38+
}
39+
3440
}

0 commit comments

Comments
 (0)