-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added inheritance of fields having parameterized type; parametric int…
…erface declarations are not supported yet
- Loading branch information
Showing
4 changed files
with
74 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
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 |
---|---|---|
@@ -1,21 +1,30 @@ | ||
# module M20 | ||
# using Inherit, Test | ||
module M20 | ||
using Inherit, Test | ||
|
||
# @abstractbase struct Fruit{T} | ||
# size::T | ||
# end | ||
# @implement struct Apple <: Fruit | ||
# end | ||
# end | ||
|
||
ex = quote | ||
struct Fruit{T <: Real, T2} | ||
@abstractbase struct Fruit{T} | ||
size::T | ||
end | ||
end | ||
ex2 = quote | ||
struct Fruit | ||
size::T | ||
@implement struct Apple <: Fruit | ||
end | ||
@implement struct Orange{U} <: Fruit | ||
weight::U | ||
end | ||
|
||
@abstractbase struct NiceFruit{K} <: Fruit | ||
price::K | ||
end | ||
|
||
@implement struct Strawberry{L} <: NiceFruit | ||
location::L | ||
end | ||
|
||
@testset "inheriting parametric fields" begin | ||
a = Apple(Int(1)) | ||
b = Orange(Int(2), Float32(3)) | ||
c = Strawberry("large", Float64(3.2), "far away") | ||
@show c | ||
@test collect(typeof(a).parameters) == [Int] | ||
@test collect(typeof(b).parameters) == [Int, Float32] | ||
@test collect(typeof(c).parameters) == [String, Float64, String] | ||
end | ||
end | ||
# @capture(ex, struct T_Symbol{P__} lines__ end) |
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