-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp: parse circular interface definitions
An undefined type detection function has been added to better diagnose incomplete type definitions. Implicit type names in interface or struct declarations are now better handled. The incomplete status is not fowarded to aliased type declarations to handle circular definitions. Fixes #999 and #995. Improves #260 (goes farther, but still fails).
- Loading branch information
Showing
4 changed files
with
120 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
type I1 interface{ A } | ||
|
||
type A = I2 | ||
|
||
type I2 interface{ F() I1 } | ||
|
||
func main() { | ||
var i I1 | ||
fmt.Println(i) | ||
} | ||
|
||
// Output: | ||
// <nil> |
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,45 @@ | ||
package main | ||
|
||
type Descriptor interface { | ||
ParentFile() FileDescriptor | ||
} | ||
|
||
type FileDescriptor interface { | ||
Enums() EnumDescriptors | ||
Services() ServiceDescriptors | ||
} | ||
|
||
type EnumDescriptors interface { | ||
Get(i int) EnumDescriptor | ||
} | ||
|
||
type EnumDescriptor interface { | ||
Values() EnumValueDescriptors | ||
} | ||
|
||
type EnumValueDescriptors interface { | ||
Get(i int) EnumValueDescriptor | ||
} | ||
|
||
type EnumValueDescriptor interface { | ||
Descriptor | ||
} | ||
|
||
type ServiceDescriptors interface { | ||
Get(i int) ServiceDescriptor | ||
} | ||
|
||
type ServiceDescriptor interface { | ||
Descriptor | ||
isServiceDescriptor | ||
} | ||
|
||
type isServiceDescriptor interface{ ProtoType(ServiceDescriptor) } | ||
|
||
func main() { | ||
var d Descriptor | ||
println(d == nil) | ||
} | ||
|
||
// Output: | ||
// true |
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