-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't decode CBOR tag data to interface (tinygo only)
tinygo v0.33 doesn't implement Type.AssignableTo(), which is needed under the hood when decoding registered CBOR tag data to Go interface. More details in tinygo-org/tinygo#4277. This commit returns error of UnmarshalTypeError type when decoding registered CBOR tag data to Go interface. This change can be reverted after tinygo implements Type.AssignalbeTo().
- Loading branch information
Showing
6 changed files
with
152 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Faye Amacker. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
//go:build !tinygo | ||
|
||
package cbor | ||
|
||
import "reflect" | ||
|
||
func implements(concreteType reflect.Type, interfaceType reflect.Type) bool { | ||
return concreteType.Implements(interfaceType) || | ||
reflect.PointerTo(concreteType).Implements(interfaceType) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) Faye Amacker. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
//go:build tinygo | ||
|
||
package cbor | ||
|
||
import "reflect" | ||
|
||
// tinygo v0.33 doesn't implement Type.AssignableTo() and it panics. | ||
// Type.AssignableTo() is used under the hood for Type.Implements(). | ||
// | ||
// More details in https://github.com/tinygo-org/tinygo/issues/4277. | ||
// | ||
// implements() always returns false until tinygo implements Type.AssignableTo(). | ||
func implements(concreteType reflect.Type, interfaceType reflect.Type) bool { | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters