Permalink
Browse files

fix Issue 9374 - 'super' should be accessible inside template constraint

  • Loading branch information...
1 parent 2471fe9 commit c683f3b0bedcb89319759e0a236a0769ca7f2ca7 @9rnsr 9rnsr committed Jan 23, 2013
Showing with 24 additions and 0 deletions.
  1. +2 −0 src/expression.c
  2. +22 −0 test/runnable/test11.d
View
@@ -3387,6 +3387,8 @@ Expression *SuperExp::semantic(Scope *sc)
s = fd->toParent();
while (s && s->isTemplateInstance())
s = s->toParent();
+ if (s->isTemplateDeclaration()) // allow inside template constraint
+ s = s->toParent();
assert(s);
cd = s->isClassDeclaration();
//printf("parent is %s %s\n", fd->toParent()->kind(), fd->toParent()->toChars());
View
@@ -1317,6 +1317,27 @@ void test8809()
assert(c.test3Dy() == 'D');
}
+/**************************************/
+// 9734
+
+void test9734()
+{
+ class C {}
+ class D : C
+ {
+ static bool test(C) { return true; }
+
+ void foo()() if (is(typeof(test(super)))) {}
+ void bar()() if (is(typeof(super) == C)) {}
+ }
+ void baz()() if (is(typeof(super))) {}
+
+ auto d = new D();
+ d.foo();
+ d.bar();
+ static assert(!__traits(compiles, baz()));
+}
+
/**************************************/
int main(string[] argv)
@@ -1384,6 +1405,7 @@ int main(string[] argv)
test64();
test65();
test8809();
+ test9734();
printf("Success\n");
return 0;

0 comments on commit c683f3b

Please sign in to comment.