Skip to content

Commit

Permalink
fix(go): replace uses of CanConvert to Type.AssignableTo (#3373)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMuller authored Feb 9, 2022
1 parent f0b811b commit ae4ea62
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
- name: Set up Go 1.17
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: '1.17'
go-version: '1.16'
- name: Set up Java 8
uses: actions/setup-java@v2
with:
Expand Down Expand Up @@ -125,10 +125,10 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
- name: Set up Go 1.17
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: '1.17'
go-version: '1.16'
- name: Set up Java 8
uses: actions/setup-java@v2
with:
Expand Down Expand Up @@ -211,7 +211,7 @@ jobs:
matrix:
# All currently supported node versions (Maintenance LTS, Active LTS, Current)
dotnet: ['3.1.x']
go: ['1.17']
go: ['1.16']
java: ['8']
node: ['12', '14', '16', '17']
os: [ubuntu-latest]
Expand All @@ -221,53 +221,53 @@ jobs:
# Test using Windows
- os: windows-latest
dotnet: '3.1.x'
go: '1.17'
go: '1.16'
java: '8'
node: '12'
python: '3.6'
# Test using macOS
- os: macos-latest
dotnet: '3.1.x'
go: '1.17'
go: '1.16'
java: '8'
node: '12'
python: '3.6'
# Test alternate .NETs
- java: '8'
dotnet: '5.0.x'
go: '1.17'
go: '1.16'
node: '12'
os: ubuntu-latest
python: '3.6'
- java: '8'
dotnet: '6.0.x'
go: '1.17'
go: '1.16'
node: '12'
os: ubuntu-latest
python: '3.6'
# Test alternate Javas
- java: '11'
dotnet: '3.1.x'
go: '1.17'
go: '1.16'
node: '12'
os: ubuntu-latest
python: '3.6'
# Test alternate Pythons
- python: '3.7'
dotnet: '3.1.x'
go: '1.17'
go: '1.16'
java: '8'
node: '12'
os: ubuntu-latest
- python: '3.8'
dotnet: '3.1.x'
go: '1.17'
go: '1.16'
java: '8'
node: '12'
os: ubuntu-latest
- python: '3.9'
dotnet: '3.1.x'
go: '1.17'
go: '1.16'
java: '8'
node: '12'
os: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/go-runtime/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aws/jsii

go 1.15
go 1.16

require (
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/go-runtime/jsii-runtime-go/cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func UnsafeCast(from interface{}, into interface{}) {
}

// If rfrom can be directly converted to rinto, just do it.
if rfrom.CanConvert(rinto.Type()) {
if rfrom.Type().AssignableTo(rinto.Type()) {
rfrom = rfrom.Convert(rinto.Type())
rinto.Set(rfrom)
return
Expand Down
3 changes: 1 addition & 2 deletions packages/@jsii/go-runtime/jsii-runtime-go/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aws/jsii-runtime-go

go 1.17
go 1.16

require (
github.com/Masterminds/semver/v3 v3.1.1
Expand All @@ -9,7 +9,6 @@ require (

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (o *ObjectStore) GetObjectAs(instanceID string, typ reflect.Type) (value re
found = false
if values, exists := o.idToObjects[instanceID]; exists {
for value = range values {
if value.CanConvert(typ) {
if value.Type().AssignableTo(typ) {
value = value.Convert(typ)
found = true
return
Expand Down

0 comments on commit ae4ea62

Please sign in to comment.