diff --git a/runtime/sema/type.go b/runtime/sema/type.go index 251769e704..216e1fc9e0 100644 --- a/runtime/sema/type.go +++ b/runtime/sema/type.go @@ -5282,7 +5282,10 @@ func (t *InterfaceType) SupportedEntitlements() (set *EntitlementOrderedSet) { }) } }) - // TODO: include inherited entitlements + + t.EffectiveInterfaceConformanceSet().ForEach(func(it *InterfaceType) { + set.SetAll(it.SupportedEntitlements()) + }) t.supportedEntitlements = set return set diff --git a/runtime/tests/checker/entitlements_test.go b/runtime/tests/checker/entitlements_test.go index 2b6ea3360a..f95dab90fa 100644 --- a/runtime/tests/checker/entitlements_test.go +++ b/runtime/tests/checker/entitlements_test.go @@ -5561,6 +5561,55 @@ func TestCheckEntitlementConditions(t *testing.T) { assert.NoError(t, err) }) + + t.Run("result value inherited interface entitlement resource", func(t *testing.T) { + t.Parallel() + _, err := ParseAndCheck(t, ` + entitlement X + entitlement Y + resource interface I { + access(X) view fun foo(): Bool { + return true + } + } + resource interface J: I { + access(Y) view fun bar(): Bool { + return true + } + } + fun bar(r: @{J}): @{J} { + post { + result.foo(): "" + result.bar(): "" + } + return <-r + } + `) + + assert.NoError(t, err) + }) + + t.Run("result inherited interface method", func(t *testing.T) { + t.Parallel() + _, err := ParseAndCheck(t, ` + entitlement X + entitlement Y + resource interface I { + access(X, Y) view fun foo(): Bool + } + resource interface J: I { + access(Y) view fun foo(): Bool + } + fun bar(r: @{J}): @{J} { + post { + result.foo(): "" + } + return <-r + } + `) + + assert.NoError(t, err) + }) } func TestCheckEntitledWriteAndMutateNotAllowed(t *testing.T) {