-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASTTRef.java
More file actions
40 lines (30 loc) · 990 Bytes
/
Copy pathASTTRef.java
File metadata and controls
40 lines (30 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.Set;
public class ASTTRef implements ASTType {
private final ASTType type;
public ASTTRef(ASTType _type) {
this.type = _type;
}
public ASTType getType() {
return type;
}
@Override
public String toStr() {
return "ref("+type.toStr()+")";
}
@Override
public boolean eqt(ASTType t) {
if (!(t instanceof ASTTRef other))
return false;
return type.eqt(other.getType());
}
@Override
public boolean subtypeOf(ASTType t, Environment<ASTType> e, Set<String> seen) throws InterpreterError {
t = ASTTypeDef.unfold(t, e);
if (!(t instanceof ASTTRef other))
return false;
ASTType thisInner = ASTTypeDef.unfold(this.type, e);
ASTType otherInner = ASTTypeDef.unfold(other.getType(), e);
// A<:>B
return thisInner.subtypeOf(otherInner, e, seen) && otherInner.subtypeOf(thisInner, e, seen);
}
}