File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -235,6 +235,13 @@ func TestRuntimeCapability_borrowAndCheck(t *testing.T) {
235235 assert(!self.account.capabilities.exists(path))
236236 }
237237
238+ access(all)
239+ fun testNever() {
240+ let path = /public/r
241+ assert(self.account.capabilities.get<Never>(path) == nil)
242+ assert(self.account.capabilities.exists(path))
243+ }
244+
238245 access(all)
239246 fun testSwap(): Int {
240247 let ref = self.account.capabilities.get<&R>(/public/r)!.borrow()!
@@ -305,6 +312,11 @@ func TestRuntimeCapability_borrowAndCheck(t *testing.T) {
305312 require .NoError (t , err )
306313 })
307314
315+ t .Run ("testNever" , func (t * testing.T ) {
316+ _ , err := invoke ("testNever" )
317+ require .NoError (t , err )
318+ })
319+
308320 t .Run ("testSwap" , func (t * testing.T ) {
309321
310322 _ , err := invoke ("testSwap" )
Original file line number Diff line number Diff line change @@ -3595,8 +3595,13 @@ func newAccountCapabilitiesGetFunction(
35953595
35963596 // Get borrow type type argument
35973597
3598- typeParameterPair := invocation .TypeParameterTypes .Oldest ()
3599- wantedBorrowType , ok := typeParameterPair .Value .(* sema.ReferenceType )
3598+ typeParameterPairValue := invocation .TypeParameterTypes .Oldest ().Value
3599+ // `Never` is never a supertype of any stored value
3600+ if typeParameterPairValue .Equal (sema .NeverType ) {
3601+ return interpreter .Nil
3602+ }
3603+
3604+ wantedBorrowType , ok := typeParameterPairValue .(* sema.ReferenceType )
36003605 if ! ok {
36013606 panic (errors .NewUnreachableError ())
36023607 }
You can’t perform that action at this time.
0 commit comments