Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion source/slang/slang-check-modifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,11 @@ bool isModifierAllowedOnDecl(bool isGLSLInput, ASTNodeType modifierType, Decl* d
case ASTNodeType::DynModifier:
return as<InterfaceDecl>(decl) || as<VarDecl>(decl) || as<ParamDecl>(decl);
case ASTNodeType::OverrideModifier:
return as<FunctionDeclBase>(decl) && as<AggTypeDecl>(getParentDecl(decl));
{
Decl* parent = getParentDecl(decl);
return as<FunctionDeclBase>(decl) &&
(as<AggTypeDecl>(parent) || as<ExtensionDecl>(parent));
}
default:
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ struct Impl : IFoo
}
}

struct Other
{
int n;
}

extension Other: IFoo
{
int getVal()
{
return n;
}

// Override should also work inside an extension
override int getGreaterVal<int x>()
{
return getVal() + x + 2;
}
}

int test<T:IFoo>(T v) { return v.getGreaterVal<1>(); }

//TEST_INPUT: set resultBuffer = out ubuffer(data=[0 0 0 0], stride=4)
Expand All @@ -37,4 +56,8 @@ void computeMain()
int result = test(impl);
resultBuffer[0] = result;
// CHECK: 44
}

Other other = {32};
resultBuffer[1] = test(other);
// CHECK-NEXT: 35
}